@qwanyx/stack 0.2.97 → 0.2.99

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 Zd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Zd)return[];let s=new Xd(r).tokenize(),i=[],o=[],a=[];if(s.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(o.length&&i.push(o),o=[]):o.push(l)}),o.length&&i.push(o),i.forEach(l=>{l=Jd(l,t),l.length&&(a=a.concat(l))}),e.flatten){let l=[],u=c=>{c.forEach(d=>{if(d.group)return u(d.group);l.push(d)})};return u(a),l}return a}function ef(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,a,l,u,c,d,f=0;f<o;f=f+3)d=n[f]<<16|n[f+1]<<8|n[f+2],a=(d&16515072)>>18,l=(d&258048)>>12,u=(d&4032)>>6,c=d&63,e+=t[a]+t[l]+t[u]+t[c];return i==1?(d=n[o],a=(d&252)>>2,l=(d&3)<<4,e+=t[a]+t[l]+"=="):i==2&&(d=n[o]<<8|n[o+1],a=(d&64512)>>10,l=(d&1008)>>4,u=(d&15)<<2,e+=t[a]+t[l]+t[u]+"="),e}const tf=256,rf=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||tf,maxHeadersSize:this.options.maxHeadersSize||rf},this.root=this.currentNode=new va({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,t){let n=this.boundaries;if(n.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=n.length-1;s>=0;s--){let i=n[s];if(e.length!==i.value.length+2&&e.length!==i.value.length+4)continue;let o=e.length===i.value.length+4;if(o&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let a=!0;for(let l=0;l<i.value.length;l++)if(e[l+2]!==i.value[l]){a=!1;break}if(a)return o?(await i.node.finalize(),this.currentNode=i.node.parentNode||this.root):(await i.node.finalizeChildNodes(),this.currentNode=new va({postalMime:this,parentNode:i.node,...this.mimeOptions})),t?this.finalize():void 0}if(this.currentNode.feed(e),t)return this.finalize()}readLine(){let e=this.readPos,t=this.readPos,n=()=>({bytes:new Uint8Array(this.buf,e,t-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(t=this.readPos),s===10)return n()}return n()}async processNodeTree(){let e={},t=new Set,n=this.textMap=new Map,s=this.forceRfc822Attachments(),i=async(o,a,l)=>{if(a=a||!1,l=l||!1,o.contentType.multipart)o.contentType.multipart==="alternative"?a=o:o.contentType.multipart==="related"&&(l=o);else if(this.isInlineMessageRfc822(o)&&!s){const u=new Ds;o.subMessage=await u.parse(o.content),n.has(o)||n.set(o,{});let c=n.get(o);(o.subMessage.text||!o.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:o.subMessage}),t.add("plain")),o.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:o.subMessage}),t.add("html")),u.textMap&&u.textMap.forEach((d,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=a||o;n.has(c)||n.set(c,{});let d=n.get(c);d[u]=d[u]||[],d[u].push({type:"text",value:o.getTextContent()}),t.add(u)}else if(o.content){const u=o.contentDisposition.parsed.params.filename||o.contentType.parsed.params.name||null,c={filename:u?En(u):null,mimeType:o.contentType.parsed.value,disposition:o.contentDisposition.parsed.value||null};switch(l&&o.contentId&&(c.related=!0),o.contentDescription&&(c.description=o.contentDescription),o.contentId&&(c.contentId=o.contentId),o.contentType.parsed.value){case"text/calendar":case"application/ics":{o.contentType.parsed.params.method&&(c.method=o.contentType.parsed.params.method.toString().toUpperCase().trim());const d=o.getTextContent().replace(/\r?\n/g,`
26
26
  `).replace(/\n*$/,`
27
27
  `);c.content=Xr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,a,l)};await i(this.root,!1,[]),n.forEach(o=>{t.forEach(a=>{if(e[a]||(e[a]=[]),o[a])o[a].forEach(l=>{switch(l.type){case"text":e[a].push(l.value);break;case"subMessage":switch(a){case"html":e[a].push(Ca(l.value));break;case"plain":e[a].push(wa(l.value));break}break}});else{let l;switch(a){case"html":l="plain";break;case"plain":l="html";break}(o[l]||[]).forEach(u=>{switch(u.type){case"text":switch(a){case"html":e[a].push(Kd(u.value));break;case"plain":e[a].push(Yd(u.value));break}break;case"subMessage":switch(a){case"html":e[a].push(Ca(u.value));break;case"plain":e[a].push(wa(u.value));break}break}})}})}),Object.keys(e).forEach(o=>{e[o]=e[o].join(`
28
- `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:a,value:l}=await s.read();if(a)break;n.push(l),t+=l.length}const i=new Uint8Array(t);let o=0;for(let a of n)i.set(a,o),o+=a.length;return i}async parse(e){var s,i;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Xr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);l&&l.length&&(t[o]=l[0])}}for(const o of["delivered-to","return-path"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);if(l&&l.length&&l[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const a=this.root.headers.filter(u=>u.key===o);let l=[];if(a.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>l=l.concat(u||[])),l&&l.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l}}for(const o of["subject","message-id","in-reply-to","references"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[l]=En(a.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let a of t.attachments||[])a!=null&&a.content&&(a.content=ef(a.content),a.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let a of t.attachments||[])a!=null&&a.content&&(a.content=o.decode(a.content),a.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){vt(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const a=await i.text();throw new Error(`API error (${i.status}): ${a}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],l=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(l>0)return{success:!0,moved:l}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(a=>`UID STORE ${a} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(a=>a.ok&&a.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const l=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(l.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${l.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const f=l.map(p=>{var _,S,D,k,w;const g=d.get(p);if(!g)return null;const m=((_=g.flags)==null?void 0:_.some(E=>E.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",v=((k=g.envelope)==null?void 0:k.subject)||"(No subject)",b=((w=g.envelope)==null?void 0:w.date)||"";return{uid:p,from:x,subject:v,date:b,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,b,_;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],a=o.body||o.raw;if(!a)return console.error("No raw email content in response"),null;const u=await new Ds().parse(a);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(S=>({filename:S.filename,mimeType:S.mimeType,contentId:S.contentId})));const c=new Map;for(const S of u.attachments||[])if(S.contentId){const D=this.contentToBase64(S.content),k=`data:${S.mimeType};base64,${D}`,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,D)=>{const k=c.get(D)||c.get(`<${D}>`);return k?`src="${k}"`:S}));const f=((v=o.flags)==null?void 0:v.some(S=>S.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.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(a=>a.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(a){return console.error("[MailClient] findEmailInAllMail failed:",a),{found:!1}}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.smtp))return{success:!1,error:"No SMTP configuration found for account"};const a={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.in_reply_to&&(a.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(a.attachments=t.attachments);const l=await this.callEmail("send",a);return{success:(l==null?void 0:l.sent)??!1,message_id:l==null?void 0:l.message_id,error:l==null?void 0:l.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class nf{constructor(e){vt(this,"config");vt(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const o=await s.text();throw new Error(`LLM API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async 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 rt{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){vt(this,"config");this.config=e}async register(e,t,n){var s,i;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:"register",params:{email:e,password:t,...n,system_id:this.config.systemId}})})).json();return a.success&&((s=a.result)!=null&&s.success)?{success:!0,userId:a.result.user_id,email:a.result.email,requiresVerification:a.result.requiresVerification}:{success:!1,error:((i=a.result)==null?void 0:i.message)||a.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const l=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(l.success&&((n=l.result)!=null&&n.token)){const{token:u,user:c}=l.result;return rt.setToken(u),rt.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=l.result)==null?void 0:o.error)||l.error||"Verification failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,a;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return rt.setToken(c),rt.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((a=u.result)==null?void 0:a.message)||u.error||"Password reset failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async login(e,t){var n,s,i,o,a,l;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,system_id:this.config.systemId}})})).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 rt.setToken(d),rt.setUser(f),(a=(o=this.config).onLogin)==null||a.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((l=c.result)==null?void 0:l.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;rt.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",...rt.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 rt.getUser()}isAuthenticated(){return rt.isAuthenticated()}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...rt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function sf(r){return As=new Ao(r),As}function of(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){vt(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,a=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,l={...this.config.headers,...rt.getAuthHeader(),...s},u={method:n,headers:l};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),f=await fetch(a,{...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 af(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
28
+ `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:a,value:l}=await s.read();if(a)break;n.push(l),t+=l.length}const i=new Uint8Array(t);let o=0;for(let a of n)i.set(a,o),o+=a.length;return i}async parse(e){var s,i;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Xr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);l&&l.length&&(t[o]=l[0])}}for(const o of["delivered-to","return-path"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);if(l&&l.length&&l[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const a=this.root.headers.filter(u=>u.key===o);let l=[];if(a.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>l=l.concat(u||[])),l&&l.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l}}for(const o of["subject","message-id","in-reply-to","references"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[l]=En(a.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let a of t.attachments||[])a!=null&&a.content&&(a.content=ef(a.content),a.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let a of t.attachments||[])a!=null&&a.content&&(a.content=o.decode(a.content),a.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){vt(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const a=await i.text();throw new Error(`API error (${i.status}): ${a}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],l=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(l>0)return{success:!0,moved:l}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(a=>`UID STORE ${a} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(a=>a.ok&&a.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const l=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(l.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${l.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const f=l.map(p=>{var _,S,D,k,w;const g=d.get(p);if(!g)return null;const m=((_=g.flags)==null?void 0:_.some(E=>E.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",v=((k=g.envelope)==null?void 0:k.subject)||"(No subject)",b=((w=g.envelope)==null?void 0:w.date)||"";return{uid:p,from:x,subject:v,date:b,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,b,_;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],a=o.body||o.raw;if(!a)return console.error("No raw email content in response"),null;const u=await new Ds().parse(a);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(S=>({filename:S.filename,mimeType:S.mimeType,contentId:S.contentId})));const c=new Map;for(const S of u.attachments||[])if(S.contentId){const D=this.contentToBase64(S.content),k=`data:${S.mimeType};base64,${D}`,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,D)=>{const k=c.get(D)||c.get(`<${D}>`);return k?`src="${k}"`:S}));const f=((v=o.flags)==null?void 0:v.some(S=>S.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.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(a=>a.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(a){return console.error("[MailClient] findEmailInAllMail failed:",a),{found:!1}}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.smtp))return{success:!1,error:"No SMTP configuration found for account"};const a={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.in_reply_to&&(a.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(a.attachments=t.attachments);const l=await this.callEmail("send",a);return{success:(l==null?void 0:l.sent)??!1,message_id:l==null?void 0:l.message_id,error:l==null?void 0:l.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class nf{constructor(e){vt(this,"config");vt(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const o=await s.text();throw new Error(`LLM API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async 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 nt{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){vt(this,"config");this.config=e}async register(e,t,n){var s,i;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:"register",params:{email:e,password:t,...n,system_id:this.config.systemId}})})).json();return a.success&&((s=a.result)!=null&&s.success)?{success:!0,userId:a.result.user_id,email:a.result.email,requiresVerification:a.result.requiresVerification}:{success:!1,error:((i=a.result)==null?void 0:i.message)||a.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const l=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(l.success&&((n=l.result)!=null&&n.token)){const{token:u,user:c}=l.result;return nt.setToken(u),nt.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=l.result)==null?void 0:o.error)||l.error||"Verification failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,a;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return nt.setToken(c),nt.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((a=u.result)==null?void 0:a.message)||u.error||"Password reset failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async login(e,t){var n,s,i,o,a,l;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,system_id:this.config.systemId}})})).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 nt.setToken(d),nt.setUser(f),(a=(o=this.config).onLogin)==null||a.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((l=c.result)==null?void 0:l.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;nt.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",...nt.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 nt.getUser()}isAuthenticated(){return nt.isAuthenticated()}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...nt.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function sf(r){return As=new Ao(r),As}function of(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){vt(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,a=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,l={...this.config.headers,...nt.getAuthHeader(),...s},u={method:n,headers:l};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),f=await fetch(a,{...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 af(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
29
29
  * @license React
30
30
  * react-jsx-runtime.production.min.js
31
31
  *
@@ -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 uf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),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 v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var $=arguments.length,te=new Array($>1?$-1:0),xe=1;xe<$;xe++)te[xe-1]=arguments[xe];_("error",A,te)}}function _(A,$,te){{var xe=v.ReactDebugCurrentFrame,je=xe.getStackAddendum();je!==""&&($+="%s",te=te.concat([je]));var Oe=te.map(function(Ne){return String(Ne)});Oe.unshift("Warning: "+$),Function.prototype.apply.call(console[A],console,Oe)}}var S=!1,D=!1,k=!1,w=!1,E=!1,M;M=Symbol.for("react.module.reference");function N(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||E||A===s||A===u||A===c||w||A===p||S||D||k||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===a||A.$$typeof===l||A.$$typeof===M||A.getModuleId!==void 0))}function T(A,$,te){var xe=A.displayName;if(xe)return xe;var je=$.displayName||$.name||"";return je!==""?te+"("+je+")":te}function B(A){return A.displayName||"Context"}function R(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var $=A;return B($)+".Consumer";case o:var te=A;return B(te._context)+".Provider";case l:return T(A,A.render,"ForwardRef");case d:var xe=A.displayName||null;return xe!==null?xe:R(A.type)||"Memo";case f:{var je=A,Oe=je._payload,Ne=je._init;try{return R(Ne(Oe))}catch{return null}}}return null}var C=Object.assign,j=0,F,O,U,W,re,q,Q;function H(){}H.__reactDisabledLog=!0;function ne(){{if(j===0){F=console.log,O=console.info,U=console.warn,W=console.error,re=console.group,q=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})}j++}}function de(){{if(j--,j===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},A,{value:F}),info:C({},A,{value:O}),warn:C({},A,{value:U}),error:C({},A,{value:W}),group:C({},A,{value:re}),groupCollapsed:C({},A,{value:q}),groupEnd:C({},A,{value:Q})})}j<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=v.ReactCurrentDispatcher,pe;function ke(A,$,te){{if(pe===void 0)try{throw Error()}catch(je){var xe=je.stack.trim().match(/\n( *(at )?)/);pe=xe&&xe[1]||""}return`
45
- `+pe+A}}var me=!1,J;{var be=typeof WeakMap=="function"?WeakMap:Map;J=new be}function se(A,$){if(!A||me)return"";{var te=J.get(A);if(te!==void 0)return te}var xe;me=!0;var je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Oe;Oe=he.current,he.current=null,ne();try{if($){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(bt){xe=bt}Reflect.construct(A,[],Ne)}else{try{Ne.call()}catch(bt){xe=bt}A.call(Ne.prototype)}}else{try{throw Error()}catch(bt){xe=bt}A()}}catch(bt){if(bt&&xe&&typeof bt.stack=="string"){for(var Be=bt.stack.split(`
46
- `),ht=xe.stack.split(`
47
- `),Ze=Be.length-1,tt=ht.length-1;Ze>=1&&tt>=0&&Be[Ze]!==ht[tt];)tt--;for(;Ze>=1&&tt>=0;Ze--,tt--)if(Be[Ze]!==ht[tt]){if(Ze!==1||tt!==1)do if(Ze--,tt--,tt<0||Be[Ze]!==ht[tt]){var Tt=`
48
- `+Be[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{me=!1,he.current=Oe,de(),Error.prepareStackTrace=je}var zr=A?A.displayName||A.name:"",vr=zr?ke(zr):"";return typeof A=="function"&&J.set(A,vr),vr}function Ae(A,$,te){return se(A,!1)}function _e(A){var $=A.prototype;return!!($&&$.isReactComponent)}function ve(A,$,te){if(A==null)return"";if(typeof A=="function")return se(A,_e(A));if(typeof A=="string")return ke(A);switch(A){case u:return ke("Suspense");case c:return ke("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return Ae(A.render);case d:return ve(A.type,$,te);case f:{var xe=A,je=xe._payload,Oe=xe._init;try{return ve(Oe(je),$,te)}catch{}}}return""}var Me=Object.prototype.hasOwnProperty,Fe={},qe=v.ReactDebugCurrentFrame;function V(A){if(A){var $=A._owner,te=ve(A.type,A._source,$?$.type:null);qe.setExtraStackFrame(te)}else qe.setExtraStackFrame(null)}function z(A,$,te,xe,je){{var Oe=Function.call.bind(Me);for(var Ne in A)if(Oe(A,Ne)){var Be=void 0;try{if(typeof A[Ne]!="function"){var ht=Error((xe||"React class")+": "+te+" type `"+Ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ne]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ht.name="Invariant Violation",ht}Be=A[Ne]($,Ne,xe,te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ze){Be=Ze}Be&&!(Be instanceof Error)&&(V(je),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",xe||"React class",te,Ne,typeof Be),V(null)),Be instanceof Error&&!(Be.message in Fe)&&(Fe[Be.message]=!0,V(je),b("Failed %s type: %s",te,Be.message),V(null))}}}var Le=Array.isArray;function ie(A){return Le(A)}function P(A){{var $=typeof Symbol=="function"&&Symbol.toStringTag,te=$&&A[Symbol.toStringTag]||A.constructor.name||"Object";return te}}function X(A){try{return ue(A),!1}catch{return!0}}function ue(A){return""+A}function ce(A){if(X(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",P(A)),ue(A)}var Ue=v.ReactCurrentOwner,yt={key:!0,ref:!0,__self:!0,__source:!0},xt,ae;function ge(A){if(Me.call(A,"ref")){var $=Object.getOwnPropertyDescriptor(A,"ref").get;if($&&$.isReactWarning)return!1}return A.ref!==void 0}function He(A){if(Me.call(A,"key")){var $=Object.getOwnPropertyDescriptor(A,"key").get;if($&&$.isReactWarning)return!1}return A.key!==void 0}function Je(A,$){typeof A.ref=="string"&&Ue.current}function Xe(A,$){{var te=function(){xt||(xt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};te.isReactWarning=!0,Object.defineProperty(A,"key",{get:te,configurable:!0})}}function Bt(A,$){{var te=function(){ae||(ae=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};te.isReactWarning=!0,Object.defineProperty(A,"ref",{get:te,configurable:!0})}}var Z=function(A,$,te,xe,je,Oe,Ne){var Be={$$typeof:e,type:A,key:$,ref:te,props:Ne,_owner:Oe};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:xe}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:je}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function L(A,$,te,xe,je){{var Oe,Ne={},Be=null,ht=null;te!==void 0&&(ce(te),Be=""+te),He($)&&(ce($.key),Be=""+$.key),ge($)&&(ht=$.ref,Je($,je));for(Oe in $)Me.call($,Oe)&&!yt.hasOwnProperty(Oe)&&(Ne[Oe]=$[Oe]);if(A&&A.defaultProps){var Ze=A.defaultProps;for(Oe in Ze)Ne[Oe]===void 0&&(Ne[Oe]=Ze[Oe])}if(Be||ht){var tt=typeof A=="function"?A.displayName||A.name||"Unknown":A;Be&&Xe(Ne,tt),ht&&Bt(Ne,tt)}return Z(A,Be,ht,je,xe,Ue.current,Ne)}}var fe=v.ReactCurrentOwner,ye=v.ReactDebugCurrentFrame;function K(A){if(A){var $=A._owner,te=ve(A.type,A._source,$?$.type:null);ye.setExtraStackFrame(te)}else ye.setExtraStackFrame(null)}var Ee;Ee=!1;function we(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Ce(){{if(fe.current){var A=R(fe.current.type);if(A)return`
44
+ */var ka;function uf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),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 v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var $=arguments.length,ee=new Array($>1?$-1:0),ye=1;ye<$;ye++)ee[ye-1]=arguments[ye];_("error",A,ee)}}function _(A,$,ee){{var ye=v.ReactDebugCurrentFrame,Me=ye.getStackAddendum();Me!==""&&($+="%s",ee=ee.concat([Me]));var Oe=ee.map(function(Be){return String(Be)});Oe.unshift("Warning: "+$),Function.prototype.apply.call(console[A],console,Oe)}}var S=!1,D=!1,k=!1,w=!1,E=!1,M;M=Symbol.for("react.module.reference");function N(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||E||A===s||A===u||A===c||w||A===p||S||D||k||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===a||A.$$typeof===l||A.$$typeof===M||A.getModuleId!==void 0))}function T(A,$,ee){var ye=A.displayName;if(ye)return ye;var Me=$.displayName||$.name||"";return Me!==""?ee+"("+Me+")":ee}function B(A){return A.displayName||"Context"}function R(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var $=A;return B($)+".Consumer";case o:var ee=A;return B(ee._context)+".Provider";case l:return T(A,A.render,"ForwardRef");case d:var ye=A.displayName||null;return ye!==null?ye:R(A.type)||"Memo";case f:{var Me=A,Oe=Me._payload,Be=Me._init;try{return R(Be(Oe))}catch{return null}}}return null}var C=Object.assign,j=0,F,I,W,q,ne,U,Q;function H(){}H.__reactDisabledLog=!0;function ie(){{if(j===0){F=console.log,I=console.info,W=console.warn,q=console.error,ne=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})}j++}}function ue(){{if(j--,j===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:q}),group:C({},A,{value:ne}),groupCollapsed:C({},A,{value:U}),groupEnd:C({},A,{value:Q})})}j<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=v.ReactCurrentDispatcher,ge;function we(A,$,ee){{if(ge===void 0)try{throw Error()}catch(Me){var ye=Me.stack.trim().match(/\n( *(at )?)/);ge=ye&&ye[1]||""}return`
45
+ `+ge+A}}var xe=!1,Z;{var be=typeof WeakMap=="function"?WeakMap:Map;Z=new be}function te(A,$){if(!A||xe)return"";{var ee=Z.get(A);if(ee!==void 0)return ee}var ye;xe=!0;var Me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Oe;Oe=he.current,he.current=null,ie();try{if($){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(bt){ye=bt}Reflect.construct(A,[],Be)}else{try{Be.call()}catch(bt){ye=bt}A.call(Be.prototype)}}else{try{throw Error()}catch(bt){ye=bt}A()}}catch(bt){if(bt&&ye&&typeof bt.stack=="string"){for(var je=bt.stack.split(`
46
+ `),gt=ye.stack.split(`
47
+ `),et=je.length-1,rt=gt.length-1;et>=1&&rt>=0&&je[et]!==gt[rt];)rt--;for(;et>=1&&rt>=0;et--,rt--)if(je[et]!==gt[rt]){if(et!==1||rt!==1)do if(et--,rt--,rt<0||je[et]!==gt[rt]){var Tt=`
48
+ `+je[et].replace(" at new "," at ");return A.displayName&&Tt.includes("<anonymous>")&&(Tt=Tt.replace("<anonymous>",A.displayName)),typeof A=="function"&&Z.set(A,Tt),Tt}while(et>=1&&rt>=0);break}}}finally{xe=!1,he.current=Oe,ue(),Error.prepareStackTrace=Me}var zr=A?A.displayName||A.name:"",vr=zr?we(zr):"";return typeof A=="function"&&Z.set(A,vr),vr}function Ae(A,$,ee){return te(A,!1)}function _e(A){var $=A.prototype;return!!($&&$.isReactComponent)}function ve(A,$,ee){if(A==null)return"";if(typeof A=="function")return te(A,_e(A));if(typeof A=="string")return we(A);switch(A){case u:return we("Suspense");case c:return we("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return Ae(A.render);case d:return ve(A.type,$,ee);case f:{var ye=A,Me=ye._payload,Oe=ye._init;try{return ve(Oe(Me),$,ee)}catch{}}}return""}var Re=Object.prototype.hasOwnProperty,Le={},qe=v.ReactDebugCurrentFrame;function V(A){if(A){var $=A._owner,ee=ve(A.type,A._source,$?$.type:null);qe.setExtraStackFrame(ee)}else qe.setExtraStackFrame(null)}function O(A,$,ee,ye,Me){{var Oe=Function.call.bind(Re);for(var Be in A)if(Oe(A,Be)){var je=void 0;try{if(typeof A[Be]!="function"){var gt=Error((ye||"React class")+": "+ee+" type `"+Be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}je=A[Be]($,Be,ye,ee,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(et){je=et}je&&!(je instanceof Error)&&(V(Me),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ye||"React class",ee,Be,typeof je),V(null)),je instanceof Error&&!(je.message in Le)&&(Le[je.message]=!0,V(Me),b("Failed %s type: %s",ee,je.message),V(null))}}}var Ue=Array.isArray;function se(A){return Ue(A)}function re(A){{var $=typeof Symbol=="function"&&Symbol.toStringTag,ee=$&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ee}}function oe(A){try{return z(A),!1}catch{return!0}}function z(A){return""+A}function de(A){if(oe(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",re(A)),z(A)}var Ce=v.ReactCurrentOwner,We={key:!0,ref:!0,__self:!0,__source:!0},dt,le;function pe(A){if(Re.call(A,"ref")){var $=Object.getOwnPropertyDescriptor(A,"ref").get;if($&&$.isReactWarning)return!1}return A.ref!==void 0}function Ve(A){if(Re.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"&&Ce.current}function Ze(A,$){{var ee=function(){dt||(dt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};ee.isReactWarning=!0,Object.defineProperty(A,"key",{get:ee,configurable:!0})}}function Bt(A,$){{var ee=function(){le||(le=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};ee.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ee,configurable:!0})}}var J=function(A,$,ee,ye,Me,Oe,Be){var je={$$typeof:e,type:A,key:$,ref:ee,props:Be,_owner:Oe};return je._store={},Object.defineProperty(je._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(je,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ye}),Object.defineProperty(je,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(je.props),Object.freeze(je)),je};function L(A,$,ee,ye,Me){{var Oe,Be={},je=null,gt=null;ee!==void 0&&(de(ee),je=""+ee),Ve($)&&(de($.key),je=""+$.key),pe($)&&(gt=$.ref,Xe($,Me));for(Oe in $)Re.call($,Oe)&&!We.hasOwnProperty(Oe)&&(Be[Oe]=$[Oe]);if(A&&A.defaultProps){var et=A.defaultProps;for(Oe in et)Be[Oe]===void 0&&(Be[Oe]=et[Oe])}if(je||gt){var rt=typeof A=="function"?A.displayName||A.name||"Unknown":A;je&&Ze(Be,rt),gt&&Bt(Be,rt)}return J(A,je,gt,Me,ye,Ce.current,Be)}}var fe=v.ReactCurrentOwner,me=v.ReactDebugCurrentFrame;function K(A){if(A){var $=A._owner,ee=ve(A.type,A._source,$?$.type:null);me.setExtraStackFrame(ee)}else me.setExtraStackFrame(null)}var De;De=!1;function Se(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function ke(){{if(fe.current){var A=R(fe.current.type);if(A)return`
49
49
 
50
- Check the render method of \``+A+"`."}return""}}function Pe(A){return""}var We={};function Se(A){{var $=Ce();if(!$){var te=typeof A=="string"?A:A.displayName||A.name;te&&($=`
50
+ Check the render method of \``+A+"`."}return""}}function Pe(A){return""}var He={};function Ee(A){{var $=ke();if(!$){var ee=typeof A=="string"?A:A.displayName||A.name;ee&&($=`
51
51
 
52
- Check the top-level render call using <`+te+">.")}return $}}function De(A,$){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var te=Se($);if(We[te])return;We[te]=!0;var xe="";A&&A._owner&&A._owner!==fe.current&&(xe=" It was passed a child from "+R(A._owner.type)+"."),K(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,xe),K(null)}}function et(A,$){{if(typeof A!="object")return;if(ie(A))for(var te=0;te<A.length;te++){var xe=A[te];we(xe)&&De(xe,$)}else if(we(A))A._store&&(A._store.validated=!0);else if(A){var je=x(A);if(typeof je=="function"&&je!==A.entries)for(var Oe=je.call(A),Ne;!(Ne=Oe.next()).done;)we(Ne.value)&&De(Ne.value,$)}}}function st(A){{var $=A.type;if($==null||typeof $=="string")return;var te;if(typeof $=="function")te=$.propTypes;else if(typeof $=="object"&&($.$$typeof===l||$.$$typeof===d))te=$.propTypes;else return;if(te){var xe=R($);z(te,A.props,"prop",xe,A)}else if($.PropTypes!==void 0&&!Ee){Ee=!0;var je=R($);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",je||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&b("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),te=0;te<$.length;te++){var xe=$[te];if(xe!=="children"&&xe!=="key"){K(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",xe),K(null);break}}A.ref!==null&&(K(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}var ze={};function ct(A,$,te,xe,je,Oe){{var Ne=N(A);if(!Ne){var Be="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Be+=" 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 ht=Pe();ht?Be+=ht:Be+=Ce();var Ze;A===null?Ze="null":ie(A)?Ze="array":A!==void 0&&A.$$typeof===e?(Ze="<"+(R(A.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):Ze=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ze,Be)}var tt=L(A,$,te,je,Oe);if(tt==null)return tt;if(Ne){var Tt=$.children;if(Tt!==void 0)if(xe)if(ie(Tt)){for(var zr=0;zr<Tt.length;zr++)et(Tt[zr],A);Object.freeze&&Object.freeze(Tt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else et(Tt,A)}if(Me.call($,"key")){var vr=R(A),bt=Object.keys($).filter(function(Md){return Md!=="key"}),Si=bt.length>0?"{key: someKey, "+bt.join(": ..., ")+": ...}":"{key: someKey}";if(!ze[vr+Si]){var jd=bt.length>0?"{"+bt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+ee+">.")}return $}}function Te(A,$){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ee=Ee($);if(He[ee])return;He[ee]=!0;var ye="";A&&A._owner&&A._owner!==fe.current&&(ye=" It was passed a child from "+R(A._owner.type)+"."),K(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ee,ye),K(null)}}function tt(A,$){{if(typeof A!="object")return;if(se(A))for(var ee=0;ee<A.length;ee++){var ye=A[ee];Se(ye)&&Te(ye,$)}else if(Se(A))A._store&&(A._store.validated=!0);else if(A){var Me=x(A);if(typeof Me=="function"&&Me!==A.entries)for(var Oe=Me.call(A),Be;!(Be=Oe.next()).done;)Se(Be.value)&&Te(Be.value,$)}}}function it(A){{var $=A.type;if($==null||typeof $=="string")return;var ee;if(typeof $=="function")ee=$.propTypes;else if(typeof $=="object"&&($.$$typeof===l||$.$$typeof===d))ee=$.propTypes;else return;if(ee){var ye=R($);O(ee,A.props,"prop",ye,A)}else if($.PropTypes!==void 0&&!De){De=!0;var Me=R($);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Me||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ge(A){{for(var $=Object.keys(A.props),ee=0;ee<$.length;ee++){var ye=$[ee];if(ye!=="children"&&ye!=="key"){K(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ye),K(null);break}}A.ref!==null&&(K(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}var ze={};function ft(A,$,ee,ye,Me,Oe){{var Be=N(A);if(!Be){var je="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(je+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var gt=Pe();gt?je+=gt:je+=ke();var et;A===null?et="null":se(A)?et="array":A!==void 0&&A.$$typeof===e?(et="<"+(R(A.type)||"Unknown")+" />",je=" Did you accidentally export a JSX literal instead of a component?"):et=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",et,je)}var rt=L(A,$,ee,Me,Oe);if(rt==null)return rt;if(Be){var Tt=$.children;if(Tt!==void 0)if(ye)if(se(Tt)){for(var zr=0;zr<Tt.length;zr++)tt(Tt[zr],A);Object.freeze&&Object.freeze(Tt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else tt(Tt,A)}if(Re.call($,"key")){var vr=R(A),bt=Object.keys($).filter(function(Md){return Md!=="key"}),Si=bt.length>0?"{key: someKey, "+bt.join(": ..., ")+": ...}":"{key: someKey}";if(!ze[vr+Si]){var jd=bt.length>0?"{"+bt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
53
53
  let props = %s;
54
54
  <%s {...props} />
55
55
  React keys must be passed directly to JSX without using spread:
56
56
  let props = %s;
57
- <%s key={someKey} {...props} />`,Si,vr,jd,vr),ze[vr+Si]=!0}}return A===n?Ve(tt):st(tt),tt}}function dt(A,$,te){return ct(A,$,te,!0)}function At(A,$,te){return ct(A,$,te,!1)}var Zt=At,jt=dt;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=jt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=lf():Vi.exports=uf();var h=Vi.exports;const lu=y.createContext(void 0);function cf({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[a,l]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),f=y.useCallback(async D=>{const k=await d.isAdmin(D);l(k)},[d]),p=y.useCallback(()=>{const D=rt.getToken(),k=rt.getUser();D&&k?(o(D),s(k),f(k._id).finally(()=>c(!1))):c(!1)},[f]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(D,k)=>{const w=await d.login(D,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),m=y.useCallback(async(D,k,w)=>d.register(D,k,w),[d]),x=y.useCallback(async(D,k)=>{const w=await d.verifyEmail(D,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),v=y.useCallback(async D=>d.requestPasswordReset(D),[d]),b=y.useCallback(async(D,k,w)=>{const E=await d.setPasswordWithCode(D,k,w);return E.success&&E.user&&E.token&&(o(E.token),s(E.user),await f(E.user._id)),E},[d,f]),_=y.useCallback(async D=>d.resendVerificationCode(D),[d]),S=y.useCallback(()=>{d.logout(),s(null),o(null),l(!1)},[d]);return h.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:a,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:v,setPasswordWithCode:b,resendVerificationCode:_,logout:S,refreshUser:p},children:t})}function df(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const ff={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:a="Mot de passe",theme:l,className:u="",isModal:c=!1}){const[d,f]=y.useState(""),[p,g]=y.useState(""),[m,x]=y.useState(""),[v,b]=y.useState(!1),_={...ff,...l};async function S(N){N.preventDefault(),b(!0),x("");const T=await r(d,p);T.success?e==null||e():x(T.error||"Connexion impossible"),b(!1)}const D={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"},E={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"},M={padding:"0.75rem",backgroundColor:_.errorBackgroundColor,border:`1px solid ${_.errorColor}20`,borderRadius:_.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:_.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:M,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:N=>f(N.target.value),required:!0,style:k,onFocus:N=>{N.target.style.borderColor=_.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=_.borderColor,N.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:w,children:a}),h.jsx("input",{type:"password",value:p,onChange:N=>g(N.target.value),required:!0,style:k,onFocus:N=>{N.target.style.borderColor=_.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=_.borderColor,N.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:v,style:E,onMouseEnter:N=>{v||(N.target.style.backgroundColor=_.primaryHoverColor)},onMouseLeave:N=>{v||(N.target.style.backgroundColor=_.primaryColor)},children:v?i:s})]})]})}function hf({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:a=>{a.target.style.color="#4B5563"},onMouseLeave:a=>{a.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,jd,vr),ze[vr+Si]=!0}}return A===n?Ge(rt):it(rt),rt}}function ht(A,$,ee){return ft(A,$,ee,!0)}function At(A,$,ee){return ft(A,$,ee,!1)}var Zt=At,jt=ht;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=jt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=lf():Vi.exports=uf();var h=Vi.exports;const lu=y.createContext(void 0);function cf({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[a,l]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),f=y.useCallback(async D=>{const k=await d.isAdmin(D);l(k)},[d]),p=y.useCallback(()=>{const D=nt.getToken(),k=nt.getUser();D&&k?(o(D),s(k),f(k._id).finally(()=>c(!1))):c(!1)},[f]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(D,k)=>{const w=await d.login(D,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),m=y.useCallback(async(D,k,w)=>d.register(D,k,w),[d]),x=y.useCallback(async(D,k)=>{const w=await d.verifyEmail(D,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),v=y.useCallback(async D=>d.requestPasswordReset(D),[d]),b=y.useCallback(async(D,k,w)=>{const E=await d.setPasswordWithCode(D,k,w);return E.success&&E.user&&E.token&&(o(E.token),s(E.user),await f(E.user._id)),E},[d,f]),_=y.useCallback(async D=>d.resendVerificationCode(D),[d]),S=y.useCallback(()=>{d.logout(),s(null),o(null),l(!1)},[d]);return h.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:a,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:v,setPasswordWithCode:b,resendVerificationCode:_,logout:S,refreshUser:p},children:t})}function df(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const ff={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:a="Mot de passe",theme:l,className:u="",isModal:c=!1}){const[d,f]=y.useState(""),[p,g]=y.useState(""),[m,x]=y.useState(""),[v,b]=y.useState(!1),_={...ff,...l};async function S(N){N.preventDefault(),b(!0),x("");const T=await r(d,p);T.success?e==null||e():x(T.error||"Connexion impossible"),b(!1)}const D={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"},E={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"},M={padding:"0.75rem",backgroundColor:_.errorBackgroundColor,border:`1px solid ${_.errorColor}20`,borderRadius:_.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:_.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:M,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:N=>f(N.target.value),required:!0,style:k,onFocus:N=>{N.target.style.borderColor=_.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=_.borderColor,N.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:w,children:a}),h.jsx("input",{type:"password",value:p,onChange:N=>g(N.target.value),required:!0,style:k,onFocus:N=>{N.target.style.borderColor=_.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=_.borderColor,N.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:v,style:E,onMouseEnter:N=>{v||(N.target.style.backgroundColor=_.primaryHoverColor)},onMouseLeave:N=>{v||(N.target.style.backgroundColor=_.primaryColor)},children:v?i:s})]})]})}function hf({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:a=>{a.target.style.color="#4B5563"},onMouseLeave:a=>{a.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 pf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[v,b]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(""),[w,E]=y.useState(""),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(!1),j={...pf,...g};async function F(H){if(H.preventDefault(),B(""),_!==D){B("Les mots de passe ne correspondent pas");return}if(_.length<8){B("Le mot de passe doit contenir au moins 8 caractères");return}C(!0);const de=await r(v,_,p?{firstName:w,lastName:M}:void 0);de.success?e==null||e(v):B(de.error||"Erreur lors de l'inscription"),C(!1)}const O={backgroundColor:j.backgroundColor,borderRadius:j.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},U={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${j.borderColor}`,borderRadius:j.borderRadius,backgroundColor:j.inputBackground,color:j.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},W={display:"block",fontSize:"0.875rem",fontWeight:500,color:j.textMutedColor,marginBottom:"0.25rem"},re={width:"100%",padding:"0.75rem",backgroundColor:R?j.textMutedColor:j.primaryColor,color:"#ffffff",border:"none",borderRadius:j.borderRadius,fontSize:"1rem",fontWeight:500,cursor:R?"not-allowed":"pointer",transition:"background-color 0.2s"},q={padding:"0.75rem",backgroundColor:j.errorBackgroundColor,border:`1px solid ${j.errorColor}20`,borderRadius:j.borderRadius,marginBottom:"1rem"},Q={color:j.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:j.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:F,children:[T&&h.jsx("div",{style:q,children:h.jsx("p",{style:{fontSize:"0.875rem",color:j.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:W,children:c}),h.jsx("input",{type:"text",value:w,onChange:H=>E(H.target.value),style:U})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:W,children:d}),h.jsx("input",{type:"text",value:M,onChange:H=>N(H.target.value),style:U})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:W,children:a}),h.jsx("input",{type:"email",value:v,onChange:H=>b(H.target.value),required:!0,style:U})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:W,children:l}),h.jsx("input",{type:"password",value:_,onChange:H=>S(H.target.value),required:!0,minLength:8,style:U})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:W,children:u}),h.jsx("input",{type:"password",value:D,onChange:H=>k(H.target.value),required:!0,style:U})]}),h.jsx("button",{type:"submit",disabled:R,style:re,onMouseEnter:H=>{R||(H.target.style.backgroundColor=j.primaryHoverColor)},onMouseLeave:H=>{R||(H.target.style.backgroundColor=j.primaryColor)},children:R?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Q,onClick:t,children:f})})]})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:a="Vérifier",loadingText:l="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:f=6,theme:p,className:g="",isModal:m=!1}){const[x,v]=y.useState(Array(f).fill("")),[b,_]=y.useState(""),[S,D]=y.useState(!1),[k,w]=y.useState(!1),[E,M]=y.useState(!1),N=y.useRef([]),T={...gf,...p};y.useEffect(()=>{var q;(q=N.current[0])==null||q.focus()},[]);const B=(q,Q)=>{var de;const H=Q.replace(/\D/g,"").slice(-1),ne=[...x];if(ne[q]=H,v(ne),_(""),H&&q<f-1&&((de=N.current[q+1])==null||de.focus()),H&&q===f-1){const he=ne.join("");he.length===f&&j(he)}},R=(q,Q)=>{var H;Q.key==="Backspace"&&!x[q]&&q>0&&((H=N.current[q-1])==null||H.focus())},C=q=>{var de;q.preventDefault();const Q=q.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),H=[...x];Q.split("").forEach((he,pe)=>{pe<f&&(H[pe]=he)}),v(H);const ne=Math.min(Q.length,f)-1;ne>=0&&((de=N.current[ne])==null||de.focus()),Q.length===f&&j(Q)};async function j(q){var ne;const Q=q||x.join("");if(Q.length!==f){_("Veuillez entrer le code complet");return}D(!0),_("");const H=await e(r,Q);H.success?t==null||t():(_(H.error||"Code invalide"),v(Array(f).fill("")),(ne=N.current[0])==null||ne.focus()),D(!1)}async function F(){if(!n)return;w(!0),M(!1),_("");const q=await n(r);q.success?(M(!0),setTimeout(()=>M(!1),3e3)):_(q.error||"Erreur lors de l'envoi"),w(!1)}const O={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)"}},U={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"},W={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"},re={color:T.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: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}`}),b&&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:b})}),E&&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((q,Q)=>h.jsx("input",{ref:H=>{N.current[Q]=H},type:"text",inputMode:"numeric",maxLength:1,value:q,onChange:H=>B(Q,H.target.value),onKeyDown:H=>R(Q,H),onPaste:C,disabled:S,style:{...U,borderColor:q?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=q?T.primaryColor:T.borderColor,H.target.style.boxShadow="none"}},Q))}),h.jsx("button",{type:"button",onClick:()=>j(),disabled:S||x.join("").length!==f,style:{...W,opacity:x.join("").length!==f?.5:1},children:S?l:a}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:F,disabled:k,style:{...re,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:re,children:d})})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[f,p]=y.useState(""),[g,m]=y.useState(""),[x,v]=y.useState(!1),b={...mf,...u};async function _(M){M.preventDefault(),v(!0),m("");const N=await r(f);N.success?e==null||e(f):m(N.error||"Erreur lors de l'envoi"),v(!1)}const S={backgroundColor:b.backgroundColor,borderRadius:b.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 ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},k={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},w={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},E={color:b.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:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:_,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:k,children:a}),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:w,onMouseEnter:M=>{x||(M.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:M=>{x||(M.target.style.backgroundColor=b.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:E,children:l})})]})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:f,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[v,b]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(!1),w={...yf,...f};async function E(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 j=await t(r,e,m);j.success?n==null||n():S(j.error||"Erreur lors de la réinitialisation"),k(!1)}const M={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)"}},N={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"},B={width:"100%",padding:"0.75rem",backgroundColor:D?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},R={color:w.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: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:E,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:N})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:v,onChange:C=>b(C.target.value),required:!0,style:N})]}),h.jsx("button",{type:"submit",disabled:D,style:B,onMouseEnter:C=>{D||(C.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:C=>{D||(C.target.style.backgroundColor=w.primaryColor)},children:D?l:a}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:R,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:f=!1,labels:p={}}){const[g,m]=y.useState(a),[x,v]=y.useState(""),[b,_]=y.useState("");async function S(N,T){const B=await r(N,T);return B.requiresVerification?(v(N),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):B}async function D(N,T,B){const R=await e(N,T,B);return R.success&&R.requiresVerification&&(v(N),m("verify-email")),R}async function k(N){const T=await n(N);return T.success&&(v(N),m("verify-reset-code")),T}async function w(N,T){return _(T),m("reset-password"),{success:!0}}const E=()=>{switch(g){case"login":return h.jsx(No,{onLogin:S,onSuccess:o,logo:l,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(uu,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,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(cu,{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(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},M=()=>{const N={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:N,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:N,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[E(),M()]})}function xf({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(fu,{...n,isModal:!0})]}),h.jsx("style",{children:`
68
+ `})]})}const pf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[v,b]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(""),[w,E]=y.useState(""),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(!1),j={...pf,...g};async function F(H){if(H.preventDefault(),B(""),_!==D){B("Les mots de passe ne correspondent pas");return}if(_.length<8){B("Le mot de passe doit contenir au moins 8 caractères");return}C(!0);const ue=await r(v,_,p?{firstName:w,lastName:M}:void 0);ue.success?e==null||e(v):B(ue.error||"Erreur lors de l'inscription"),C(!1)}const I={backgroundColor:j.backgroundColor,borderRadius:j.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 ${j.borderColor}`,borderRadius:j.borderRadius,backgroundColor:j.inputBackground,color:j.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},q={display:"block",fontSize:"0.875rem",fontWeight:500,color:j.textMutedColor,marginBottom:"0.25rem"},ne={width:"100%",padding:"0.75rem",backgroundColor:R?j.textMutedColor:j.primaryColor,color:"#ffffff",border:"none",borderRadius:j.borderRadius,fontSize:"1rem",fontWeight:500,cursor:R?"not-allowed":"pointer",transition:"background-color 0.2s"},U={padding:"0.75rem",backgroundColor:j.errorBackgroundColor,border:`1px solid ${j.errorColor}20`,borderRadius:j.borderRadius,marginBottom:"1rem"},Q={color:j.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:j.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:j.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:q,children:c}),h.jsx("input",{type:"text",value:w,onChange:H=>E(H.target.value),style:W})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:q,children:d}),h.jsx("input",{type:"text",value:M,onChange:H=>N(H.target.value),style:W})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:q,children:a}),h.jsx("input",{type:"email",value:v,onChange:H=>b(H.target.value),required:!0,style:W})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:q,children:l}),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:q,children:u}),h.jsx("input",{type:"password",value:D,onChange:H=>k(H.target.value),required:!0,style:W})]}),h.jsx("button",{type:"submit",disabled:R,style:ne,onMouseEnter:H=>{R||(H.target.style.backgroundColor=j.primaryHoverColor)},onMouseLeave:H=>{R||(H.target.style.backgroundColor=j.primaryColor)},children:R?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Q,onClick:t,children:f})})]})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:a="Vérifier",loadingText:l="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:f=6,theme:p,className:g="",isModal:m=!1}){const[x,v]=y.useState(Array(f).fill("")),[b,_]=y.useState(""),[S,D]=y.useState(!1),[k,w]=y.useState(!1),[E,M]=y.useState(!1),N=y.useRef([]),T={...gf,...p};y.useEffect(()=>{var U;(U=N.current[0])==null||U.focus()},[]);const B=(U,Q)=>{var ue;const H=Q.replace(/\D/g,"").slice(-1),ie=[...x];if(ie[U]=H,v(ie),_(""),H&&U<f-1&&((ue=N.current[U+1])==null||ue.focus()),H&&U===f-1){const he=ie.join("");he.length===f&&j(he)}},R=(U,Q)=>{var H;Q.key==="Backspace"&&!x[U]&&U>0&&((H=N.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((he,ge)=>{ge<f&&(H[ge]=he)}),v(H);const ie=Math.min(Q.length,f)-1;ie>=0&&((ue=N.current[ie])==null||ue.focus()),Q.length===f&&j(Q)};async function j(U){var ie;const Q=U||x.join("");if(Q.length!==f){_("Veuillez entrer le code complet");return}D(!0),_("");const H=await e(r,Q);H.success?t==null||t():(_(H.error||"Code invalide"),v(Array(f).fill("")),(ie=N.current[0])==null||ie.focus()),D(!1)}async function F(){if(!n)return;w(!0),M(!1),_("");const U=await n(r);U.success?(M(!0),setTimeout(()=>M(!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"},q={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"},ne={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}`}),b&&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:b})}),E&&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=>{N.current[Q]=H},type:"text",inputMode:"numeric",maxLength:1,value:U,onChange:H=>B(Q,H.target.value),onKeyDown:H=>R(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:()=>j(),disabled:S||x.join("").length!==f,style:{...q,opacity:x.join("").length!==f?.5:1},children:S?l:a}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:F,disabled:k,style:{...ne,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:ne,children:d})})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[f,p]=y.useState(""),[g,m]=y.useState(""),[x,v]=y.useState(!1),b={...mf,...u};async function _(M){M.preventDefault(),v(!0),m("");const N=await r(f);N.success?e==null||e(f):m(N.error||"Erreur lors de l'envoi"),v(!1)}const S={backgroundColor:b.backgroundColor,borderRadius:b.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 ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},k={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},w={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},E={color:b.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:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:_,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:k,children:a}),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:w,onMouseEnter:M=>{x||(M.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:M=>{x||(M.target.style.backgroundColor=b.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:E,children:l})})]})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:f,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[v,b]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(!1),w={...yf,...f};async function E(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 j=await t(r,e,m);j.success?n==null||n():S(j.error||"Erreur lors de la réinitialisation"),k(!1)}const M={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)"}},N={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"},B={width:"100%",padding:"0.75rem",backgroundColor:D?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},R={color:w.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: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:E,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:N})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:v,onChange:C=>b(C.target.value),required:!0,style:N})]}),h.jsx("button",{type:"submit",disabled:D,style:B,onMouseEnter:C=>{D||(C.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:C=>{D||(C.target.style.backgroundColor=w.primaryColor)},children:D?l:a}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:R,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:f=!1,labels:p={}}){const[g,m]=y.useState(a),[x,v]=y.useState(""),[b,_]=y.useState("");async function S(N,T){const B=await r(N,T);return B.requiresVerification?(v(N),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):B}async function D(N,T,B){const R=await e(N,T,B);return R.success&&R.requiresVerification&&(v(N),m("verify-email")),R}async function k(N){const T=await n(N);return T.success&&(v(N),m("verify-reset-code")),T}async function w(N,T){return _(T),m("reset-password"),{success:!0}}const E=()=>{switch(g){case"login":return h.jsx(No,{onLogin:S,onSuccess:o,logo:l,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(uu,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,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(cu,{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(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},M=()=>{const N={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:N,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:N,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[E(),M()]})}function xf({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(fu,{...n,isModal:!0})]}),h.jsx("style",{children:`
69
69
  @keyframes authFlowSlideUp {
70
70
  from {
71
71
  opacity: 0;
@@ -80,32 +80,32 @@ React keys must be passed directly to JSX without using spread:
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:[l&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:l,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})]}),a&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),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 wf({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((a,l)=>{const u=a.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:a.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(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 Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var N,T;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const B=Cf(r),R=Math.ceil(B.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:B.slice(0,R).map(C=>C.title),right:B.slice(R).map(C=>C.title)}),[B.slice(0,R),B.slice(R)]}),[l,u]=y.useState(()=>{const B=Ea[s];if(typeof window>"u")return B.base;const R=window.innerWidth;return"lg"in B&&R>=1024?B.lg:R>=768?B.md:R>=640?B.sm:B.base});y.useEffect(()=>{const B=()=>{const R=Ea[s],C=window.innerWidth;"lg"in R&&C>=1024?u(R.lg):C>=768?u(R.md):C>=640?u(R.sm):u(R.base)};return window.addEventListener("resize",B),B(),()=>window.removeEventListener("resize",B)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(!1),[b,_]=y.useState(!1),[S,D]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const B=setInterval(()=>{m(R=>!R),setTimeout(()=>{d(R=>(R+1)%a[0].length),_(R=>!R)},250)},e+Math.random()*(t-e));return()=>clearInterval(B)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let B=null;const R=setTimeout(()=>{B=setInterval(()=>{v(C=>!C),setTimeout(()=>{p(C=>(C+1)%a[1].length),D(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(R),B&&clearInterval(B)}},[a,e,t]);const k=(N=a[0])==null?void 0:N[c],w=(T=a[1])==null?void 0:T[f];if(r.length===0||!k)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const E=i==="2:3"?l*1.5:l,M=(B,R,C)=>h.jsx("div",{className:"relative",style:{width:l,height:E,perspective:"1000px"},onClick:()=>n==null?void 0:n(B),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${R?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:B.data.image,alt:B.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:B.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[M(k,g,b),w&&M(w,x,S)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:_,renderEmpty:S,renderLoading:D,theme:k={}}){const w={...kf,...k},[E,M]=y.useState([]),[N,T]=y.useState(!1),[B,R]=y.useState(null),[C,j]=y.useState(new Set),[F,O]=y.useState(null),[U,W]=y.useState(null),[re,q]=y.useState(null),[Q,H]=y.useState(!1),[ne,de]=y.useState(""),he=l!==void 0?l:ne,pe=ae=>{u?u(ae):de(ae)},ke=y.useMemo(()=>{if(!he.trim())return E;const ae=he.toLowerCase();return E.filter(ge=>$r(ge.from).toLowerCase().includes(ae)||$r(ge.subject).toLowerCase().includes(ae))},[E,he]),me=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),J=y.useCallback(async()=>{if(me){T(!0),R(null);try{const ae=await me.listEmails(t,n,s);ae!=null&&ae.messages&&(M(ae.messages),x==null||x(ae.messages))}catch(ae){const ge=ae instanceof Error?ae:new Error("Failed to fetch emails");R(ge.message),m==null||m(ge)}T(!1)}},[me,t,n,s,m,x]);y.useEffect(()=>{M([]),j(new Set),W(null),R(null),l===void 0&&de(""),d&&J()},[s,d]);const be=y.useCallback(async ae=>{if(me){W(ae),q(null),H(!0);try{const ge=await me.getEmailParsed(t,ae.uid,s||"INBOX");ge!=null&&ge.body&&q(ge.body)}catch(ge){console.error("Failed to fetch email body:",ge)}H(!1)}},[me,t,s]),se=y.useCallback(ae=>{f==null||f(ae),o&&be(ae)},[f,o,be]),Ae=y.useCallback((ae,ge,He)=>{if(!i){f==null||f(ae),o&&be(ae);return}const Je=ae.uid;if(He.shiftKey&&F!==null){const Xe=Math.min(F,ge),Bt=Math.max(F,ge),Z=E.slice(Xe,Bt+1).map(fe=>fe.uid),L=new Set(Z);j(L),p==null||p(Array.from(L))}else if(He.ctrlKey||He.metaKey)j(Xe=>{const Bt=new Set(Xe);return Bt.has(Je)?Bt.delete(Je):Bt.add(Je),p==null||p(Array.from(Bt)),Bt}),O(ge);else{const Xe=new Set([Je]);j(Xe),O(ge),p==null||p(Array.from(Xe))}},[i,F,E,C,f,p,o]),_e=y.useCallback(async()=>{if(!me||C.size===0)return;const ae=s||"INBOX";try{const ge=await me.trashEmails(t,Array.from(C),ae);if(console.log("Trash result:",ge),ge.success&&ge.moved>0){M(Je=>Je.filter(Xe=>!C.has(Xe.uid)));const He=Array.from(C);j(new Set),g==null||g(He)}else R("Failed to move emails to trash")}catch(ge){const He=ge instanceof Error?ge:new Error("Trash failed");console.error("Trash error:",He),R(He.message),m==null||m(He)}},[me,t,C,s,g,m]),ve=y.useCallback(async()=>{if(!me||C.size===0)return;const ae=s||"INBOX";try{const ge=await me.archiveEmails(t,Array.from(C),ae);if(console.log("Archive result:",ge),ge.success&&ge.archived>0){M(Je=>Je.filter(Xe=>!C.has(Xe.uid)));const He=Array.from(C);j(new Set),g==null||g(He)}else R("Failed to archive emails")}catch(ge){const He=ge instanceof Error?ge:new Error("Archive failed");console.error("Archive error:",He),R(He.message),m==null||m(He)}},[me,t,C,s,g,m]),Me=y.useCallback(()=>{if(C.size===E.length)j(new Set),p==null||p([]);else{const ae=new Set(E.map(ge=>ge.uid));j(ae),p==null||p(Array.from(ae))}},[E,C.size,p]),Fe=y.useCallback(()=>{j(new Set),p==null||p([])},[p]),qe={delete:_e,archive:ve,refresh:J,selectAll:Me,clearSelection:Fe},V=ae=>{if(!ae)return"";const ge=new Date(ae),He=new Date;return ge.toDateString()===He.toDateString()?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ge.toLocaleDateString([],{month:"short",day:"numeric"})},z=(ae,ge)=>h.jsx("div",{style:{padding:"12px 16px",background:ge?w.selectedBackground:ae.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:ae.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:500,color:ae.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:V(ae.date)})]})}),Le=ae=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(ae.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(ae.from)," • ",new Date(ae.date).toLocaleString()]}),Q?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):re?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:re}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),ie=(ae,ge)=>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:ge.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:ae.length===E.length?"Deselect All":"Select All"}),ae.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[ae.length," selected"]}),h.jsx("button",{onClick:ge.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:ge.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:ge.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"})})]}),P=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),X=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),ue=v||z,ce=b||Le,Ue=_||ie,yt=S||P,xt=D||X;return N&&E.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:xt()}):h.jsxs("div",{style:{display:"flex",background:w.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&U?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&U?`1px solid ${w.border}`:"none",overflow:"hidden"},children:[i&&Ue(Array.from(C),qe),a&&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:he,onChange:ae=>pe(ae.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),he&&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"})})})]})}),B&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:B}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ke.length===0?yt():ke.map((ae,ge)=>h.jsx("div",{onClick:He=>Ae(ae,ge,He),onDoubleClick:()=>se(ae),children:ue(ae,C.has(ae.uid))},ae.uid))})]}),o&&U&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ce(U)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(D=>{const k=new Set(D);return k.has(S)?k.delete(S):k.add(S),t==null||t(Array.from(k)),k})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(D=>D.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(D=>D.id))}},[r,u.size,t,n]),v=y.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]),b=y.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]),_=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.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 ${l}`,children:o}):h.jsxs("div",{className:`space-y-2 ${l}`,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:[a&&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:b,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 D=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":D?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.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(S,D,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 D=((k=S.disabled)==null?void 0:k.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(S.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:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},Of={},Su={},ku={},zf={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$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)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,Oo=3,zo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",sr=`
83
+ `,children:[l&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:l,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})]}),a&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),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 wf({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((a,l)=>{const u=a.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:a.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(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 Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var N,T;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const B=Cf(r),R=Math.ceil(B.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:B.slice(0,R).map(C=>C.title),right:B.slice(R).map(C=>C.title)}),[B.slice(0,R),B.slice(R)]}),[l,u]=y.useState(()=>{const B=Ea[s];if(typeof window>"u")return B.base;const R=window.innerWidth;return"lg"in B&&R>=1024?B.lg:R>=768?B.md:R>=640?B.sm:B.base});y.useEffect(()=>{const B=()=>{const R=Ea[s],C=window.innerWidth;"lg"in R&&C>=1024?u(R.lg):C>=768?u(R.md):C>=640?u(R.sm):u(R.base)};return window.addEventListener("resize",B),B(),()=>window.removeEventListener("resize",B)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(!1),[b,_]=y.useState(!1),[S,D]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const B=setInterval(()=>{m(R=>!R),setTimeout(()=>{d(R=>(R+1)%a[0].length),_(R=>!R)},250)},e+Math.random()*(t-e));return()=>clearInterval(B)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let B=null;const R=setTimeout(()=>{B=setInterval(()=>{v(C=>!C),setTimeout(()=>{p(C=>(C+1)%a[1].length),D(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(R),B&&clearInterval(B)}},[a,e,t]);const k=(N=a[0])==null?void 0:N[c],w=(T=a[1])==null?void 0:T[f];if(r.length===0||!k)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const E=i==="2:3"?l*1.5:l,M=(B,R,C)=>h.jsx("div",{className:"relative",style:{width:l,height:E,perspective:"1000px"},onClick:()=>n==null?void 0:n(B),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${R?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:B.data.image,alt:B.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:B.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[M(k,g,b),w&&M(w,x,S)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:_,renderEmpty:S,renderLoading:D,theme:k={}}){const w={...kf,...k},[E,M]=y.useState([]),[N,T]=y.useState(!1),[B,R]=y.useState(null),[C,j]=y.useState(new Set),[F,I]=y.useState(null),[W,q]=y.useState(null),[ne,U]=y.useState(null),[Q,H]=y.useState(!1),[ie,ue]=y.useState(""),he=l!==void 0?l:ie,ge=le=>{u?u(le):ue(le)},we=y.useMemo(()=>{if(!he.trim())return E;const le=he.toLowerCase();return E.filter(pe=>$r(pe.from).toLowerCase().includes(le)||$r(pe.subject).toLowerCase().includes(le))},[E,he]),xe=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),Z=y.useCallback(async()=>{if(xe){T(!0),R(null);try{const le=await xe.listEmails(t,n,s);le!=null&&le.messages&&(M(le.messages),x==null||x(le.messages))}catch(le){const pe=le instanceof Error?le:new Error("Failed to fetch emails");R(pe.message),m==null||m(pe)}T(!1)}},[xe,t,n,s,m,x]);y.useEffect(()=>{M([]),j(new Set),q(null),R(null),l===void 0&&ue(""),d&&Z()},[s,d]);const be=y.useCallback(async le=>{if(xe){q(le),U(null),H(!0);try{const pe=await xe.getEmailParsed(t,le.uid,s||"INBOX");pe!=null&&pe.body&&U(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}H(!1)}},[xe,t,s]),te=y.useCallback(le=>{f==null||f(le),o&&be(le)},[f,o,be]),Ae=y.useCallback((le,pe,Ve)=>{if(!i){f==null||f(le),o&&be(le);return}const Xe=le.uid;if(Ve.shiftKey&&F!==null){const Ze=Math.min(F,pe),Bt=Math.max(F,pe),J=E.slice(Ze,Bt+1).map(fe=>fe.uid),L=new Set(J);j(L),p==null||p(Array.from(L))}else if(Ve.ctrlKey||Ve.metaKey)j(Ze=>{const Bt=new Set(Ze);return Bt.has(Xe)?Bt.delete(Xe):Bt.add(Xe),p==null||p(Array.from(Bt)),Bt}),I(pe);else{const Ze=new Set([Xe]);j(Ze),I(pe),p==null||p(Array.from(Ze))}},[i,F,E,C,f,p,o]),_e=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const pe=await xe.trashEmails(t,Array.from(C),le);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){M(Xe=>Xe.filter(Ze=>!C.has(Ze.uid)));const Ve=Array.from(C);j(new Set),g==null||g(Ve)}else R("Failed to move emails to trash")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ve),R(Ve.message),m==null||m(Ve)}},[xe,t,C,s,g,m]),ve=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const pe=await xe.archiveEmails(t,Array.from(C),le);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){M(Xe=>Xe.filter(Ze=>!C.has(Ze.uid)));const Ve=Array.from(C);j(new Set),g==null||g(Ve)}else R("Failed to archive emails")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ve),R(Ve.message),m==null||m(Ve)}},[xe,t,C,s,g,m]),Re=y.useCallback(()=>{if(C.size===E.length)j(new Set),p==null||p([]);else{const le=new Set(E.map(pe=>pe.uid));j(le),p==null||p(Array.from(le))}},[E,C.size,p]),Le=y.useCallback(()=>{j(new Set),p==null||p([])},[p]),qe={delete:_e,archive:ve,refresh:Z,selectAll:Re,clearSelection:Le},V=le=>{if(!le)return"";const pe=new Date(le),Ve=new Date;return pe.toDateString()===Ve.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},O=(le,pe)=>h.jsx("div",{style:{padding:"12px 16px",background:pe?w.selectedBackground:le.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:le.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:le.seen?400:500,color:le.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:V(le.date)})]})}),Ue=le=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(le.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(le.from)," • ",new Date(le.date).toLocaleString()]}),Q?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):ne?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:ne}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),se=(le,pe)=>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:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:le.length===E.length?"Deselect All":"Select All"}),le.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[le.length," selected"]}),h.jsx("button",{onClick:pe.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:pe.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:pe.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"})})]}),re=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),oe=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),z=v||O,de=b||Ue,Ce=_||se,We=S||re,dt=D||oe;return N&&E.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:dt()}):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&&Ce(Array.from(C),qe),a&&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:he,onChange:le=>ge(le.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),he&&h.jsx("button",{onClick:()=>ge(""),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"})})})]})}),B&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:B}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:we.length===0?We():we.map((le,pe)=>h.jsx("div",{onClick:Ve=>Ae(le,pe,Ve),onDoubleClick:()=>te(le),children:z(le,C.has(le.uid))},le.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:de(W)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(D=>{const k=new Set(D);return k.has(S)?k.delete(S):k.add(S),t==null||t(Array.from(k)),k})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(D=>D.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(D=>D.id))}},[r,u.size,t,n]),v=y.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]),b=y.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]),_=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.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 ${l}`,children:o}):h.jsxs("div",{className:`space-y-2 ${l}`,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:[a&&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:b,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 D=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":D?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.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(S,D,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 D=((k=S.disabled)==null?void 0:k.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(S.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:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},Of={},Su={},ku={},zf={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$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)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,Oo=3,zo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",sr=`
84
84
 
85
- `,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:zo,left:Po,right:Oo,start:$o},nh={[Io]:"center",[qo]:"end",[zo]:"justify",[Po]:"left",[Oo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Y=oh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const ah=100;let Qi=!1,Uo=0;function lh(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 uh(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 ch(r,e,t){if(G(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=ft(i,t);if(o)return $e(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{kt(r,()=>{const s=le()||function(f){return f.getEditorState().read(()=>{const p=le();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=dh(m,r,a,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&ee(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let k=0;k<_.length;k++){const w=_[k],E=Lu(w),M=w.parentNode;if(M!=null&&w!==l&&E===null&&!Bi(w,M,r)){if(mr){const N=w.innerText||w.nodeValue;N&&(c+=N)}M.removeChild(w)}}const S=p.removedNodes,D=S.length;if(D>0){let k=0;for(let w=0;w<D;w++){const E=S[w];(Bi(E,m,r)||l===E)&&(m.appendChild(E),k++)}D!==k&&i.set(v,b)}}}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],b=v.parentNode;b==null||v.nodeName!=="BR"||Bi(v,m,r)||b.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=Qe()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&ee(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&ee(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),ee(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!I(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let fh=1;const hh=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 $e(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 ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return ee(r)||Ar(r)||$e(r)}function gh(r,e){if(e!=null)return void(r.__key=e);_t(),uc();const t=Qe(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),I(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const a=i.getWritable();a.__prev=o.__key,o.__next=a.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Qe(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;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 a=e.__key;s._dirtyType=Du,I(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ut(r){_t();const e=Qe(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ft(t);n!==null&&n.getWritable()}if(r!==null){const n=ft(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Qe()._compositionKey}function ft(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,Qe());return t!==void 0?ft(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ge().getTextContent())}function Ge(){return Iu(ar())}function Iu(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()?ft("root"):null:ft(t)}function Ra(r,e){return e?r.getTextContentSize():0}function Ou(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 zu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Nt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&ee(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ut(null),oi||Vn||Fo)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||G(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=le();if(!G(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=it(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function mh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(ee(o)||I(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function yh(){const r=Ge();Kt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&Y(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function Oa(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 Oa(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?Oa(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function oe(r,e,t){return fc(r,e,t)}function ci(r){return!gt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&Y(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&&Y(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return gt(r)||I(r)&&r.isShadowRoot()}function Jt(r){const e=Qe(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&Y(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||Y(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||Y(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&Y(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!gt(r.getParent())||I(e)||$e(e)||Y(99)}function Mi(r){return($e(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 bh(r,e,t){let n=r._blockCursorElement;if(G(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,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=Rs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Nt(r){return $t?(r||window).getSelection():null}function vh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function za(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function 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($e(r)&&!r.isInline())return!0;if(!I(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function _h(){return Qe()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||Y(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&(I(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let yr,mt,In,fi,Xi,Zi,jr,Ot,eo,On,ot="",pt="",Ut=null,Rt="",rr="",Wu=!1,zn=!1,_s=null;function zs(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||mt._keyToDOMMap.delete(r),I(t)){const n=qs(t,jr);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 kh="40px";function Hu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===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&&Y(60);const n=t.createDOM(yr,mt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,mt),ee(t)?n.setAttribute("data-lexical-text","true"):$e(t)&&n.setAttribute("data-lexical-decorator","true"),I(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const f=pt;pt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),pt=f})(qs(t,Ot),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ot+=sr,rr+=sr)}else{const s=t.getTextContent();if($e(t)){const i=t.decorate(mt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else ee(t)&&(t.isDirectionless()||(pt+=s));ot+=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=ot;ot="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=Ot.get(r[o]);a!==null&&ee(a)&&(Ut===null&&(Ut=a.getFormat()),Rt===""&&(Rt=a.getStyle()))}ci(e)&&(ot+=sr),s.element.__lexicalTextContent=ot,ot=i+ot}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":$e(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==pt||n!==_s){const i=pt==="",o=i?_s:(s=pt,eh.test(s)?"rtl":th.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=yr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=pt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=pt;var s;pt="",Ut=null,Rt="",function(i,o,a){const l=ot,u=i.__size,c=o.__size;ot="";const d=a.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 b=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw v}zs(f,null)}const g=Ot.get(p);ee(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,Ot);if(f.length!==u&&Y(227),p.length!==c&&Y(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,_){const S=v-1,D=b-1;let k,w,E=_.getFirstChild(),M=0,N=0;for(;M<=S&&N<=D;){const R=m[M],C=x[N];if(R===C)E=Ri(_n(C,_.element)),M++,N++;else{k===void 0&&(k=new Set(m)),w===void 0&&(w=new Set(x));const F=w.has(R),O=k.has(C);if(F)if(O){const U=Is(mt,C);U===E?E=Ri(_n(C,_.element)):(_.withBefore(E).insertChild(U),_n(C,_.element)),M++,N++}else $s(C,_.withBefore(E)),N++;else E=Ri(no(R)),zs(R,_.element),M++}const j=Ot.get(C);j!==null&&ee(j)&&(Ut===null&&(Ut=j.getFormat()),Rt===""&&(Rt=j.getStyle()))}const T=M>S,B=N>D;if(T&&!B){const R=x[D+1],C=R===void 0?null:mt.getElementByKey(R);ro(x,g,N,D,_.withBefore(C))}else B&&!T&&to(m,M,S,_.element)})(o,f,p,u,c,a)}ci(o)&&(ot+=sr),d.__lexicalTextContent=ot,ot=l+ot}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!zn&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!zn&&i.setTextStyle(Rt)}(e),pt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&Y(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||Y(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(mt,r);if(t===n&&!s){if(I(t)){const o=i.__lexicalTextContent;o!==void 0&&(ot+=o,rr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(pt+=a)}else{const o=t.getTextContent();ee(t)&&!t.isDirectionless()&&(pt+=o),rr+=o,ot+=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&&Y(62),e.replaceChild(o,i),zs(r,null),o}if(I(t)&&I(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Eh(t,n,i),gt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ot+=sr,rr+=sr)}else{const o=n.getTextContent();if($e(n)){const a=n.decorate(mt,yr);a!==null&&Yu(r,a)}else ee(n)&&!n.isDirectionless()&&(pt+=o);ot+=o,rr+=o}if(!zn&&gt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=mt._pendingDecorators;const n=mt._decorators;if(t===null){if(n[r]===e)return;t=Pu(mt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===mt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){ot="",rr="",pt="",Wu=n===Zr,_s=null,mt=t,yr=t._config,In=t._nodes,fi=mt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,Ot=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),mt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=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&&Y(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!oe(e,jf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))oe(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))oe(e,Mf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))oe(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))oe(e,Rf,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))oe(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))oe(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,oe(e,Ns,r);else if(function(a){return a===" "}(t))oe(e,Ff,r);else if(function(a,l){return Mt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,oe(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,oe(e,Ns,r);else if(function(a,l,u,c){return Mt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?oe(e,vu,r):(r.preventDefault(),oe(e,Er,!0));else if(function(a){return a==="Escape"}(t))oe(e,_u,r);else if(function(a,l,u,c,d){return Mt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?oe(e,wu,r):(r.preventDefault(),oe(e,Er,!1));else if(function(a,l,u){return fn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!1);else if(function(a,l){return Mt&&l&&fn(a)}(t,i))r.preventDefault(),oe(e,Ln,!0);else if(function(a,l){return Mt&&l&&hn(a)}(t,i))r.preventDefault(),oe(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))oe(e,Lf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),oe(e,jo,void 0);else if(function(a,l,u,c){return Mt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),oe(e,Mo,void 0);else{const a=e._editorState._selection;a===null||G(a)?!mr&&Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&oe(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&kt(e,()=>{$e(en(t))||(ao=!0)})}],["compositionstart",function(r,e){kt(e,()=>{const t=le();if(G(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ut(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||ee(s)&&s.getStyle()!==t.style)&&oe(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:kt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),kt(e,()=>{const t=le(),n=r.data,s=ec(r);if(n!=null&&G(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Nt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&ee(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||oe(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ut(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);_t(),Bu(Qe())}),Wr=null}],["click",function(r,e){kt(e,()=>{const t=le(),n=Nt(e._window),s=Zn();if(n){if(G(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!gt(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))}}}oe(e,gu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&kt(n,()=>{const o=le();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!G(p))return;Kt(p.clone())}if(G(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ut(null),Nn=0,setTimeout(()=>{kt(n,()=>{ut(null)})},so),G(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),ee(g)||Y(142),o.style=g.getStyle()}}else{ut(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!v&&x||oe(n,Er,!0)}return}}var a;if(!G(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||gt(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":oe(n,Yr,t);break;case"insertFromComposition":ut(null),oe(n,Yr,t);break;case"insertLineBreak":ut(null),oe(n,Kr,!1);break;case"insertParagraph":ut(null),Bn&&!Vn?(Bn=!1,oe(n,Kr,!1)):oe(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":oe(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||I(p)||I(g)||!p.isToken()||!g.isToken()})(d,f)&&oe(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":oe(n,Ki,t);break;case"deleteContent":oe(n,Er,!1);break;case"deleteWordBackward":oe(n,Fn,!0);break;case"deleteWordForward":oe(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":oe(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":oe(n,Ln,!1);break;case"formatStrikeThrough":oe(n,It,"strikethrough");break;case"formatBold":oe(n,It,"bold");break;case"formatItalic":oe(n,It,"italic");break;case"formatUnderline":oe(n,It,"underline");break;case"historyUndo":oe(n,jo,void 0);break;case"historyRedo":oe(n,Mo,void 0)}else{if(l===`
86
- `)t.preventDefault(),oe(n,Kr,!1);else if(l===sr)t.preventDefault(),oe(n,Rn,void 0);else if(l==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else l!=null&&Zu(o,i,l,t.timeStamp,!0)?(t.preventDefault(),oe(n,Yr,l)):Wr=l;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,a=i.getNode(),l=Qe(),u=Nt(l._window),c=u!==null?u.anchorNode:null,d=i.key,f=l.getElementByKey(d),p=t.length;return d!==o.key||!ee(a)||(!s&&(!Bs||Ju<n+50)||a.isDirty()&&p<2||Ou(t))&&i.offset!==o.offset&&!a.isComposing()||Cr(a)||a.isDirty()&&p>1||(s||!Bs)&&f!==null&&!a.isComposing()&&c!==Fs(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||a.getFormat()!==r.format||a.getStyle()!==r.style||mh(r,a)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||kt(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const a=le();if(G(a)){const l=a.anchor,u=l.getNode();if(a.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(a.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Xu,v=Ge(),b=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&l.offset===g&&l.key===m)a.format=f,a.style=p;else if(l.type==="text")ee(u)||Y(141),a.format=u.getFormat(),a.style=u.getStyle();else if(l.type==="element"&&!b){const _=l.getNode();a.style="",_ instanceof on&&_.getChildrenSize()===0?(a.format=_.getTextFormat(),a.style=_.getTextStyle()):a.format=0}}else{const c=l.key,d=a.focus.key,f=a.getNodes(),p=f.length,g=a.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,b=g?c:d;let _=Xf,S=!1;for(let D=0;D<p;D++){const k=f[D],w=k.getTextContentSize();if(ee(k)&&w!==0&&!(D===0&&k.__key===v&&m===w||D===p-1&&k.__key===b&&x===0)&&(S=!0,_&=k.getFormat(),_===0))break}a.format=S?_:0}}oe(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ut(null),t!==null&&e!=null){if(e===""){const n=ft(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&ee(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
- `){const n=le();if(G(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void oe(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=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,a=Qr.get(o),l=a||i;l!==n&&Wa(t,l,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):a&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Ah(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&Y(162);const n=t-1;n>=0||Y(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const a=Vo(o),l=a[a.length-1]._key;Qr.get(l)===o&&Qr.delete(l)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&Y(198);const i=tc(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(a){const l=le();if(!G(l)||!I(a))return l;const{anchor:u,focus:c}=l,d=u.getNode(),f=c.getNode();return Tn(d,a)&&u.set(a.__key,0,"element"),Tn(f,a)&&c.set(a.__key,0,"element"),l}(r);let o=!1;if(G(i)&&e){const a=i.anchor,l=i.focus;a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(G(i)&&e&&!o){const a=r.getIndexWithinParent();Dr(r),Ws(i,s,a,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&gt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){Y(64,this.name)}static clone(e){Y(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,gh(this,e)}getType(){return this.__type}isInline(){Y(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ft(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||le();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(ee(this))return n;if(G(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if($e(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:ft(e)}getParentOrThrow(){const e=this.getParent();return e===null&&Y(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Yt(t))return I(e)||e===this&&$e(e)||Y(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&Y(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:ft(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:ft(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 a=0;a<s;a++){const l=t[a];if(o.has(l))return l}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const a=I(i)?t?i.getFirstChild():i.getLastChild():null;if(a!==null){i=a;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(l!==null){i=l;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&Y(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=ft(this.__key);return e===null&&Y(113),e}getWritable(){_t();const e=ar(),t=Qe(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,a=le();if(a!==null&&a.setCachedNodes(null),o.has(s))return Ps(i),i;const l=Jo(i);return o.add(s),Ps(l),n.set(s,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){Y(70)}updateDOM(e,t,n){Y(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){Y(72)}static importJSON(e){Y(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){_t();let n=le();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,a=e.getWritable(),l=this.getParentOrThrow().getWritable(),u=l.__size;Dr(a);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?l.__first=o:c.getWritable().__next=o,a.__prev=f,d===null?l.__last=o:d.getWritable().__prev=o,a.__next=p,a.__parent=g,l.__size=u,t&&(I(this)&&I(a)||Y(139),this.getChildren().forEach(m=>{a.append(m)})),G(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,a),x.key===i&&Qa(x,a)}return hr()===i&&ut(o),a}insertAfter(e,t=!0){_t(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=le();let a=!1,l=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),G(o)){const g=i.__key,m=o.anchor,x=o.focus;a=m.type==="element"&&m.key===g&&m.offset===p+1,l=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,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&&G(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;a&&o.anchor.set(g,p+2,"element"),l&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){_t(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),l=n.__prev,u=this.getIndexWithinParent();o===null?a.__first=i:o.getWritable().__next=i,a.__size++,n.__prev=i,s.__prev=l,s.__next=n.__key,s.__parent=n.__parent;const c=le();return t&&G(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return nt()}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(!ee(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(!ee(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
- `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&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:Th,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Th(r){return{node:Mr()}}function Mr(){return Jt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let a=!1;const l=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(a=!0,l||i.add(...o)):l&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(a&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!l||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[a,l,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);l!==0&&n.deleteData(a,l),n.insertData(a,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return ih[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,a=document.createElement(o);let l=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(l=document.createElement(i),a.appendChild(l)),Ga(l,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(a.style.cssText=u),a}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,a=Li(0,i),l=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((a===null?u:a)!==(l===null?c:l))return!0;if(a===l&&u!==c){const m=t.firstChild;m==null&&Y(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;l!==null&&a!==null&&(d=t.firstChild,d==null&&Y(49)),sc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&nc(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:Mh,priority:0}),b:()=>({conversion:Bh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Nh,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=it(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)||Y(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"?rh[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=sh[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=le(),o=this.getTextContent(),a=this.__key;if(typeof o=="string"){const l=o.length;n===void 0&&(n=l),s===void 0&&(s=l)}else n=0,s=0;if(!G(i))return ac(a,n,a,s,"text","text");{const l=hr();l!==i.anchor.key&&l!==i.focus.key||ut(a),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,a=n.length;let l=e;l<0&&(l=a+l,l<0&&(l=0));const u=le();if(s&&G(u)){const d=e+a;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){_t();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),a=[],l=n.length;let u="";for(let D=0;D<l;D++)u!==""&&o.has(D)&&(a.push(u),u=""),u+=n[D];u!==""&&a.push(u);const c=a.length;if(c===0)return[];if(a[0]===n)return[t];const d=a[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let v=!1;t.isSegmented()?(p=it(d),p.__format=g,p.__style=m,p.__detail=x,v=!0):(p=t.getWritable(),p.__text=d);const b=le(),_=[p];let S=d.length;for(let D=1;D<c;D++){const k=a[D],w=k.length,E=it(k).getWritable();E.__format=g,E.__style=m,E.__detail=x;const M=E.__key,N=S+w;if(G(b)){const T=b.anchor,B=b.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=N&&(T.key=M,T.offset-=S,b.dirty=!0),B.key===s&&B.type==="text"&&B.offset>S&&B.offset<=N&&(B.key=M,B.offset-=S,b.dirty=!0)}i===s&&ut(M),S=N,_.push(E)}if(f!==null){(function(w){const E=w.getPreviousSibling(),M=w.getNextSibling();E!==null&&Ps(E),M!==null&&Ps(M)})(this);const D=f.getWritable(),k=this.getIndexWithinParent();v?(D.splice(k,0,_),this.remove()):D.splice(k,1,_),G(b)&&Ws(b,f,k,c-1)}return _}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||Y(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&ut(n);const a=le();if(G(a)){const d=a.anchor,f=a.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),a.dirty=!0),f!==null&&f.key===s&&(nl(f,t,n,e,o),a.dirty=!0)}const l=e.__text,u=t?l+i:i+l;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Nh(r){return{forChild:Zo(r.style),node:null}}function Bh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function jh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Mh(r){const e=r;r.parentElement===null&&Y(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!jh(i);)o.push(i),i=i.parentNode;const a=s===void 0?i:s;for(let l=0;l<o.length;l++)Ka.set(o[l],a);return a}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const a=n[o];a===`
85
+ `,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:zo,left:Po,right:Oo,start:$o},nh={[Io]:"center",[qo]:"end",[zo]:"justify",[Po]:"left",[Oo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Y=oh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const ah=100;let Qi=!1,Uo=0;function lh(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 uh(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 ch(r,e,t){if(G(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=pt(i,t);if(o)return $e(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{kt(r,()=>{const s=ce()||function(f){return f.getEditorState().read(()=>{const p=ce();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=dh(m,r,a,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&X(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let k=0;k<_.length;k++){const w=_[k],E=Lu(w),M=w.parentNode;if(M!=null&&w!==l&&E===null&&!Bi(w,M,r)){if(mr){const N=w.innerText||w.nodeValue;N&&(c+=N)}M.removeChild(w)}}const S=p.removedNodes,D=S.length;if(D>0){let k=0;for(let w=0;w<D;w++){const E=S[w];(Bi(E,m,r)||l===E)&&(m.appendChild(E),k++)}D!==k&&i.set(v,b)}}}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],b=v.parentNode;b==null||v.nodeName!=="BR"||Bi(v,m,r)||b.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=Je()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&X(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&X(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),X(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!P(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let fh=1;const hh=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 $e(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 ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return X(r)||Ar(r)||$e(r)}function gh(r,e){if(e!=null)return void(r.__key=e);_t(),uc();const t=Je(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),P(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const a=i.getWritable();a.__prev=o.__key,o.__next=a.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Je(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;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 a=e.__key;s._dirtyType=Du,P(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ct(r){_t();const e=Je(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=pt(t);n!==null&&n.getWritable()}if(r!==null){const n=pt(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Je()._compositionKey}function pt(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,Je());return t!==void 0?pt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ke().getTextContent())}function Ke(){return Iu(ar())}function Iu(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=Je(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?pt("root"):null:pt(t)}function Ra(r,e){return e?r.getTextContentSize():0}function Ou(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 zu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Nt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&X(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ct(null),oi||Vn||Fo)i.remove();else{const m=Je();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||G(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=ce();if(!G(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=ot(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function mh(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)||P(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function yh(){const r=Ke();Kt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&Y(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function Oa(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 Oa(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?Oa(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function ae(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&Y(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&&Y(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return yt(r)||P(r)&&r.isShadowRoot()}function Jt(r){const e=Je(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&Y(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||Y(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||Y(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&Y(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!yt(r.getParent())||P(e)||$e(e)||Y(99)}function Mi(r){return($e(r)||P(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 bh(r,e,t){let n=r._blockCursorElement;if(G(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,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=Rs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Nt(r){return $t?(r||window).getSelection():null}function vh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function za(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function 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($e(r)&&!r.isInline())return!0;if(!P(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 _h(){return Je()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||Y(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&(P(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let yr,xt,In,fi,Xi,Zi,jr,Ot,eo,On,at="",mt="",Ut=null,Rt="",rr="",Wu=!1,zn=!1,_s=null;function zs(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||xt._keyToDOMMap.delete(r),P(t)){const n=qs(t,jr);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 kh="40px";function Hu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===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&&Y(60);const n=t.createDOM(yr,xt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,xt),X(t)?n.setAttribute("data-lexical-text","true"):$e(t)&&n.setAttribute("data-lexical-decorator","true"),P(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const f=mt;mt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=f})(qs(t,Ot),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(at+=sr,rr+=sr)}else{const s=t.getTextContent();if($e(t)){const i=t.decorate(xt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else X(t)&&(t.isDirectionless()||(mt+=s));at+=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=at;at="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=Ot.get(r[o]);a!==null&&X(a)&&(Ut===null&&(Ut=a.getFormat()),Rt===""&&(Rt=a.getStyle()))}ci(e)&&(at+=sr),s.element.__lexicalTextContent=at,at=i+at}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":$e(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,eh.test(s)?"rtl":th.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=yr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=mt;var s;mt="",Ut=null,Rt="",function(i,o,a){const l=at,u=i.__size,c=o.__size;at="";const d=a.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 b=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw v}zs(f,null)}const g=Ot.get(p);X(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,Ot);if(f.length!==u&&Y(227),p.length!==c&&Y(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,_){const S=v-1,D=b-1;let k,w,E=_.getFirstChild(),M=0,N=0;for(;M<=S&&N<=D;){const R=m[M],C=x[N];if(R===C)E=Ri(_n(C,_.element)),M++,N++;else{k===void 0&&(k=new Set(m)),w===void 0&&(w=new Set(x));const F=w.has(R),I=k.has(C);if(F)if(I){const W=Is(xt,C);W===E?E=Ri(_n(C,_.element)):(_.withBefore(E).insertChild(W),_n(C,_.element)),M++,N++}else $s(C,_.withBefore(E)),N++;else E=Ri(no(R)),zs(R,_.element),M++}const j=Ot.get(C);j!==null&&X(j)&&(Ut===null&&(Ut=j.getFormat()),Rt===""&&(Rt=j.getStyle()))}const T=M>S,B=N>D;if(T&&!B){const R=x[D+1],C=R===void 0?null:xt.getElementByKey(R);ro(x,g,N,D,_.withBefore(C))}else B&&!T&&to(m,M,S,_.element)})(o,f,p,u,c,a)}ci(o)&&(at+=sr),d.__lexicalTextContent=at,at=l+at}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!zn&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!zn&&i.setTextStyle(Rt)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&Y(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||Y(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if(P(t)){const o=i.__lexicalTextContent;o!==void 0&&(at+=o,rr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(mt+=a)}else{const o=t.getTextContent();X(t)&&!t.isDirectionless()&&(mt+=o),rr+=o,at+=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&&Y(62),e.replaceChild(o,i),zs(r,null),o}if(P(t)&&P(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Eh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(at+=sr,rr+=sr)}else{const o=n.getTextContent();if($e(n)){const a=n.decorate(xt,yr);a!==null&&Yu(r,a)}else X(n)&&!n.isDirectionless()&&(mt+=o);at+=o,rr+=o}if(!zn&&yt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){at="",rr="",mt="",Wu=n===Zr,_s=null,xt=t,yr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,Ot=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,Ot=void 0,yr=void 0,eo=void 0,On=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&Y(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!ae(e,jf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))ae(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ae(e,Mf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))ae(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ae(e,Rf,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))ae(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))ae(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,ae(e,Ns,r);else if(function(a){return a===" "}(t))ae(e,Ff,r);else if(function(a,l){return Mt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,ae(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,ae(e,Ns,r);else if(function(a,l,u,c){return Mt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?ae(e,vu,r):(r.preventDefault(),ae(e,Er,!0));else if(function(a){return a==="Escape"}(t))ae(e,_u,r);else if(function(a,l,u,c,d){return Mt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?ae(e,wu,r):(r.preventDefault(),ae(e,Er,!1));else if(function(a,l,u){return fn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),ae(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),ae(e,Fn,!1);else if(function(a,l){return Mt&&l&&fn(a)}(t,i))r.preventDefault(),ae(e,Ln,!0);else if(function(a,l){return Mt&&l&&hn(a)}(t,i))r.preventDefault(),ae(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))ae(e,Lf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),ae(e,jo,void 0);else if(function(a,l,u,c){return Mt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),ae(e,Mo,void 0);else{const a=e._editorState._selection;a===null||G(a)?!mr&&Ia(t,i,s)&&(r.preventDefault(),ae(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),ae(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),ae(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),ae(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&ae(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&kt(e,()=>{$e(en(t))||(ao=!0)})}],["compositionstart",function(r,e){kt(e,()=>{const t=ce();if(G(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ct(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||X(s)&&s.getStyle()!==t.style)&&ae(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:kt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),kt(e,()=>{const t=ce(),n=r.data,s=ec(r);if(n!=null&&G(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Nt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&X(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||ae(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ct(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);_t(),Bu(Je())}),Wr=null}],["click",function(r,e){kt(e,()=>{const t=ce(),n=Nt(e._window),s=Zn();if(n){if(G(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&Ke().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(P(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))}}}ae(e,gu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&kt(n,()=>{const o=ce();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!G(p))return;Kt(p.clone())}if(G(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ct(null),Nn=0,setTimeout(()=>{kt(n,()=>{ct(null)})},so),G(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),X(g)||Y(142),o.style=g.getStyle()}}else{ct(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!v&&x||ae(n,Er,!0)}return}}var a;if(!G(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":ae(n,Yr,t);break;case"insertFromComposition":ct(null),ae(n,Yr,t);break;case"insertLineBreak":ct(null),ae(n,Kr,!1);break;case"insertParagraph":ct(null),Bn&&!Vn?(Bn=!1,ae(n,Kr,!1)):ae(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ae(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||P(p)||P(g)||!p.isToken()||!g.isToken()})(d,f)&&ae(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":ae(n,Ki,t);break;case"deleteContent":ae(n,Er,!1);break;case"deleteWordBackward":ae(n,Fn,!0);break;case"deleteWordForward":ae(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ae(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ae(n,Ln,!1);break;case"formatStrikeThrough":ae(n,It,"strikethrough");break;case"formatBold":ae(n,It,"bold");break;case"formatItalic":ae(n,It,"italic");break;case"formatUnderline":ae(n,It,"underline");break;case"historyUndo":ae(n,jo,void 0);break;case"historyRedo":ae(n,Mo,void 0)}else{if(l===`
86
+ `)t.preventDefault(),ae(n,Kr,!1);else if(l===sr)t.preventDefault(),ae(n,Rn,void 0);else if(l==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else l!=null&&Zu(o,i,l,t.timeStamp,!0)?(t.preventDefault(),ae(n,Yr,l)):Wr=l;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,a=i.getNode(),l=Je(),u=Nt(l._window),c=u!==null?u.anchorNode:null,d=i.key,f=l.getElementByKey(d),p=t.length;return d!==o.key||!X(a)||(!s&&(!Bs||Ju<n+50)||a.isDirty()&&p<2||Ou(t))&&i.offset!==o.offset&&!a.isComposing()||Cr(a)||a.isDirty()&&p>1||(s||!Bs)&&f!==null&&!a.isComposing()&&c!==Fs(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||a.getFormat()!==r.format||a.getStyle()!==r.style||mh(r,a)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||kt(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const a=ce();if(G(a)){const l=a.anchor,u=l.getNode();if(a.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(a.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Xu,v=Ke(),b=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&l.offset===g&&l.key===m)a.format=f,a.style=p;else if(l.type==="text")X(u)||Y(141),a.format=u.getFormat(),a.style=u.getStyle();else if(l.type==="element"&&!b){const _=l.getNode();a.style="",_ instanceof on&&_.getChildrenSize()===0?(a.format=_.getTextFormat(),a.style=_.getTextStyle()):a.format=0}}else{const c=l.key,d=a.focus.key,f=a.getNodes(),p=f.length,g=a.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,b=g?c:d;let _=Xf,S=!1;for(let D=0;D<p;D++){const k=f[D],w=k.getTextContentSize();if(X(k)&&w!==0&&!(D===0&&k.__key===v&&m===w||D===p-1&&k.__key===b&&x===0)&&(S=!0,_&=k.getFormat(),_===0))break}a.format=S?_:0}}ae(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ct(null),t!==null&&e!=null){if(e===""){const n=pt(t),s=Fs(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=ce();if(G(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void ae(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=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,a=Qr.get(o),l=a||i;l!==n&&Wa(t,l,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):a&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Ah(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&Y(162);const n=t-1;n>=0||Y(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const a=Vo(o),l=a[a.length-1]._key;Qr.get(l)===o&&Qr.delete(l)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&Y(198);const i=tc(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(a){const l=ce();if(!G(l)||!P(a))return l;const{anchor:u,focus:c}=l,d=u.getNode(),f=c.getNode();return Tn(d,a)&&u.set(a.__key,0,"element"),Tn(f,a)&&c.set(a.__key,0,"element"),l}(r);let o=!1;if(G(i)&&e){const a=i.anchor,l=i.focus;a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(G(i)&&e&&!o){const a=r.getIndexWithinParent();Dr(r),Ws(i,s,a,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&yt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){Y(64,this.name)}static clone(e){Y(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,gh(this,e)}getType(){return this.__type}isInline(){Y(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=pt(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ce();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(X(this))return n;if(G(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if($e(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:pt(e)}getParentOrThrow(){const e=this.getParent();return e===null&&Y(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Yt(t))return P(e)||e===this&&$e(e)||Y(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&Y(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:pt(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:pt(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();P(this)&&t.unshift(this),P(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let a=0;a<s;a++){const l=t[a];if(o.has(l))return l}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const a=P(i)?t?i.getFirstChild():i.getLastChild():null;if(a!==null){i=a;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(l!==null){i=l;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&Y(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=Je()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=pt(this.__key);return e===null&&Y(113),e}getWritable(){_t();const e=ar(),t=Je(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,a=ce();if(a!==null&&a.setCachedNodes(null),o.has(s))return Ps(i),i;const l=Jo(i);return o.add(s),Ps(l),n.set(s,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){Y(70)}updateDOM(e,t,n){Y(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){Y(72)}static importJSON(e){Y(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){_t();let n=ce();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,a=e.getWritable(),l=this.getParentOrThrow().getWritable(),u=l.__size;Dr(a);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?l.__first=o:c.getWritable().__next=o,a.__prev=f,d===null?l.__last=o:d.getWritable().__prev=o,a.__next=p,a.__parent=g,l.__size=u,t&&(P(this)&&P(a)||Y(139),this.getChildren().forEach(m=>{a.append(m)})),G(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,a),x.key===i&&Qa(x,a)}return hr()===i&&ct(o),a}insertAfter(e,t=!0){_t(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ce();let a=!1,l=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),G(o)){const g=i.__key,m=o.anchor,x=o.focus;a=m.type==="element"&&m.key===g&&m.offset===p+1,l=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,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&&G(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;a&&o.anchor.set(g,p+2,"element"),l&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){_t(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),l=n.__prev,u=this.getIndexWithinParent();o===null?a.__first=i:o.getWritable().__next=i,a.__size++,n.__prev=i,s.__prev=l,s.__next=n.__key,s.__parent=n.__parent;const c=ce();return t&&G(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return st()}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(P(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(P(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:Th,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Th(r){return{node:Mr()}}function Mr(){return Jt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let a=!1;const l=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(a=!0,l||i.add(...o)):l&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(a&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!l||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[a,l,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);l!==0&&n.deleteData(a,l),n.insertData(a,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return ih[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,a=document.createElement(o);let l=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(l=document.createElement(i),a.appendChild(l)),Ga(l,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(a.style.cssText=u),a}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,a=Li(0,i),l=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((a===null?u:a)!==(l===null?c:l))return!0;if(a===l&&u!==c){const m=t.firstChild;m==null&&Y(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;l!==null&&a!==null&&(d=t.firstChild,d==null&&Y(49)),sc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&nc(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:Mh,priority:0}),b:()=>({conversion:Bh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Nh,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=ot(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)||Y(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"?rh[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=sh[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=ce(),o=this.getTextContent(),a=this.__key;if(typeof o=="string"){const l=o.length;n===void 0&&(n=l),s===void 0&&(s=l)}else n=0,s=0;if(!G(i))return ac(a,n,a,s,"text","text");{const l=hr();l!==i.anchor.key&&l!==i.focus.key||ct(a),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,a=n.length;let l=e;l<0&&(l=a+l,l<0&&(l=0));const u=ce();if(s&&G(u)){const d=e+a;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){_t();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),a=[],l=n.length;let u="";for(let D=0;D<l;D++)u!==""&&o.has(D)&&(a.push(u),u=""),u+=n[D];u!==""&&a.push(u);const c=a.length;if(c===0)return[];if(a[0]===n)return[t];const d=a[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let v=!1;t.isSegmented()?(p=ot(d),p.__format=g,p.__style=m,p.__detail=x,v=!0):(p=t.getWritable(),p.__text=d);const b=ce(),_=[p];let S=d.length;for(let D=1;D<c;D++){const k=a[D],w=k.length,E=ot(k).getWritable();E.__format=g,E.__style=m,E.__detail=x;const M=E.__key,N=S+w;if(G(b)){const T=b.anchor,B=b.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=N&&(T.key=M,T.offset-=S,b.dirty=!0),B.key===s&&B.type==="text"&&B.offset>S&&B.offset<=N&&(B.key=M,B.offset-=S,b.dirty=!0)}i===s&&ct(M),S=N,_.push(E)}if(f!==null){(function(w){const E=w.getPreviousSibling(),M=w.getNextSibling();E!==null&&Ps(E),M!==null&&Ps(M)})(this);const D=f.getWritable(),k=this.getIndexWithinParent();v?(D.splice(k,0,_),this.remove()):D.splice(k,1,_),G(b)&&Ws(b,f,k,c-1)}return _}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||Y(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&ct(n);const a=ce();if(G(a)){const d=a.anchor,f=a.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),a.dirty=!0),f!==null&&f.key===s&&(nl(f,t,n,e,o),a.dirty=!0)}const l=e.__text,u=t?l+i:i+l;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Nh(r){return{forChild:Zo(r.style),node:null}}function Bh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function jh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Mh(r){const e=r;r.parentElement===null&&Y(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!jh(i);)o.push(i),i=i.parentNode;const a=s===void 0?i:s;for(let l=0;l<o.length;l++)Ka.set(o[l],a);return a}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const a=n[o];a===`
89
89
  `||a===`\r
90
- `?s.push(Mr()):a===" "?s.push(Xn()):a!==""&&s.push(it(a))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:it(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Rh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Rh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function it(r=""){return Jt(new sn(r))}function ee(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",a=n.includes("underline"),l=r.verticalAlign;return u=>(ee(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),a&&!u.hasFormat("underline")&&u.toggleFormat("underline"),l!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),l!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){Y(126)}setDetail(e){Y(127)}setMode(e){Y(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Jt(new Jn)}function Fh(r){return r instanceof Jn}class Lh{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=ft(this.key);return e===null&&Y(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&&ut(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Lh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(ee(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!I(e)){const i=e.getNextSibling();if(ee(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(I(e)){const t=e.getLastDescendant();I(t)||ee(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(ee(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=ft(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 G(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!!G(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let a=i.getNode(),l=o.getNode();const u=i.offset,c=o.offset;if(I(a)){const f=a.getDescendantByIndex(u);a=f??a}if(I(l)){let f=l.getDescendantByIndex(c);f!==null&&f!==a&&l.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),l=f??l}let d;return d=a.is(l)?I(a)&&a.getChildrenSize()>0?[]:[a]:a.getNodesBetween(l),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),[a,l]=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,ee(f)){let p=f.getTextContent();f===t?f===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=a<l?p.slice(a,l):p.slice(l,a)):p=o?p.slice(a):p.slice(l):f===n&&(p=o?p.slice(0,l):p.slice(0,a)),u+=p}else!$e(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Qe(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(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()):a===" "?s.push(Xn()):a!==""&&s.push(ot(a))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:ot(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Rh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Rh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function ot(r=""){return Jt(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",a=n.includes("underline"),l=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"),a&&!u.hasFormat("underline")&&u.toggleFormat("underline"),l!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),l!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){Y(126)}setDetail(e){Y(127)}setMode(e){Y(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Jt(new Jn)}function Fh(r){return r instanceof Jn}class Lh{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(P(t)){const o=t.getDescendantByIndex(s);t=o??t}if(P(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=pt(this.key);return e===null&&Y(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&&ct(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Lh(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(!P(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 Qa(r,e){if(P(e)){const t=e.getLastDescendant();P(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=pt(s);i!==null&&n.push(i)}return es()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function G(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!!G(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let a=i.getNode(),l=o.getNode();const u=i.offset,c=o.offset;if(P(a)){const f=a.getDescendantByIndex(u);a=f??a}if(P(l)){let f=l.getDescendantByIndex(c);f!==null&&f!==a&&l.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),l=f??l}let d;return d=a.is(l)?P(a)&&a.getChildrenSize()>0?[]:[a]:a.getNodesBetween(l),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),[a,l]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const f=e[d];if(P(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=a<l?p.slice(a,l):p.slice(l,a)):p=o?p.slice(a):p.slice(l):f===n&&(p=o?p.slice(0,l):p.slice(0,a)),u+=p}else!$e(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Je(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(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(Xn()):n.push(it(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,v,b,_){const S=x.getNode(),D=S.getChildAtIndex(x.offset),k=it(),w=gt(S)?nt().append(k):k;k.setFormat(b),k.setStyle(_),D===null?S.append(w):D.insertBefore(w),x.is(v)&&v.set(k.__key,0,"text"),x.set(k.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let f=c[0];ee(f)||Y(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(ee(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=it(),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()&&l===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(ee(x)&&!Cr(x)||(x=it(),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()&&l!==p){const x=it(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(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=it(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(l!==u||x===s&&v===i){if(Fh(f)){const _=it(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=it(e);if(_.setFormat(s),_.setStyle(i),_.select(),l===0)f.insertBefore(_,!1);else{const[S]=f.splitText(l);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-l;f=f.spliceText(l,b,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=I(f)?f:f.getParentOrThrow();let b=I(m)?m:m.getParentOrThrow(),_=m;if(!v.is(b)&&b.isInline())do _=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(ee(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const E=it(m.getTextContent());m.replace(E),m=E}gt(a.getNode())||a.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const E=m.getParentOrThrow();E.canBeEmpty()||E.getChildrenSize()!==1?m.remove():E.remove()}else x.add(m.__key);const S=b.getChildren(),D=new Set(c),k=v.is(b),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let E=S.length-1;E>=0;E--){const M=S[E];if(M.is(f)||I(M)&&M.isParentOf(f))break;M.isAttached()&&(!D.has(M)||M.is(_)?k||w.insertAfter(M,!1):M.remove())}if(!k){let E=b,M=null;for(;E!==null;){const N=E.getChildren(),T=N.length;(T===0||N[T-1].is(M))&&(x.delete(E.__key),M=E),E=E.getParent()}}if(f.isToken())if(l===p)f.select();else{const E=it(e);E.select(),f.replace(E)}else f=f.spliceText(l,p-l,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let E=1;E<d;E++){const M=c[E],N=M.__key;x.has(N)||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(),a=i.getNode();const l=pn(o,cr),u=pn(a,cr);ee(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&ee(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=it(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&ee(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(ee(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}ee(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&ee(o)?o.selectEnd():a.isAttached()&&ee(a)&&a.selectStart(),I(l)&&I(u)&&l!==u&&(l.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ut(null);const n=this.getNodes(),s=[];for(const S of n)ee(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const k=D.getFormatFlags(e,S);D.setTextFormat(k)}})},o=s.length;if(o===0)return this.toggleFormat(e),ut(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;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 b=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),D=g===0?S[0]:S[1];D.setFormat(m),c.type==="text"&&c.set(D.__key,0,"text"),d.type==="text"&&d.set(D.__key,b-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);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(_));for(let S=f+1;S<x;S++){const D=s[S],k=D.getFormatFlags(e,_);D.setFormat(k)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=le();return G(g)||Y(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)||$e(g))&&!g.isInline())){I(n)||Y(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=nt();let x=null;for(let v=0;v<g.length;v++){const b=g[v],_=Ar(b);if(_||$e(b)&&b.isInline()||I(b)&&b.isInline()||ee(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!I(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;I(d=c)&&cr(d)&&!d.isEmpty()&&I(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(I(n)||Y(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&Y(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const _=[m];for(;b!==v;)b.getNextSibling()||Y(140),b=b.getNextSibling(),_.push(b);let S=g;for(const D of _)S=S.insertAfter(D)}(n,c));const f=pn(o,cr);l&&I(f)&&(l.canMergeWhenEmpty()||cr(u))&&(f.append(...l.getChildren()),l.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=nt();return Ge().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);I(t)||Y(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(ee(o)&&!this.isCollapsed()){const d=l>u?u:l,f=l>u?l: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(ee(o)){const d=c?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(ee(a)){const d=a.getTextContent().length,f=c?u:l;f===0?e.pop():f!==d&&([a]=a.splitText(f),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if($e(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Kt(p)}const f=t?a.getPreviousSibling():a.getNextSibling();if(ee(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=a.getParentOrThrow();let g,m;return I(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=Qe(),u=Nt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!I(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,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=gt(p)?p:xh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let b=0;b<m.length;b++){const _=m[b];Tn(_,g)?x.push(_):v=!0}if(v&&x.length>0)if(t){const b=x[0];I(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];I(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(b){const _=b.focus,S=b.anchor,D=S.key,k=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,D,k,w),b._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($e(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&I(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Kt(a)}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 a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.focus,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,b=x?m:g,_=b-1;v!==_&&(Ou(f.getTextContent().slice(v,b))||(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()&&gt(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 Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),ee(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(I(f)){const p=n.getElementByKey(f.getKey());p===null&&Y(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),I(f)||Y(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(I(m)&&function(x,v,b){const _=x.getParent();return b===null||_===null||!_.canBeEmpty()||_!==b.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}ee(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(I(f)||Y(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&$e(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(I(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return ee(s)?Qt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&I(o)&&o.isInline()){const a=o.getPreviousSibling();ee(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else I(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):ee(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&I(i)&&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 a=o.getNextSibling();ee(a)&&(r.key=a.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Qe();if(i.isComposing()&&i._compositionKey!==r.key&&G(t)){const o=t.anchor,a=t.focus;dr(r,o.key,o.offset,o.type),dr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,G(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,G(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if($e(l)&&$e(u))return null}return ic(o,a,i),[o,a]}function co(r){return I(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),a=new br(Qt(r,e,s),Qt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(G(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,a&&G(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,G(r)?r.format:0,G(r)?r.style:"")}function le(){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(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(l,c,"element"),i.set(l,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),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(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(l,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!I(i))return;const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(I(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(I(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,ee(n)?(o=n.getTextContentSize(),a="text"):I(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,ee(s)?a="text":I(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Ih(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!G(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),b=f.offset,_=p.offset,S=e.format,D=e.style,k=e.isCollapsed();let w=x,E=v,M=!1;if(f.type==="text"){w=Fs(x);const j=f.getNode();M=j.getFormat()!==S||j.getStyle()!==D}else G(r)&&r.anchor.type==="text"&&(M=!0);var N,T,B,R,C;if(p.type==="text"&&(E=Fs(v)),w!==null&&E!==null&&(k&&(r===null||M||G(r)&&(r.format!==S||r.style!==D))&&(N=S,T=D,B=b,R=g,C=performance.now(),Xu=[N,T,B,R,C]),u!==b||c!==_||a!==w||l!==E||n.type==="Range"&&k||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,b,E,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const j=e instanceof br&&e.anchor.type==="element"?w.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(j!==null){let F;if(j instanceof Text){const O=document.createRange();O.selectNode(j),F=O.getBoundingClientRect()}else F=j.getBoundingClientRect();(function(O,U,W){const re=W.ownerDocument,q=re.defaultView;if(q===null)return;let{top:Q,bottom:H}=U,ne=0,de=0,he=W;for(;he!==null;){const pe=he===re.body;if(pe)ne=0,de=di(O).innerHeight;else{const me=he.getBoundingClientRect();ne=me.top,de=me.bottom}let ke=0;if(Q<ne?ke=-(ne-Q):H>de&&(ke=H-de),ke!==0)if(pe)q.scrollBy(0,ke);else{const me=he.scrollTop;he.scrollTop+=ke;const J=he.scrollTop-me;Q-=J,H-=J}if(pe)break;he=Yn(he)}})(t,F,i)}}oo=!0}}function lc(r){let e=le()||Zn();e===null&&(e=Ge().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=le();G(t)&&(e=t),G(e)||Y(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=nt();return Ge().append(s),s.select(),[Ge(),0]}if(ee(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!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 at=null,lt=null,Ct=!1,zi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return Ct||at!==null&&at._readOnly}function _t(){Ct&&Y(13)}function uc(){ws>99&&Y(14)}function ar(){return at===null&&Y(195,cc()),at}function Qe(){return lt===null&&Y(196,cc()),lt}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function zh(){return lt}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&Y(30,l),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function $h(r){return ta(r,Qe()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&Y(17,t);const s=n.klass;r.type!==s.getType()&&Y(18,s.name);const i=s.importJSON(r),o=r.children;if(I(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=at,s=Ct,i=lt;at=e,Ct=!0,lt=r;try{return t()}finally{at=n,Ct=s,lt=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,a=t._selection,l=r._dirtyType!==Nr,u=at,c=Ct,d=lt,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){lt=r,at=t,Ct=!1,r._updating=!0;try{const k=r._dirtyType,w=r._dirtyElements,E=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,k,w,E)}catch(k){if(k instanceof Error&&r._onError(k),zi)throw k;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,sl),r._updating=f,at=u,Ct=c,lt=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,_=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(k,w){const E=k._decorators;let M=k._pendingDecorators||E;const N=w._nodeMap;let T;for(T in M)N.has(T)||(M===E&&(M=Pu(k)),delete M[T])}(r,t);const S=s?null:Nt(r._window);if(r._editable&&S!==null&&(l||a===null||a.dirty)){lt=r,at=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const k=r._blockCursorElement;k!==null&&Qo(k,r,n),Ih(o,a,r,S,b,n)}bh(r,n,a),p!==null&&p.observe(n,sl)}finally{lt=d,at=u}}g!==null&&function(k,w,E,M,N){const T=Array.from(k._listeners.mutation),B=T.length;for(let R=0;R<B;R++){const[C,j]=T[R],F=w.get(j);F!==void 0&&C(F,{dirtyLeaves:M,prevEditorState:N,updateTags:E})}}(r,g,b,m,i),G(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,jn("decorator",r,!0,D)),function(k,w,E){const M=Ma(w),N=Ma(E);M!==N&&jn("textcontent",k,!0,N)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(k,w){if(k._deferred=[],w.length!==0){const E=k._updating;k._updating=!0;try{for(let M=0;M<w.length;M++)w[M]()}finally{k._updating=E}}}(r,_),function(k){const w=k._updates;if(w.length!==0){const E=w.shift();if(E){const[M,N]=E;hc(k,M,N)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||lt!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&Y(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=at,d=Ct,f=lt,p=r._updating;at=l,Ct=!1,r._updating=!0,lt=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(v){const b=v.getEditorState()._selection,_=Nt(v._window);return G(b)||b==null?ea(b,_,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(v,b){const _=b.getEditorState()._selection,S=v._selection;if(G(S)){const D=S.anchor,k=S.focus;let w;if(D.type==="text"&&(w=D.getNode(),w.selectionTransform(_,S)),k.type==="text"){const E=k.getNode();w!==E&&E.selectionTransform(_,S)}}}(l,r),r._dirtyType!==Nr&&(i?function(v,b){const _=b._dirtyLeaves,S=v._nodeMap;for(const D of _){const k=S.get(D);ee(k)&&k.isAttached()&&k.isSimpleText()&&!k.isUnmergeable()&&Ba(k)}}(l,r):function(v,b){const _=b._dirtyLeaves,S=b._dirtyElements,D=v._nodeMap,k=hr(),w=new Map;let E=_,M=E.size,N=S,T=N.size;for(;M>0||T>0;){if(M>0){b._dirtyLeaves=new Set;for(const B of E){const R=D.get(B);ee(R)&&R.isAttached()&&R.isSimpleText()&&!R.isUnmergeable()&&Ba(R),R!==void 0&&ol(R,k)&&il(b,R,w),_.add(B)}if(E=b._dirtyLeaves,M=E.size,M>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const B of N){const R=B[0],C=B[1];if(R!=="root"&&!C)continue;const j=D.get(R);j!==void 0&&ol(j,k)&&il(b,j,w),S.set(R,C)}E=b._dirtyLeaves,M=E.size,N=b._dirtyElements,T=N.size,ws++}b._dirtyLeaves=_,b._dirtyElements=S}(l,r),ll(r),function(v,b,_,S){const D=v._nodeMap,k=b._nodeMap,w=[];for(const[E]of S){const M=k.get(E);M!==void 0&&(M.isAttached()||(I(M)&&Uu(M,E,D,k,w,S),D.has(E)||S.delete(E),w.push(E)))}for(const E of w)k.delete(E);for(const E of _){const M=k.get(E);M===void 0||M.isAttached()||(D.has(E)||_.delete(E),k.delete(E))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(G(x)){const v=l._nodeMap,b=x.anchor.key,_=x.focus.key;v.get(b)!==void 0&&v.get(_)!==void 0||Y(19)}else Wt(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{at=c,Ct=d,lt=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1}(l,r)?l._flushSync?(l._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function kt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&Y(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&Y(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&Y(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&Y(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 nh[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(ee(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:ft(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&Y(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ft(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&Y(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=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){_t();const n=le();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(ee(l)||I(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(ee(l)||I(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return G(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||Y(226,String(e),String(t),String(i));const a=o.__key,l=[],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&&Y(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===a&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const b=p.getWritable();b.__next=v,x.__prev=b.__key}m.__key===a&&Y(76),x.__parent=a,l.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=le();if(G(g)){const m=new Set(u),x=new Set(l),{anchor:v,focus:b}=g;cl(v,m,x)&&Hs(v,v.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.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 cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){Y(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function $e(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(){Y(51)}getTextContent(){const e=this.__cachedText;return!es()&&Qe()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){Y(52)}replace(e){Y(53)}insertBefore(e){Y(54)}insertAfter(e){Y(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];I(n)||$e(n)||Y(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 gt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&Y(130,t.name),I(r)){const n=e.children;Array.isArray(n)||Y(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(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:qh,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=nt();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=nt();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||ee(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function qh(r){const e=nt();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function nt(){return Jt(new on)}function tn(r){return r instanceof on}const Ie=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Wh(r){const e=r||{},t=zh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:zu()),l=e.editorState,u=[ts,sn,Qn,Jn,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,b=null;if(typeof x!="function"){const k=x;x=k.replace,v=k.with,b=k.withKlass||null}const _=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(_,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:b,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:a,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,_=S=>{Object.keys(S).forEach(D=>{let k=v.get(D);k===void 0&&(k=[],v.set(D,k)),k.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||b.has(D))return;b.add(D);const k=D.call(S.klass);k!==null&&_(k)}),x&&_(x),v}(p,d?d.import:void 0),f);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=zu(),this._onError=i,this._htmlConversions=o,this._editable=a,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&Y(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&&Y(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&Y(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),kt(o,()=>{const l=ar();if(l.isEmpty())return;if(a==="root")return void Ge().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return oe(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const v=l.isEditable();switch(p){case"cut":return v&&oe(l,Ro,x);case"copy":return oe(l,ii,x);case"paste":return v&&oe(l,si,x);case"dragstart":return v&&oe(l,Su,x);case"dragover":return v&&oe(l,ku,x);case"dragend":return v&&oe(l,zf,x);case"focus":return v&&oe(l,Uf,x);case"blur":return v&&oe(l,Wf,x);case"drop":return v&&oe(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&Y(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),a=at,l=Ct,u=lt,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,at=o,Ct=!1,lt=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,at=a,Ct=l,lt=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=le(),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,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Nf(null,n),c=Wh({editable:r.editable,html:l,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=nt();p.append(g);const m=yc?document.activeElement:null;(le()!==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,a),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Kh)}function Qh(){return Ge().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(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($e(s))return!1;if(I(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!ee(l))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(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 ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rp=new Map;function np(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),f=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);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 sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ge(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;I(a)||tp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return $e(t)&&!t.isIsolated()||I(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(gt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if($e(r)||!I(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=lp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>I(t)&&!t.isInline());return I(e)||up(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 hp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,f,p,g]=l;r.update(()=>{const m=le();if(G(m)){const x=m.anchor;let v=x.getNode(),b=0,_=0;if(ee(v)&&u>=0&&c>=0&&(b=u,_=u+c,m.setTextNodeRange(v,b,v,_)),b===_&&d===""||(m.insertRawText(d),v=x.getNode()),ee(v)){b=f,_=f+p;const S=v.getTextContentSize();b=b>S?S:b,_=_>S?S:_,m.setTextNodeRange(v,b,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Ge().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=I(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=ee(p)&&n!==null?bc(n,p):p,o=p}const a=I(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<a.length;p++){const g=a[p],m=kc(r,g,f,n);!s&&I(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||za(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(za(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(a==null||!Yt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(f=c(f)),Os(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:nt)),a==null?f.length>0?o=o.concat(f):Os(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):I(a)&&a.append(...f),o}function pp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(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 mp(r,e=le()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=le()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,bp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(G(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=le();if(G(l)){const u=o[a];u===`
93
+ `?n.push(Mr()):o===" "?n.push(Xn()):n.push(ot(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,v,b,_){const S=x.getNode(),D=S.getChildAtIndex(x.offset),k=ot(),w=yt(S)?st().append(k):k;k.setFormat(b),k.setStyle(_),D===null?S.append(w):D.insertBefore(w),x.is(v)&&v.set(k.__key,0,"text"),x.set(k.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let f=c[0];X(f)||Y(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(X(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=ot(),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()&&l===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(X(x)&&!Cr(x)||(x=ot(),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()&&l!==p){const x=ot(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||P(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=ot(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(l!==u||x===s&&v===i){if(Fh(f)){const _=ot(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=ot(e);if(_.setFormat(s),_.setStyle(i),_.select(),l===0)f.insertBefore(_,!1);else{const[S]=f.splitText(l);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-l;f=f.spliceText(l,b,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=P(f)?f:f.getParentOrThrow();let b=P(m)?m:m.getParentOrThrow(),_=m;if(!v.is(b)&&b.isInline())do _=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(X(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const E=ot(m.getTextContent());m.replace(E),m=E}yt(a.getNode())||a.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const E=m.getParentOrThrow();E.canBeEmpty()||E.getChildrenSize()!==1?m.remove():E.remove()}else x.add(m.__key);const S=b.getChildren(),D=new Set(c),k=v.is(b),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let E=S.length-1;E>=0;E--){const M=S[E];if(M.is(f)||P(M)&&M.isParentOf(f))break;M.isAttached()&&(!D.has(M)||M.is(_)?k||w.insertAfter(M,!1):M.remove())}if(!k){let E=b,M=null;for(;E!==null;){const N=E.getChildren(),T=N.length;(T===0||N[T-1].is(M))&&(x.delete(E.__key),M=E),E=E.getParent()}}if(f.isToken())if(l===p)f.select();else{const E=ot(e);E.select(),f.replace(E)}else f=f.spliceText(l,p-l,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let E=1;E<d;E++){const M=c[E],N=M.__key;x.has(N)||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(),a=i.getNode();const l=pn(o,cr),u=pn(a,cr);X(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&X(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=ot(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&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(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&X(o)?o.selectEnd():a.isAttached()&&X(a)&&a.selectStart(),P(l)&&P(u)&&l!==u&&(l.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ct(null);const n=this.getNodes(),s=[];for(const S of n)X(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const k=D.getFormatFlags(e,S);D.setTextFormat(k)}})},o=s.length;if(o===0)return this.toggleFormat(e),ct(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;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 b=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),D=g===0?S[0]:S[1];D.setFormat(m),c.type==="text"&&c.set(D.__key,0,"text"),d.type==="text"&&d.set(D.__key,b-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);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(_));for(let S=f+1;S<x;S++){const D=s[S],k=D.getFormatFlags(e,_);D.setFormat(k)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ce();return G(g)||Y(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(P(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=>(P(g)||$e(g))&&!g.isInline())){P(n)||Y(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=st();let x=null;for(let v=0;v<g.length;v++){const b=g[v],_=Ar(b);if(_||$e(b)&&b.isInline()||P(b)&&b.isInline()||X(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!P(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;P(d=c)&&cr(d)&&!d.isEmpty()&&P(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(P(n)||Y(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&Y(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const _=[m];for(;b!==v;)b.getNextSibling()||Y(140),b=b.getNextSibling(),_.push(b);let S=g;for(const D of _)S=S.insertAfter(D)}(n,c));const f=pn(o,cr);l&&P(f)&&(l.canMergeWhenEmpty()||cr(u))&&(f.append(...l.getChildren()),l.remove()),P(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=P(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=st();return Ke().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);P(t)||Y(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(X(o)&&!this.isCollapsed()){const d=l>u?u:l,f=l>u?l: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?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(X(a)){const d=a.getTextContent().length,f=c?u:l;f===0?e.pop():f!==d&&([a]=a.splitText(f),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if($e(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Kt(p)}const f=t?a.getPreviousSibling():a.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=a.getParentOrThrow();let g,m;return P(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=Je(),u=Nt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!P(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,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=yt(p)?p:xh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let b=0;b<m.length;b++){const _=m[b];Tn(_,g)?x.push(_):v=!0}if(v&&x.length>0)if(t){const b=x[0];P(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];P(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(b){const _=b.focus,S=b.anchor,D=S.key,k=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,D,k,w),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&P(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(P(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($e(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&P(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Kt(a)}else o.remove(),Je().dispatchCommand(Bo,void 0);return}if(!e&&P(o)&&P(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.focus,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,b=x?m:g,_=b-1;v!==_&&(Ou(f.getTextContent().slice(v,b))||(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()&&yt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Wt(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),X(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(P(f)){const p=n.getElementByKey(f.getKey());p===null&&Y(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),P(f)||Y(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(P(m)&&function(x,v,b){const _=x.getParent();return b===null||_===null||!_.canBeEmpty()||_!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=P(m)?m:m.getParentOrThrow()),i=0}X(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(P(f)||Y(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&$e(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(P(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return X(s)?Qt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&P(o)&&o.isInline()){const a=o.getPreviousSibling();X(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else P(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&&P(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&P(o)&&o.isInline()&&!o.canInsertTextAfter()){const a=o.getNextSibling();X(a)&&(r.key=a.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Je();if(i.isComposing()&&i._compositionKey!==r.key&&G(t)){const o=t.anchor,a=t.focus;dr(r,o.key,o.offset,o.type),dr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,G(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,G(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if($e(l)&&$e(u))return null}return ic(o,a,i),[o,a]}function co(r){return P(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),a=new br(Qt(r,e,s),Qt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(G(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,a&&G(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,G(r)?r.format:0,G(r)?r.style:"")}function ce(){return ar()._selection}function Zn(){return Je()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(l,c,"element"),i.set(l,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),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(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(l,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!P(i))return;const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(P(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(P(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,X(n)?(o=n.getTextContentSize(),a="text"):P(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,X(s)?a="text":P(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Ih(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!G(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),b=f.offset,_=p.offset,S=e.format,D=e.style,k=e.isCollapsed();let w=x,E=v,M=!1;if(f.type==="text"){w=Fs(x);const j=f.getNode();M=j.getFormat()!==S||j.getStyle()!==D}else G(r)&&r.anchor.type==="text"&&(M=!0);var N,T,B,R,C;if(p.type==="text"&&(E=Fs(v)),w!==null&&E!==null&&(k&&(r===null||M||G(r)&&(r.format!==S||r.style!==D))&&(N=S,T=D,B=b,R=g,C=performance.now(),Xu=[N,T,B,R,C]),u!==b||c!==_||a!==w||l!==E||n.type==="Range"&&k||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,b,E,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const j=e instanceof br&&e.anchor.type==="element"?w.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(j!==null){let F;if(j instanceof Text){const I=document.createRange();I.selectNode(j),F=I.getBoundingClientRect()}else F=j.getBoundingClientRect();(function(I,W,q){const ne=q.ownerDocument,U=ne.defaultView;if(U===null)return;let{top:Q,bottom:H}=W,ie=0,ue=0,he=q;for(;he!==null;){const ge=he===ne.body;if(ge)ie=0,ue=di(I).innerHeight;else{const xe=he.getBoundingClientRect();ie=xe.top,ue=xe.bottom}let we=0;if(Q<ie?we=-(ie-Q):H>ue&&(we=H-ue),we!==0)if(ge)U.scrollBy(0,we);else{const xe=he.scrollTop;he.scrollTop+=we;const Z=he.scrollTop-xe;Q-=Z,H-=Z}if(ge)break;he=Yn(he)}})(t,F,i)}}oo=!0}}function lc(r){let e=ce()||Zn();e===null&&(e=Ke().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=ce();G(t)&&(e=t),G(e)||Y(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=st();return Ke().append(s),s.select(),[Ke(),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(!P(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 lt=null,ut=null,Ct=!1,zi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return Ct||lt!==null&&lt._readOnly}function _t(){Ct&&Y(13)}function uc(){ws>99&&Y(14)}function ar(){return lt===null&&Y(195,cc()),lt}function Je(){return ut===null&&Y(196,cc()),ut}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function zh(){return ut}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&Y(30,l),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function $h(r){return ta(r,Je()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&Y(17,t);const s=n.klass;r.type!==s.getType()&&Y(18,s.name);const i=s.importJSON(r),o=r.children;if(P(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=lt,s=Ct,i=ut;lt=e,Ct=!0,ut=r;try{return t()}finally{lt=n,Ct=s,ut=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,a=t._selection,l=r._dirtyType!==Nr,u=lt,c=Ct,d=ut,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){ut=r,lt=t,Ct=!1,r._updating=!0;try{const k=r._dirtyType,w=r._dirtyElements,E=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,k,w,E)}catch(k){if(k instanceof Error&&r._onError(k),zi)throw k;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,sl),r._updating=f,lt=u,Ct=c,ut=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,_=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(k,w){const E=k._decorators;let M=k._pendingDecorators||E;const N=w._nodeMap;let T;for(T in M)N.has(T)||(M===E&&(M=Pu(k)),delete M[T])}(r,t);const S=s?null:Nt(r._window);if(r._editable&&S!==null&&(l||a===null||a.dirty)){ut=r,lt=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const k=r._blockCursorElement;k!==null&&Qo(k,r,n),Ih(o,a,r,S,b,n)}bh(r,n,a),p!==null&&p.observe(n,sl)}finally{ut=d,lt=u}}g!==null&&function(k,w,E,M,N){const T=Array.from(k._listeners.mutation),B=T.length;for(let R=0;R<B;R++){const[C,j]=T[R],F=w.get(j);F!==void 0&&C(F,{dirtyLeaves:M,prevEditorState:N,updateTags:E})}}(r,g,b,m,i),G(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,jn("decorator",r,!0,D)),function(k,w,E){const M=Ma(w),N=Ma(E);M!==N&&jn("textcontent",k,!0,N)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(k,w){if(k._deferred=[],w.length!==0){const E=k._updating;k._updating=!0;try{for(let M=0;M<w.length;M++)w[M]()}finally{k._updating=E}}}(r,_),function(k){const w=k._updates;if(w.length!==0){const E=w.shift();if(E){const[M,N]=E;hc(k,M,N)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||ut!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&Y(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=lt,d=Ct,f=ut,p=r._updating;lt=l,Ct=!1,r._updating=!0,ut=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(v){const b=v.getEditorState()._selection,_=Nt(v._window);return G(b)||b==null?ea(b,_,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(v,b){const _=b.getEditorState()._selection,S=v._selection;if(G(S)){const D=S.anchor,k=S.focus;let w;if(D.type==="text"&&(w=D.getNode(),w.selectionTransform(_,S)),k.type==="text"){const E=k.getNode();w!==E&&E.selectionTransform(_,S)}}}(l,r),r._dirtyType!==Nr&&(i?function(v,b){const _=b._dirtyLeaves,S=v._nodeMap;for(const D of _){const k=S.get(D);X(k)&&k.isAttached()&&k.isSimpleText()&&!k.isUnmergeable()&&Ba(k)}}(l,r):function(v,b){const _=b._dirtyLeaves,S=b._dirtyElements,D=v._nodeMap,k=hr(),w=new Map;let E=_,M=E.size,N=S,T=N.size;for(;M>0||T>0;){if(M>0){b._dirtyLeaves=new Set;for(const B of E){const R=D.get(B);X(R)&&R.isAttached()&&R.isSimpleText()&&!R.isUnmergeable()&&Ba(R),R!==void 0&&ol(R,k)&&il(b,R,w),_.add(B)}if(E=b._dirtyLeaves,M=E.size,M>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const B of N){const R=B[0],C=B[1];if(R!=="root"&&!C)continue;const j=D.get(R);j!==void 0&&ol(j,k)&&il(b,j,w),S.set(R,C)}E=b._dirtyLeaves,M=E.size,N=b._dirtyElements,T=N.size,ws++}b._dirtyLeaves=_,b._dirtyElements=S}(l,r),ll(r),function(v,b,_,S){const D=v._nodeMap,k=b._nodeMap,w=[];for(const[E]of S){const M=k.get(E);M!==void 0&&(M.isAttached()||(P(M)&&Uu(M,E,D,k,w,S),D.has(E)||S.delete(E),w.push(E)))}for(const E of w)k.delete(E);for(const E of _){const M=k.get(E);M===void 0||M.isAttached()||(D.has(E)||_.delete(E),k.delete(E))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(G(x)){const v=l._nodeMap,b=x.anchor.key,_=x.focus.key;v.get(b)!==void 0&&v.get(_)!==void 0||Y(19)}else Wt(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{lt=c,Ct=d,ut=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1}(l,r)?l._flushSync?(l._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function kt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&Y(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&Y(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&Y(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&Y(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 nh[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=Je()._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),P(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;P(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;P(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 P(i)&&i.getLastDescendant()||i||null}const s=t[e];return P(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:pt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&Y(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:pt(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&Y(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(),P(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(),P(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){_t();const n=ce();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(X(l)||P(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(X(l)||P(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return G(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||Y(226,String(e),String(t),String(i));const a=o.__key,l=[],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&&Y(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===a&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const b=p.getWritable();b.__next=v,x.__prev=b.__key}m.__key===a&&Y(76),x.__parent=a,l.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=ce();if(G(g)){const m=new Set(u),x=new Set(l),{anchor:v,focus:b}=g;cl(v,m,x)&&Hs(v,v.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.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 P(r){return r instanceof lr}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){Y(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function $e(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(){Y(51)}getTextContent(){const e=this.__cachedText;return!es()&&Je()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){Y(52)}replace(e){Y(53)}insertBefore(e){Y(54)}insertAfter(e){Y(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];P(n)||$e(n)||Y(56)}return super.append(...e)}static importJSON(e){const t=Ke();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&Y(130,t.name),P(r)){const n=e.children;Array.isArray(n)||Y(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Ke())}))}}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:qh,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=st();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=st();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 qh(r){const e=st();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function st(){return Jt(new on)}function tn(r){return r instanceof on}const Ie=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Wh(r){const e=r||{},t=zh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:zu()),l=e.editorState,u=[ts,sn,Qn,Jn,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,b=null;if(typeof x!="function"){const k=x;x=k.replace,v=k.with,b=k.withKlass||null}const _=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(_,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:b,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:a,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,_=S=>{Object.keys(S).forEach(D=>{let k=v.get(D);k===void 0&&(k=[],v.set(D,k)),k.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||b.has(D))return;b.add(D);const k=D.call(S.klass);k!==null&&_(k)}),x&&_(x),v}(p,d?d.import:void 0),f);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=zu(),this._onError=i,this._htmlConversions=o,this._editable=a,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&Y(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&&Y(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&Y(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),kt(o,()=>{const l=ar();if(l.isEmpty())return;if(a==="root")return void Ke().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return ae(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const v=l.isEditable();switch(p){case"cut":return v&&ae(l,Ro,x);case"copy":return ae(l,ii,x);case"paste":return v&&ae(l,si,x);case"dragstart":return v&&ae(l,Su,x);case"dragover":return v&&ae(l,ku,x);case"dragend":return v&&ae(l,zf,x);case"focus":return v&&ae(l,Uf,x);case"blur":return v&&ae(l,Wf,x);case"drop":return v&&ae(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&Y(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),a=lt,l=Ct,u=ut,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,lt=o,Ct=!1,ut=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,lt=a,Ct=l,ut=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=ce(),i=Ke();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,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Nf(null,n),c=Wh({editable:r.editable,html:l,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=Ke();if(p.isEmpty()){const g=st();p.append(g);const m=yc?document.activeElement:null;(ce()!==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(()=>{Ke().isEmpty()&&f(d)},ds)}}}(c,a),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Kh)}function Qh(){return Ke().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(r,!1))return!1;const e=Ke().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if($e(s))return!1;if(P(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!X(l))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(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 ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rp=new Map;function np(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),f=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);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 sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ke(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;P(a)||tp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return $e(t)&&!t.isIsolated()||P(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if($e(r)||!P(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 lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=lp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>P(t)&&!t.isInline());return P(e)||up(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ke()&&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 hp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,f,p,g]=l;r.update(()=>{const m=ce();if(G(m)){const x=m.anchor;let v=x.getNode(),b=0,_=0;if(X(v)&&u>=0&&c>=0&&(b=u,_=u+c,m.setTextNodeRange(v,b,v,_)),b===_&&d===""||(m.insertRawText(d),v=x.getNode()),X(v)){b=f,_=f+p;const S=v.getTextContentSize();b=b>S?S:b,_=_>S?S:_,m.setTextNodeRange(v,b,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Ke().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=P(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=X(p)&&n!==null?bc(n,p):p,o=p}const a=P(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<a.length;p++){const g=a[p],m=kc(r,g,f,n);!s&&P(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||za(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(za(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(a==null||!Yt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(f=c(f)),Os(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:st)),a==null?f.length>0?o=o.concat(f):Os(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):P(a)&&a.append(...f),o}function pp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(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 mp(r,e=ce()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=ce()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,bp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(G(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=ce();if(G(l)){const u=o[a];u===`
94
94
  `||u===`\r
95
- `?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(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=Jo(t);u=ee(u)&&e!==null?bc(e,u):u,o=u}const a=I(o)?o.getChildren():[],l=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(ee(o)){const u=o.__text;u.length>0?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&I(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function xp(r,e){const t=[],n=Ge().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);ee(s)&&sp(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=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 a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Uh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=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 a=le();if(a===null)return!1;t=_p(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=le()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,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=nt(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=nt();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?nt():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=nt();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?nt():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=le();if(!G(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const a=yi(i,u=>I(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return $e(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=le();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=le();return!!G(t)&&(t.deleteCharacter(e),!0)},Ie),r.registerCommand(Fn,e=>{const t=le();return!!G(t)&&(t.deleteWord(e),!0)},Ie),r.registerCommand(Ln,e=>{const t=le();return!!G(t)&&(t.deleteLine(e),!0)},Ie),r.registerCommand(Yr,e=>{const t=le();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(G(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Ie),r.registerCommand(Ki,()=>{const e=le();return!!G(e)&&(e.removeText(),!0)},Ie),r.registerCommand(It,e=>{const t=le();return!!G(t)&&(t.formatText(e),!0)},Ie),r.registerCommand(Of,e=>{const t=le();if(!G(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},Ie),r.registerCommand(Kr,e=>{const t=le();return!!G(t)&&(t.insertLineBreak(e),!0)},Ie),r.registerCommand(Rn,()=>{const e=le();return!!G(e)&&(e.insertParagraph(),!0)},Ie),r.registerCommand(Pf,()=>(lc([Xn()]),!0),Ie),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Ie),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Ie),r.registerCommand(xu,e=>{const t=le();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(G(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(bu,e=>{const t=le();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(G(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&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(yu,e=>{const t=le();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!G(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Ie),r.registerCommand(mu,e=>{const t=le();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!G(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Ie),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=le();if(!G(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!gt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Ie),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=le();return!!G(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Ie),r.registerCommand(Ns,e=>{const t=le();if(!G(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Ie),r.registerCommand(_u,()=>{const e=le();return!!G(e)&&(r.blur(),!0)},Ie),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ph();if(ee(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=le();return!!G(n)},Ie),r.registerCommand(Su,e=>{const[t]=fs(e),n=le();return!(t&&!G(n))},Ie),r.registerCommand(ku,e=>{const[t]=fs(e),n=le();if(t&&!G(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);$e(i)&&e.preventDefault()}return!0},Ie),r.registerCommand(Yi,()=>(yh(),!0),Ie),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Ie),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=le();G(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Ie),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:le()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=le(),a=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},Ie))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(y.Suspense,{fallback:null,children:a[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:_,"data-testid":S,...D},k){const[w,E]=y.useState(r.isEditable()),M=y.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),N=y.useMemo(()=>function(...T){return B=>{T.forEach(R=>{typeof R=="function"?R(B):R!=null&&(R.current=B)})}}(k,M),[M,k]);return Tc(()=>(E(r.isEditable()),r.registerEditableListener(T=>{E(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,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"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:N,role:w?x:void 0,spellCheck:v,style:b,tabIndex:_,...D})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=zt();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,Op=4;function zp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(G(i)&&G(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const a=function(v,b,_){const S=v._nodeMap,D=[];for(const k of b){const w=S.get(k);w!==void 0&&D.push(w)}for(const[k,w]of _){if(!w)continue;const E=S.get(k);E===void 0||gt(E)||D.push(E)}return D}(e,t,n);if(a.length===0)return Ft;if(a.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),_=v.get(o.anchor.key);return b&&_&&!r._nodeMap.has(b.__key)&&ee(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const l=a[0],u=r._nodeMap.get(l.__key);if(!ee(u)||!ee(l)||u.__mode!==l.__mode)return Ft;const c=u.__text,d=l.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?Op:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=zp(s,i,a,l,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 a.size>0||l.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||a.size===1&&function(x,v,b){const _=v._nodeMap.get(x),S=b._nodeMap.get(x),D=v._selection,k=b._selection;return!(G(D)&&G(k)&&D.anchor.type==="element"&&D.focus.type==="element"&&k.anchor.type==="text"&&k.focus.type==="text"||!ee(_)||!ee(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand($f,()=>(El(e),!1),Ie),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Ie),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,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,a,l,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 Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Hp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Gp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),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(Dl)},s.componentDidCatch=function(i,o){var a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,u,c,d=this.state.error,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])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(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 Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Ye(t)){const n=t.getParent();if(Re(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Re(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Re(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Ye);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Re(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Ye(r)&&Re(r.getFirstChild())}function Al(r){return Et().append(r)}function Bc(r,e){return Ye(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=le();if(t!==null){const n=t.getNodes();if(G(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=St(e);if(Yt(l)){a.replace(u);const c=Et();I(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(Ye(a)){const c=a.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!I(o)||!o.isEmpty()||Ye(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if(Re(a)){if(!s.has(l)){const u=St(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Yt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Re(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Et();let i;if(Rr(s,r.getChildren()),Re(t)&&e===t.getListType())t.append(s),Re(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Re(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 Jp(r){r.update(()=>{const e=le();if(G(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=dp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=nt();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Xp(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(Re(i)){i.append(r);const o=n.getFirstChild();Re(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Re(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Re(i)&&i.append(r)}else if(Re(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 Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Re(t?t.getParent():void 0)&&Ye(t)&&Re(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(),a=St(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=Et(),u=St(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function eg(){const r=le();if(!G(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();Re(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=nt(),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 a=St(n.getListType());if(tn(i))i.insertAfter(a);else{const l=Et();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!Ye(l)&&!Re(l))break;l=u}l.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends 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 Re(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Re(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Ye(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Re(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,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(!Re(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(Re(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=nt();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,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Re(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?(Xp(this),t++):(Zp(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(!G(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 Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=Re(l)&&l.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(a!==void 0){const l=Gs(a);t.getChildren().some(u=>Re(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Re(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 tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Et(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Et(r.hasAttribute("checked"))}}function Et(r){return Jt(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,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Re(e)||Ht(163),function(t){const n=t.getNextSibling();Re(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),Re(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,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(Re(n))s.append(n);else if(I(n))if(n.isInline())s.append(n);else{const i=it(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Ye(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Qp(t)-1,l=a%o.length,u=o[l],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!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(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=>{Re(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=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:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function St(r,e=1){return Jt(new ln(r,e))}function Re(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=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,a=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:lg,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(!ag.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(!G(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 lg(r){let e=null;if(vh(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 Jt(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=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(I(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=le();if(!G(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!ug(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.remove()}});else{if(o.length===1){const u=function(c,d){let 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 a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!I(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)l.append(d[f])}u.remove()}else l!==null&&l.append(u)}})}}function cg({validateUrl:r,attributes:e}){const[t]=zt();return y.useEffect(()=>{if(!t.hasNodes([Or]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=le();if(!G(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(a=>I(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function dg(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 fg({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);vt(this,"__src");vt(this,"__altText");vt(this,"__width");vt(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:dg,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(fg,{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 hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
95
+ `?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=P(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=X(u)&&e!==null?bc(e,u):u,o=u}const a=P(o)?o.getChildren():[],l=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),P(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?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&P(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function xp(r,e){const t=[],n=Ke().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);X(s)&&sp(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=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 a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Uh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=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 a=ce();if(a===null)return!1;t=_p(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=ce()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,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=st(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=st();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?st():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=st();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?st():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=ce();if(!G(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const a=yi(i,u=>P(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return $e(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=ce();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ce();return!!G(t)&&(t.deleteCharacter(e),!0)},Ie),r.registerCommand(Fn,e=>{const t=ce();return!!G(t)&&(t.deleteWord(e),!0)},Ie),r.registerCommand(Ln,e=>{const t=ce();return!!G(t)&&(t.deleteLine(e),!0)},Ie),r.registerCommand(Yr,e=>{const t=ce();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(G(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Ie),r.registerCommand(Ki,()=>{const e=ce();return!!G(e)&&(e.removeText(),!0)},Ie),r.registerCommand(It,e=>{const t=ce();return!!G(t)&&(t.formatText(e),!0)},Ie),r.registerCommand(Of,e=>{const t=ce();if(!G(t)&&!Wt(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>P(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Ie),r.registerCommand(Kr,e=>{const t=ce();return!!G(t)&&(t.insertLineBreak(e),!0)},Ie),r.registerCommand(Rn,()=>{const e=ce();return!!G(e)&&(e.insertParagraph(),!0)},Ie),r.registerCommand(Pf,()=>(lc([Xn()]),!0),Ie),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Ie),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Ie),r.registerCommand(xu,e=>{const t=ce();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(G(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(bu,e=>{const t=ce();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(G(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ke().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(yu,e=>{const t=ce();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!G(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Ie),r.registerCommand(mu,e=>{const t=ce();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!G(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Ie),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ce();if(!G(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Ie),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ce();return!!G(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Ie),r.registerCommand(Ns,e=>{const t=ce();if(!G(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Ie),r.registerCommand(_u,()=>{const e=ce();return!!G(e)&&(r.blur(),!0)},Ie),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ph();if(X(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ce();return!!G(n)},Ie),r.registerCommand(Su,e=>{const[t]=fs(e),n=ce();return!(t&&!G(n))},Ie),r.registerCommand(ku,e=>{const[t]=fs(e),n=ce();if(t&&!G(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);$e(i)&&e.preventDefault()}return!0},Ie),r.registerCommand(Yi,()=>(yh(),!0),Ie),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Ie),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ce();G(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Ie),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ce()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ce(),a=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},Ie))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(y.Suspense,{fallback:null,children:a[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:_,"data-testid":S,...D},k){const[w,E]=y.useState(r.isEditable()),M=y.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),N=y.useMemo(()=>function(...T){return B=>{T.forEach(R=>{typeof R=="function"?R(B):R!=null&&(R.current=B)})}}(k,M),[M,k]);return Tc(()=>(E(r.isEditable()),r.registerEditableListener(T=>{E(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,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"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:N,role:w?x:void 0,spellCheck:v,style:b,tabIndex:_,...D})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=zt();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,Op=4;function zp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(G(i)&&G(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const a=function(v,b,_){const S=v._nodeMap,D=[];for(const k of b){const w=S.get(k);w!==void 0&&D.push(w)}for(const[k,w]of _){if(!w)continue;const E=S.get(k);E===void 0||yt(E)||D.push(E)}return D}(e,t,n);if(a.length===0)return Ft;if(a.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),_=v.get(o.anchor.key);return b&&_&&!r._nodeMap.has(b.__key)&&X(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const l=a[0],u=r._nodeMap.get(l.__key);if(!X(u)||!X(l)||u.__mode!==l.__mode)return Ft;const c=u.__text,d=l.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?Op:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=zp(s,i,a,l,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 a.size>0||l.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||a.size===1&&function(x,v,b){const _=v._nodeMap.get(x),S=b._nodeMap.get(x),D=v._selection,k=b._selection;return!(G(D)&&G(k)&&D.anchor.type==="element"&&D.focus.type==="element"&&k.anchor.type==="text"&&k.focus.type==="text"||!X(_)||!X(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand($f,()=>(El(e),!1),Ie),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Ie),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,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,a,l,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 Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Hp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Gp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),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(Dl)},s.componentDidCatch=function(i,o){var a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,u,c,d=this.state.error,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])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(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 Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Qe(t)){const n=t.getParent();if(Fe(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Fe(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Fe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Qe);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Fe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Qe(r)&&Fe(r.getFirstChild())}function Al(r){return Et().append(r)}function Bc(r,e){return Qe(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ce();if(t!==null){const n=t.getNodes();if(G(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=St(e);if(Yt(l)){a.replace(u);const c=Et();P(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(Qe(a)){const c=a.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!P(o)||!o.isEmpty()||Qe(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if(Fe(a)){if(!s.has(l)){const u=St(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Yt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Fe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Et();let i;if(Rr(s,r.getChildren()),Fe(t)&&e===t.getListType())t.append(s),Fe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Fe(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 Jp(r){r.update(()=>{const e=ce();if(G(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=dp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=st();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Xp(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(Fe(i)){i.append(r);const o=n.getFirstChild();Fe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Fe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Fe(i)&&i.append(r)}else if(Fe(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 Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Fe(t?t.getParent():void 0)&&Qe(t)&&Fe(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(),a=St(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=Et(),u=St(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function eg(){const r=ce();if(!G(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Qe(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Fe(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=st(),t.insertAfter(i);else{if(!Qe(s))return!1;i=Et(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const a=St(n.getListType());if(tn(i))i.insertAfter(a);else{const l=Et();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!Qe(l)&&!Fe(l))break;l=u}l.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends 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 Fe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Fe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Qe(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Fe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,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(P(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Qe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Fe(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&&(P(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(Fe(n)||Ht(39),Qe(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=st();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Qe(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Fe(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(;Qe(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?(Xp(this),t++):(Zp(this),t--);return this}canInsertAfter(e){return Qe(e)}canReplaceWith(e){return Qe(e)}canMergeWith(e){return tn(e)||Qe(e)}extractWithChild(e,t){if(!G(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 Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=Fe(l)&&l.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(a!==void 0){const l=Gs(a);t.getChildren().some(u=>Fe(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Fe(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 tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Et(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Et(r.hasAttribute("checked"))}}function Et(r){return Jt(new Ir(void 0,r))}function Qe(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Fe(e)||Ht(163),function(t){const n=t.getNextSibling();Fe(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())Qe(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Fe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,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(Qe(n))super.append(n);else{const s=Et();if(Fe(n))s.append(n);else if(P(n))if(n.isInline())s.append(n);else{const i=ot(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Qe(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Qp(t)-1,l=a%o.length,u=o[l],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!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Qe(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Fe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=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:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function St(r,e=1){return Jt(new ln(r,e))}function Fe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=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,a=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:lg,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(!ag.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(!G(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 lg(r){let e=null;if(vh(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 Jt(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=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(P(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ce();if(!G(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!ug(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.remove()}});else{if(o.length===1){const u=function(c,d){let 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 a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!P(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)l.append(d[f])}u.remove()}else l!==null&&l.append(u)}})}}function cg({validateUrl:r,attributes:e}){const[t]=zt();return y.useEffect(()=>{if(!t.hasNodes([Or]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ce();if(!G(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(a=>P(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function dg(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 fg({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);vt(this,"__src");vt(this,"__altText");vt(this,"__width");vt(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:dg,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(fg,{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 hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
96
96
  * @license QR Code generator library (TypeScript)
97
97
  * Copyright (c) Project Nayuki.
98
98
  * SPDX-License-Identifier: MIT
99
- */var Fr;(r=>{const e=class Te{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<Te.MIN_VERSION||l>Te.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let 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(l,u){const c=r.QrSegment.makeSegments(l);return Te.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return Te.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,f=-1,p=!0){if(!(Te.MIN_VERSION<=c&&c<=d&&d<=Te.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const _=Te.getNumDataCodewords(g,u)*8,S=o.getTotalBits(l,g);if(S<=_){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const _ of[Te.Ecc.MEDIUM,Te.Ecc.QUARTILE,Te.Ecc.HIGH])p&&m<=Te.getNumDataCodewords(g,_)*8&&(u=_);let x=[];for(const _ of l){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=Te.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 b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((_,S)=>b[S>>>3]|=_<<7-(S&7)),new Te(g,u,b,f)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let c=u;for(let 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 l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(l,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=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,f!=2&&f!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=Te.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Te.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Te.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Te.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const v=Te.reedSolomonComputeDivisor(f);for(let _=0,S=0;_<d;_++){let D=l.slice(S,S+m-f+(_<g?0:1));S+=D.length;const k=Te.reedSolomonComputeRemainder(D,v);_<g&&D.push(0),x.push(D.concat(k))}let b=[];for(let _=0;_<x[0].length;_++)x.forEach((S,D)=>{(_!=m-f||D>=g)&&b.push(S[_])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(Te.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<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(l){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let l=0;for(let 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?l+=Te.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Te.PENALTY_N3),p=this.modules[f][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Te.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?l+=Te.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Te.PENALTY_N3),p=this.modules[x][f],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Te.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]&&(l+=Te.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),l+=d*Te.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<Te.MIN_VERSION||l>Te.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(Te.getNumRawDataModules(l)/8)-Te.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*Te.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let f=0;f<u.length;f++)u[f]=Te.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Te.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Te.reedSolomonMultiply(p,f))}return c}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class Ke{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new Ke(Ke.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!Ke.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new Ke(Ke.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!Ke.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=Ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=Ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(Ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new Ke(Ke.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:Ke.isNumeric(l)?[Ke.makeNumeric(l)]:Ke.isAlphanumeric(l)?[Ke.makeAlphanumeric(l)]:[Ke.makeBytes(Ke.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new Ke(Ke.Mode.ECI,0,u)}static isNumeric(l){return Ke.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Ke.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
99
+ */var Fr;(r=>{const e=class Ne{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<Ne.MIN_VERSION||l>Ne.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let 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(l,u){const c=r.QrSegment.makeSegments(l);return Ne.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return Ne.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,f=-1,p=!0){if(!(Ne.MIN_VERSION<=c&&c<=d&&d<=Ne.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const _=Ne.getNumDataCodewords(g,u)*8,S=o.getTotalBits(l,g);if(S<=_){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const _ of[Ne.Ecc.MEDIUM,Ne.Ecc.QUARTILE,Ne.Ecc.HIGH])p&&m<=Ne.getNumDataCodewords(g,_)*8&&(u=_);let x=[];for(const _ of l){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=Ne.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 b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((_,S)=>b[S>>>3]|=_<<7-(S&7)),new Ne(g,u,b,f)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let c=u;for(let 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 l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(l,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=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,f!=2&&f!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=Ne.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ne.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Ne.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ne.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const v=Ne.reedSolomonComputeDivisor(f);for(let _=0,S=0;_<d;_++){let D=l.slice(S,S+m-f+(_<g?0:1));S+=D.length;const k=Ne.reedSolomonComputeRemainder(D,v);_<g&&D.push(0),x.push(D.concat(k))}let b=[];for(let _=0;_<x[0].length;_++)x.forEach((S,D)=>{(_!=m-f||D>=g)&&b.push(S[_])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(Ne.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<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(l){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let l=0;for(let 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?l+=Ne.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ne.PENALTY_N3),p=this.modules[f][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ne.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?l+=Ne.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ne.PENALTY_N3),p=this.modules[x][f],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ne.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]&&(l+=Ne.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),l+=d*Ne.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<Ne.MIN_VERSION||l>Ne.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(Ne.getNumRawDataModules(l)/8)-Ne.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*Ne.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let f=0;f<u.length;f++)u[f]=Ne.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Ne.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ne.reedSolomonMultiply(p,f))}return c}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class Ye{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new Ye(Ye.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!Ye.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new Ye(Ye.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!Ye.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=Ye.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=Ye.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(Ye.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new Ye(Ye.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:Ye.isNumeric(l)?[Ye.makeNumeric(l)]:Ye.isAlphanumeric(l)?[Ye.makeAlphanumeric(l)]:[Ye.makeBytes(Ye.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new Ye(Ye.Mode.ECI,0,u)}static isNumeric(l){return Ye.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Ye.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
100
100
  * @license qrcode.react
101
101
  * Copyright (c) Paul O'Shannessy
102
102
  * SPDX-License-Identifier: ISC
103
- */var pg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",Oc="#FFFFFF",zc="#000000",$c=!1,qc=1,gg=4,mg=0,yg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,a){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===n.length-1){if(!o)return;i===null?t.push(`M${a+e},${s+e} h1v1H${a+e}z`):t.push(`M${i+e},${s+e} h${a+1-i}v1H${i+e}z`);return}o&&i===null&&(i=a)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function xg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*yg),o=s/e,a=(n.width||i)*o,l=(n.height||i)*o,u=n.x==null?r.length/2-a/2:n.x*o,c=n.y==null?r.length/2-l/2:n.y*o,d=n.opacity==null?1:n.opacity;let f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(a+u-g),v=Math.ceil(l+c-m);f={x:g,y:m,w:x,h:v}}const p=n.crossOrigin;return{x:u,y:c,h:l,w:a,excavation:f,opacity:d,crossOrigin:p}}function bg(r,e){return e!=null?Math.max(Math.floor(e),0):r?gg:mg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:a}){let l=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,pg[e],t,void 0,void 0,a)},[r,e,t,a]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=y.useMemo(()=>{let p=l.getModules();const g=bg(n,s),m=p.length+g*2,x=xg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[l,o,i,n,s]);return{qrcode:l,margin:c,cells:u,numCells:d,calculatedImageSettings:f}}var vg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),_g=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=Oc,fgColor:l=zc,includeMargin:u=$c,minVersion:c=qc,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"]),b=p==null?void 0:p.src,_=y.useRef(null),S=y.useRef(null),D=y.useCallback(C=>{_.current=C,typeof t=="function"?t(C):t&&(t.current=C)},[t]),[k,w]=y.useState(!1),{margin:E,cells:M,numCells:N,calculatedImageSettings:T}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});y.useEffect(()=>{if(_.current!=null){const C=_.current,j=C.getContext("2d");if(!j)return;let F=M;const O=S.current,U=T!=null&&O!==null&&O.complete&&O.naturalHeight!==0&&O.naturalWidth!==0;U&&T.excavation!=null&&(F=Wc(M,T.excavation));const W=window.devicePixelRatio||1;C.height=C.width=i*W;const re=i/N*W;j.scale(re,re),j.fillStyle=a,j.fillRect(0,0,N,N),j.fillStyle=l,vg?j.fill(new Path2D(Uc(F,E))):M.forEach(function(q,Q){q.forEach(function(H,ne){H&&j.fillRect(ne+E,Q+E,1,1)})}),T&&(j.globalAlpha=T.opacity),U&&j.drawImage(O,T.x+E,T.y+E,T.w,T.h)}}),y.useEffect(()=>{w(!1)},[b]);const B=yo({height:i,width:i},x);let R=null;return b!=null&&(R=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{w(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:B,height:i,width:i,ref:D,role:"img"},v)),R)});_g.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=Oc,fgColor:l=zc,includeMargin:u=$c,minVersion:c=qc,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:b,calculatedImageSettings:_}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=v,D=null;g!=null&&_!=null&&(_.excavation!=null&&(S=Wc(v,_.excavation)),D=y.createElement("image",{href:g.src,height:_.h,width:_.w,x:_.x+x,y:_.y+x,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const k=Uc(S,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!f&&y.createElement("title",null,f),y.createElement("path",{fill:a,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:l,d:k,shapeRendering:"crispEdges"}),D)});Vc.displayName="QRCodeSVG";function wg(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 Cg({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(Vc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);vt(this,"__data");vt(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:wg,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(Cg,{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 Sg(r){return r instanceof un}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Eg={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 Dg({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:a,hasContent:l}){const[u]=zt(),[c,d]=y.useState(!1),f=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(It,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(It,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(It,"underline")},[u]),v=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),_=y.useCallback(()=>{u.update(()=>{const w=le();G(w)&&ip(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},D=`
103
+ */var pg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",Oc="#FFFFFF",zc="#000000",$c=!1,qc=1,gg=4,mg=0,yg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,a){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===n.length-1){if(!o)return;i===null?t.push(`M${a+e},${s+e} h1v1H${a+e}z`):t.push(`M${i+e},${s+e} h${a+1-i}v1H${i+e}z`);return}o&&i===null&&(i=a)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function xg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*yg),o=s/e,a=(n.width||i)*o,l=(n.height||i)*o,u=n.x==null?r.length/2-a/2:n.x*o,c=n.y==null?r.length/2-l/2:n.y*o,d=n.opacity==null?1:n.opacity;let f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(a+u-g),v=Math.ceil(l+c-m);f={x:g,y:m,w:x,h:v}}const p=n.crossOrigin;return{x:u,y:c,h:l,w:a,excavation:f,opacity:d,crossOrigin:p}}function bg(r,e){return e!=null?Math.max(Math.floor(e),0):r?gg:mg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:a}){let l=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,pg[e],t,void 0,void 0,a)},[r,e,t,a]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=y.useMemo(()=>{let p=l.getModules();const g=bg(n,s),m=p.length+g*2,x=xg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[l,o,i,n,s]);return{qrcode:l,margin:c,cells:u,numCells:d,calculatedImageSettings:f}}var vg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),_g=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=Oc,fgColor:l=zc,includeMargin:u=$c,minVersion:c=qc,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"]),b=p==null?void 0:p.src,_=y.useRef(null),S=y.useRef(null),D=y.useCallback(C=>{_.current=C,typeof t=="function"?t(C):t&&(t.current=C)},[t]),[k,w]=y.useState(!1),{margin:E,cells:M,numCells:N,calculatedImageSettings:T}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});y.useEffect(()=>{if(_.current!=null){const C=_.current,j=C.getContext("2d");if(!j)return;let F=M;const I=S.current,W=T!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;W&&T.excavation!=null&&(F=Wc(M,T.excavation));const q=window.devicePixelRatio||1;C.height=C.width=i*q;const ne=i/N*q;j.scale(ne,ne),j.fillStyle=a,j.fillRect(0,0,N,N),j.fillStyle=l,vg?j.fill(new Path2D(Uc(F,E))):M.forEach(function(U,Q){U.forEach(function(H,ie){H&&j.fillRect(ie+E,Q+E,1,1)})}),T&&(j.globalAlpha=T.opacity),W&&j.drawImage(I,T.x+E,T.y+E,T.w,T.h)}}),y.useEffect(()=>{w(!1)},[b]);const B=yo({height:i,width:i},x);let R=null;return b!=null&&(R=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{w(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:B,height:i,width:i,ref:D,role:"img"},v)),R)});_g.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=Oc,fgColor:l=zc,includeMargin:u=$c,minVersion:c=qc,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:b,calculatedImageSettings:_}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=v,D=null;g!=null&&_!=null&&(_.excavation!=null&&(S=Wc(v,_.excavation)),D=y.createElement("image",{href:g.src,height:_.h,width:_.w,x:_.x+x,y:_.y+x,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const k=Uc(S,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!f&&y.createElement("title",null,f),y.createElement("path",{fill:a,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:l,d:k,shapeRendering:"crispEdges"}),D)});Vc.displayName="QRCodeSVG";function wg(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 Cg({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(Vc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);vt(this,"__data");vt(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:wg,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(Cg,{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 Sg(r){return r instanceof un}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Eg={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 Dg({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:a,hasContent:l}){const[u]=zt(),[c,d]=y.useState(!1),f=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(It,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(It,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(It,"underline")},[u]),v=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),_=y.useCallback(()=>{u.update(()=>{const w=ce();G(w)&&ip(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},D=`
104
104
  .mail-editor-toolbar-btn:hover:not(:disabled) {
105
105
  background: ${r.border};
106
106
  }
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: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: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:b,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||!l||e,onBlur:k,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!l?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!l||e?"not-allowed":"pointer",opacity:i||!l?.5:1},children:i?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:()=>{a==null||a("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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:()=>{a==null||a("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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:()=>{a==null||a("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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 Ag({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ge();i.clear();const o=nt();i.append(o),o.select();const l=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,l).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Tg({text:r,trigger:e}){const[t]=zt(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=le();if(G(i))i.insertText(s);else{const o=Ge(),a=o.getLastChild();if(a){a.selectEnd();const l=le();G(l)&&l.insertText(s)}else{const l=nt(),u=it(s);l.append(u),o.append(l)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Ng({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 Gc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:a="200px",externalUpdate:l,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const v={...kg,...s},[b,_]=y.useState(!1),S=y.useRef(void 0),[D,k]=y.useState(r),[w,E]=y.useState(!1),[M,N]=y.useState(null),T=g??w,B=m??M;y.useEffect(()=>{l!==void 0&&l!==S.current&&(S.current=l,_(!0))},[l]);const R=y.useCallback(()=>{_(!1)},[]),C=q=>q.replace(/<[^>]*>/g,"").trim(),j=q=>q.split(`
108
- `).map(Q=>`<p>${Q||"<br>"}</p>`).join(""),F=async q=>{const Q=C(D);if(!Q)return;const H=q==="restructure"?d:q==="proofread"?f:p;if(H){E(!0),N(q);try{const ne=await H(Q),de=j(ne);k(de),e==null||e(de),S.current=Date.now(),_(!0)}catch(ne){console.error(`AI ${q} failed:`,ne)}finally{E(!1),N(null)}}},O=C(D).length>0,U={namespace:"MailEditor",theme:Eg,onError:q=>{console.error("Lexical error:",q)},nodes:[ln,Ir,Or,ns,bi,xi,vi,un],editable:!i},W=y.useCallback((q,Q)=>{q.read(()=>{const H=Sc(Q,null);k(H),e==null||e(H)})},[e]),re=`
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: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: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:b,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||!l||e,onBlur:k,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!l?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!l||e?"not-allowed":"pointer",opacity:i||!l?.5:1},children:i?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:()=>{a==null||a("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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:()=>{a==null||a("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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:()=>{a==null||a("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter: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 Ag({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ke();i.clear();const o=st();i.append(o),o.select();const l=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,l).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Tg({text:r,trigger:e}){const[t]=zt(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=ce();if(G(i))i.insertText(s);else{const o=Ke(),a=o.getLastChild();if(a){a.selectEnd();const l=ce();G(l)&&l.insertText(s)}else{const l=st(),u=ot(s);l.append(u),o.append(l)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Ng({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 Gc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:a="200px",externalUpdate:l,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const v={...kg,...s},[b,_]=y.useState(!1),S=y.useRef(void 0),[D,k]=y.useState(r),[w,E]=y.useState(!1),[M,N]=y.useState(null),T=g??w,B=m??M;y.useEffect(()=>{l!==void 0&&l!==S.current&&(S.current=l,_(!0))},[l]);const R=y.useCallback(()=>{_(!1)},[]),C=U=>U.replace(/<[^>]*>/g,"").trim(),j=U=>U.split(`
108
+ `).map(Q=>`<p>${Q||"<br>"}</p>`).join(""),F=async U=>{const Q=C(D);if(!Q)return;const H=U==="restructure"?d:U==="proofread"?f:p;if(H){E(!0),N(U);try{const ie=await H(Q),ue=j(ie);k(ue),e==null||e(ue),S.current=Date.now(),_(!0)}catch(ie){console.error(`AI ${U} failed:`,ie)}finally{E(!1),N(null)}}},I=C(D).length>0,W={namespace:"MailEditor",theme:Eg,onError:U=>{console.error("Lexical error:",U)},nodes:[ln,Ir,Or,ns,bi,xi,vi,un],editable:!i},q=y.useCallback((U,Q)=>{U.read(()=>{const H=Sc(Q,null);k(H),e==null||e(H)})},[e]),ne=`
109
109
  .mail-editor-paragraph {
110
110
  margin: 0 0 8px 0;
111
111
  line-height: 1.5;
@@ -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 ${v.border}`,borderRadius:"8px",background:v.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:a},children:[h.jsx("style",{children:re}),x,h.jsxs(Vh,{initialConfig:U,children:[h.jsx(Dg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:B,onAiAction:F,hasContent:O}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{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:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:W}),h.jsx(Ag,{html:b?D:r,isExternalUpdate:b,onImportComplete:R}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:v})]})}const Bg={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 jg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:a,insertText:l,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:b,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:D}){const k={...Bg,...c},[w,E]=y.useState(r),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(e),[j,F]=y.useState(t),[O,U]=y.useState([]),[W,re]=y.useState(!1),[q,Q]=y.useState(""),[H,ne]=y.useState(f),[de,he]=y.useState(!1),pe=y.useRef(void 0);y.useEffect(()=>{a!==void 0&&a!==pe.current&&(pe.current=a,F(t),he(!0))},[a,t]);const ke=P=>{F(P),he(!1),o==null||o(P)},me=y.useRef(null),[J,be]=y.useState(!1),se=P=>{const X=P.target.files;if(X){const ue=Array.from(X);console.log("[MailComposer] Files selected:",ue.map(ce=>({name:ce.name,size:ce.size,type:ce.type}))),U(ce=>[...ce,...ue])}me.current&&(me.current.value="")},Ae=P=>{P.preventDefault(),P.stopPropagation(),be(!0)},_e=P=>{P.preventDefault(),P.stopPropagation(),be(!1)},ve=P=>{if(P.preventDefault(),P.stopPropagation(),be(!1),P.dataTransfer.files&&P.dataTransfer.files.length>0){const X=Array.from(P.dataTransfer.files);console.log("[MailComposer] Files dropped:",X.map(ue=>({name:ue.name,size:ue.size,type:ue.type}))),U(ue=>[...ue,...X])}else console.log("[MailComposer] Drop event but no files:",P.dataTransfer.types)},Me=P=>P.type.startsWith("image/")?"image":P.type==="application/pdf"?"picture_as_pdf":P.type.includes("spreadsheet")||P.type.includes("excel")?"table_chart":P.type.includes("document")||P.type.includes("word")?"description":"attach_file",Fe=P=>{U(X=>X.filter((ue,ce)=>ce!==P))},qe=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,V=async()=>{if(!w.trim()){Q("Recipient email is required");return}if(!R.trim()){Q("Subject is required");return}re(!0),Q("");try{const P=await Promise.all(O.map(async ce=>{const Ue=await ce.arrayBuffer(),yt=btoa(new Uint8Array(Ue).reduce((xt,ae)=>xt+String.fromCharCode(ae),""));return{filename:ce.name,content_type:ce.type||"application/octet-stream",data:yt,size:ce.size}})),X=j.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ue={to:w.trim(),cc:M.trim()||void 0,bcc:T.trim()||void 0,subject:R.trim(),html:X,attachments:P,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",ue.to,"subject:",ue.subject,"attachmentsCount:",ue.attachments.length),ue.attachments.length>0&&ue.attachments.forEach((ce,Ue)=>{var yt;console.log(`[MailComposer] Attachment ${Ue+1}:`,ce.filename,"size:",ce.size,"type:",ce.content_type,"data length:",((yt=ce.data)==null?void 0:yt.length)||0)}),await s(ue),E(""),N(""),B(""),C(""),F(""),U([])}catch(P){Q(P instanceof Error?P.message:"Failed to send email")}finally{re(!1)}},z={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},Le={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},ie=(P,X=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:X?"not-allowed":"pointer",opacity:X?.6:1,background:P?k.buttonPrimary:k.buttonSecondary,color:P?"#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:[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:Le,children:"To"}),h.jsx("input",{type:"email",value:w,onChange:P=>E(P.target.value),placeholder:"recipient@example.com",disabled:d||W,style:z})]}),!H&&h.jsx("button",{type:"button",onClick:()=>ne(!0),disabled:d||W,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:Le,children:"CC"}),h.jsx("input",{type:"email",value:M,onChange:P=>N(P.target.value),placeholder:"cc@example.com",disabled:d||W,style:z})]}),h.jsxs("div",{children:[h.jsx("label",{style:Le,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:P=>B(P.target.value),placeholder:"bcc@example.com",disabled:d||W,style:z})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:Le,children:"Subject"}),h.jsx("input",{type:"text",value:R,onChange:P=>C(P.target.value),placeholder:"Email subject",disabled:d||W,style:z})]}),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(Gc,{value:j,onChange:ke,placeholder:p,replyTo:n,theme:k,disabled:d||W,minHeight:m,externalUpdate:de?a:void 0,insertText:l,insertTextTrigger:u,onAiRestructure:b,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:D})})}),h.jsxs("div",{children:[h.jsx("label",{style:{...Le,marginBottom:"8px"},children:"Attachments"}),h.jsx("input",{ref:me,type:"file",multiple:!0,onChange:se,style:{display:"none"}}),h.jsxs("div",{onClick:()=>{var P;return(P=me.current)==null?void 0:P.click()},onDragOver:Ae,onDragLeave:_e,onDrop:ve,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||W?"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((P,X)=>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:Me(P)}),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:P.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:qe(P.size)})]}),h.jsx("button",{type:"button",onClick:()=>Fe(X),disabled:d||W,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"})})]},`${P.name}-${X}`))})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!v&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||W,style:ie(!1,d||W),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:V,disabled:d||W||!w.trim()||!R.trim(),style:ie(!0,d||W||!w.trim()||!R.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:W?"spin 1s linear infinite":"none"},children:W?"sync":"send"}),W?"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:a},children:[h.jsx("style",{children:ne}),x,h.jsxs(Vh,{initialConfig:W,children:[h.jsx(Dg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:B,onAiAction:F,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{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:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:q}),h.jsx(Ag,{html:b?D:r,isExternalUpdate:b,onImportComplete:R}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:v})]})}const Bg={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 jg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:a,insertText:l,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:b,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:D}){const k={...Bg,...c},[w,E]=y.useState(r),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(e),[j,F]=y.useState(t),[I,W]=y.useState([]),[q,ne]=y.useState(!1),[U,Q]=y.useState(""),[H,ie]=y.useState(f),[ue,he]=y.useState("message"),[ge,we]=y.useState(!1),xe=y.useRef(void 0);y.useEffect(()=>{a!==void 0&&a!==xe.current&&(xe.current=a,F(t),we(!0))},[a,t]);const Z=z=>{F(z),we(!1),o==null||o(z)},be=y.useRef(null),[te,Ae]=y.useState(!1),_e=z=>{const de=z.target.files;if(de){const Ce=Array.from(de);console.log("[MailComposer] Files selected:",Ce.map(We=>({name:We.name,size:We.size,type:We.type}))),W(We=>[...We,...Ce])}be.current&&(be.current.value="")},ve=z=>{z.preventDefault(),z.stopPropagation(),Ae(!0)},Re=z=>{z.preventDefault(),z.stopPropagation(),Ae(!1)},Le=z=>{if(z.preventDefault(),z.stopPropagation(),Ae(!1),z.dataTransfer.files&&z.dataTransfer.files.length>0){const de=Array.from(z.dataTransfer.files);console.log("[MailComposer] Files dropped:",de.map(Ce=>({name:Ce.name,size:Ce.size,type:Ce.type}))),W(Ce=>[...Ce,...de])}else console.log("[MailComposer] Drop event but no files:",z.dataTransfer.types)},qe=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",V=z=>{W(de=>de.filter((Ce,We)=>We!==z))},O=z=>z<1024?`${z} B`:z<1024*1024?`${(z/1024).toFixed(1)} KB`:`${(z/(1024*1024)).toFixed(1)} MB`,Ue=async()=>{if(!w.trim()){Q("Recipient email is required");return}if(!R.trim()){Q("Subject is required");return}ne(!0),Q("");try{const z=await Promise.all(I.map(async We=>{const dt=await We.arrayBuffer(),le=btoa(new Uint8Array(dt).reduce((pe,Ve)=>pe+String.fromCharCode(Ve),""));return{filename:We.name,content_type:We.type||"application/octet-stream",data:le,size:We.size}})),de=j.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),Ce={to:w.trim(),cc:M.trim()||void 0,bcc:T.trim()||void 0,subject:R.trim(),html:de,attachments:z,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",Ce.to,"subject:",Ce.subject,"attachmentsCount:",Ce.attachments.length),Ce.attachments.length>0&&Ce.attachments.forEach((We,dt)=>{var le;console.log(`[MailComposer] Attachment ${dt+1}:`,We.filename,"size:",We.size,"type:",We.content_type,"data length:",((le=We.data)==null?void 0:le.length)||0)}),await s(Ce),E(""),N(""),B(""),C(""),F(""),W([])}catch(z){Q(z instanceof Error?z.message:"Failed to send email")}finally{ne(!1)}},se={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},re={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},oe=(z,de=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:de?"not-allowed":"pointer",opacity:de?.6:1,background:z?k.buttonPrimary:k.buttonSecondary,color:z?"#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:re,children:"To"}),h.jsx("input",{type:"email",value:w,onChange:z=>E(z.target.value),placeholder:"recipient@example.com",disabled:d||q,style:se})]}),!H&&h.jsx("button",{type:"button",onClick:()=>ie(!0),disabled:d||q,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:re,children:"CC"}),h.jsx("input",{type:"email",value:M,onChange:z=>N(z.target.value),placeholder:"cc@example.com",disabled:d||q,style:se})]}),h.jsxs("div",{children:[h.jsx("label",{style:re,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:z=>B(z.target.value),placeholder:"bcc@example.com",disabled:d||q,style:se})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:re,children:"Subject"}),h.jsx("input",{type:"text",value:R,onChange:z=>C(z.target.value),placeholder:"Email subject",disabled:d||q,style:se})]}),h.jsx("input",{ref:be,type:"file",multiple:!0,onChange:_e,style:{display:"none"}}),h.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${k.border}`,marginBottom:"0"},children:[h.jsx("button",{type:"button",onClick:()=>he("message"),disabled:d||q,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ue==="message"?`2px solid ${k.primary}`:"2px solid transparent",color:ue==="message"?k.primary:k.textSecondary,fontWeight:ue==="message"?600:400,cursor:d||q?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),h.jsxs("button",{type:"button",onClick:()=>he("attachments"),disabled:d||q,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ue==="attachments"?`2px solid ${k.primary}`:"2px solid transparent",color:ue==="attachments"?k.primary:k.textSecondary,fontWeight:ue==="attachments"?600:400,cursor:d||q?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",I.length>0&&h.jsx("span",{style:{background:k.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:I.length})]}),ue==="message"&&h.jsx("button",{type:"button",onClick:()=>{var z;return(z=be.current)==null?void 0:z.click()},disabled:d||q,title:"Add attachment",style:{marginLeft:"auto",padding:"6px 10px",border:"none",background:"none",color:k.textSecondary,cursor:d||q?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})})]}),ue==="message"&&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(Gc,{value:j,onChange:Z,placeholder:p,replyTo:n,theme:k,disabled:d||q,minHeight:m,externalUpdate:ge?a:void 0,insertText:l,insertTextTrigger:u,onAiRestructure:b,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:D})})}),ue==="attachments"&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[h.jsxs("div",{onClick:()=>{var z;return(z=be.current)==null?void 0:z.click()},onDragOver:ve,onDragLeave:Re,onDrop:Le,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${te?k.primary:k.border}`,borderRadius:"8px",background:te?`${k.primary}10`:"transparent",color:te?k.primary:k.textSecondary,cursor:d||q?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:te?"file_download":"cloud_upload"}),h.jsx("span",{style:{fontSize:"14px"},children:te?"Drop files here":"Drop files or click to add"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:I.length>0?h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:I.map((z,de)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${k.border}`,gap:"12px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:k.textSecondary},children:qe(z)}),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:z.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:O(z.size)})]}),h.jsx("button",{type:"button",onClick:()=>V(de),disabled:d||q,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:d||q?"not-allowed":"pointer",color:k.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${z.name}-${de}`))}):h.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:k.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!v&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||q,style:oe(!1,d||q),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:Ue,disabled:d||q||!w.trim()||!R.trim(),style:oe(!0,d||q||!w.trim()||!R.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:q?"spin 1s linear infinite":"none"},children:q?"sync":"send"}),q?"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 Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Mg,...d},[g,m]=y.useState(!1),[x,v]=y.useState(""),b=y.useRef(null),_=y.useRef(null);y.useEffect(()=>{function T(B){b.current&&!b.current.contains(B.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase())===x.toLowerCase()}),k=e.map(T=>r.find(B=>B.id===T)).filter(Boolean),w=y.useCallback(T=>{var B;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(B=_.current)==null||B.focus())},[e,t,c]),E=y.useCallback(T=>{t(e.filter(B=>B!==T))},[e,t]),M=y.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&w(T.id),v("")},[D,x,i,w]),N=y.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?M():S.length>0&&w(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,M,w,E]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[l&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),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:B=>{B.stopPropagation(),E(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:N,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&&!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:[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:B=>{B.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:[T.label,o&&a&&h.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),a(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:B=>{B.currentTarget.style.opacity="1",B.currentTarget.style.color="#ef4444"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.5",B.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:M,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 Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),v=y.useMemo(()=>e&&r.find(E=>E.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const E=d.toLowerCase();return r.filter(M=>{var N,T;return((N=M.label)==null?void 0:N.toLowerCase().includes(E))||((T=M.notes)==null?void 0:T.toLowerCase().includes(E))})},[r,d]);y.useEffect(()=>{const E=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const _=E=>{s&&s(E),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},k=E=>{f(E.target.value),p||g(!0)},w=E=>{E.key==="Enter"?(E.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):E.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${l}`,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:E=>{E.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:D,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:E=>{E.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:E=>{E.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 a=="number"?`${a}px`:a,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:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((E,M)=>h.jsxs("div",{onClick:()=>_(E),style:{padding:"10px 14px",cursor:"pointer",borderBottom:M<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:E.color||c.text,marginBottom:E.notes?"2px":0},children:E.label}),E.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.notes})]},E.id))})]})}function Pg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=y.useState(null),[x,v]=y.useState(null),[b,_]=y.useState(null),S=y.useRef(null),D=e.reduce((B,R)=>{let C=r.filter(j=>n(j)===R.id);return s&&(C=C.sort((j,F)=>s(j)-s(F))),B[R.id]=C,B},{}),k=y.useCallback((B,R)=>{const C=t(R),j=n(R);m(C),S.current=j,B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const F=B.target;F.style.opacity="0.5"})},[t,n]),w=y.useCallback(B=>{const R=B.target;R.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),E=y.useCallback((B,R,C)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",v(R),_(C)},[]),M=y.useCallback(B=>{const R=B.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(v(null),_(null))},[]),N=y.useCallback((B,R,C)=>{if(B.preventDefault(),!g)return;const j=S.current;j===R?a==null||a(g,R,C):j&&o(g,j,R,C),m(null),v(null),_(null),S.current=null},[g,o,a]),T=(B,R)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[B.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:B.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:B.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(B=>{const R=D[B.id]||[],C=x===B.id;return h.jsxs("div",{"data-kanban-column":B.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:j=>{j.preventDefault(),g&&!C&&v(B.id)},onDragLeave:M,onDrop:j=>N(j,B.id,b??R.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(B,R.length):T(B,R.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:[R.map((j,F)=>{const O=t(j),U=g===O,W=C&&b===F&&!U;return h.jsxs("div",{children:[W&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:re=>k(re,j),onDragEnd:w,onDragOver:re=>E(re,B.id,F),onClick:()=>l==null?void 0:l(j),className:`cursor-grab active:cursor-grabbing transition-all ${U?"opacity-50 scale-95":""} ${p}`,children:i(j,U)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:j=>{j.preventDefault(),E(j,B.id,R.length)},children:C&&b===R.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.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(B)})]},B.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function zg(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[a&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=Og(r),i=zg(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:l})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Ug,...g},{allDayItems:x,timedItems:v}=y.useMemo(()=>{const w=[],E=[];for(const M of r)a(M)?w.push(M):E.push(M);return{allDayItems:w,timedItems:E}},[r,a]),b=y.useMemo(()=>{const w=[];for(let E=t;E<=n;E++)w.push(E);return w},[t,n]),_=(n-t+1)*s,S=y.useCallback(w=>{const E=i(w);if(!E)return null;const M=Wg(E);if(!M)return null;const{hours:N,minutes:T}=M,B=Math.max(t,Math.min(n,N)),R=N<t?0:T,C=(B-t)*s+R/60*s,j=o(w),F=Math.max(20,j/60*s);return{top:C,height:F}},[i,o,t,n,s]),D=y.useMemo(()=>{if(!f||!Vg(e))return null;const w=new Date,E=w.getHours(),M=w.getMinutes();return E<t||E>n?null:(E-t)*s+M/60*s},[e,f,t,n,s]),k=y.useCallback(w=>{if(!d)return;const E=w.currentTarget.getBoundingClientRect(),N=(w.clientY-E.top)/s*60,T=Math.floor(N/60)+t,B=Math.round(N%60/15)*15,R=Math.min(n,Math.max(t,T)),C=B>=60?0:B,j=`${R.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(j)},[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)},l(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[b.map((w,E)=>h.jsxs("div",{style:{position:"absolute",top:E*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:Hg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<b.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}),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}})]}),v.map(w=>{const E=S(w);return E?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:M=>{M.stopPropagation(),c==null||c(w)},children:u(w)},l(w)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const a=s==="widget",[l,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(0),[b,_]=y.useState(null),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState(!0),[N,T]=y.useState([]),[B,R]=y.useState({completed:0,total:0}),C=y.useRef(!1),j=y.useRef(!0);y.useEffect(()=>{j.current=E},[E]);const F=y.useRef(null),O=y.useRef(null),U=y.useRef(null),W=y.useRef(null),re=y.useRef(null),q=y.useRef([]),Q=y.useRef(null),H=y.useRef(null),ne=y.useRef(null),de=y.useRef(null),he=y.useRef(!1),pe=y.useRef([]),ke=y.useRef(null),me=y.useRef(null),J=y.useRef([]),be=y.useRef([]),se=y.useRef("insert"),Ae=y.useRef(!1),_e=y.useRef(0),ve=y.useRef(0),Me=y.useRef(0),Fe=Z=>{const L=Math.floor(Z/60),fe=Math.floor(Z%60);return`${L.toString().padStart(2,"0")}:${fe.toString().padStart(2,"0")}`},qe=async Z=>{const L=await Z.arrayBuffer(),fe=new AudioContext,ye=await fe.decodeAudioData(L);return await fe.close(),ye},V=Z=>{const L=Z.numberOfChannels,fe=Z.sampleRate,ye=1,K=16,Ee=K/8,we=L*Ee,Ce=fe*we,Pe=Z.length*we,We=new ArrayBuffer(44+Pe),Se=new DataView(We),De=(Ve,ze)=>{for(let ct=0;ct<ze.length;ct++)Se.setUint8(Ve+ct,ze.charCodeAt(ct))};De(0,"RIFF"),Se.setUint32(4,36+Pe,!0),De(8,"WAVE"),De(12,"fmt "),Se.setUint32(16,16,!0),Se.setUint16(20,ye,!0),Se.setUint16(22,L,!0),Se.setUint32(24,fe,!0),Se.setUint32(28,Ce,!0),Se.setUint16(32,we,!0),Se.setUint16(34,K,!0),De(36,"data"),Se.setUint32(40,Pe,!0);const et=[];for(let Ve=0;Ve<L;Ve++)et.push(Z.getChannelData(Ve));let st=44;for(let Ve=0;Ve<Z.length;Ve++)for(let ze=0;ze<L;ze++){const ct=Math.max(-1,Math.min(1,et[ze][Ve])),dt=ct<0?ct*32768:ct*32767;Se.setInt16(st,dt,!0),st+=2}return new Blob([We],{type:"audio/wav"})},z=async(Z,L,fe,ye)=>{const K=new AudioContext,Ee=Z.sampleRate,we=Math.max(Z.numberOfChannels,L.numberOfChannels),Ce=Math.min(fe,Z.length),Pe=Math.max(0,Z.length-fe),We=ye==="insert"?Ce+L.length+Pe:Ce+L.length,Se=K.createBuffer(we,We,Ee);for(let De=0;De<we;De++){const et=Se.getChannelData(De),st=De<Z.numberOfChannels?Z.getChannelData(De):Z.getChannelData(0);for(let ze=0;ze<Ce;ze++)et[ze]=st[ze];const Ve=De<L.numberOfChannels?L.getChannelData(De):L.getChannelData(0);for(let ze=0;ze<L.length;ze++)et[Ce+ze]=Ve[ze];if(ye==="insert")for(let ze=0;ze<Pe;ze++)et[Ce+L.length+ze]=st[fe+ze]}return await K.close(),Se},Le=y.useCallback(()=>{const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const fe=Z.getBoundingClientRect(),ye=fe.width,K=fe.height,Ee=pe.current,we=f||c||1,Ce=l==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,ye,K);const Pe=8,We="rgba(0, 0, 0, 0.4)",Se=L.createLinearGradient(0,0,0,Pe);Se.addColorStop(0,We),Se.addColorStop(1,"transparent"),L.fillStyle=Se,L.fillRect(0,0,ye,Pe);const De=L.createLinearGradient(0,K-Pe,0,K);De.addColorStop(0,"transparent"),De.addColorStop(1,We),L.fillStyle=De,L.fillRect(0,K-Pe,ye,Pe);const et=L.createLinearGradient(0,0,Pe,0);et.addColorStop(0,We),et.addColorStop(1,"transparent"),L.fillStyle=et,L.fillRect(0,0,Pe,K);const st=L.createLinearGradient(ye-Pe,0,ye,0);st.addColorStop(0,"transparent"),st.addColorStop(1,We),L.fillStyle=st,L.fillRect(ye-Pe,0,Pe,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(ye,K/2),L.stroke();const Ve=ye/2;if(Ee.length>0)if(l==="recording")for(let dt=0;dt<Ee.length;dt++){const At=Ee.length-1-dt,Zt=Ve-At*4;if(Zt<-3||Zt>ye)continue;const jt=Ee[dt]*(K/2-12),A=K/2-jt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,jt*2)}else{const dt=we>0?Ce/we*Ee.length:0;for(let At=0;At<Ee.length;At++){const Zt=dt-At,jt=Ve-Zt*4;if(jt<-3||jt>ye)continue;const A=Ee[At]*(K/2-12),$=K/2-A;L.fillStyle=At<=dt?"#10b981":"#4b5563",L.fillRect(jt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ve,0),L.lineTo(Ve,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Fe(Ce),Ve,K-6),l==="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"},[l,x,c,f]),ie=()=>{const Z=re.current;if(!Z||!he.current)return;const L=Z.frequencyBinCount,fe=new Uint8Array(L);Z.getByteTimeDomainData(fe);let ye=0;for(let we=0;we<L;we++){const Ce=(fe[we]-128)/128;ye+=Ce*Ce}const K=Math.sqrt(ye/L),Ee=Math.min(1,K*3);pe.current.push(Ee),Le(),he.current&&(H.current=requestAnimationFrame(ie))},P=async()=>{try{_(null),D(!1),ke.current===null&&(pe.current=[]);const Z=await navigator.mediaDevices.getUserMedia({audio:!0});U.current=Z;const L=new AudioContext;W.current=L;const fe=L.createAnalyser();fe.fftSize=2048,re.current=fe,L.createMediaStreamSource(Z).connect(fe);const K=new MediaRecorder(Z);O.current=K,q.current=[],K.ondataavailable=Ee=>{Ee.data.size>0&&q.current.push(Ee.data)},K.onstop=async()=>{try{if(he.current=!1,q.current.length===0){_("No audio was recorded. Please try again."),u("idle"),Z.getTracks().forEach(Se=>Se.stop());return}const Ee=new Blob(q.current,{type:"audio/webm"});let we,Ce;if(ke.current!==null&&me.current)try{const Se=await qe(Ee),De=me.current.sampleRate,et=Math.floor(ke.current*De),st=await z(me.current,Se,et,se.current);we=V(st),Ce=st.length/st.sampleRate,se.current==="insert"&&(pe.current=[...pe.current,...be.current]),ke.current=null,me.current=null,J.current=[],be.current=[]}catch{we=Ee,Ce=_e.current>0?_e.current:1}else we=Ee,Ce=_e.current>0?_e.current:1;if(de.current=we,Z.getTracks().forEach(Se=>Se.stop()),j.current&&t){T(Se=>[...Se,we]),R(Se=>({...Se,total:Se.total+1})),de.current=null,pe.current=[],v(0),p(0),d(0),u("idle");return}const Pe=URL.createObjectURL(we),We=new Audio(Pe);We.ontimeupdate=()=>{v(We.currentTime)},We.onended=()=>{m(!1)},ne.current=We,p(Ce),v(Ce),u("editing")}catch{_("Failed to process recording"),u("idle")}},K.start(100),he.current=!0,u("recording"),d(0),_e.current=0,Q.current=setInterval(()=>{_e.current+=1,d(_e.current),_e.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),he.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.")}},X=()=>{he.current=!1,D(!1),w(null),H.current&&(cancelAnimationFrame(H.current),H.current=null),Q.current&&(clearInterval(Q.current),Q.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},ue=Z=>{const L=F.current;if(!L)return;const fe=f||c;if(fe<=0)return;const ye=pe.current;if(ye.length===0)return;const K=L.getBoundingClientRect(),Ee=Z-ve.current,we=4,Ce=K.width/L.width,Pe=ye.length/fe*we,We=-Ee/(Pe*Ce),Se=Me.current+We,De=Math.max(0,Math.min(Se,fe));ne.current&&(ne.current.currentTime=De),v(De)},ce=()=>{ne.current&&(ne.current.currentTime=0),v(0)},Ue=()=>{const Z=f||c;ne.current&&(ne.current.currentTime=Z),v(Z)},yt=()=>{const Z=ne.current;Z&&(g?(Z.pause(),v(Z.currentTime),m(!1)):(Z.currentTime=x,Z.play().catch(()=>{}),m(!0)))},xt=async Z=>{if(!de.current){P();return}try{ne.current&&(ne.current.pause(),m(!1)),se.current=Z,me.current=await qe(de.current);const L=f||c;ke.current=x;const fe=L>0?x/L:0,ye=Math.floor(fe*pe.current.length);J.current=pe.current.slice(0,ye),be.current=pe.current.slice(ye),pe.current=[...J.current],P()}catch{_("Failed to prepare recording. Please try again.")}},ae=()=>{ne.current&&(ne.current.pause(),ne.current=null),de.current=null,me.current=null,ke.current=null,J.current=[],m(!1),v(0),p(0),d(0),P()},ge=()=>{de.current?r(de.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{l==="recording"&&F.current&&re.current&&he.current&&(H.current=requestAnimationFrame(ie))},[l]),y.useEffect(()=>{const Z=F.current;if(!Z)return;const L=()=>{const fe=window.devicePixelRatio||1,ye=Z.getBoundingClientRect();Z.width=ye.width*fe,Z.height=ye.height*fe;const K=Z.getContext("2d");K&&K.scale(fe,fe)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),y.useEffect(()=>{if(l==="idle"){const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const fe=Z.getBoundingClientRect(),ye=fe.width,K=fe.height;L.fillStyle="#2d3b35",L.fillRect(0,0,ye,K);const Ee=8,we="rgba(0, 0, 0, 0.4)",Ce=L.createLinearGradient(0,0,0,Ee);Ce.addColorStop(0,we),Ce.addColorStop(1,"transparent"),L.fillStyle=Ce,L.fillRect(0,0,ye,Ee);const Pe=L.createLinearGradient(0,K-Ee,0,K);Pe.addColorStop(0,"transparent"),Pe.addColorStop(1,we),L.fillStyle=Pe,L.fillRect(0,K-Ee,ye,Ee);const We=L.createLinearGradient(0,0,Ee,0);We.addColorStop(0,we),We.addColorStop(1,"transparent"),L.fillStyle=We,L.fillRect(0,0,Ee,K);const Se=L.createLinearGradient(ye-Ee,0,ye,0);Se.addColorStop(0,"transparent"),Se.addColorStop(1,we),L.fillStyle=Se,L.fillRect(ye-Ee,0,Ee,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(ye,K/2),L.stroke();const De=ye/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(De,0),L.lineTo(De,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",De,K-6)}},[l]);const He=y.useCallback(Z=>{T(L=>[...L,Z]),R(L=>({...L,total:L.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||N.length===0||!t)return;C.current=!0;const L=N[0];try{const fe=await t(L);fe&&n&&n(fe)}catch(fe){console.error("Transcription failed:",fe)}finally{T(fe=>fe.slice(1)),R(fe=>({...fe,completed:fe.completed+1})),C.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{he.current=!1,Q.current&&clearInterval(Q.current),H.current&&cancelAnimationFrame(H.current),U.current&&U.current.getTracks().forEach(Z=>Z.stop()),W.current&&W.current.state!=="closed"&&W.current.close()},[]),y.useEffect(()=>{if(l==="editing"&&g){let Z;const L=()=>{const fe=ne.current;if(fe&&g){const ye=F.current;if(ye){const K=ye.getContext("2d");if(K){const Ee=ye.getBoundingClientRect(),we=Ee.width,Ce=Ee.height,Pe=pe.current,We=f||c||1,Se=fe.currentTime;K.fillStyle="#2d3b35",K.fillRect(0,0,we,Ce);const De=8,et="rgba(0, 0, 0, 0.4)",st=K.createLinearGradient(0,0,0,De);st.addColorStop(0,et),st.addColorStop(1,"transparent"),K.fillStyle=st,K.fillRect(0,0,we,De);const Ve=K.createLinearGradient(0,Ce-De,0,Ce);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,et),K.fillStyle=Ve,K.fillRect(0,Ce-De,we,De);const ze=K.createLinearGradient(0,0,De,0);ze.addColorStop(0,et),ze.addColorStop(1,"transparent"),K.fillStyle=ze,K.fillRect(0,0,De,Ce);const ct=K.createLinearGradient(we-De,0,we,0);ct.addColorStop(0,"transparent"),ct.addColorStop(1,et),K.fillStyle=ct,K.fillRect(we-De,0,De,Ce),K.strokeStyle="#5a6b62",K.lineWidth=1,K.beginPath(),K.moveTo(0,Ce/2),K.lineTo(we,Ce/2),K.stroke();const dt=we/2,At=3,Zt=4,jt=We>0?Se/We*Pe.length:0;for(let te=0;te<Pe.length;te++){const xe=jt-te,je=dt-xe*Zt;if(je<-At||je>we)continue;const Oe=Pe[te]*(Ce/2-12),Ne=Ce/2-Oe;K.fillStyle=te<=jt?"#10b981":"#4b5563",K.fillRect(je,Ne,At,Oe*2)}K.strokeStyle="#ef4444",K.lineWidth=1,K.beginPath(),K.moveTo(dt,0),K.lineTo(dt,Ce),K.stroke(),K.fillStyle="#fff",K.font="bold 18px monospace",K.textAlign="center";const A=Math.floor(Se/60),$=Math.floor(Se%60);K.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,dt,Ce-6),K.textAlign="left"}}Z=requestAnimationFrame(L)}};return Z=requestAnimationFrame(L),()=>cancelAnimationFrame(Z)}},[l,g,f,c]),y.useEffect(()=>{l==="editing"&&!g&&Le()},[l,x,g,Le]),b)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:b}),h.jsx("button",{onClick:()=>{_(null),P()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Je={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Xe={...Je,opacity:.3,cursor:"not-allowed"},Bt=a?{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(l==="editing"){Ae.current=!0,ve.current=Z.clientX,Me.current=x;const L=ye=>{Ae.current&&ue(ye.clientX)},fe=()=>{Ae.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",fe)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",fe)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:a?"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:ce,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Xe:Je,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(l==="recording"){const Z=O.current;Z&&(Z.state==="recording"?(Z.pause(),D(!0)):Z.state==="paused"&&(Z.resume(),D(!1)))}else yt()},disabled:l==="idle",style:l==="idle"?Xe:Je,title:g||l==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||l==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ue,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Xe:Je,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"?X():l==="idle"?(w("insert"),P()):l==="editing"&&(w("insert"),xt("insert"))},disabled:l==="recording"&&k!=="insert"||g,style:l==="recording"&&k!=="insert"||g?Xe:Je,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:()=>{j.current||(k==="mic"?X():l==="idle"?(w("mic"),P()):l==="editing"&&(w("mic"),xt("replace")))},onMouseDown:()=>{j.current&&l==="idle"&&!g&&(w("mic"),P())},onMouseUp:()=>{j.current&&l==="recording"&&k==="mic"&&X()},onMouseLeave:()=>{j.current&&l==="recording"&&k==="mic"&&X()},onTouchStart:Z=>{Z.preventDefault(),j.current&&l==="idle"&&!g&&(w("mic"),P())},onTouchEnd:Z=>{Z.preventDefault(),j.current&&l==="recording"&&k==="mic"&&X()},disabled:l==="recording"&&k!=="mic"||g,style:l==="recording"&&k!=="mic"||g?Xe:Je,title:E?"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"?X():l==="editing"&&(w("startover"),ae())},disabled:l==="idle"||l==="recording"&&k!=="startover"||g,style:l==="idle"||l==="recording"&&k!=="startover"||g?Xe:Je,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:[B.total>0&&B.completed<B.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"}),B.completed,"/",B.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(!E),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:E?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:E?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:E?"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:()=>{l==="editing"&&de.current&&He(de.current)},disabled:l!=="editing",style:l!=="editing"?Xe:Je,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:ge,disabled:l!=="editing",style:l!=="editing"?Xe:Je,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),B.total>0&&B.completed<B.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${B.completed/B.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:a="",rows:l,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:v,voice:b="coral",onVoiceChange:_,generateButton:S,generatePrompt:D,generateSourceText:k,generateSourceError:w}){const[E,M]=y.useState(!1),[N,T]=y.useState(null),[B,R]=y.useState(!1),[C,j]=y.useState(""),[F,O]=y.useState(!1),[U,W]=y.useState(!1),[re,q]=y.useState(null),[Q,H]=y.useState(g||b),[ne,de]=y.useState(p),[he,pe]=y.useState(Date.now()),ke=y.useRef(null),me=y.useRef(null),J=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&de(p)},[p]),y.useEffect(()=>{g!==void 0&&H(g)},[g]);const be=J&&ne&&c&&d?`${c.getFileUrl(d,ne)}?v=${he}`:v,se=V=>{t(e?`${e}
183
+ `})]})}const Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Mg,...d},[g,m]=y.useState(!1),[x,v]=y.useState(""),b=y.useRef(null),_=y.useRef(null);y.useEffect(()=>{function T(B){b.current&&!b.current.contains(B.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase())===x.toLowerCase()}),k=e.map(T=>r.find(B=>B.id===T)).filter(Boolean),w=y.useCallback(T=>{var B;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(B=_.current)==null||B.focus())},[e,t,c]),E=y.useCallback(T=>{t(e.filter(B=>B!==T))},[e,t]),M=y.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&w(T.id),v("")},[D,x,i,w]),N=y.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?M():S.length>0&&w(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,M,w,E]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[l&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),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:B=>{B.stopPropagation(),E(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:N,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&&!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:[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:B=>{B.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:[T.label,o&&a&&h.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),a(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:B=>{B.currentTarget.style.opacity="1",B.currentTarget.style.color="#ef4444"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.5",B.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:M,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 Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),v=y.useMemo(()=>e&&r.find(E=>E.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const E=d.toLowerCase();return r.filter(M=>{var N,T;return((N=M.label)==null?void 0:N.toLowerCase().includes(E))||((T=M.notes)==null?void 0:T.toLowerCase().includes(E))})},[r,d]);y.useEffect(()=>{const E=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const _=E=>{s&&s(E),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},k=E=>{f(E.target.value),p||g(!0)},w=E=>{E.key==="Enter"?(E.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):E.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${l}`,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:E=>{E.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:D,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:E=>{E.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:E=>{E.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 a=="number"?`${a}px`:a,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:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((E,M)=>h.jsxs("div",{onClick:()=>_(E),style:{padding:"10px 14px",cursor:"pointer",borderBottom:M<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:E.color||c.text,marginBottom:E.notes?"2px":0},children:E.label}),E.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.notes})]},E.id))})]})}function Pg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=y.useState(null),[x,v]=y.useState(null),[b,_]=y.useState(null),S=y.useRef(null),D=e.reduce((B,R)=>{let C=r.filter(j=>n(j)===R.id);return s&&(C=C.sort((j,F)=>s(j)-s(F))),B[R.id]=C,B},{}),k=y.useCallback((B,R)=>{const C=t(R),j=n(R);m(C),S.current=j,B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const F=B.target;F.style.opacity="0.5"})},[t,n]),w=y.useCallback(B=>{const R=B.target;R.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),E=y.useCallback((B,R,C)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",v(R),_(C)},[]),M=y.useCallback(B=>{const R=B.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(v(null),_(null))},[]),N=y.useCallback((B,R,C)=>{if(B.preventDefault(),!g)return;const j=S.current;j===R?a==null||a(g,R,C):j&&o(g,j,R,C),m(null),v(null),_(null),S.current=null},[g,o,a]),T=(B,R)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[B.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:B.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:B.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(B=>{const R=D[B.id]||[],C=x===B.id;return h.jsxs("div",{"data-kanban-column":B.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:j=>{j.preventDefault(),g&&!C&&v(B.id)},onDragLeave:M,onDrop:j=>N(j,B.id,b??R.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(B,R.length):T(B,R.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:[R.map((j,F)=>{const I=t(j),W=g===I,q=C&&b===F&&!W;return h.jsxs("div",{children:[q&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:ne=>k(ne,j),onDragEnd:w,onDragOver:ne=>E(ne,B.id,F),onClick:()=>l==null?void 0:l(j),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(j,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:j=>{j.preventDefault(),E(j,B.id,R.length)},children:C&&b===R.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.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(B)})]},B.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function zg(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[a&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=Og(r),i=zg(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:l})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Ug,...g},{allDayItems:x,timedItems:v}=y.useMemo(()=>{const w=[],E=[];for(const M of r)a(M)?w.push(M):E.push(M);return{allDayItems:w,timedItems:E}},[r,a]),b=y.useMemo(()=>{const w=[];for(let E=t;E<=n;E++)w.push(E);return w},[t,n]),_=(n-t+1)*s,S=y.useCallback(w=>{const E=i(w);if(!E)return null;const M=Wg(E);if(!M)return null;const{hours:N,minutes:T}=M,B=Math.max(t,Math.min(n,N)),R=N<t?0:T,C=(B-t)*s+R/60*s,j=o(w),F=Math.max(20,j/60*s);return{top:C,height:F}},[i,o,t,n,s]),D=y.useMemo(()=>{if(!f||!Vg(e))return null;const w=new Date,E=w.getHours(),M=w.getMinutes();return E<t||E>n?null:(E-t)*s+M/60*s},[e,f,t,n,s]),k=y.useCallback(w=>{if(!d)return;const E=w.currentTarget.getBoundingClientRect(),N=(w.clientY-E.top)/s*60,T=Math.floor(N/60)+t,B=Math.round(N%60/15)*15,R=Math.min(n,Math.max(t,T)),C=B>=60?0:B,j=`${R.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(j)},[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)},l(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[b.map((w,E)=>h.jsxs("div",{style:{position:"absolute",top:E*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:Hg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<b.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}),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}})]}),v.map(w=>{const E=S(w);return E?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:M=>{M.stopPropagation(),c==null||c(w)},children:u(w)},l(w)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const a=s==="widget",[l,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(0),[b,_]=y.useState(null),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState(!0),[N,T]=y.useState([]),[B,R]=y.useState({completed:0,total:0}),C=y.useRef(!1),j=y.useRef(!0);y.useEffect(()=>{j.current=E},[E]);const F=y.useRef(null),I=y.useRef(null),W=y.useRef(null),q=y.useRef(null),ne=y.useRef(null),U=y.useRef([]),Q=y.useRef(null),H=y.useRef(null),ie=y.useRef(null),ue=y.useRef(null),he=y.useRef(!1),ge=y.useRef([]),we=y.useRef(null),xe=y.useRef(null),Z=y.useRef([]),be=y.useRef([]),te=y.useRef("insert"),Ae=y.useRef(!1),_e=y.useRef(0),ve=y.useRef(0),Re=y.useRef(0),Le=J=>{const L=Math.floor(J/60),fe=Math.floor(J%60);return`${L.toString().padStart(2,"0")}:${fe.toString().padStart(2,"0")}`},qe=async J=>{const L=await J.arrayBuffer(),fe=new AudioContext,me=await fe.decodeAudioData(L);return await fe.close(),me},V=J=>{const L=J.numberOfChannels,fe=J.sampleRate,me=1,K=16,De=K/8,Se=L*De,ke=fe*Se,Pe=J.length*Se,He=new ArrayBuffer(44+Pe),Ee=new DataView(He),Te=(Ge,ze)=>{for(let ft=0;ft<ze.length;ft++)Ee.setUint8(Ge+ft,ze.charCodeAt(ft))};Te(0,"RIFF"),Ee.setUint32(4,36+Pe,!0),Te(8,"WAVE"),Te(12,"fmt "),Ee.setUint32(16,16,!0),Ee.setUint16(20,me,!0),Ee.setUint16(22,L,!0),Ee.setUint32(24,fe,!0),Ee.setUint32(28,ke,!0),Ee.setUint16(32,Se,!0),Ee.setUint16(34,K,!0),Te(36,"data"),Ee.setUint32(40,Pe,!0);const tt=[];for(let Ge=0;Ge<L;Ge++)tt.push(J.getChannelData(Ge));let it=44;for(let Ge=0;Ge<J.length;Ge++)for(let ze=0;ze<L;ze++){const ft=Math.max(-1,Math.min(1,tt[ze][Ge])),ht=ft<0?ft*32768:ft*32767;Ee.setInt16(it,ht,!0),it+=2}return new Blob([He],{type:"audio/wav"})},O=async(J,L,fe,me)=>{const K=new AudioContext,De=J.sampleRate,Se=Math.max(J.numberOfChannels,L.numberOfChannels),ke=Math.min(fe,J.length),Pe=Math.max(0,J.length-fe),He=me==="insert"?ke+L.length+Pe:ke+L.length,Ee=K.createBuffer(Se,He,De);for(let Te=0;Te<Se;Te++){const tt=Ee.getChannelData(Te),it=Te<J.numberOfChannels?J.getChannelData(Te):J.getChannelData(0);for(let ze=0;ze<ke;ze++)tt[ze]=it[ze];const Ge=Te<L.numberOfChannels?L.getChannelData(Te):L.getChannelData(0);for(let ze=0;ze<L.length;ze++)tt[ke+ze]=Ge[ze];if(me==="insert")for(let ze=0;ze<Pe;ze++)tt[ke+L.length+ze]=it[fe+ze]}return await K.close(),Ee},Ue=y.useCallback(()=>{const J=F.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const fe=J.getBoundingClientRect(),me=fe.width,K=fe.height,De=ge.current,Se=f||c||1,ke=l==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,me,K);const Pe=8,He="rgba(0, 0, 0, 0.4)",Ee=L.createLinearGradient(0,0,0,Pe);Ee.addColorStop(0,He),Ee.addColorStop(1,"transparent"),L.fillStyle=Ee,L.fillRect(0,0,me,Pe);const Te=L.createLinearGradient(0,K-Pe,0,K);Te.addColorStop(0,"transparent"),Te.addColorStop(1,He),L.fillStyle=Te,L.fillRect(0,K-Pe,me,Pe);const tt=L.createLinearGradient(0,0,Pe,0);tt.addColorStop(0,He),tt.addColorStop(1,"transparent"),L.fillStyle=tt,L.fillRect(0,0,Pe,K);const it=L.createLinearGradient(me-Pe,0,me,0);it.addColorStop(0,"transparent"),it.addColorStop(1,He),L.fillStyle=it,L.fillRect(me-Pe,0,Pe,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(me,K/2),L.stroke();const Ge=me/2;if(De.length>0)if(l==="recording")for(let ht=0;ht<De.length;ht++){const At=De.length-1-ht,Zt=Ge-At*4;if(Zt<-3||Zt>me)continue;const jt=De[ht]*(K/2-12),A=K/2-jt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,jt*2)}else{const ht=Se>0?ke/Se*De.length:0;for(let At=0;At<De.length;At++){const Zt=ht-At,jt=Ge-Zt*4;if(jt<-3||jt>me)continue;const A=De[At]*(K/2-12),$=K/2-A;L.fillStyle=At<=ht?"#10b981":"#4b5563",L.fillRect(jt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ge,0),L.lineTo(Ge,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(ke),Ge,K-6),l==="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"},[l,x,c,f]),se=()=>{const J=ne.current;if(!J||!he.current)return;const L=J.frequencyBinCount,fe=new Uint8Array(L);J.getByteTimeDomainData(fe);let me=0;for(let Se=0;Se<L;Se++){const ke=(fe[Se]-128)/128;me+=ke*ke}const K=Math.sqrt(me/L),De=Math.min(1,K*3);ge.current.push(De),Ue(),he.current&&(H.current=requestAnimationFrame(se))},re=async()=>{try{_(null),D(!1),we.current===null&&(ge.current=[]);const J=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=J;const L=new AudioContext;q.current=L;const fe=L.createAnalyser();fe.fftSize=2048,ne.current=fe,L.createMediaStreamSource(J).connect(fe);const K=new MediaRecorder(J);I.current=K,U.current=[],K.ondataavailable=De=>{De.data.size>0&&U.current.push(De.data)},K.onstop=async()=>{try{if(he.current=!1,U.current.length===0){_("No audio was recorded. Please try again."),u("idle"),J.getTracks().forEach(Ee=>Ee.stop());return}const De=new Blob(U.current,{type:"audio/webm"});let Se,ke;if(we.current!==null&&xe.current)try{const Ee=await qe(De),Te=xe.current.sampleRate,tt=Math.floor(we.current*Te),it=await O(xe.current,Ee,tt,te.current);Se=V(it),ke=it.length/it.sampleRate,te.current==="insert"&&(ge.current=[...ge.current,...be.current]),we.current=null,xe.current=null,Z.current=[],be.current=[]}catch{Se=De,ke=_e.current>0?_e.current:1}else Se=De,ke=_e.current>0?_e.current:1;if(ue.current=Se,J.getTracks().forEach(Ee=>Ee.stop()),j.current&&t){T(Ee=>[...Ee,Se]),R(Ee=>({...Ee,total:Ee.total+1})),ue.current=null,ge.current=[],v(0),p(0),d(0),u("idle");return}const Pe=URL.createObjectURL(Se),He=new Audio(Pe);He.ontimeupdate=()=>{v(He.currentTime)},He.onended=()=>{m(!1)},ie.current=He,p(ke),v(ke),u("editing")}catch{_("Failed to process recording"),u("idle")}},K.start(100),he.current=!0,u("recording"),d(0),_e.current=0,Q.current=setInterval(()=>{_e.current+=1,d(_e.current),_e.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),he.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.")}},oe=()=>{he.current=!1,D(!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()},z=J=>{const L=F.current;if(!L)return;const fe=f||c;if(fe<=0)return;const me=ge.current;if(me.length===0)return;const K=L.getBoundingClientRect(),De=J-ve.current,Se=4,ke=K.width/L.width,Pe=me.length/fe*Se,He=-De/(Pe*ke),Ee=Re.current+He,Te=Math.max(0,Math.min(Ee,fe));ie.current&&(ie.current.currentTime=Te),v(Te)},de=()=>{ie.current&&(ie.current.currentTime=0),v(0)},Ce=()=>{const J=f||c;ie.current&&(ie.current.currentTime=J),v(J)},We=()=>{const J=ie.current;J&&(g?(J.pause(),v(J.currentTime),m(!1)):(J.currentTime=x,J.play().catch(()=>{}),m(!0)))},dt=async J=>{if(!ue.current){re();return}try{ie.current&&(ie.current.pause(),m(!1)),te.current=J,xe.current=await qe(ue.current);const L=f||c;we.current=x;const fe=L>0?x/L:0,me=Math.floor(fe*ge.current.length);Z.current=ge.current.slice(0,me),be.current=ge.current.slice(me),ge.current=[...Z.current],re()}catch{_("Failed to prepare recording. Please try again.")}},le=()=>{ie.current&&(ie.current.pause(),ie.current=null),ue.current=null,xe.current=null,we.current=null,Z.current=[],m(!1),v(0),p(0),d(0),re()},pe=()=>{ue.current?r(ue.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{l==="recording"&&F.current&&ne.current&&he.current&&(H.current=requestAnimationFrame(se))},[l]),y.useEffect(()=>{const J=F.current;if(!J)return;const L=()=>{const fe=window.devicePixelRatio||1,me=J.getBoundingClientRect();J.width=me.width*fe,J.height=me.height*fe;const K=J.getContext("2d");K&&K.scale(fe,fe)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),y.useEffect(()=>{if(l==="idle"){const J=F.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const fe=J.getBoundingClientRect(),me=fe.width,K=fe.height;L.fillStyle="#2d3b35",L.fillRect(0,0,me,K);const De=8,Se="rgba(0, 0, 0, 0.4)",ke=L.createLinearGradient(0,0,0,De);ke.addColorStop(0,Se),ke.addColorStop(1,"transparent"),L.fillStyle=ke,L.fillRect(0,0,me,De);const Pe=L.createLinearGradient(0,K-De,0,K);Pe.addColorStop(0,"transparent"),Pe.addColorStop(1,Se),L.fillStyle=Pe,L.fillRect(0,K-De,me,De);const He=L.createLinearGradient(0,0,De,0);He.addColorStop(0,Se),He.addColorStop(1,"transparent"),L.fillStyle=He,L.fillRect(0,0,De,K);const Ee=L.createLinearGradient(me-De,0,me,0);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,Se),L.fillStyle=Ee,L.fillRect(me-De,0,De,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(me,K/2),L.stroke();const Te=me/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Te,0),L.lineTo(Te,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Te,K-6)}},[l]);const Ve=y.useCallback(J=>{T(L=>[...L,J]),R(L=>({...L,total:L.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||N.length===0||!t)return;C.current=!0;const L=N[0];try{const fe=await t(L);fe&&n&&n(fe)}catch(fe){console.error("Transcription failed:",fe)}finally{T(fe=>fe.slice(1)),R(fe=>({...fe,completed:fe.completed+1})),C.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{he.current=!1,Q.current&&clearInterval(Q.current),H.current&&cancelAnimationFrame(H.current),W.current&&W.current.getTracks().forEach(J=>J.stop()),q.current&&q.current.state!=="closed"&&q.current.close()},[]),y.useEffect(()=>{if(l==="editing"&&g){let J;const L=()=>{const fe=ie.current;if(fe&&g){const me=F.current;if(me){const K=me.getContext("2d");if(K){const De=me.getBoundingClientRect(),Se=De.width,ke=De.height,Pe=ge.current,He=f||c||1,Ee=fe.currentTime;K.fillStyle="#2d3b35",K.fillRect(0,0,Se,ke);const Te=8,tt="rgba(0, 0, 0, 0.4)",it=K.createLinearGradient(0,0,0,Te);it.addColorStop(0,tt),it.addColorStop(1,"transparent"),K.fillStyle=it,K.fillRect(0,0,Se,Te);const Ge=K.createLinearGradient(0,ke-Te,0,ke);Ge.addColorStop(0,"transparent"),Ge.addColorStop(1,tt),K.fillStyle=Ge,K.fillRect(0,ke-Te,Se,Te);const ze=K.createLinearGradient(0,0,Te,0);ze.addColorStop(0,tt),ze.addColorStop(1,"transparent"),K.fillStyle=ze,K.fillRect(0,0,Te,ke);const ft=K.createLinearGradient(Se-Te,0,Se,0);ft.addColorStop(0,"transparent"),ft.addColorStop(1,tt),K.fillStyle=ft,K.fillRect(Se-Te,0,Te,ke),K.strokeStyle="#5a6b62",K.lineWidth=1,K.beginPath(),K.moveTo(0,ke/2),K.lineTo(Se,ke/2),K.stroke();const ht=Se/2,At=3,Zt=4,jt=He>0?Ee/He*Pe.length:0;for(let ee=0;ee<Pe.length;ee++){const ye=jt-ee,Me=ht-ye*Zt;if(Me<-At||Me>Se)continue;const Oe=Pe[ee]*(ke/2-12),Be=ke/2-Oe;K.fillStyle=ee<=jt?"#10b981":"#4b5563",K.fillRect(Me,Be,At,Oe*2)}K.strokeStyle="#ef4444",K.lineWidth=1,K.beginPath(),K.moveTo(ht,0),K.lineTo(ht,ke),K.stroke(),K.fillStyle="#fff",K.font="bold 18px monospace",K.textAlign="center";const A=Math.floor(Ee/60),$=Math.floor(Ee%60);K.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,ht,ke-6),K.textAlign="left"}}J=requestAnimationFrame(L)}};return J=requestAnimationFrame(L),()=>cancelAnimationFrame(J)}},[l,g,f,c]),y.useEffect(()=>{l==="editing"&&!g&&Ue()},[l,x,g,Ue]),b)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:b}),h.jsx("button",{onClick:()=>{_(null),re()},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"},Ze={...Xe,opacity:.3,cursor:"not-allowed"},Bt=a?{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:J=>{if(l==="editing"){Ae.current=!0,ve.current=J.clientX,Re.current=x;const L=me=>{Ae.current&&z(me.clientX)},fe=()=>{Ae.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",fe)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",fe)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:a?"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:de,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Ze: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(l==="recording"){const J=I.current;J&&(J.state==="recording"?(J.pause(),D(!0)):J.state==="paused"&&(J.resume(),D(!1)))}else We()},disabled:l==="idle",style:l==="idle"?Ze:Xe,title:g||l==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||l==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ce,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Ze: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"?oe():l==="idle"?(w("insert"),re()):l==="editing"&&(w("insert"),dt("insert"))},disabled:l==="recording"&&k!=="insert"||g,style:l==="recording"&&k!=="insert"||g?Ze: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:()=>{j.current||(k==="mic"?oe():l==="idle"?(w("mic"),re()):l==="editing"&&(w("mic"),dt("replace")))},onMouseDown:()=>{j.current&&l==="idle"&&!g&&(w("mic"),re())},onMouseUp:()=>{j.current&&l==="recording"&&k==="mic"&&oe()},onMouseLeave:()=>{j.current&&l==="recording"&&k==="mic"&&oe()},onTouchStart:J=>{J.preventDefault(),j.current&&l==="idle"&&!g&&(w("mic"),re())},onTouchEnd:J=>{J.preventDefault(),j.current&&l==="recording"&&k==="mic"&&oe()},disabled:l==="recording"&&k!=="mic"||g,style:l==="recording"&&k!=="mic"||g?Ze:Xe,title:E?"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"?oe():l==="editing"&&(w("startover"),le())},disabled:l==="idle"||l==="recording"&&k!=="startover"||g,style:l==="idle"||l==="recording"&&k!=="startover"||g?Ze: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:[B.total>0&&B.completed<B.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"}),B.completed,"/",B.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(!E),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:E?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:E?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:E?"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:()=>{l==="editing"&&ue.current&&Ve(ue.current)},disabled:l!=="editing",style:l!=="editing"?Ze:Xe,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:pe,disabled:l!=="editing",style:l!=="editing"?Ze:Xe,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),B.total>0&&B.completed<B.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${B.completed/B.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:a="",rows:l,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:v,voice:b="coral",onVoiceChange:_,generateButton:S,generatePrompt:D,generateSourceText:k,generateSourceError:w}){const[E,M]=y.useState(!1),[N,T]=y.useState(null),[B,R]=y.useState(!1),[C,j]=y.useState(""),[F,I]=y.useState(!1),[W,q]=y.useState(!1),[ne,U]=y.useState(null),[Q,H]=y.useState(g||b),[ie,ue]=y.useState(p),[he,ge]=y.useState(Date.now()),we=y.useRef(null),xe=y.useRef(null),Z=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&ue(p)},[p]),y.useEffect(()=>{g!==void 0&&H(g)},[g]);const be=Z&&ie&&c&&d?`${c.getFileUrl(d,ie)}?v=${he}`:v,te=V=>{t(e?`${e}
184
184
 
185
- ${V}`:V)},Ae=async V=>{if(!(!(typeof e=="string"?e:"").trim()||E||!s)){M(!0),T(V),R(!1);try{const z=await s(V,e);t(z)}catch(z){console.error(`${V} failed:`,z)}finally{M(!1),T(null)}}},_e=()=>{setTimeout(()=>{var V;(V=ke.current)!=null&&V.contains(document.activeElement)||R(!1)},150)},ve=async()=>{if(!(!C.trim()||E||!i)){M(!0),T(C);try{const V=await i(C,e);t(V),j("")}catch(V){console.error("AI prompt failed:",V)}finally{M(!1),T(null)}}},Me=async()=>{if(!(typeof e=="string"?e:"").trim()||F)return;if(!(J||x)){console.warn("TTS: No generation mode available",{integratedTTS:J,hasCallback:!!x,llmClient:!!u,graphClient:!!c,nodeId:d,audioFilename:f}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}me.current&&(me.current.pause(),me.current.currentTime=0),O(!0);try{if(J&&u&&c&&d&&f){console.log("TTS: Generating audio...",{voice:Q,textLength:e.length});const z=await u.tts(e,{voice:Q});console.log("TTS: Audio generated, uploading...",{audioLength:z==null?void 0:z.length});const Le=atob(z),ie=new Uint8Array(Le.length);for(let ue=0;ue<Le.length;ue++)ie[ue]=Le.charCodeAt(ue);const P=new Blob([ie],{type:"audio/mpeg"}),X=new File([P],f,{type:"audio/mpeg"});await c.uploadFile(d,f,X),console.log("TTS: Upload complete",{nodeId:d,audioFilename:f}),pe(Date.now()),de(f),m==null||m(f,Q)}else x&&(await x(e,Q),pe(Date.now()))}catch(z){console.error("TTS generation failed:",z),alert("Erreur TTS: "+(z instanceof Error?z.message:"Erreur inconnue"))}finally{O(!1)}},Fe=async()=>{if(!(!u||!D||U)){if(!(k!=null&&k.trim())){q(w||"Le texte source est requis pour la génération.");return}W(!0),q(null);try{const V=await u.chat([{role:"system",content:D},{role:"user",content:k}]);t(V)}catch(V){q(V instanceof Error?V.message:"Erreur de génération")}finally{W(!1)}}},qe=V=>{H(V),_==null||_(V)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[h.jsx(Xc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:se,hideSaveButton:!0,variant:"div"}),i&&h.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[h.jsx("textarea",{value:C,onChange:V=>j(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Enter"&&V.ctrlKey&&(V.preventDefault(),ve())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:E,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),h.jsx("button",{type:"button",onClick:ve,disabled:E||!C.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:E?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||J||x||S)&&h.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[r&&h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),S&&u&&D&&h.jsxs("button",{type:"button",onClick:Fe,disabled:U,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:S.label,children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:U?"hourglass_empty":S.icon||"auto_awesome"}),S.label]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?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"})}),(J||x)&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("select",{value:Q,onChange:V=>qe(V.target.value),disabled:F,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(V=>h.jsxs("option",{value:V.id,children:[V.name," - ",V.description]},V.id))}),h.jsx("button",{type:"button",onClick:Me,disabled:F||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:F?"Génération en cours...":"Générer audio TTS",children:h.jsx("span",{className:`material-icons ${F?"animate-pulse text-blue-600":be?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:F?"hourglass_empty":"record_voice_over"})}),be&&h.jsxs(h.Fragment,{children:[h.jsx("audio",{ref:me,src:be,controls:!0,className:"h-6 w-32"},he),h.jsx("button",{type:"button",onClick:()=>{me.current&&me.current.pause(),de(void 0),m==null||m("",Q)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:h.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&h.jsxs("div",{className:"relative",ref:ke,children:[h.jsx("button",{type:"button",onClick:()=>R(!B),disabled:E||!(typeof e=="string"?e:"").trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:E?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),N==="restructure"&&"Restructuring...",N==="proofread"&&"Proofreading...",N==="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"})]})}),B&&!E&&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:_e,children:[h.jsxs("button",{type:"button",onClick:()=>Ae("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:()=>Ae("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:()=>Ae("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:V=>t(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:o,rows:l,disabled:E||U,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),re&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),h.jsx("p",{className:"text-sm text-neutral-600",children:re})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx("button",{type:"button",onClick:()=>q(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Yg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[f,p]=y.useState(null),[g,m]=y.useState(n),[x,v]=y.useState(0),[b,_]=y.useState({x:0,y:0,width:100,height:100}),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState({x:0,y:0}),[N,T]=y.useState({x:0,y:0,width:100,height:100}),B=o==="dark",R=y.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=y.useCallback((J,be)=>{const se=J/be,Ae=.05;for(const[_e,ve]of Object.entries(gs))if(ve!==null&&Math.abs(se-ve)/ve<Ae)return _e;return"free"},[]);y.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const be=C(J.width,J.height);m(be),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,C]);const j=y.useCallback(()=>{const{width:J,height:be}=R(),se=gs[g];if(se===null){_({x:0,y:0,width:100,height:100});return}const Ae=J/be;let _e,ve;Ae>se?(ve=100,_e=se/Ae*100):(_e=100,ve=Ae/se*100);const Me=(100-_e)/2,Fe=(100-ve)/2;_({x:Me,y:Fe,width:_e,height:ve})},[g,R]);y.useEffect(()=>{u.current&&j()},[g,x,j]),y.useEffect(()=>{const J=l.current,be=u.current;if(!J||!be||c)return;const se=J.getContext("2d");if(!se)return;const Ae=a.current;if(!Ae)return;const _e=Ae.clientWidth,ve=Ae.clientHeight-140,{width:Me,height:Fe}=R(),qe=Me/Fe;let V,z;_e/ve>qe?(z=Math.min(ve,Fe),V=z*qe):(V=Math.min(_e,Me),z=V/qe),V>_e&&(V=_e,z=V/qe),z>ve&&(z=ve,V=z*qe),J.width=V,J.height=z,se.clearRect(0,0,V,z),se.save(),se.translate(V/2,z/2),se.rotate(x*Math.PI/180);let Le,ie;x===90||x===270?(Le=z,ie=V):(Le=V,ie=z),se.drawImage(be,-Le/2,-ie/2,Le,ie),se.restore(),se.fillStyle="rgba(0, 0, 0, 0.6)";const P=b.x/100*V,X=b.y/100*z,ue=b.width/100*V,ce=b.height/100*z;se.fillRect(0,0,V,X),se.fillRect(0,X+ce,V,z-X-ce),se.fillRect(0,X,P,ce),se.fillRect(P+ue,X,V-P-ue,ce),se.strokeStyle="#fff",se.lineWidth=2,se.strokeRect(P,X,ue,ce),se.strokeStyle="rgba(255, 255, 255, 0.3)",se.lineWidth=1,se.beginPath(),se.moveTo(P+ue/3,X),se.lineTo(P+ue/3,X+ce),se.moveTo(P+ue*2/3,X),se.lineTo(P+ue*2/3,X+ce),se.moveTo(P,X+ce/3),se.lineTo(P+ue,X+ce/3),se.moveTo(P,X+ce*2/3),se.lineTo(P+ue,X+ce*2/3),se.stroke();const Ue=14;se.fillStyle="#fff",se.strokeStyle="#333",se.lineWidth=1,[{x:P,y:X},{x:P+ue,y:X},{x:P,y:X+ce},{x:P+ue,y:X+ce}].forEach(xt=>{se.fillRect(xt.x-Ue/2,xt.y-Ue/2,Ue,Ue),se.strokeRect(xt.x-Ue/2,xt.y-Ue/2,Ue,Ue)})},[b,x,c,R]);const F=J=>{const be=l.current;if(!be)return;const se=be.getBoundingClientRect(),Ae=(J.clientX-se.left)/se.width*100,_e=(J.clientY-se.top)/se.height*100,ve=4,Me=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Fe of Me)if(Math.abs(Ae-Fe.x)<ve&&Math.abs(_e-Fe.y)<ve){w(Fe.name),M({x:Ae,y:_e}),T({...b});return}Ae>=b.x&&Ae<=b.x+b.width&&_e>=b.y&&_e<=b.y+b.height&&(D(!0),M({x:Ae,y:_e}),T({...b}))},O=J=>{const be=l.current;if(!be)return;const se=be.getBoundingClientRect(),Ae=(J.clientX-se.left)/se.width*100,_e=(J.clientY-se.top)/se.height*100;if(S){const ve=Ae-E.x,Me=_e-E.y;let Fe=N.x+ve,qe=N.y+Me;Fe=Math.max(0,Math.min(Fe,100-N.width)),qe=Math.max(0,Math.min(qe,100-N.height)),_({...N,x:Fe,y:qe})}else if(k){const ve=gs[g],{width:Me,height:Fe}=R(),qe=Me/Fe,V=ve?ve/qe:null;let z={...N};const Le=Ae-E.x,ie=_e-E.y;if(k==="se")z.width=Math.max(10,Math.min(100-z.x,N.width+Le)),V?(z.height=z.width/V,z.y+z.height>100&&(z.height=100-z.y,z.width=z.height*V)):z.height=Math.max(10,Math.min(100-z.y,N.height+ie));else if(k==="sw"){const P=-Le,X=Math.max(10,N.width+P),ue=N.x+N.width-X;ue>=0&&(z.width=X,z.x=ue,V?(z.height=z.width/V,z.y+z.height>100&&(z.height=100-z.y,z.width=z.height*V,z.x=N.x+N.width-z.width)):z.height=Math.max(10,Math.min(100-z.y,N.height+ie)))}else if(k==="ne")if(z.width=Math.max(10,Math.min(100-z.x,N.width+Le)),V){const P=z.width/V,X=N.y+N.height-P;X>=0?(z.height=P,z.y=X):(z.y=0,z.height=N.y+N.height,z.width=z.height*V)}else{const P=-ie,X=Math.max(10,N.height+P),ue=N.y+N.height-X;ue>=0&&(z.height=X,z.y=ue)}else if(k==="nw"){const P=-Le,X=Math.max(10,N.width+P),ue=N.x+N.width-X;if(ue>=0)if(z.width=X,z.x=ue,V){const ce=z.width/V,Ue=N.y+N.height-ce;Ue>=0?(z.height=ce,z.y=Ue):(z.y=0,z.height=N.y+N.height,z.width=z.height*V,z.x=N.x+N.width-z.width)}else{const ce=-ie,Ue=Math.max(10,N.height+ce),yt=N.y+N.height-Ue;yt>=0&&(z.height=Ue,z.y=yt)}}z.x=Math.max(0,z.x),z.y=Math.max(0,z.y),z.width=Math.min(z.width,100-z.x),z.height=Math.min(z.height,100-z.y),_(z)}},U=()=>{D(!1),w(null)},W=J=>{v(be=>J==="right"?(be+90)%360:(be-90+360)%360)},re=()=>{const J=u.current;if(!J)return;const{width:be,height:se}=R(),Ae=b.x/100*be,_e=b.y/100*se,ve=b.width/100*be,Me=b.height/100*se,Fe=document.createElement("canvas"),qe=Fe.getContext("2d");if(!qe)return;Fe.width=ve,Fe.height=Me;const V=document.createElement("canvas"),z=V.getContext("2d");z&&(V.width=be,V.height=se,z.save(),z.translate(be/2,se/2),z.rotate(x*Math.PI/180),z.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),z.restore(),qe.drawImage(V,Ae,_e,ve,Me,0,0,ve,Me),Fe.toBlob(Le=>{Le&&e(Le)},s,i))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:B?"#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 ${B?"#333":"#ddd"}`,background:B?"#242424":"#fff",flexShrink:0},ne={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},de={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},he={...de,background:"#E67E22",color:"#fff"},pe={...de,background:B?"#333":"#e5e5e5",color:B?"#fff":"#333"},ke={padding:"10px",borderRadius:"8px",border:"none",background:B?"#333":"#e5e5e5",color:B?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},me=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":B?"#333":"#e5e5e5",color:J?"#fff":B?"#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:B?"#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:a,style:q,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:l,style:{cursor:S?"grabbing":k?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:O,onMouseUp:U,onMouseLeave:U})}),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:me(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:ne,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>W("left"),style:ke,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:()=>W("right"),style:ke,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:re,style:he,children:"Enregistrer"})]})]})]})]})}var Qg={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 Jg(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=Jg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Xg(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]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(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 Xg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Qg,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 zl={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)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function Zg(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 e0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Zc(r){var e=_i(r);return(e.local?e0:Zg)(e)}function t0(){}function ua(r){return r==null?t0:function(){return this.querySelector(r)}}function r0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Dt(n,this._parents)}function n0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function s0(){return[]}function ed(r){return r==null?s0:function(){return this.querySelectorAll(r)}}function i0(r){return function(){return n0(r.apply(this,arguments))}}function o0(r){typeof r=="function"?r=i0(r):r=ed(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Dt(n,s)}function td(r){return function(){return this.matches(r)}}function rd(r){return function(e){return e.matches(r)}}var a0=Array.prototype.find;function l0(r){return function(){return a0.call(this.children,r)}}function u0(){return this.firstElementChild}function c0(r){return this.select(r==null?u0:l0(typeof r=="function"?r:rd(r)))}var d0=Array.prototype.filter;function f0(){return Array.from(this.children)}function h0(r){return function(){return d0.call(this.children,r)}}function p0(r){return this.selectAll(r==null?f0:h0(typeof r=="function"?r:rd(r)))}function g0(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Dt(n,this._parents)}function nd(r){return new Array(r.length)}function m0(){return new Dt(this._enter||this._groups.map(nd),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 y0(r){return function(){return r}}function x0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function b0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(f[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(f[a])===l&&(s[a]=l)}function v0(r){return r.__data__}function _0(r,e){if(!arguments.length)return Array.from(this,v0);var t=e?b0:x0,n=this._parents,s=this._groups;typeof r!="function"&&(r=y0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=w0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),v=l[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,_=0,S,D;b<g;++b)if(S=m[b]){for(b>=_&&(_=b+1);!(D=x[_])&&++_<g;);S._next=D||null}}return o=new Dt(o,n),o._enter=a,o._exit=l,o}function w0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function C0(){return new Dt(this._exit||this._groups.map(nd),this._parents)}function S0(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 k0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,f=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;l<s;++l)a[l]=t[l];return new Dt(a,this._parents)}function E0(){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 D0(r){r||(r=A0);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],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Dt(s,this._parents).order()}function A0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function T0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function N0(){return Array.from(this)}function B0(){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 j0(){let r=0;for(const e of this)++r;return r}function M0(){return!this.node()}function R0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function F0(r){return function(){this.removeAttribute(r)}}function L0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function P0(r,e){return function(){this.setAttribute(r,e)}}function I0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function z0(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 $0(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?L0:F0:typeof e=="function"?t.local?z0:O0:t.local?I0:P0)(t,e))}function sd(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function q0(r){return function(){this.style.removeProperty(r)}}function U0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function W0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function H0(r,e,t){return arguments.length>1?this.each((e==null?q0:typeof e=="function"?W0:U0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||sd(r).getComputedStyle(r,null).getPropertyValue(e)}function V0(r){return function(){delete this[r]}}function G0(r,e){return function(){this[r]=e}}function K0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Y0(r,e){return arguments.length>1?this.each((e==null?V0:typeof e=="function"?K0:G0)(r,e)):this.node()[r]}function id(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new od(r)}function od(r){this._node=r,this._names=id(r.getAttribute("class")||"")}od.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 ad(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Q0(r){return function(){ad(this,r)}}function J0(r){return function(){ld(this,r)}}function X0(r,e){return function(){(e.apply(this,arguments)?ad:ld)(this,r)}}function Z0(r,e){var t=id(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"?X0:e?Q0:J0)(t,e))}function em(){this.textContent=""}function tm(r){return function(){this.textContent=r}}function rm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function nm(r){return arguments.length?this.each(r==null?em:(typeof r=="function"?rm:tm)(r)):this.node().textContent}function sm(){this.innerHTML=""}function im(r){return function(){this.innerHTML=r}}function om(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function am(r){return arguments.length?this.each(r==null?sm:(typeof r=="function"?om:im)(r)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function um(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function dm(){return this.each(cm)}function fm(r){var e=typeof r=="function"?r:Zc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function hm(){return null}function pm(r,e){var t=typeof r=="function"?r:Zc(r),n=e==null?hm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gm(){var r=this.parentNode;r&&r.removeChild(this)}function mm(){return this.each(gm)}function ym(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(r){return this.select(r?xm:ym)}function vm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function _m(r){return function(e){r.call(this,e,this.__data__)}}function wm(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 Cm(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 Sm(r,e,t){return function(){var n=this.__on,s,i=_m(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function km(r,e,t){var n=wm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?Sm:Cm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function ud(r,e,t){var n=sd(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 Em(r,e){return function(){return ud(this,r,e)}}function Dm(r,e){return function(){return ud(this,r,e.apply(this,arguments))}}function Am(r,e){return this.each((typeof e=="function"?Dm:Em)(r,e))}function*Tm(){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 cd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],cd)}function Nm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:r0,selectAll:o0,selectChild:c0,selectChildren:p0,filter:g0,data:_0,enter:m0,exit:C0,join:S0,merge:k0,selection:Nm,order:E0,sort:D0,call:T0,nodes:N0,node:B0,size:j0,empty:M0,each:R0,attr:$0,style:H0,property:Y0,classed:Z0,text:nm,html:am,raise:um,lower:dm,append:fm,insert:pm,remove:mm,clone:bm,datum:vm,on:km,dispatch:Am,[Symbol.iterator]:Tm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],cd)}function Bm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=Bm(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 jm(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 Mm(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 dd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Lm=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Pm=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),Im=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),zm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:$m,formatHsl:qm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function $m(){return this.rgb().formatHex8()}function qm(){return fd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Rm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(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=Fm.exec(r))?new wt(e[1],e[2],e[3],1):(e=Lm.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Pm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Im.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=zm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Wl(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 Um(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?Um(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,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,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),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Wm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Wm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function fd(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,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Pt(o,a,l,r.opacity)}function Hm(r,e,t,n){return arguments.length===1?fd(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,Hm,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,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(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const hd=r=>()=>r;function Vm(r,e){return function(t){return r+t*e}}function Gm(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 Km(r){return(r=+r)==1?pd:function(e,t){return t-e?Gm(e,t,r):hd(isNaN(e)?t:e)}}function pd(r,e){var t=e-r;return t?Vm(r,t):hd(isNaN(r)?e:r)}const Yl=function r(e){var t=Km(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=pd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function 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 Ym(r){return function(){return r}}function Qm(r){return function(e){return r(e)+""}}function Jm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Qm(l[0].x):Ym(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gd(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Xm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:gd(e.a,e.b,e.c,e.d,e.e,e.f)}function Zm(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,gd(r.a,r.b,r.c,r.d,r.e,r.f))}function md(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 a(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 l(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),a(u.skewX,c.skewX,d,f),l(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 e2=md(Xm,"px, ","px)","deg)"),t2=md(Zm,", ",")",")"),r2=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function n2(r){return((r=Math.exp(r))-1/r)/2}function s2(r){return((r=Math.exp(2*r))-1)/(r+1)}const i2=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-a,g=d-l,m=p*p+g*g,x,v;if(m<r2)v=Math.log(f/u)/e,x=function(w){return[a+w*p,l+w*g,u*Math.exp(e*w*v)]};else{var b=Math.sqrt(m),_=(f*f-u*u+n*m)/(2*u*t*b),S=(f*f-u*u-n*m)/(2*f*t*b),D=Math.log(Math.sqrt(_*_+1)-_),k=Math.log(Math.sqrt(S*S+1)-S);v=(k-D)/e,x=function(w){var E=w*v,M=Jl(D),N=u/(t*b)*(M*s2(e*E+D)-n2(D));return[a+N*p,l+N*g,u*M/Jl(e*E+D)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,yd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,xd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(xd(o2),Lr=Wn.now()+wi)}function o2(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=bd.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 bd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function a2(){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{a2()}finally{nn=0,u2(),Lr=0}}function l2(){var r=Wn.now(),e=r-ei;e>yd&&(wi-=e,ei=r)}function u2(){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(l2,yd)),nn=1,xd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var c2=la("start","end","cancel","interrupt"),d2=[],vd=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;f2(r,t,{name:e,index:n,group:s,on:c2,tween:d2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vd})}function ha(r,e){var t=qt(r,e);if(t.state>vd)throw new Error("too late; already scheduled");return t}function Xt(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 f2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=bd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return l();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(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 a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),l())}function l(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function h2(r){return this.each(function(){Es(this,r)})}function p2(r,e){var t,n;return function(){var s=Xt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function g2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function m2(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?p2:g2)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return qt(s,n).value[e]}}function _d(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Jm)(r,e)}function y2(r){return function(){this.removeAttribute(r)}}function x2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function b2(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 v2(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 _2(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function w2(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function C2(r,e){var t=_i(r),n=t==="transform"?t2:_d;return this.attrTween(r,typeof e=="function"?(t.local?w2:_2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?x2:y2)(t):(t.local?v2:b2)(t,n,e))}function S2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function k2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function E2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&k2(r,i)),t}return s._value=e,s}function D2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&S2(r,i)),t}return s._value=e,s}function A2(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?E2:D2)(n,e))}function T2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function N2(r,e){return e=+e,function(){ha(this,r).delay=e}}function B2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?T2:N2)(e,r)):qt(this.node(),e).delay}function j2(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function M2(r,e){return e=+e,function(){Xt(this,r).duration=e}}function R2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?j2:M2)(e,r)):qt(this.node(),e).duration}function F2(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function L2(r){var e=this._id;return arguments.length?this.each(F2(e,r)):qt(this.node(),e).ease}function P2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function I2(r){if(typeof r!="function")throw new Error;return this.each(P2(this._id,r))}function O2(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new ir(n,this._parents,this._name,this._id)}function z2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),f,p=0;p<c;++p)(f=l[p]||u[p])&&(d[p]=f);for(;a<n;++a)o[a]=e[a];return new ir(o,this._parents,this._name,this._id)}function $2(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 q2(r,e,t){var n,s,i=$2(e)?ha:Xt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function U2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(q2(t,r,e))}function W2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function H2(){return this.on("end.remove",W2(this._id))}function V2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,f=0;f<l;++f)(c=a[f])&&(d=r.call(c,c.__data__,f,a))&&("__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 G2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ed(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var f=r.call(c,c.__data__,d,l),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 K2=ss.prototype.constructor;function Y2(){return new K2(this._groups,this._parents)}function Q2(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 wd(r){return function(){this.style.removeProperty(r)}}function J2(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 X2(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function Z2(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Xt(this,r),u=l.on,c=l.value[i]==null?a||(a=wd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function ey(r,e,t){var n=(r+="")=="transform"?e2:_d;return e==null?this.styleTween(r,Q2(r,n)).on("end.style."+r,wd(r)):typeof e=="function"?this.styleTween(r,X2(r,n,pa(this,"style."+r,e))).each(Z2(this._id,r)):this.styleTween(r,J2(r,n,e),t).on("end.style."+r,null)}function ty(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function ry(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&ty(r,o,t)),n}return i._value=e,i}function ny(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,ry(r,e,t??""))}function sy(r){return function(){this.textContent=r}}function iy(r){return function(){var e=r(this);this.textContent=e??""}}function oy(r){return this.tween("text",typeof r=="function"?iy(pa(this,"text",r)):sy(r==null?"":r+""))}function ay(r){return function(e){this.textContent=r.call(this,e)}}function ly(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&ay(s)),e}return n._value=r,n}function uy(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,ly(r))}function cy(){for(var r=this._name,e=this._id,t=Cd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=qt(l,e);Ci(l,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function dy(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={value:function(){--s===0&&i()}};t.each(function(){var u=Xt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var fy=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Cd(){return++fy}var tr=ss.prototype;ir.prototype={constructor:ir,select:V2,selectAll:G2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:O2,merge:z2,selection:Y2,transition:cy,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:U2,attr:C2,attrTween:A2,style:ey,styleTween:ny,text:oy,textTween:uy,remove:H2,tween:m2,delay:B2,duration:R2,ease:L2,easeVarying:I2,end:dy,[Symbol.iterator]:tr[Symbol.iterator]};function hy(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var py={time:null,delay:0,duration:250,ease:hy};function gy(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 my(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Cd(),(t=py).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||gy(l,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=h2;ss.prototype.transition=my;const bs=r=>()=>r;function yy(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 xy(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function by(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function vy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function _y(){return navigator.maxTouchPoints||"ontouchstart"in this}function wy(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 Cy(){var r=xy,e=by,t=wy,n=vy,s=_y,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=i2,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(C){C.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(C,j,F,O){var U=C.selection?C.selection():C;U.property("__zoom",ru),C!==U?D(C,j,F,O):U.interrupt().each(function(){k(this,arguments).event(O).start().zoom(null,typeof j=="function"?j.apply(this,arguments):j).end()})},v.scaleBy=function(C,j,F,O){v.scaleTo(C,function(){var U=this.__zoom.k,W=typeof j=="function"?j.apply(this,arguments):j;return U*W},F,O)},v.scaleTo=function(C,j,F,O){v.transform(C,function(){var U=e.apply(this,arguments),W=this.__zoom,re=F==null?S(U):typeof F=="function"?F.apply(this,arguments):F,q=W.invert(re),Q=typeof j=="function"?j.apply(this,arguments):j;return t(_(b(W,Q),re,q),U,o)},F,O)},v.translateBy=function(C,j,F,O){v.transform(C,function(){return t(this.__zoom.translate(typeof j=="function"?j.apply(this,arguments):j,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,O)},v.translateTo=function(C,j,F,O,U){v.transform(C,function(){var W=e.apply(this,arguments),re=this.__zoom,q=O==null?S(W):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(re.k).translate(typeof j=="function"?-j.apply(this,arguments):-j,typeof F=="function"?-F.apply(this,arguments):-F),W,o)},O,U)};function b(C,j){return j=Math.max(i[0],Math.min(i[1],j)),j===C.k?C:new nr(j,C.x,C.y)}function _(C,j,F){var O=j[0]-F[0]*C.k,U=j[1]-F[1]*C.k;return O===C.x&&U===C.y?C:new nr(C.k,O,U)}function S(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,j,F,O){C.on("start.zoom",function(){k(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(O).end()}).tween("zoom",function(){var U=this,W=arguments,re=k(U,W).event(O),q=e.apply(U,W),Q=F==null?S(q):typeof F=="function"?F.apply(U,W):F,H=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),ne=U.__zoom,de=typeof j=="function"?j.apply(U,W):j,he=l(ne.invert(Q).concat(H/ne.k),de.invert(Q).concat(H/de.k));return function(pe){if(pe===1)pe=de;else{var ke=he(pe),me=H/ke[2];pe=new nr(me,Q[0]-ke[0]*me,Q[1]-ke[1]*me)}re.zoom(null,pe)}})}function k(C,j,F){return!F&&C.__zooming||new w(C,j)}function w(C,j){this.that=C,this.args=j,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,j),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,j){return this.mouse&&C!=="mouse"&&(this.mouse[1]=j.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=j.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=j.invert(this.touch1[0])),this.that.__zoom=j,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var j=Lt(this.that).datum();u.call(C,this.that,new yy(C,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),j)}};function E(C,...j){if(!r.apply(this,arguments))return;var F=k(this,j).event(C),O=this.__zoom,U=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),W=wr(C);if(F.wheel)(F.mouse[0][0]!==W[0]||F.mouse[0][1]!==W[1])&&(F.mouse[1]=O.invert(F.mouse[0]=W)),clearTimeout(F.wheel);else{if(O.k===U)return;F.mouse=[W,O.invert(W)],Es(this),F.start()}xn(C),F.wheel=setTimeout(re,g),F.zoom("mouse",t(_(b(O,U),F.mouse[0],F.mouse[1]),F.extent,o));function re(){F.wheel=null,F.end()}}function M(C,...j){if(f||!r.apply(this,arguments))return;var F=C.currentTarget,O=k(this,j,!0).event(C),U=Lt(C.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",H,!0),W=wr(C,F),re=C.clientX,q=C.clientY;jm(C.view),Wi(C),O.mouse=[W,this.__zoom.invert(W)],Es(this),O.start();function Q(ne){if(xn(ne),!O.moved){var de=ne.clientX-re,he=ne.clientY-q;O.moved=de*de+he*he>m}O.event(ne).zoom("mouse",t(_(O.that.__zoom,O.mouse[0]=wr(ne,F),O.mouse[1]),O.extent,o))}function H(ne){U.on("mousemove.zoom mouseup.zoom",null),Mm(ne.view,O.moved),xn(ne),O.event(ne).end()}}function N(C,...j){if(r.apply(this,arguments)){var F=this.__zoom,O=wr(C.changedTouches?C.changedTouches[0]:C,this),U=F.invert(O),W=F.k*(C.shiftKey?.5:2),re=t(_(b(F,W),O,U),e.apply(this,j),o);xn(C),a>0?Lt(this).transition().duration(a).call(D,re,O,C):Lt(this).call(v.transform,re,O,C)}}function T(C,...j){if(r.apply(this,arguments)){var F=C.touches,O=F.length,U=k(this,j,C.changedTouches.length===O).event(C),W,re,q,Q;for(Wi(C),re=0;re<O;++re)q=F[re],Q=wr(q,this),Q=[Q,this.__zoom.invert(Q),q.identifier],U.touch0?!U.touch1&&U.touch0[2]!==Q[2]&&(U.touch1=Q,U.taps=0):(U.touch0=Q,W=!0,U.taps=1+!!c);c&&(c=clearTimeout(c)),W&&(U.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Es(this),U.start())}}function B(C,...j){if(this.__zooming){var F=k(this,j).event(C),O=C.changedTouches,U=O.length,W,re,q,Q;for(xn(C),W=0;W<U;++W)re=O[W],q=wr(re,this),F.touch0&&F.touch0[2]===re.identifier?F.touch0[0]=q:F.touch1&&F.touch1[2]===re.identifier&&(F.touch1[0]=q);if(re=F.that.__zoom,F.touch1){var H=F.touch0[0],ne=F.touch0[1],de=F.touch1[0],he=F.touch1[1],pe=(pe=de[0]-H[0])*pe+(pe=de[1]-H[1])*pe,ke=(ke=he[0]-ne[0])*ke+(ke=he[1]-ne[1])*ke;re=b(re,Math.sqrt(pe/ke)),q=[(H[0]+de[0])/2,(H[1]+de[1])/2],Q=[(ne[0]+he[0])/2,(ne[1]+he[1])/2]}else if(F.touch0)q=F.touch0[0],Q=F.touch0[1];else return;F.zoom("touch",t(_(re,q,Q),F.extent,o))}}function R(C,...j){if(this.__zooming){var F=k(this,j).event(C),O=C.changedTouches,U=O.length,W,re;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),W=0;W<U;++W)re=O[W],F.touch0&&F.touch0[2]===re.identifier?delete F.touch0:F.touch1&&F.touch1[2]===re.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&&(re=wr(re,this),Math.hypot(d[0]-re[0],d[1]-re[1])<x)){var q=Lt(this).on("dblclick.zoom");q&&q.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?(a=+C,v):a},v.interpolate=function(C){return arguments.length?(l=C,v):l},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 Sd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=Cy().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const _={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(_),o==null||o(_)});l.current=x;const v=Lt(a.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]),y.useEffect(()=>{l.current&&l.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=y.useCallback((x,v,b,_=!0)=>{if(!a.current||!l.current)return;const S=Lt(a.current),D=ri.translate(x,v).scale(b);S.call(l.current.transform,D)},[]),f=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,v=50)=>{if(!a.current||!l.current||x.length===0)return;const _=a.current.getBoundingClientRect();let S=1/0,D=1/0,k=-1/0,w=-1/0;for(const O of x){const U=O.width||200,W=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),k=Math.max(k,O.x+U),w=Math.max(w,O.y+W)}const E=k-S,M=w-D,N=(_.width-v*2)/E,T=(_.height-v*2)/M,B=Math.min(N,T,t),R=(S+k)/2,C=(D+w)/2,j=_.width/2-R*B,F=_.height/2-C*B;d(j,F,B,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function kd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),f=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((_,S)=>{const D=g.current;return{x:(_-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=y.useCallback((_,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,k=parseFloat(D.dataset.x||"0"),w=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:k,nodeY:w},p.current={x:k,y:w},a(_),u(!0),d({x:0,y:0}),t==null||t(_)},[i,m,t]),v=y.useCallback(_=>{if(!l||!o||!f.current)return;const S=g.current,D=f.current,k=_.clientX-D.x,w=_.clientY-D.y,E=k/S.k,M=w/S.k,N=D.nodeX+E,T=D.nodeY+M;p.current={x:N,y:T},d({x:E,y:M}),n==null||n(o,N,T,E,M)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const _=p.current;s==null||s(o,_.x,_.y),a(null),u(!1),d({x:0,y:0}),f.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const _=D=>{v(D)},S=()=>{b()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",S)}},[l,v,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function Ed(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?N=>{const T=typeof N=="function"?N(u):N;i==null||i(Array.from(T))}:a,[d,f]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),v=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{v.current=t},[t]);const b=y.useCallback((N,T)=>{const B=x.current;return{x:(N-B.x)/B.k,y:(T-B.y)/B.k}},[]),_=y.useCallback((N,T)=>{const B=v.current.get(N);if(!B)return!1;const R=B.width||200,C=B.height||100;return B.x<T.x+T.width&&B.x+R>T.x&&B.y<T.y+T.height&&B.y+C>T.y},[]),S=y.useCallback(N=>{if(n||N.target.closest("[data-qmap-node]"))return;N.preventDefault();const B=b(N.clientX,N.clientY);m.current=B,f({x:B.x,y:B.y,width:0,height:0}),g(!0),N.shiftKey||c(new Set)},[n,b]),D=y.useCallback(N=>{if(!p||!m.current)return;const T=m.current,B=b(N.clientX,N.clientY),R={x:Math.min(T.x,B.x),y:Math.min(T.y,B.y),width:Math.abs(B.x-T.x),height:Math.abs(B.y-T.y)};f(R);const C=new Set;for(const[j]of v.current)_(j,R)&&C.add(j);c(C)},[p,b,_]),k=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const N=B=>{D(B)},T=()=>{k()};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",T)}},[p,D,k]);const w=y.useCallback((N,T=!1)=>{c(B=>{const R=new Set(T?B:[]);return B.has(N)&&T?R.delete(N):R.add(N),i==null||i(Array.from(R)),R})},[i]),E=y.useCallback(()=>{const N=new Set(v.current.keys());c(N),i==null||i(Array.from(N))},[i]),M=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:k,toggleSelect:w,selectAll:E,clearSelection:M}}const Dd=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const f=y.useCallback(v=>{i&&v.button===0&&o(e,v)},[e,i,o]),p=y.useCallback(v=>{s||a==null||a(v)},[s,a]),g=y.useCallback(v=>{v.stopPropagation(),l==null||l(v)},[l]),m=y.useCallback(v=>{v.preventDefault(),v.stopPropagation(),u==null||u(v)},[u]),x=t.rotation||0;return h.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:f,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Ad(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 ky(n,s);case"bezier":default:return Sy(n,s)}}function Sy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function ky(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 Ey(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,f;return u<c?(d=s.x+(i>0?a:-a),f=s.y+o*a/Math.abs(i)):(f=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:f}}function Dy(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 Ay(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function Ty(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 Ny(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,a=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+a)}return{x:e,y:t,width:n-e,height:s-t}}function By(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function jy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Td=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Ad(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),f=y.useCallback(()=>{u(!0)},[]),p=y.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:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(My,{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 My({pathD:r,label:e,color:t}){const n=y.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 Nd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return 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:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return h.jsx(Td,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Bd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return 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}})}),Ry=200,Fy=100,Ly="bezier",Py="#94a3b8",Iy=2,Oy=.1,zy=4;function $y({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Ry,defaultNodeHeight:i=Fy,onNodeMove:o,onNodeClick:a,onNodeDoubleClick:l,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Oy,maxZoom:x=zy,initialTransform:v,defaultEdgeStyle:b=Ly,defaultEdgeColor:_=Py,defaultEdgeWidth:S=Iy,draggable:D=!0,selectable:k=!0,zoomable:w=!0,pannable:E=!0,className:M="",style:N,background:T="#f8fafc",showGrid:B=!1,gridSize:R=20}){const C=r.data||{positions:{}},j=C.positions||{},F=y.useMemo(()=>{const ie=new Map;for(const P of e){const X=j[P._id]||{x:0,y:0};ie.set(P._id,{x:X.x,y:X.y,width:X.width||s,height:X.height||i,rotation:X.rotation||0})}return ie},[e,j,s,i]),{transform:O,containerRef:U,zoomIn:W,zoomOut:re,resetZoom:q,fitToContent:Q}=Sd({minZoom:m,maxZoom:x,initialTransform:v||C.transform,zoomable:w,pannable:E,onTransformChange:ie=>{g==null||g(ie);const P={...C,transform:ie};p==null||p(P)}}),[H,ne]=y.useState(new Map),[de,he]=y.useState(new Map),pe=y.useRef(new Map);y.useEffect(()=>{const ie=new Map;pe.current.forEach((X,ue)=>{if(X){const ce=X.getBoundingClientRect();ie.set(ue,{width:ce.width,height:ce.height})}}),e.some(X=>{const ue=ie.get(X._id),ce=de.get(X._id);return ue?ce?ue.width!==ce.width||ue.height!==ce.height:!0:!1})&&he(ie)},[e,de]);const{draggedNodeId:ke,startDrag:me}=kd({transform:O,disabled:!D,onDragStart:ie=>{const P=F.get(ie);P&&ne(new Map([[ie,{x:P.x,y:P.y}]]))},onDragMove:(ie,P,X)=>{ne(new Map([[ie,{x:P,y:X}]]))},onDragEnd:(ie,P,X)=>{ne(new Map),o==null||o(ie,P,X)}}),{selectedIds:J,selectionBox:be,isSelecting:se,startSelection:Ae,toggleSelect:_e,clearSelection:ve}=Ed({transform:O,nodePositions:F,disabled:!k,controlledSelectedIds:c,onSelectionChange:d}),Me=y.useCallback(ie=>{const P=F.get(ie)||{x:0,y:0,width:s,height:i},X=H.get(ie),ue=de.get(ie),ce=(ue==null?void 0:ue.width)||P.width||s,Ue=(ue==null?void 0:ue.height)||P.height||i;return X?{...P,x:X.x,y:X.y,width:ce,height:Ue}:{...P,width:ce,height:Ue}},[F,H,de,s,i]),Fe=y.useMemo(()=>{const ie=new Map;for(const P of F.keys())ie.set(P,Me(P));return ie},[F,Me]),qe=y.useCallback((ie,P)=>{_e(ie._id,P.shiftKey),a==null||a(ie,P)},[_e,a]),V=y.useCallback(ie=>{ie.target.closest("[data-qmap-node]")||ve()},[ve]),z=y.useCallback(ie=>{ie.button===0&&(ie.target.closest("[data-qmap-node]")||Ae(ie))},[Ae]),Le=B?`
185
+ ${V}`:V)},Ae=async V=>{if(!(!(typeof e=="string"?e:"").trim()||E||!s)){M(!0),T(V),R(!1);try{const O=await s(V,e);t(O)}catch(O){console.error(`${V} failed:`,O)}finally{M(!1),T(null)}}},_e=()=>{setTimeout(()=>{var V;(V=we.current)!=null&&V.contains(document.activeElement)||R(!1)},150)},ve=async()=>{if(!(!C.trim()||E||!i)){M(!0),T(C);try{const V=await i(C,e);t(V),j("")}catch(V){console.error("AI prompt failed:",V)}finally{M(!1),T(null)}}},Re=async()=>{if(!(typeof e=="string"?e:"").trim()||F)return;if(!(Z||x)){console.warn("TTS: No generation mode available",{integratedTTS:Z,hasCallback:!!x,llmClient:!!u,graphClient:!!c,nodeId:d,audioFilename:f}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}xe.current&&(xe.current.pause(),xe.current.currentTime=0),I(!0);try{if(Z&&u&&c&&d&&f){console.log("TTS: Generating audio...",{voice:Q,textLength:e.length});const O=await u.tts(e,{voice:Q});console.log("TTS: Audio generated, uploading...",{audioLength:O==null?void 0:O.length});const Ue=atob(O),se=new Uint8Array(Ue.length);for(let z=0;z<Ue.length;z++)se[z]=Ue.charCodeAt(z);const re=new Blob([se],{type:"audio/mpeg"}),oe=new File([re],f,{type:"audio/mpeg"});await c.uploadFile(d,f,oe),console.log("TTS: Upload complete",{nodeId:d,audioFilename:f}),ge(Date.now()),ue(f),m==null||m(f,Q)}else x&&(await x(e,Q),ge(Date.now()))}catch(O){console.error("TTS generation failed:",O),alert("Erreur TTS: "+(O instanceof Error?O.message:"Erreur inconnue"))}finally{I(!1)}},Le=async()=>{if(!(!u||!D||W)){if(!(k!=null&&k.trim())){U(w||"Le texte source est requis pour la génération.");return}q(!0),U(null);try{const V=await u.chat([{role:"system",content:D},{role:"user",content:k}]);t(V)}catch(V){U(V instanceof Error?V.message:"Erreur de génération")}finally{q(!1)}}},qe=V=>{H(V),_==null||_(V)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[h.jsx(Xc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:te,hideSaveButton:!0,variant:"div"}),i&&h.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[h.jsx("textarea",{value:C,onChange:V=>j(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Enter"&&V.ctrlKey&&(V.preventDefault(),ve())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:E,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),h.jsx("button",{type:"button",onClick:ve,disabled:E||!C.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:E?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||Z||x||S)&&h.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[r&&h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),S&&u&&D&&h.jsxs("button",{type:"button",onClick:Le,disabled:W,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:S.label,children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:W?"hourglass_empty":S.icon||"auto_awesome"}),S.label]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?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"})}),(Z||x)&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("select",{value:Q,onChange:V=>qe(V.target.value),disabled:F,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(V=>h.jsxs("option",{value:V.id,children:[V.name," - ",V.description]},V.id))}),h.jsx("button",{type:"button",onClick:Re,disabled:F||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:F?"Génération en cours...":"Générer audio TTS",children:h.jsx("span",{className:`material-icons ${F?"animate-pulse text-blue-600":be?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:F?"hourglass_empty":"record_voice_over"})}),be&&h.jsxs(h.Fragment,{children:[h.jsx("audio",{ref:xe,src:be,controls:!0,className:"h-6 w-32"},he),h.jsx("button",{type:"button",onClick:()=>{xe.current&&xe.current.pause(),ue(void 0),m==null||m("",Q)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:h.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&h.jsxs("div",{className:"relative",ref:we,children:[h.jsx("button",{type:"button",onClick:()=>R(!B),disabled:E||!(typeof e=="string"?e:"").trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:E?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),N==="restructure"&&"Restructuring...",N==="proofread"&&"Proofreading...",N==="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"})]})}),B&&!E&&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:_e,children:[h.jsxs("button",{type:"button",onClick:()=>Ae("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:()=>Ae("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:()=>Ae("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:V=>t(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:o,rows:l,disabled:E||W,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),ne&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),h.jsx("p",{className:"text-sm text-neutral-600",children:ne})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx("button",{type:"button",onClick:()=>U(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Yg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[f,p]=y.useState(null),[g,m]=y.useState(n),[x,v]=y.useState(0),[b,_]=y.useState({x:0,y:0,width:100,height:100}),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState({x:0,y:0}),[N,T]=y.useState({x:0,y:0,width:100,height:100}),B=o==="dark",R=y.useCallback(()=>{const Z=u.current;return Z?x===90||x===270?{width:Z.height,height:Z.width}:{width:Z.width,height:Z.height}:{width:100,height:100}},[x]),C=y.useCallback((Z,be)=>{const te=Z/be,Ae=.05;for(const[_e,ve]of Object.entries(gs))if(ve!==null&&Math.abs(te-ve)/ve<Ae)return _e;return"free"},[]);y.useEffect(()=>{const Z=new Image;Z.crossOrigin="anonymous",Z.onload=()=>{u.current=Z;const be=C(Z.width,Z.height);m(be),d(!1)},Z.onerror=()=>{p("Failed to load image"),d(!1)},Z.src=r},[r,C]);const j=y.useCallback(()=>{const{width:Z,height:be}=R(),te=gs[g];if(te===null){_({x:0,y:0,width:100,height:100});return}const Ae=Z/be;let _e,ve;Ae>te?(ve=100,_e=te/Ae*100):(_e=100,ve=Ae/te*100);const Re=(100-_e)/2,Le=(100-ve)/2;_({x:Re,y:Le,width:_e,height:ve})},[g,R]);y.useEffect(()=>{u.current&&j()},[g,x,j]),y.useEffect(()=>{const Z=l.current,be=u.current;if(!Z||!be||c)return;const te=Z.getContext("2d");if(!te)return;const Ae=a.current;if(!Ae)return;const _e=Ae.clientWidth,ve=Ae.clientHeight-140,{width:Re,height:Le}=R(),qe=Re/Le;let V,O;_e/ve>qe?(O=Math.min(ve,Le),V=O*qe):(V=Math.min(_e,Re),O=V/qe),V>_e&&(V=_e,O=V/qe),O>ve&&(O=ve,V=O*qe),Z.width=V,Z.height=O,te.clearRect(0,0,V,O),te.save(),te.translate(V/2,O/2),te.rotate(x*Math.PI/180);let Ue,se;x===90||x===270?(Ue=O,se=V):(Ue=V,se=O),te.drawImage(be,-Ue/2,-se/2,Ue,se),te.restore(),te.fillStyle="rgba(0, 0, 0, 0.6)";const re=b.x/100*V,oe=b.y/100*O,z=b.width/100*V,de=b.height/100*O;te.fillRect(0,0,V,oe),te.fillRect(0,oe+de,V,O-oe-de),te.fillRect(0,oe,re,de),te.fillRect(re+z,oe,V-re-z,de),te.strokeStyle="#fff",te.lineWidth=2,te.strokeRect(re,oe,z,de),te.strokeStyle="rgba(255, 255, 255, 0.3)",te.lineWidth=1,te.beginPath(),te.moveTo(re+z/3,oe),te.lineTo(re+z/3,oe+de),te.moveTo(re+z*2/3,oe),te.lineTo(re+z*2/3,oe+de),te.moveTo(re,oe+de/3),te.lineTo(re+z,oe+de/3),te.moveTo(re,oe+de*2/3),te.lineTo(re+z,oe+de*2/3),te.stroke();const Ce=14;te.fillStyle="#fff",te.strokeStyle="#333",te.lineWidth=1,[{x:re,y:oe},{x:re+z,y:oe},{x:re,y:oe+de},{x:re+z,y:oe+de}].forEach(dt=>{te.fillRect(dt.x-Ce/2,dt.y-Ce/2,Ce,Ce),te.strokeRect(dt.x-Ce/2,dt.y-Ce/2,Ce,Ce)})},[b,x,c,R]);const F=Z=>{const be=l.current;if(!be)return;const te=be.getBoundingClientRect(),Ae=(Z.clientX-te.left)/te.width*100,_e=(Z.clientY-te.top)/te.height*100,ve=4,Re=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Le of Re)if(Math.abs(Ae-Le.x)<ve&&Math.abs(_e-Le.y)<ve){w(Le.name),M({x:Ae,y:_e}),T({...b});return}Ae>=b.x&&Ae<=b.x+b.width&&_e>=b.y&&_e<=b.y+b.height&&(D(!0),M({x:Ae,y:_e}),T({...b}))},I=Z=>{const be=l.current;if(!be)return;const te=be.getBoundingClientRect(),Ae=(Z.clientX-te.left)/te.width*100,_e=(Z.clientY-te.top)/te.height*100;if(S){const ve=Ae-E.x,Re=_e-E.y;let Le=N.x+ve,qe=N.y+Re;Le=Math.max(0,Math.min(Le,100-N.width)),qe=Math.max(0,Math.min(qe,100-N.height)),_({...N,x:Le,y:qe})}else if(k){const ve=gs[g],{width:Re,height:Le}=R(),qe=Re/Le,V=ve?ve/qe:null;let O={...N};const Ue=Ae-E.x,se=_e-E.y;if(k==="se")O.width=Math.max(10,Math.min(100-O.x,N.width+Ue)),V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V)):O.height=Math.max(10,Math.min(100-O.y,N.height+se));else if(k==="sw"){const re=-Ue,oe=Math.max(10,N.width+re),z=N.x+N.width-oe;z>=0&&(O.width=oe,O.x=z,V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V,O.x=N.x+N.width-O.width)):O.height=Math.max(10,Math.min(100-O.y,N.height+se)))}else if(k==="ne")if(O.width=Math.max(10,Math.min(100-O.x,N.width+Ue)),V){const re=O.width/V,oe=N.y+N.height-re;oe>=0?(O.height=re,O.y=oe):(O.y=0,O.height=N.y+N.height,O.width=O.height*V)}else{const re=-se,oe=Math.max(10,N.height+re),z=N.y+N.height-oe;z>=0&&(O.height=oe,O.y=z)}else if(k==="nw"){const re=-Ue,oe=Math.max(10,N.width+re),z=N.x+N.width-oe;if(z>=0)if(O.width=oe,O.x=z,V){const de=O.width/V,Ce=N.y+N.height-de;Ce>=0?(O.height=de,O.y=Ce):(O.y=0,O.height=N.y+N.height,O.width=O.height*V,O.x=N.x+N.width-O.width)}else{const de=-se,Ce=Math.max(10,N.height+de),We=N.y+N.height-Ce;We>=0&&(O.height=Ce,O.y=We)}}O.x=Math.max(0,O.x),O.y=Math.max(0,O.y),O.width=Math.min(O.width,100-O.x),O.height=Math.min(O.height,100-O.y),_(O)}},W=()=>{D(!1),w(null)},q=Z=>{v(be=>Z==="right"?(be+90)%360:(be-90+360)%360)},ne=()=>{const Z=u.current;if(!Z)return;const{width:be,height:te}=R(),Ae=b.x/100*be,_e=b.y/100*te,ve=b.width/100*be,Re=b.height/100*te,Le=document.createElement("canvas"),qe=Le.getContext("2d");if(!qe)return;Le.width=ve,Le.height=Re;const V=document.createElement("canvas"),O=V.getContext("2d");O&&(V.width=be,V.height=te,O.save(),O.translate(be/2,te/2),O.rotate(x*Math.PI/180),O.drawImage(Z,-Z.width/2,-Z.height/2,Z.width,Z.height),O.restore(),qe.drawImage(V,Ae,_e,ve,Re,0,0,ve,Re),Le.toBlob(Ue=>{Ue&&e(Ue)},s,i))},U={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:B?"#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 ${B?"#333":"#ddd"}`,background:B?"#242424":"#fff",flexShrink:0},ie={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"},he={...ue,background:"#E67E22",color:"#fff"},ge={...ue,background:B?"#333":"#e5e5e5",color:B?"#fff":"#333"},we={padding:"10px",borderRadius:"8px",border:"none",background:B?"#333":"#e5e5e5",color:B?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=Z=>({padding:"8px 14px",borderRadius:"6px",border:Z?"2px solid #E67E22":"2px solid transparent",background:Z?"#E67E22":B?"#333":"#e5e5e5",color:Z?"#fff":B?"#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:B?"#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:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:a,style:U,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:l,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(Z=>h.jsx("button",{onClick:()=>m(Z),style:xe(g===Z),children:Z==="free"?"Libre":Z},Z))}),h.jsxs("div",{style:ie,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>q("left"),style:we,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:()=>q("right"),style:we,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:ge,children:"Annuler"}),h.jsx("button",{onClick:ne,style:he,children:"Enregistrer"})]})]})]})]})}var Qg={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 Jg(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=Jg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Xg(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]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(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 Xg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Qg,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 zl={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)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function Zg(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 e0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Zc(r){var e=_i(r);return(e.local?e0:Zg)(e)}function t0(){}function ua(r){return r==null?t0:function(){return this.querySelector(r)}}function r0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Dt(n,this._parents)}function n0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function s0(){return[]}function ed(r){return r==null?s0:function(){return this.querySelectorAll(r)}}function i0(r){return function(){return n0(r.apply(this,arguments))}}function o0(r){typeof r=="function"?r=i0(r):r=ed(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Dt(n,s)}function td(r){return function(){return this.matches(r)}}function rd(r){return function(e){return e.matches(r)}}var a0=Array.prototype.find;function l0(r){return function(){return a0.call(this.children,r)}}function u0(){return this.firstElementChild}function c0(r){return this.select(r==null?u0:l0(typeof r=="function"?r:rd(r)))}var d0=Array.prototype.filter;function f0(){return Array.from(this.children)}function h0(r){return function(){return d0.call(this.children,r)}}function p0(r){return this.selectAll(r==null?f0:h0(typeof r=="function"?r:rd(r)))}function g0(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Dt(n,this._parents)}function nd(r){return new Array(r.length)}function m0(){return new Dt(this._enter||this._groups.map(nd),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 y0(r){return function(){return r}}function x0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function b0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(f[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(f[a])===l&&(s[a]=l)}function v0(r){return r.__data__}function _0(r,e){if(!arguments.length)return Array.from(this,v0);var t=e?b0:x0,n=this._parents,s=this._groups;typeof r!="function"&&(r=y0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=w0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),v=l[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,_=0,S,D;b<g;++b)if(S=m[b]){for(b>=_&&(_=b+1);!(D=x[_])&&++_<g;);S._next=D||null}}return o=new Dt(o,n),o._enter=a,o._exit=l,o}function w0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function C0(){return new Dt(this._exit||this._groups.map(nd),this._parents)}function S0(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 k0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,f=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;l<s;++l)a[l]=t[l];return new Dt(a,this._parents)}function E0(){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 D0(r){r||(r=A0);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],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Dt(s,this._parents).order()}function A0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function T0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function N0(){return Array.from(this)}function B0(){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 j0(){let r=0;for(const e of this)++r;return r}function M0(){return!this.node()}function R0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function F0(r){return function(){this.removeAttribute(r)}}function L0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function P0(r,e){return function(){this.setAttribute(r,e)}}function I0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function z0(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 $0(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?L0:F0:typeof e=="function"?t.local?z0:O0:t.local?I0:P0)(t,e))}function sd(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function q0(r){return function(){this.style.removeProperty(r)}}function U0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function W0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function H0(r,e,t){return arguments.length>1?this.each((e==null?q0:typeof e=="function"?W0:U0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||sd(r).getComputedStyle(r,null).getPropertyValue(e)}function V0(r){return function(){delete this[r]}}function G0(r,e){return function(){this[r]=e}}function K0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Y0(r,e){return arguments.length>1?this.each((e==null?V0:typeof e=="function"?K0:G0)(r,e)):this.node()[r]}function id(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new od(r)}function od(r){this._node=r,this._names=id(r.getAttribute("class")||"")}od.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 ad(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Q0(r){return function(){ad(this,r)}}function J0(r){return function(){ld(this,r)}}function X0(r,e){return function(){(e.apply(this,arguments)?ad:ld)(this,r)}}function Z0(r,e){var t=id(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"?X0:e?Q0:J0)(t,e))}function em(){this.textContent=""}function tm(r){return function(){this.textContent=r}}function rm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function nm(r){return arguments.length?this.each(r==null?em:(typeof r=="function"?rm:tm)(r)):this.node().textContent}function sm(){this.innerHTML=""}function im(r){return function(){this.innerHTML=r}}function om(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function am(r){return arguments.length?this.each(r==null?sm:(typeof r=="function"?om:im)(r)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function um(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function dm(){return this.each(cm)}function fm(r){var e=typeof r=="function"?r:Zc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function hm(){return null}function pm(r,e){var t=typeof r=="function"?r:Zc(r),n=e==null?hm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gm(){var r=this.parentNode;r&&r.removeChild(this)}function mm(){return this.each(gm)}function ym(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(r){return this.select(r?xm:ym)}function vm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function _m(r){return function(e){r.call(this,e,this.__data__)}}function wm(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 Cm(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 Sm(r,e,t){return function(){var n=this.__on,s,i=_m(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function km(r,e,t){var n=wm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?Sm:Cm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function ud(r,e,t){var n=sd(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 Em(r,e){return function(){return ud(this,r,e)}}function Dm(r,e){return function(){return ud(this,r,e.apply(this,arguments))}}function Am(r,e){return this.each((typeof e=="function"?Dm:Em)(r,e))}function*Tm(){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 cd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],cd)}function Nm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:r0,selectAll:o0,selectChild:c0,selectChildren:p0,filter:g0,data:_0,enter:m0,exit:C0,join:S0,merge:k0,selection:Nm,order:E0,sort:D0,call:T0,nodes:N0,node:B0,size:j0,empty:M0,each:R0,attr:$0,style:H0,property:Y0,classed:Z0,text:nm,html:am,raise:um,lower:dm,append:fm,insert:pm,remove:mm,clone:bm,datum:vm,on:km,dispatch:Am,[Symbol.iterator]:Tm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],cd)}function Bm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=Bm(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 jm(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 Mm(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 dd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Lm=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Pm=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),Im=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),zm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:$m,formatHsl:qm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function $m(){return this.rgb().formatHex8()}function qm(){return fd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Rm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(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=Fm.exec(r))?new wt(e[1],e[2],e[3],1):(e=Lm.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Pm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Im.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=zm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Wl(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 Um(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?Um(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,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,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),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Wm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Wm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function fd(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,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Pt(o,a,l,r.opacity)}function Hm(r,e,t,n){return arguments.length===1?fd(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,Hm,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,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(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const hd=r=>()=>r;function Vm(r,e){return function(t){return r+t*e}}function Gm(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 Km(r){return(r=+r)==1?pd:function(e,t){return t-e?Gm(e,t,r):hd(isNaN(e)?t:e)}}function pd(r,e){var t=e-r;return t?Vm(r,t):hd(isNaN(r)?e:r)}const Yl=function r(e){var t=Km(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=pd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function 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 Ym(r){return function(){return r}}function Qm(r){return function(e){return r(e)+""}}function Jm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Qm(l[0].x):Ym(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gd(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Xm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:gd(e.a,e.b,e.c,e.d,e.e,e.f)}function Zm(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,gd(r.a,r.b,r.c,r.d,r.e,r.f))}function md(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 a(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 l(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),a(u.skewX,c.skewX,d,f),l(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 e2=md(Xm,"px, ","px)","deg)"),t2=md(Zm,", ",")",")"),r2=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function n2(r){return((r=Math.exp(r))-1/r)/2}function s2(r){return((r=Math.exp(2*r))-1)/(r+1)}const i2=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-a,g=d-l,m=p*p+g*g,x,v;if(m<r2)v=Math.log(f/u)/e,x=function(w){return[a+w*p,l+w*g,u*Math.exp(e*w*v)]};else{var b=Math.sqrt(m),_=(f*f-u*u+n*m)/(2*u*t*b),S=(f*f-u*u-n*m)/(2*f*t*b),D=Math.log(Math.sqrt(_*_+1)-_),k=Math.log(Math.sqrt(S*S+1)-S);v=(k-D)/e,x=function(w){var E=w*v,M=Jl(D),N=u/(t*b)*(M*s2(e*E+D)-n2(D));return[a+N*p,l+N*g,u*M/Jl(e*E+D)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,yd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,xd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(xd(o2),Lr=Wn.now()+wi)}function o2(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=bd.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 bd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function a2(){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{a2()}finally{nn=0,u2(),Lr=0}}function l2(){var r=Wn.now(),e=r-ei;e>yd&&(wi-=e,ei=r)}function u2(){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(l2,yd)),nn=1,xd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var c2=la("start","end","cancel","interrupt"),d2=[],vd=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;f2(r,t,{name:e,index:n,group:s,on:c2,tween:d2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vd})}function ha(r,e){var t=qt(r,e);if(t.state>vd)throw new Error("too late; already scheduled");return t}function Xt(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 f2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=bd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return l();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(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 a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),l())}function l(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function h2(r){return this.each(function(){Es(this,r)})}function p2(r,e){var t,n;return function(){var s=Xt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function g2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function m2(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?p2:g2)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return qt(s,n).value[e]}}function _d(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Jm)(r,e)}function y2(r){return function(){this.removeAttribute(r)}}function x2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function b2(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 v2(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 _2(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function w2(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function C2(r,e){var t=_i(r),n=t==="transform"?t2:_d;return this.attrTween(r,typeof e=="function"?(t.local?w2:_2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?x2:y2)(t):(t.local?v2:b2)(t,n,e))}function S2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function k2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function E2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&k2(r,i)),t}return s._value=e,s}function D2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&S2(r,i)),t}return s._value=e,s}function A2(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?E2:D2)(n,e))}function T2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function N2(r,e){return e=+e,function(){ha(this,r).delay=e}}function B2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?T2:N2)(e,r)):qt(this.node(),e).delay}function j2(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function M2(r,e){return e=+e,function(){Xt(this,r).duration=e}}function R2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?j2:M2)(e,r)):qt(this.node(),e).duration}function F2(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function L2(r){var e=this._id;return arguments.length?this.each(F2(e,r)):qt(this.node(),e).ease}function P2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function I2(r){if(typeof r!="function")throw new Error;return this.each(P2(this._id,r))}function O2(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new ir(n,this._parents,this._name,this._id)}function z2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),f,p=0;p<c;++p)(f=l[p]||u[p])&&(d[p]=f);for(;a<n;++a)o[a]=e[a];return new ir(o,this._parents,this._name,this._id)}function $2(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 q2(r,e,t){var n,s,i=$2(e)?ha:Xt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function U2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(q2(t,r,e))}function W2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function H2(){return this.on("end.remove",W2(this._id))}function V2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,f=0;f<l;++f)(c=a[f])&&(d=r.call(c,c.__data__,f,a))&&("__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 G2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ed(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var f=r.call(c,c.__data__,d,l),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 K2=ss.prototype.constructor;function Y2(){return new K2(this._groups,this._parents)}function Q2(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 wd(r){return function(){this.style.removeProperty(r)}}function J2(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 X2(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function Z2(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Xt(this,r),u=l.on,c=l.value[i]==null?a||(a=wd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function ey(r,e,t){var n=(r+="")=="transform"?e2:_d;return e==null?this.styleTween(r,Q2(r,n)).on("end.style."+r,wd(r)):typeof e=="function"?this.styleTween(r,X2(r,n,pa(this,"style."+r,e))).each(Z2(this._id,r)):this.styleTween(r,J2(r,n,e),t).on("end.style."+r,null)}function ty(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function ry(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&ty(r,o,t)),n}return i._value=e,i}function ny(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,ry(r,e,t??""))}function sy(r){return function(){this.textContent=r}}function iy(r){return function(){var e=r(this);this.textContent=e??""}}function oy(r){return this.tween("text",typeof r=="function"?iy(pa(this,"text",r)):sy(r==null?"":r+""))}function ay(r){return function(e){this.textContent=r.call(this,e)}}function ly(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&ay(s)),e}return n._value=r,n}function uy(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,ly(r))}function cy(){for(var r=this._name,e=this._id,t=Cd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=qt(l,e);Ci(l,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function dy(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={value:function(){--s===0&&i()}};t.each(function(){var u=Xt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var fy=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Cd(){return++fy}var tr=ss.prototype;ir.prototype={constructor:ir,select:V2,selectAll:G2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:O2,merge:z2,selection:Y2,transition:cy,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:U2,attr:C2,attrTween:A2,style:ey,styleTween:ny,text:oy,textTween:uy,remove:H2,tween:m2,delay:B2,duration:R2,ease:L2,easeVarying:I2,end:dy,[Symbol.iterator]:tr[Symbol.iterator]};function hy(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var py={time:null,delay:0,duration:250,ease:hy};function gy(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 my(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Cd(),(t=py).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||gy(l,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=h2;ss.prototype.transition=my;const bs=r=>()=>r;function yy(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 xy(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function by(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function vy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function _y(){return navigator.maxTouchPoints||"ontouchstart"in this}function wy(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 Cy(){var r=xy,e=by,t=wy,n=vy,s=_y,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=i2,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(C){C.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(C,j,F,I){var W=C.selection?C.selection():C;W.property("__zoom",ru),C!==W?D(C,j,F,I):W.interrupt().each(function(){k(this,arguments).event(I).start().zoom(null,typeof j=="function"?j.apply(this,arguments):j).end()})},v.scaleBy=function(C,j,F,I){v.scaleTo(C,function(){var W=this.__zoom.k,q=typeof j=="function"?j.apply(this,arguments):j;return W*q},F,I)},v.scaleTo=function(C,j,F,I){v.transform(C,function(){var W=e.apply(this,arguments),q=this.__zoom,ne=F==null?S(W):typeof F=="function"?F.apply(this,arguments):F,U=q.invert(ne),Q=typeof j=="function"?j.apply(this,arguments):j;return t(_(b(q,Q),ne,U),W,o)},F,I)},v.translateBy=function(C,j,F,I){v.transform(C,function(){return t(this.__zoom.translate(typeof j=="function"?j.apply(this,arguments):j,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},v.translateTo=function(C,j,F,I,W){v.transform(C,function(){var q=e.apply(this,arguments),ne=this.__zoom,U=I==null?S(q):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(U[0],U[1]).scale(ne.k).translate(typeof j=="function"?-j.apply(this,arguments):-j,typeof F=="function"?-F.apply(this,arguments):-F),q,o)},I,W)};function b(C,j){return j=Math.max(i[0],Math.min(i[1],j)),j===C.k?C:new nr(j,C.x,C.y)}function _(C,j,F){var I=j[0]-F[0]*C.k,W=j[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 D(C,j,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,q=arguments,ne=k(W,q).event(I),U=e.apply(W,q),Q=F==null?S(U):typeof F=="function"?F.apply(W,q):F,H=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),ie=W.__zoom,ue=typeof j=="function"?j.apply(W,q):j,he=l(ie.invert(Q).concat(H/ie.k),ue.invert(Q).concat(H/ue.k));return function(ge){if(ge===1)ge=ue;else{var we=he(ge),xe=H/we[2];ge=new nr(xe,Q[0]-we[0]*xe,Q[1]-we[1]*xe)}ne.zoom(null,ge)}})}function k(C,j,F){return!F&&C.__zooming||new w(C,j)}function w(C,j){this.that=C,this.args=j,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,j),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,j){return this.mouse&&C!=="mouse"&&(this.mouse[1]=j.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=j.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=j.invert(this.touch1[0])),this.that.__zoom=j,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var j=Lt(this.that).datum();u.call(C,this.that,new yy(C,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),j)}};function E(C,...j){if(!r.apply(this,arguments))return;var F=k(this,j).event(C),I=this.__zoom,W=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),q=wr(C);if(F.wheel)(F.mouse[0][0]!==q[0]||F.mouse[0][1]!==q[1])&&(F.mouse[1]=I.invert(F.mouse[0]=q)),clearTimeout(F.wheel);else{if(I.k===W)return;F.mouse=[q,I.invert(q)],Es(this),F.start()}xn(C),F.wheel=setTimeout(ne,g),F.zoom("mouse",t(_(b(I,W),F.mouse[0],F.mouse[1]),F.extent,o));function ne(){F.wheel=null,F.end()}}function M(C,...j){if(f||!r.apply(this,arguments))return;var F=C.currentTarget,I=k(this,j,!0).event(C),W=Lt(C.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",H,!0),q=wr(C,F),ne=C.clientX,U=C.clientY;jm(C.view),Wi(C),I.mouse=[q,this.__zoom.invert(q)],Es(this),I.start();function Q(ie){if(xn(ie),!I.moved){var ue=ie.clientX-ne,he=ie.clientY-U;I.moved=ue*ue+he*he>m}I.event(ie).zoom("mouse",t(_(I.that.__zoom,I.mouse[0]=wr(ie,F),I.mouse[1]),I.extent,o))}function H(ie){W.on("mousemove.zoom mouseup.zoom",null),Mm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function N(C,...j){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(C.changedTouches?C.changedTouches[0]:C,this),W=F.invert(I),q=F.k*(C.shiftKey?.5:2),ne=t(_(b(F,q),I,W),e.apply(this,j),o);xn(C),a>0?Lt(this).transition().duration(a).call(D,ne,I,C):Lt(this).call(v.transform,ne,I,C)}}function T(C,...j){if(r.apply(this,arguments)){var F=C.touches,I=F.length,W=k(this,j,C.changedTouches.length===I).event(C),q,ne,U,Q;for(Wi(C),ne=0;ne<I;++ne)U=F[ne],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,q=!0,W.taps=1+!!c);c&&(c=clearTimeout(c)),q&&(W.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Es(this),W.start())}}function B(C,...j){if(this.__zooming){var F=k(this,j).event(C),I=C.changedTouches,W=I.length,q,ne,U,Q;for(xn(C),q=0;q<W;++q)ne=I[q],U=wr(ne,this),F.touch0&&F.touch0[2]===ne.identifier?F.touch0[0]=U:F.touch1&&F.touch1[2]===ne.identifier&&(F.touch1[0]=U);if(ne=F.that.__zoom,F.touch1){var H=F.touch0[0],ie=F.touch0[1],ue=F.touch1[0],he=F.touch1[1],ge=(ge=ue[0]-H[0])*ge+(ge=ue[1]-H[1])*ge,we=(we=he[0]-ie[0])*we+(we=he[1]-ie[1])*we;ne=b(ne,Math.sqrt(ge/we)),U=[(H[0]+ue[0])/2,(H[1]+ue[1])/2],Q=[(ie[0]+he[0])/2,(ie[1]+he[1])/2]}else if(F.touch0)U=F.touch0[0],Q=F.touch0[1];else return;F.zoom("touch",t(_(ne,U,Q),F.extent,o))}}function R(C,...j){if(this.__zooming){var F=k(this,j).event(C),I=C.changedTouches,W=I.length,q,ne;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),q=0;q<W;++q)ne=I[q],F.touch0&&F.touch0[2]===ne.identifier?delete F.touch0:F.touch1&&F.touch1[2]===ne.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&&(ne=wr(ne,this),Math.hypot(d[0]-ne[0],d[1]-ne[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?(a=+C,v):a},v.interpolate=function(C){return arguments.length?(l=C,v):l},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 Sd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=Cy().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const _={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(_),o==null||o(_)});l.current=x;const v=Lt(a.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]),y.useEffect(()=>{l.current&&l.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=y.useCallback((x,v,b,_=!0)=>{if(!a.current||!l.current)return;const S=Lt(a.current),D=ri.translate(x,v).scale(b);S.call(l.current.transform,D)},[]),f=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,v=50)=>{if(!a.current||!l.current||x.length===0)return;const _=a.current.getBoundingClientRect();let S=1/0,D=1/0,k=-1/0,w=-1/0;for(const I of x){const W=I.width||200,q=I.height||100;S=Math.min(S,I.x),D=Math.min(D,I.y),k=Math.max(k,I.x+W),w=Math.max(w,I.y+q)}const E=k-S,M=w-D,N=(_.width-v*2)/E,T=(_.height-v*2)/M,B=Math.min(N,T,t),R=(S+k)/2,C=(D+w)/2,j=_.width/2-R*B,F=_.height/2-C*B;d(j,F,B,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function kd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),f=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((_,S)=>{const D=g.current;return{x:(_-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=y.useCallback((_,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,k=parseFloat(D.dataset.x||"0"),w=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:k,nodeY:w},p.current={x:k,y:w},a(_),u(!0),d({x:0,y:0}),t==null||t(_)},[i,m,t]),v=y.useCallback(_=>{if(!l||!o||!f.current)return;const S=g.current,D=f.current,k=_.clientX-D.x,w=_.clientY-D.y,E=k/S.k,M=w/S.k,N=D.nodeX+E,T=D.nodeY+M;p.current={x:N,y:T},d({x:E,y:M}),n==null||n(o,N,T,E,M)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const _=p.current;s==null||s(o,_.x,_.y),a(null),u(!1),d({x:0,y:0}),f.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const _=D=>{v(D)},S=()=>{b()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",S)}},[l,v,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function Ed(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?N=>{const T=typeof N=="function"?N(u):N;i==null||i(Array.from(T))}:a,[d,f]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),v=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{v.current=t},[t]);const b=y.useCallback((N,T)=>{const B=x.current;return{x:(N-B.x)/B.k,y:(T-B.y)/B.k}},[]),_=y.useCallback((N,T)=>{const B=v.current.get(N);if(!B)return!1;const R=B.width||200,C=B.height||100;return B.x<T.x+T.width&&B.x+R>T.x&&B.y<T.y+T.height&&B.y+C>T.y},[]),S=y.useCallback(N=>{if(n||N.target.closest("[data-qmap-node]"))return;N.preventDefault();const B=b(N.clientX,N.clientY);m.current=B,f({x:B.x,y:B.y,width:0,height:0}),g(!0),N.shiftKey||c(new Set)},[n,b]),D=y.useCallback(N=>{if(!p||!m.current)return;const T=m.current,B=b(N.clientX,N.clientY),R={x:Math.min(T.x,B.x),y:Math.min(T.y,B.y),width:Math.abs(B.x-T.x),height:Math.abs(B.y-T.y)};f(R);const C=new Set;for(const[j]of v.current)_(j,R)&&C.add(j);c(C)},[p,b,_]),k=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const N=B=>{D(B)},T=()=>{k()};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",T)}},[p,D,k]);const w=y.useCallback((N,T=!1)=>{c(B=>{const R=new Set(T?B:[]);return B.has(N)&&T?R.delete(N):R.add(N),i==null||i(Array.from(R)),R})},[i]),E=y.useCallback(()=>{const N=new Set(v.current.keys());c(N),i==null||i(Array.from(N))},[i]),M=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:k,toggleSelect:w,selectAll:E,clearSelection:M}}const Dd=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const f=y.useCallback(v=>{i&&v.button===0&&o(e,v)},[e,i,o]),p=y.useCallback(v=>{s||a==null||a(v)},[s,a]),g=y.useCallback(v=>{v.stopPropagation(),l==null||l(v)},[l]),m=y.useCallback(v=>{v.preventDefault(),v.stopPropagation(),u==null||u(v)},[u]),x=t.rotation||0;return h.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:f,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Ad(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 ky(n,s);case"bezier":default:return Sy(n,s)}}function Sy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function ky(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 Ey(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,f;return u<c?(d=s.x+(i>0?a:-a),f=s.y+o*a/Math.abs(i)):(f=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:f}}function Dy(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 Ay(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function Ty(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 Ny(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,a=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+a)}return{x:e,y:t,width:n-e,height:s-t}}function By(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function jy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Td=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Ad(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),f=y.useCallback(()=>{u(!0)},[]),p=y.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:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(My,{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 My({pathD:r,label:e,color:t}){const n=y.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 Nd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return 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:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return h.jsx(Td,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Bd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return 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}})}),Ry=200,Fy=100,Ly="bezier",Py="#94a3b8",Iy=2,Oy=.1,zy=4;function $y({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Ry,defaultNodeHeight:i=Fy,onNodeMove:o,onNodeClick:a,onNodeDoubleClick:l,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Oy,maxZoom:x=zy,initialTransform:v,defaultEdgeStyle:b=Ly,defaultEdgeColor:_=Py,defaultEdgeWidth:S=Iy,draggable:D=!0,selectable:k=!0,zoomable:w=!0,pannable:E=!0,className:M="",style:N,background:T="#f8fafc",showGrid:B=!1,gridSize:R=20}){const C=r.data||{positions:{}},j=C.positions||{},F=y.useMemo(()=>{const se=new Map;for(const re of e){const oe=j[re._id]||{x:0,y:0};se.set(re._id,{x:oe.x,y:oe.y,width:oe.width||s,height:oe.height||i,rotation:oe.rotation||0})}return se},[e,j,s,i]),{transform:I,containerRef:W,zoomIn:q,zoomOut:ne,resetZoom:U,fitToContent:Q}=Sd({minZoom:m,maxZoom:x,initialTransform:v||C.transform,zoomable:w,pannable:E,onTransformChange:se=>{g==null||g(se);const re={...C,transform:se};p==null||p(re)}}),[H,ie]=y.useState(new Map),[ue,he]=y.useState(new Map),ge=y.useRef(new Map);y.useEffect(()=>{const se=new Map;ge.current.forEach((oe,z)=>{if(oe){const de=oe.getBoundingClientRect();se.set(z,{width:de.width,height:de.height})}}),e.some(oe=>{const z=se.get(oe._id),de=ue.get(oe._id);return z?de?z.width!==de.width||z.height!==de.height:!0:!1})&&he(se)},[e,ue]);const{draggedNodeId:we,startDrag:xe}=kd({transform:I,disabled:!D,onDragStart:se=>{const re=F.get(se);re&&ie(new Map([[se,{x:re.x,y:re.y}]]))},onDragMove:(se,re,oe)=>{ie(new Map([[se,{x:re,y:oe}]]))},onDragEnd:(se,re,oe)=>{ie(new Map),o==null||o(se,re,oe)}}),{selectedIds:Z,selectionBox:be,isSelecting:te,startSelection:Ae,toggleSelect:_e,clearSelection:ve}=Ed({transform:I,nodePositions:F,disabled:!k,controlledSelectedIds:c,onSelectionChange:d}),Re=y.useCallback(se=>{const re=F.get(se)||{x:0,y:0,width:s,height:i},oe=H.get(se),z=ue.get(se),de=(z==null?void 0:z.width)||re.width||s,Ce=(z==null?void 0:z.height)||re.height||i;return oe?{...re,x:oe.x,y:oe.y,width:de,height:Ce}:{...re,width:de,height:Ce}},[F,H,ue,s,i]),Le=y.useMemo(()=>{const se=new Map;for(const re of F.keys())se.set(re,Re(re));return se},[F,Re]),qe=y.useCallback((se,re)=>{_e(se._id,re.shiftKey),a==null||a(se,re)},[_e,a]),V=y.useCallback(se=>{se.target.closest("[data-qmap-node]")||ve()},[ve]),O=y.useCallback(se=>{se.button===0&&(se.target.closest("[data-qmap-node]")||Ae(se))},[Ae]),Ue=B?`
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:U,className:`qmap-container ${M}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:T,backgroundImage:Le,backgroundSize:B?`${R}px ${R}px`:void 0,cursor:se?"crosshair":E?"grab":"default",...N},onMouseDown:z,onClick:V,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(Nd,{edges:t,nodePositions:Fe,defaultStyle:b,defaultColor:_,defaultWidth:S,onEdgeClick:f}),e.map(ie=>{const P=Me(ie._id),X=J.has(ie._id),ue=ke===ie._id;return h.jsx(Dd,{nodeId:ie._id,position:P,isSelected:X,isDragging:ue,draggable:D,onDragStart:me,onClick:ce=>qe(ie,ce),onDoubleClick:ce=>l==null?void 0:l(ie,ce),onContextMenu:ce=>u==null?void 0:u(ie,ce),nodeRef:ce=>{ce?pe.current.set(ie._id,ce):pe.current.delete(ie._id)},children:n(ie,X,P)},ie._id)})]}),be&&h.jsx(Bd,{box:be,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:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),h.jsx("button",{onClick:re,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:()=>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=Sg;exports.AnimatedCardFlip=Sf;exports.ApiClient=au;exports.AudioEditor=Xc;exports.AuthFlow=fu;exports.AuthFlowModal=xf;exports.AuthManager=rt;exports.AuthProvider=cf;exports.AuthService=Ao;exports.Card=_f;exports.ComboBox=Rg;exports.ComboStack=Lg;exports.DataOperations=vs;exports.Detail=wf;exports.ForgotPasswordForm=cu;exports.GraphClient=Pd;exports.ImageEditor=Yg;exports.KanbanBoard=Pg;exports.LLMClient=nf;exports.LoginForm=No;exports.LoginModal=hf;exports.Mail=Ef;exports.MailClient=iu;exports.MailComposer=jg;exports.MailEditor=Gc;exports.NetflixCard=Yc;exports.NetflixDetail=Jc;exports.NetflixLane=Qc;exports.NetflixStack=qg;exports.QMap=$y;exports.QMapEdgeComponent=Td;exports.QMapEdgeLayer=Nd;exports.QMapNode=Dd;exports.QMapSelectionBox=Bd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Df;exports.Stack=vf;exports.TTS_VOICES=ou;exports.Timeline=Gg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Kg;exports.calculateBoundingBox=Ny;exports.calculateEdgePath=Ad;exports.distance=By;exports.distanceSquared=jy;exports.getApiClient=To;exports.getAuthService=of;exports.getConnectionPoint=Ey;exports.getNodeCenter=ga;exports.getNodeSidePoint=Dy;exports.initializeApiClient=af;exports.initializeAuthService=sf;exports.pointInRect=Ay;exports.rectsIntersect=Ty;exports.useAuth=df;exports.useMutation=bf;exports.useNodeDrag=kd;exports.useQuery=hu;exports.useSelection=Ed;exports.useZoomPan=Sd;
188
+ `:void 0;return h.jsxs("div",{ref:W,className:`qmap-container ${M}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:T,backgroundImage:Ue,backgroundSize:B?`${R}px ${R}px`:void 0,cursor:te?"crosshair":E?"grab":"default",...N},onMouseDown:O,onClick:V,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(Nd,{edges:t,nodePositions:Le,defaultStyle:b,defaultColor:_,defaultWidth:S,onEdgeClick:f}),e.map(se=>{const re=Re(se._id),oe=Z.has(se._id),z=we===se._id;return h.jsx(Dd,{nodeId:se._id,position:re,isSelected:oe,isDragging:z,draggable:D,onDragStart:xe,onClick:de=>qe(se,de),onDoubleClick:de=>l==null?void 0:l(se,de),onContextMenu:de=>u==null?void 0:u(se,de),nodeRef:de=>{de?ge.current.set(se._id,de):ge.current.delete(se._id)},children:n(se,oe,re)},se._id)})]}),be&&h.jsx(Bd,{box:be,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:q,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:ne,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=Sg;exports.AnimatedCardFlip=Sf;exports.ApiClient=au;exports.AudioEditor=Xc;exports.AuthFlow=fu;exports.AuthFlowModal=xf;exports.AuthManager=nt;exports.AuthProvider=cf;exports.AuthService=Ao;exports.Card=_f;exports.ComboBox=Rg;exports.ComboStack=Lg;exports.DataOperations=vs;exports.Detail=wf;exports.ForgotPasswordForm=cu;exports.GraphClient=Pd;exports.ImageEditor=Yg;exports.KanbanBoard=Pg;exports.LLMClient=nf;exports.LoginForm=No;exports.LoginModal=hf;exports.Mail=Ef;exports.MailClient=iu;exports.MailComposer=jg;exports.MailEditor=Gc;exports.NetflixCard=Yc;exports.NetflixDetail=Jc;exports.NetflixLane=Qc;exports.NetflixStack=qg;exports.QMap=$y;exports.QMapEdgeComponent=Td;exports.QMapEdgeLayer=Nd;exports.QMapNode=Dd;exports.QMapSelectionBox=Bd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Df;exports.Stack=vf;exports.TTS_VOICES=ou;exports.Timeline=Gg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Kg;exports.calculateBoundingBox=Ny;exports.calculateEdgePath=Ad;exports.distance=By;exports.distanceSquared=jy;exports.getApiClient=To;exports.getAuthService=of;exports.getConnectionPoint=Ey;exports.getNodeCenter=ga;exports.getNodeSidePoint=Dy;exports.initializeApiClient=af;exports.initializeAuthService=sf;exports.pointInRect=Ay;exports.rectsIntersect=Ty;exports.useAuth=df;exports.useMutation=bf;exports.useNodeDrag=kd;exports.useQuery=hu;exports.useSelection=Ed;exports.useZoomPan=Sd;