authorly-editor 0.1.4 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,18 +1,25 @@
1
- "use strict";var Mo=Object.defineProperty;var To=(e,t,n)=>t in e?Mo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Re=(e,t,n)=>To(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("react"),No=require("react-dom");function F(){return`cb-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,9)}`}function _e(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>_e(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=_e(e[n]));return t}function Gt(e,t){let n;return function(...o){clearTimeout(n),n=setTimeout(()=>e(...o),t)}}function Bo(e,t){let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>n=!1,t))}}function $o(e){return e.hasAttribute("data-block-id")}function ye(e){if(!e)return null;let t=e;for(;t;){if(t instanceof HTMLElement&&t.hasAttribute("data-block-id"))return t;t=t.parentNode}return null}function Ho(e){return e.textContent||""}function Xt(e){return e.trim().split(/\s+/).filter(t=>t.length>0).length}function Zt(e,t=!0){return t?e.length:e.replace(/\s/g,"").length}function qo(){const e=window.getSelection();return e?e.isCollapsed:!0}function Jt(){const e=window.getSelection();return e&&e.rangeCount>0?e.getRangeAt(0):null}function Qt(e){const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}function jo(){var e;return((e=Jt())==null?void 0:e.cloneRange())||null}function Ro(e){e&&Qt(e)}function Do(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!1),n&&(n.removeAllRanges(),n.addRange(t))}function Io(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!0),n&&(n.removeAllRanges(),n.addRange(t))}function zo(e){return(e.textContent||"").trim().length===0&&!e.querySelector("img, video, iframe")}function en(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""}function tn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ye=new Map;function Po(e){const t=tn(en(e));if(!t)return"heading";const n=Ye.get(t)||0;return Ye.set(t,n+1),n===0?t:`${t}-${n}`}function Oo(){Ye.clear()}function Fo(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Uo(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function Vo(e){return e.outerHTML}function Wo(e){const t=e.parentElement;return t?Array.from(t.children).indexOf(e):-1}function Pe(e,t){const n=t.parentElement;n&&n.insertBefore(e,t.nextSibling)}function nn(e,t){const n=t.parentElement;n&&n.insertBefore(e,t)}function _o(e,t){var c;const n=e.parentNode,o=e.nextSibling===t?e:e.nextSibling;(c=t.parentNode)==null||c.insertBefore(e,t),n==null||n.insertBefore(t,o)}function Yo(e,t){const n=t.toLowerCase().split("+"),o=n.pop(),c={ctrl:n.includes("ctrl")||n.includes("cmd"),shift:n.includes("shift"),alt:n.includes("alt")},r=e.ctrlKey||e.metaKey;return e.key.toLowerCase()===o&&r===c.ctrl&&e.shiftKey===c.shift&&e.altKey===c.alt}function Ko(e,t,n){const o=document.createElement(e);if(t)for(const[c,r]of Object.entries(t))o.setAttribute(c,r);if(n)for(const c of n)typeof c=="string"?o.appendChild(document.createTextNode(c)):o.appendChild(c);return o}function Go(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function Xo(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function Zo(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Jo(e){return requestAnimationFrame(e)}function Qo(e){cancelAnimationFrame(e)}const ec={get(e,t){try{const n=localStorage.getItem(e);return n?JSON.parse(n):t}catch{return t}},set(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}};class tc{constructor(){Re(this,"listeners",new Map)}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){var o;(o=this.listeners.get(t))==null||o.delete(n)}emit(t,n){var o;(o=this.listeners.get(t))==null||o.forEach(c=>c(n))}removeAllListeners(){this.listeners.clear()}}class on{constructor(){Re(this,"blocks",new Map);Re(this,"defaultBlock","paragraph")}register(t){this.blocks.set(t.name,t)}unregister(t){this.blocks.delete(t)}get(t){return this.blocks.get(t)}has(t){return this.blocks.has(t)}getAll(){return Array.from(this.blocks.values())}getNames(){return Array.from(this.blocks.keys())}setDefaultBlock(t){this.has(t)&&(this.defaultBlock=t)}getDefaultBlock(){return this.defaultBlock}createBlock(t,n){const o=this.get(t);if(!o)return console.warn(`Block type "${t}" is not registered`),null;const c={id:F(),type:t,...n},r=o.create(c);return r.setAttribute("data-block-id",c.id),r.setAttribute("data-block-type",t),r}getBlockType(t){return t.getAttribute("data-block-type")}getBlockData(t){const n=this.getBlockType(t);if(!n)return null;const o=this.get(n);return o?o.getData(t):null}updateBlock(t,n){const o=this.getBlockType(t);if(!o)return;const c=this.get(o);c&&c.update(t,n)}transformBlock(t,n){const o=this.getBlockType(t);if(!o||o===n)return t;const c=this.get(o),r=this.get(n);if(!c||!r)return null;const i=t.innerHTML,a=t.getAttribute("data-block-id")||F(),d=this.createBlock(n,{id:a});if(!d)return null;if(r.editable){const w=d.querySelector('[contenteditable="true"]')||d;w instanceof HTMLElement&&(w.innerHTML=i)}return d}}const de=new on,ct={name:"paragraph",tag:"p",editable:!0,allowedChildren:["text","inline"],className:"cb-paragraph",icon:"paragraph",label:"Paragraph",shortcut:"Ctrl+0",create(e){const t=document.createElement("p");return t.className="cb-paragraph",t.setAttribute("contenteditable","true"),t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","paragraph"),e!=null&&e.content&&(t.innerHTML=e.content),e!=null&&e.align&&(t.style.textAlign=e.align),e!=null&&e.className&&(t.className=`cb-paragraph ${e.className}`),e!=null&&e.content||t.setAttribute("data-placeholder","Type something..."),t},getData(e){return{id:e.getAttribute("data-block-id")||F(),type:"paragraph",content:e.innerHTML,align:e.style.textAlign,className:e.className}},update(e,t){t.content!==void 0&&(e.innerHTML=t.content),t.align&&(e.style.textAlign=t.align),t.className&&(e.className=`cb-paragraph ${t.className}`)}};function we(e){return{name:"heading",tag:`h${e}`,editable:!0,allowedChildren:["text","inline"],className:`cb-heading cb-h${e}`,icon:`heading${e}`,label:e===1?"Title":`Heading ${e}`,shortcut:`Ctrl+${e}`,create(t){const n=(t==null?void 0:t.level)||e,o=`h${n}`,c=document.createElement(o);return c.className=`cb-heading cb-h${n}`,c.setAttribute("contenteditable","true"),c.setAttribute("data-block-id",(t==null?void 0:t.id)||F()),c.setAttribute("data-block-type","heading"),c.setAttribute("data-heading-level",String(n)),t!=null&&t.content&&(c.innerHTML=t.content),t!=null&&t.align&&(c.style.textAlign=t.align),t!=null&&t.content||c.setAttribute("data-placeholder",n===1?"Title":`Heading ${n}`),c},getData(t){const n=t.getAttribute("data-heading-level");return{id:t.getAttribute("data-block-id")||F(),type:"heading",level:n?parseInt(n,10):e,content:t.innerHTML,align:t.style.textAlign}},update(t,n){n.content!==void 0&&(t.innerHTML=n.content),n.align&&(t.style.textAlign=n.align),n.level&&n.level!==e&&t.setAttribute("data-heading-level",String(n.level))}}}const rt=we(1),lt=we(2),it=we(3),cn=we(4),rn=we(5),ln=we(6);function nc(e,t){return we(e).create({...t,level:e,type:"heading"})}function Be(e,t){const n=document.createElement("li");if(n.className="cb-list-item",n.setAttribute("data-item-id",e.id),t==="checkList"){const o=document.createElement("div");o.className="cb-checklist-wrapper";const c=document.createElement("input");c.type="checkbox",c.className="cb-checkbox",c.checked=e.checked||!1,c.setAttribute("tabindex","-1");const r=document.createElement("span");r.className="cb-checklist-content",r.setAttribute("contenteditable","true"),r.innerHTML=e.content,o.appendChild(c),o.appendChild(r),n.appendChild(o),e.checked&&n.classList.add("cb-checked")}else n.setAttribute("contenteditable","true"),n.innerHTML=e.content;if(e.children&&e.children.length>0){const o=document.createElement(t==="numberedList"?"ol":"ul");o.className=`cb-nested-list cb-${t}`,e.children.forEach(c=>{o.appendChild(Be(c,t))}),n.appendChild(o)}return n}function an(e,t){const n=[];return e.querySelectorAll(":scope > li").forEach(o=>{const c={id:o.getAttribute("data-item-id")||F(),content:"",checked:!1,children:[]};if(t==="checkList"){const i=o.querySelector(".cb-checkbox"),a=o.querySelector(".cb-checklist-content");c.checked=(i==null?void 0:i.checked)||!1,c.content=(a==null?void 0:a.innerHTML)||""}else{const i=o.cloneNode(!0),a=i.querySelector("ul, ol");a&&a.remove(),c.content=i.innerHTML}const r=o.querySelector(":scope > ul, :scope > ol");r&&(c.children=an(r,t)),n.push(c)}),n}function at(e){const t=e==="numberedList"?"ol":"ul";return{name:e,tag:t,editable:!0,allowedChildren:["text","inline","block"],className:`cb-list cb-${e}`,icon:e==="bulletList"?"list":e==="numberedList"?"listOrdered":"checkList",label:e==="bulletList"?"Bullet List":e==="numberedList"?"Numbered List":"Checklist",shortcut:e==="bulletList"?"Ctrl+Shift+8":e==="numberedList"?"Ctrl+Shift+7":void 0,create(o){const c=document.createElement(t);if(c.className=`cb-list cb-${e}`,c.setAttribute("data-block-id",(o==null?void 0:o.id)||F()),c.setAttribute("data-block-type",e),o!=null&&o.items&&o.items.length>0)o.items.forEach(r=>{c.appendChild(Be(r,e))});else{const r={id:F(),content:"",checked:!1};c.appendChild(Be(r,e))}return c},getData(o){return{id:o.getAttribute("data-block-id")||F(),type:e,items:an(o,e)}},update(o,c){c.items&&(o.innerHTML="",c.items.forEach(r=>{o.appendChild(Be(r,e))}))}}}const st=at("bulletList"),dt=at("numberedList"),sn=at("checkList");function oc(e,t,n=""){const o=e.getAttribute("data-block-type"),c={id:F(),content:n,checked:!1},r=Be(c,o);if(t){const a=e.querySelector(`[data-item-id="${t}"]`);a&&a.parentElement===e?a.after(r):e.appendChild(r)}else e.appendChild(r);const i=o==="checkList"?r.querySelector(".cb-checklist-content"):r;return i instanceof HTMLElement&&i.focus(),c}function cc(e,t){const n=e.querySelector(`[data-item-id="${t}"]`);if(!n)return!1;if(e.querySelectorAll(":scope > li").length<=1){const c=n.querySelector(".cb-checklist-content")||n;return c instanceof HTMLElement&&(c.innerHTML=""),!1}return n.remove(),!0}function rc(e){const t=e.querySelector(".cb-checkbox");return t?(t.checked=!t.checked,e.classList.toggle("cb-checked",t.checked),t.checked):!1}function lc(e){const t=e.previousElementSibling;if(!t)return!1;const n=e.parentElement;if(!n)return!1;const o=n.getAttribute("data-block-type"),c=o==="numberedList"?"ol":"ul";let r=t.querySelector(`:scope > ${c}`);return r||(r=document.createElement(c),r.className=`cb-nested-list cb-${o}`,t.appendChild(r)),r.appendChild(e),!0}function ic(e){const t=e.parentElement;if(!t||!t.classList.contains("cb-nested-list"))return!1;const n=t.parentElement;if(!n)return!1;const o=n.parentElement;return o?(o.insertBefore(e,n.nextSibling),t.children.length===0&&t.remove(),!0):!1}const ut={name:"quote",tag:"blockquote",editable:!0,allowedChildren:["text","inline"],className:"cb-quote",icon:"quote",label:"Quote",shortcut:"Ctrl+Shift+.",create(e){const t=document.createElement("blockquote");t.className="cb-quote",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","quote");const n=document.createElement("p");if(n.className="cb-quote-content",n.setAttribute("contenteditable","true"),e!=null&&e.content?n.innerHTML=e.content:n.setAttribute("data-placeholder","Type a quote..."),t.appendChild(n),e!=null&&e.citation){const o=document.createElement("cite");o.className="cb-quote-citation",o.setAttribute("contenteditable","true"),o.textContent=e.citation,t.appendChild(o)}return t},getData(e){const t=e.querySelector(".cb-quote-content"),n=e.querySelector(".cb-quote-citation");return{id:e.getAttribute("data-block-id")||F(),type:"quote",content:(t==null?void 0:t.innerHTML)||e.innerHTML,citation:(n==null?void 0:n.textContent)||void 0}},update(e,t){if(t.content!==void 0){const n=e.querySelector(".cb-quote-content");n&&(n.innerHTML=t.content)}if(t.citation!==void 0){let n=e.querySelector(".cb-quote-citation");t.citation?(n||(n=document.createElement("cite"),n.className="cb-quote-citation",n.setAttribute("contenteditable","true"),e.appendChild(n)),n.textContent=t.citation):n&&n.remove()}}};function ac(e,t){let n=e.querySelector(".cb-quote-citation");n||(n=document.createElement("cite"),n.className="cb-quote-citation",n.setAttribute("contenteditable","true"),e.appendChild(n)),n.textContent=t}function sc(e){const t=e.querySelector(".cb-quote-citation");t&&t.remove()}const dn=[{value:"plaintext",label:"Plain Text"},{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"csharp",label:"C#"},{value:"cpp",label:"C++"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"php",label:"PHP"},{value:"ruby",label:"Ruby"},{value:"swift",label:"Swift"},{value:"kotlin",label:"Kotlin"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"scss",label:"SCSS"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"xml",label:"XML"},{value:"markdown",label:"Markdown"},{value:"sql",label:"SQL"},{value:"bash",label:"Bash"},{value:"shell",label:"Shell"},{value:"dockerfile",label:"Dockerfile"}],pt={name:"code",tag:"pre",editable:!0,allowedChildren:["text"],className:"cb-code-block",icon:"code",label:"Code Block",shortcut:"Ctrl+Shift+C",create(e){const t=document.createElement("div");t.className="cb-code-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","code");const n=document.createElement("div");n.className="cb-code-toolbar";const o=document.createElement("select");o.className="cb-code-language",o.setAttribute("tabindex","-1"),dn.forEach(a=>{const d=document.createElement("option");d.value=a.value,d.textContent=a.label,(e==null?void 0:e.language)===a.value&&(d.selected=!0),o.appendChild(d)});const c=document.createElement("button");c.type="button",c.className="cb-code-copy",c.setAttribute("tabindex","-1"),c.innerHTML='<span class="cb-copy-text">Copy</span>',c.onclick=()=>{const a=t.querySelector("code");a&&(navigator.clipboard.writeText(a.textContent||""),c.innerHTML='<span class="cb-copy-text">Copied!</span>',setTimeout(()=>{c.innerHTML='<span class="cb-copy-text">Copy</span>'},2e3))},n.appendChild(o),n.appendChild(c);const r=document.createElement("pre");r.className="cb-code-block";const i=document.createElement("code");return i.className=`cb-code language-${(e==null?void 0:e.language)||"plaintext"}`,i.setAttribute("contenteditable","true"),i.setAttribute("spellcheck","false"),i.setAttribute("data-placeholder","Write your code here..."),e!=null&&e.content&&(i.textContent=e.content),o.onchange=()=>{i.className=`cb-code language-${o.value}`,t.setAttribute("data-language",o.value)},r.appendChild(i),t.appendChild(n),t.appendChild(r),e!=null&&e.language&&t.setAttribute("data-language",e.language),t},getData(e){const t=e.querySelector("code"),n=e.querySelector(".cb-code-language");return{id:e.getAttribute("data-block-id")||F(),type:"code",content:(t==null?void 0:t.textContent)||"",language:(n==null?void 0:n.value)||e.getAttribute("data-language")||"plaintext"}},update(e,t){if(t.content!==void 0){const n=e.querySelector("code");n&&(n.textContent=t.content)}if(t.language){const n=e.querySelector("code"),o=e.querySelector(".cb-code-language");n&&(n.className=`cb-code language-${t.language}`),o&&(o.value=t.language),e.setAttribute("data-language",t.language)}}};function dc(e,t){const n=e.querySelector("code"),o=e.querySelector(".cb-code-language");n&&(n.className=`cb-code language-${t}`),o&&(o.value=t),e.setAttribute("data-language",t)}function uc(e){const t=e.querySelector("code");return(t==null?void 0:t.textContent)||""}function un(e){["se","sw","ne","nw","e","w"].forEach(n=>{const o=document.createElement("div");o.className=`cb-image-resize-handle handle-${n}`,o.setAttribute("data-handle",n),e.appendChild(o)})}const ht={name:"image",tag:"figure",editable:!1,allowedChildren:[],className:"cb-image",icon:"image",label:"Image",create(e){const t=document.createElement("figure");t.className="cb-image",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","image");const n=document.createElement("div");if(n.className="cb-image-container",e!=null&&e.src){const c=document.createElement("div");c.className="cb-image-resizable";const r=document.createElement("img");r.className="cb-image-element",r.src=e.src,r.alt=e.alt||"",e.width&&(r.style.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height&&(r.style.height=typeof e.height=="number"?`${e.height}px`:e.height),c.appendChild(r),un(c),n.appendChild(c)}else{const c=document.createElement("div");c.className="cb-image-placeholder",c.innerHTML=`
1
+ "use strict";var Eo=Object.defineProperty;var Ao=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tt=(e,t,n)=>Ao(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),m=require("react"),Ze=require("react-dom"),u=require("lucide-react"),Qt=require("@excalidraw/excalidraw");function le(){return`cb-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,9)}`}function vt(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>vt(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=vt(e[n]));return t}function yt(e,t){let n;const o=function(...r){clearTimeout(n),n=setTimeout(()=>e(...r),t)};return o.cancel=function(){clearTimeout(n)},o}function No(e,t){let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>n=!1,t))}}function To(e){return e.hasAttribute("data-block-id")}function Ue(e){if(!e)return null;let t=e;for(;t;){if(t instanceof HTMLElement&&t.hasAttribute("data-block-id"))return t;t=t.parentNode}return null}function Lo(e){return e.textContent||""}function on(e){return e.trim().split(/\s+/).filter(t=>t.length>0).length}function cn(e,t=!0){return t?e.length:e.replace(/\s/g,"").length}function jo(){const e=window.getSelection();return e?e.isCollapsed:!0}function rn(){const e=window.getSelection();return e&&e.rangeCount>0?e.getRangeAt(0):null}function ln(e){const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}function Mo(){var e;return((e=rn())==null?void 0:e.cloneRange())||null}function Do(e){e&&ln(e)}function Bo(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!1),n&&(n.removeAllRanges(),n.addRange(t))}function Ro(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!0),n&&(n.removeAllRanges(),n.addRange(t))}function $o(e){return(e.textContent||"").trim().length===0&&!e.querySelector("img, video, iframe")}function an(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""}function sn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const kt=new Map;function Ho(e){const t=sn(an(e));if(!t)return"heading";const n=kt.get(t)||0;return kt.set(t,n+1),n===0?t:`${t}-${n}`}function qo(){kt.clear()}function Io(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function zo(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function Po(e){return e.outerHTML}function Fo(e){const t=e.parentElement;return t?Array.from(t.children).indexOf(e):-1}function lt(e,t){const n=t.parentElement;n&&n.insertBefore(e,t.nextSibling)}function dn(e,t){const n=t.parentElement;n&&n.insertBefore(e,t)}function Oo(e,t){var r;const n=e.parentNode,o=e.nextSibling===t?e:e.nextSibling;(r=t.parentNode)==null||r.insertBefore(e,t),n==null||n.insertBefore(t,o)}function Uo(e,t){const n=t.toLowerCase().split("+"),o=n.pop(),r={ctrl:n.includes("ctrl")||n.includes("cmd"),shift:n.includes("shift"),alt:n.includes("alt")},a=e.ctrlKey||e.metaKey;return e.key.toLowerCase()===o&&a===r.ctrl&&e.shiftKey===r.shift&&e.altKey===r.alt}function Wo(e,t,n){const o=document.createElement(e);if(t)for(const[r,a]of Object.entries(t))o.setAttribute(r,a);if(n)for(const r of n)typeof r=="string"?o.appendChild(document.createTextNode(r)):o.appendChild(r);return o}function Xo(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function _o(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function Ko(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Yo(e){return requestAnimationFrame(e)}function Vo(e){cancelAnimationFrame(e)}const Jo={get(e,t){try{const n=localStorage.getItem(e);return n?JSON.parse(n):t}catch{return t}},set(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}};class Go{constructor(){tt(this,"listeners",new Map)}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){var o;(o=this.listeners.get(t))==null||o.delete(n)}emit(t,n){var o;(o=this.listeners.get(t))==null||o.forEach(r=>r(n))}removeAllListeners(){this.listeners.clear()}}class un{constructor(){tt(this,"blocks",new Map);tt(this,"defaultBlock","paragraph")}register(t){this.blocks.set(t.name,t)}unregister(t){this.blocks.delete(t)}get(t){return this.blocks.get(t)}has(t){return this.blocks.has(t)}getAll(){return Array.from(this.blocks.values())}getNames(){return Array.from(this.blocks.keys())}setDefaultBlock(t){this.has(t)&&(this.defaultBlock=t)}getDefaultBlock(){return this.defaultBlock}createBlock(t,n){const o=this.get(t);if(!o)return console.warn(`Block type "${t}" is not registered`),null;const r={id:le(),type:t,...n},a=o.create(r);return a.setAttribute("data-block-id",r.id),a.setAttribute("data-block-type",t),a}getBlockType(t){return t.getAttribute("data-block-type")}getBlockData(t){const n=this.getBlockType(t);if(!n)return null;const o=this.get(n);return o?o.getData(t):null}updateBlock(t,n){const o=this.getBlockType(t);if(!o)return;const r=this.get(o);r&&r.update(t,n)}transformBlock(t,n){const o=this.getBlockType(t);if(!o||o===n)return t;const r=this.get(o),a=this.get(n);if(!r||!a)return null;const s=t.innerHTML,d=t.getAttribute("data-block-id")||le(),w=this.createBlock(n,{id:d});if(!w)return null;if(a.editable){const H=w.querySelector('[contenteditable="true"]')||w;H instanceof HTMLElement&&(H.innerHTML=s)}return w}}const Re=new un,Mt={name:"paragraph",tag:"p",editable:!0,allowedChildren:["text","inline"],className:"cb-paragraph",icon:"paragraph",label:"Paragraph",shortcut:"Ctrl+0",create(e){const t=document.createElement("p");return t.className="cb-paragraph",t.setAttribute("contenteditable","true"),t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","paragraph"),e!=null&&e.content&&(t.innerHTML=e.content),e!=null&&e.align&&(t.style.textAlign=e.align),e!=null&&e.className&&(t.className=`cb-paragraph ${e.className}`),e!=null&&e.content||t.setAttribute("data-placeholder","Type something..."),t},getData(e){return{id:e.getAttribute("data-block-id")||le(),type:"paragraph",content:e.innerHTML,align:e.style.textAlign,className:e.className}},update(e,t){t.content!==void 0&&(e.innerHTML=t.content),t.align&&(e.style.textAlign=t.align),t.className&&(e.className=`cb-paragraph ${t.className}`)}};function Ke(e){return{name:"heading",tag:`h${e}`,editable:!0,allowedChildren:["text","inline"],className:`cb-heading cb-h${e}`,icon:`heading${e}`,label:e===1?"Title":`Heading ${e}`,shortcut:`Ctrl+${e}`,create(t){const n=(t==null?void 0:t.level)||e,o=`h${n}`,r=document.createElement(o);return r.className=`cb-heading cb-h${n}`,r.setAttribute("contenteditable","true"),r.setAttribute("data-block-id",(t==null?void 0:t.id)||le()),r.setAttribute("data-block-type","heading"),r.setAttribute("data-heading-level",String(n)),t!=null&&t.content&&(r.innerHTML=t.content),t!=null&&t.align&&(r.style.textAlign=t.align),t!=null&&t.content||r.setAttribute("data-placeholder",n===1?"Title":`Heading ${n}`),r},getData(t){const n=t.getAttribute("data-heading-level");return{id:t.getAttribute("data-block-id")||le(),type:"heading",level:n?parseInt(n,10):e,content:t.innerHTML,align:t.style.textAlign}},update(t,n){n.content!==void 0&&(t.innerHTML=n.content),n.align&&(t.style.textAlign=n.align),n.level&&n.level!==e&&t.setAttribute("data-heading-level",String(n.level))}}}const Dt=Ke(1),Bt=Ke(2),Rt=Ke(3),bn=Ke(4),pn=Ke(5),mn=Ke(6);function Qo(e,t){return Ke(e).create({...t,level:e,type:"heading"})}function et(e,t){const n=document.createElement("li");if(n.className="cb-list-item",n.setAttribute("data-item-id",e.id),t==="checkList"){const o=document.createElement("div");o.className="cb-checklist-wrapper";const r=document.createElement("input");r.type="checkbox",r.className="cb-checkbox",r.checked=e.checked||!1,r.setAttribute("tabindex","-1");const a=document.createElement("span");a.className="cb-checklist-content",a.setAttribute("contenteditable","true"),a.innerHTML=e.content,o.appendChild(r),o.appendChild(a),n.appendChild(o),e.checked&&n.classList.add("cb-checked")}else n.setAttribute("contenteditable","true"),n.innerHTML=e.content;if(e.children&&e.children.length>0){const o=document.createElement(t==="numberedList"?"ol":"ul");o.className=`cb-nested-list cb-${t}`,e.children.forEach(r=>{o.appendChild(et(r,t))}),n.appendChild(o)}return n}function gn(e,t){const n=[];return e.querySelectorAll(":scope > li").forEach(o=>{const r={id:o.getAttribute("data-item-id")||le(),content:"",checked:!1,children:[]};if(t==="checkList"){const s=o.querySelector(".cb-checkbox"),d=o.querySelector(".cb-checklist-content");r.checked=(s==null?void 0:s.checked)||!1,r.content=(d==null?void 0:d.innerHTML)||""}else{const s=o.cloneNode(!0),d=s.querySelector("ul, ol");d&&d.remove(),r.content=s.innerHTML}const a=o.querySelector(":scope > ul, :scope > ol");a&&(r.children=gn(a,t)),n.push(r)}),n}function $t(e){const t=e==="numberedList"?"ol":"ul";return{name:e,tag:t,editable:!0,allowedChildren:["text","inline","block"],className:`cb-list cb-${e}`,icon:e==="bulletList"?"list":e==="numberedList"?"listOrdered":"checkList",label:e==="bulletList"?"Bullet List":e==="numberedList"?"Numbered List":"Checklist",shortcut:e==="bulletList"?"Ctrl+Shift+8":e==="numberedList"?"Ctrl+Shift+7":void 0,create(o){const r=document.createElement(t);if(r.className=`cb-list cb-${e}`,r.setAttribute("data-block-id",(o==null?void 0:o.id)||le()),r.setAttribute("data-block-type",e),o!=null&&o.items&&o.items.length>0)o.items.forEach(a=>{r.appendChild(et(a,e))});else{const a={id:le(),content:(o==null?void 0:o.content)||"",checked:!1};r.appendChild(et(a,e))}return r},getData(o){return{id:o.getAttribute("data-block-id")||le(),type:e,items:gn(o,e)}},update(o,r){r.items&&(o.innerHTML="",r.items.forEach(a=>{o.appendChild(et(a,e))}))}}}const Ht=$t("bulletList"),qt=$t("numberedList"),fn=$t("checkList");function Zo(e,t,n=""){const o=e.getAttribute("data-block-type"),r={id:le(),content:n,checked:!1},a=et(r,o);if(t){const d=e.querySelector(`[data-item-id="${t}"]`);d&&d.parentElement===e?d.after(a):e.appendChild(a)}else e.appendChild(a);const s=o==="checkList"?a.querySelector(".cb-checklist-content"):a;return s instanceof HTMLElement&&s.focus(),r}function ec(e,t){const n=e.querySelector(`[data-item-id="${t}"]`);if(!n)return!1;if(e.querySelectorAll(":scope > li").length<=1){const r=n.querySelector(".cb-checklist-content")||n;return r instanceof HTMLElement&&(r.innerHTML=""),!1}return n.remove(),!0}function tc(e){const t=e.querySelector(".cb-checkbox");return t?(t.checked=!t.checked,e.classList.toggle("cb-checked",t.checked),t.checked):!1}function nc(e){const t=e.previousElementSibling;if(!t)return!1;const n=e.parentElement;if(!n)return!1;const o=n.getAttribute("data-block-type"),r=o==="numberedList"?"ol":"ul";let a=t.querySelector(`:scope > ${r}`);return a||(a=document.createElement(r),a.className=`cb-nested-list cb-${o}`,t.appendChild(a)),a.appendChild(e),!0}function oc(e){const t=e.parentElement;if(!t||!t.classList.contains("cb-nested-list"))return!1;const n=t.parentElement;if(!n)return!1;const o=n.parentElement;return o?(o.insertBefore(e,n.nextSibling),t.children.length===0&&t.remove(),!0):!1}const It={name:"quote",tag:"blockquote",editable:!0,allowedChildren:["text","inline"],className:"cb-quote",icon:"quote",label:"Quote",shortcut:"Ctrl+Shift+.",create(e){const t=document.createElement("blockquote");t.className="cb-quote",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","quote");const n=document.createElement("p");if(n.className="cb-quote-content",n.setAttribute("contenteditable","true"),e!=null&&e.content?n.innerHTML=e.content:n.setAttribute("data-placeholder","Type a quote..."),t.appendChild(n),e!=null&&e.citation){const o=document.createElement("cite");o.className="cb-quote-citation",o.setAttribute("contenteditable","true"),o.textContent=e.citation,t.appendChild(o)}return t},getData(e){const t=e.querySelector(".cb-quote-content"),n=e.querySelector(".cb-quote-citation");return{id:e.getAttribute("data-block-id")||le(),type:"quote",content:(t==null?void 0:t.innerHTML)||e.innerHTML,citation:(n==null?void 0:n.textContent)||void 0}},update(e,t){if(t.content!==void 0){const n=e.querySelector(".cb-quote-content");n&&(n.innerHTML=t.content)}if(t.citation!==void 0){let n=e.querySelector(".cb-quote-citation");t.citation?(n||(n=document.createElement("cite"),n.className="cb-quote-citation",n.setAttribute("contenteditable","true"),e.appendChild(n)),n.textContent=t.citation):n&&n.remove()}}};function cc(e,t){let n=e.querySelector(".cb-quote-citation");n||(n=document.createElement("cite"),n.className="cb-quote-citation",n.setAttribute("contenteditable","true"),e.appendChild(n)),n.textContent=t}function rc(e){const t=e.querySelector(".cb-quote-citation");t&&t.remove()}const hn=[{value:"plaintext",label:"Plain Text"},{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"csharp",label:"C#"},{value:"cpp",label:"C++"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"php",label:"PHP"},{value:"ruby",label:"Ruby"},{value:"swift",label:"Swift"},{value:"kotlin",label:"Kotlin"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"scss",label:"SCSS"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"xml",label:"XML"},{value:"markdown",label:"Markdown"},{value:"sql",label:"SQL"},{value:"bash",label:"Bash"},{value:"shell",label:"Shell"},{value:"dockerfile",label:"Dockerfile"}],zt={name:"code",tag:"pre",editable:!0,allowedChildren:["text"],className:"cb-code-block",icon:"code",label:"Code Block",shortcut:"Ctrl+Shift+C",create(e){const t=document.createElement("div");t.className="cb-code-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","code");const n=document.createElement("div");n.className="cb-code-toolbar";const o=document.createElement("select");o.className="cb-code-language",o.setAttribute("tabindex","-1"),hn.forEach(d=>{const w=document.createElement("option");w.value=d.value,w.textContent=d.label,(e==null?void 0:e.language)===d.value&&(w.selected=!0),o.appendChild(w)});const r=document.createElement("button");r.type="button",r.className="cb-code-copy",r.setAttribute("tabindex","-1"),r.innerHTML='<span class="cb-copy-text">Copy</span>',r.onclick=()=>{const d=t.querySelector("code");d&&(navigator.clipboard.writeText(d.textContent||""),r.innerHTML='<span class="cb-copy-text">Copied!</span>',setTimeout(()=>{r.innerHTML='<span class="cb-copy-text">Copy</span>'},2e3))},n.appendChild(o),n.appendChild(r);const a=document.createElement("pre");a.className="cb-code-block";const s=document.createElement("code");return s.className=`cb-code language-${(e==null?void 0:e.language)||"plaintext"}`,s.setAttribute("contenteditable","true"),s.setAttribute("spellcheck","false"),s.setAttribute("data-placeholder","Write your code here..."),e!=null&&e.content&&(s.textContent=e.content),o.onchange=()=>{s.className=`cb-code language-${o.value}`,t.setAttribute("data-language",o.value)},a.appendChild(s),t.appendChild(n),t.appendChild(a),e!=null&&e.language&&t.setAttribute("data-language",e.language),t},getData(e){const t=e.querySelector("code"),n=e.querySelector(".cb-code-language");return{id:e.getAttribute("data-block-id")||le(),type:"code",content:(t==null?void 0:t.textContent)||"",language:(n==null?void 0:n.value)||e.getAttribute("data-language")||"plaintext"}},update(e,t){if(t.content!==void 0){const n=e.querySelector("code");n&&(n.textContent=t.content)}if(t.language){const n=e.querySelector("code"),o=e.querySelector(".cb-code-language");n&&(n.className=`cb-code language-${t.language}`),o&&(o.value=t.language),e.setAttribute("data-language",t.language)}}};function lc(e,t){const n=e.querySelector("code"),o=e.querySelector(".cb-code-language");n&&(n.className=`cb-code language-${t}`),o&&(o.value=t),e.setAttribute("data-language",t)}function ac(e){const t=e.querySelector("code");return(t==null?void 0:t.textContent)||""}function vn(e){["se","sw","ne","nw","e","w"].forEach(n=>{const o=document.createElement("div");o.className=`cb-image-resize-handle handle-${n}`,o.setAttribute("data-handle",n),e.appendChild(o)})}const Pt={name:"image",tag:"figure",editable:!1,allowedChildren:[],className:"cb-image",icon:"image",label:"Image",create(e){const t=document.createElement("figure");t.className="cb-image",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","image");const n=document.createElement("div");if(n.className="cb-image-container",e!=null&&e.src){const r=document.createElement("div");r.className="cb-image-resizable";const a=document.createElement("img");a.className="cb-image-element",a.src=e.src,a.alt=e.alt||"",e.width&&(a.style.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height&&(a.style.height=typeof e.height=="number"?`${e.height}px`:e.height),r.appendChild(a),vn(r),n.appendChild(r)}else{const r=document.createElement("div");r.className="cb-image-placeholder",r.innerHTML=`
2
2
  <div class="cb-image-placeholder-content">
3
- <svg width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
4
- <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
5
- <circle cx="9" cy="9" r="2"/>
6
- <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>
7
- </svg>
8
- <span>Drop an image here, or click to upload</span>
9
- <span class="cb-image-placeholder-hint">Supports JPG, PNG, GIF, WebP up to 10MB</span>
3
+ <div class="cb-image-placeholder-icon">
4
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
5
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
6
+ <circle cx="9" cy="9" r="2"/>
7
+ <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>
8
+ </svg>
9
+ </div>
10
+ <div class="cb-image-placeholder-text">
11
+ <span class="cb-image-placeholder-title">Click to upload or drag image</span>
12
+ <span class="cb-image-placeholder-hint">JPG, PNG, GIF, WebP • Max 10MB</span>
13
+ </div>
10
14
  <input type="file" accept="image/*" class="cb-image-input" />
11
15
  </div>
12
- <div class="cb-image-url-wrapper">
13
- <input type="text" class="cb-image-url-input" placeholder="Paste image URL and press Enter" />
16
+ <div class="cb-image-url-divider">
17
+ <span>or</span>
18
+ </div>
19
+ <div class="cb-image-url-wrapper" contenteditable="false">
20
+ <input type="url" class="cb-image-url-input" placeholder="Paste image URL and press Enter" />
14
21
  </div>
15
- `,n.appendChild(c)}if(t.appendChild(n),e!=null&&e.src){const c=document.createElement("div");c.className="cb-image-controls",c.innerHTML=`
22
+ `,n.appendChild(r)}if(t.appendChild(n),e!=null&&e.src){const r=document.createElement("div");r.className="cb-image-controls",r.innerHTML=`
16
23
  <button type="button" class="cb-image-align" data-align="left" title="Align left">
17
24
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
18
25
  <line x1="17" x2="3" y1="10" y2="10"/><line x1="21" x2="3" y1="6" y2="6"/><line x1="21" x2="3" y1="14" y2="14"/><line x1="17" x2="3" y1="18" y2="18"/>
@@ -35,7 +42,7 @@
35
42
  <path d="M18 22V8a2 2 0 0 0-2-2H2"/>
36
43
  </svg>
37
44
  </button>
38
- `,t.appendChild(c)}const o=document.createElement("figcaption");return o.className="cb-image-caption",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Add a caption..."),e!=null&&e.caption&&(o.textContent=e.caption),t.appendChild(o),e!=null&&e.align&&t.setAttribute("data-align",e.align),t},getData(e){const t=e.querySelector("img"),n=e.querySelector("figcaption");return{id:e.getAttribute("data-block-id")||F(),type:"image",src:(t==null?void 0:t.src)||"",alt:(t==null?void 0:t.alt)||"",caption:(n==null?void 0:n.textContent)||void 0,width:(t==null?void 0:t.style.width)||void 0,height:(t==null?void 0:t.style.height)||void 0,align:e.getAttribute("data-align")||void 0}},update(e,t){const n=e.querySelector("img"),o=e.querySelector("figcaption");n&&(t.src&&(n.src=t.src),t.alt!==void 0&&(n.alt=t.alt),t.width&&(n.style.width=typeof t.width=="number"?`${t.width}px`:t.width),t.height&&(n.style.height=typeof t.height=="number"?`${t.height}px`:t.height)),o&&t.caption!==void 0&&(o.textContent=t.caption),t.align&&e.setAttribute("data-align",t.align)}};function Ke(e,t,n=""){let o=e.querySelector("img");const c=e.querySelector(".cb-image-container");if(!o&&c){const r=c.querySelector(".cb-image-placeholder");r&&r.remove();const i=document.createElement("div");i.className="cb-image-resizable",o=document.createElement("img"),o.className="cb-image-element",i.appendChild(o),un(i),c.appendChild(i)}o&&(o.src=t,o.alt=n)}function pn(e,t){e.setAttribute("data-align",t)}function hn(e){return new Promise((t,n)=>{if(!e.type.startsWith("image/")){n(new Error("File is not an image"));return}const o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error),o.readAsDataURL(e)})}function pc(e,t,n,o){return new Promise((c,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>{const a=document.createElement("canvas"),d=a.getContext("2d");if(!d){r(new Error("Could not get canvas context"));return}const w=i.naturalWidth/n,x=i.naturalHeight/o,m=t.x*w,T=t.y*x,A=t.width*w,C=t.height*x;a.width=A,a.height=C,d.drawImage(i,m,T,A,C,0,0,A,C),c(a.toDataURL("image/png"))},i.onerror=()=>r(new Error("Failed to load image")),i.src=e})}function hc(e,t,n){var oe,he,S,B,W;const o=document.createElement("div");o.className="cb-crop-modal",o.innerHTML=`
45
+ `,t.appendChild(r)}const o=document.createElement("figcaption");return o.className="cb-image-caption",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Add a caption..."),e!=null&&e.caption&&(o.textContent=e.caption),t.appendChild(o),e!=null&&e.align&&t.setAttribute("data-align",e.align),t},getData(e){const t=e.querySelector("img"),n=e.querySelector("figcaption");return{id:e.getAttribute("data-block-id")||le(),type:"image",src:(t==null?void 0:t.src)||"",alt:(t==null?void 0:t.alt)||"",caption:(n==null?void 0:n.textContent)||void 0,width:(t==null?void 0:t.style.width)||void 0,height:(t==null?void 0:t.style.height)||void 0,align:e.getAttribute("data-align")||void 0}},update(e,t){const n=e.querySelector("img"),o=e.querySelector("figcaption");n&&(t.src&&(n.src=t.src),t.alt!==void 0&&(n.alt=t.alt),t.width&&(n.style.width=typeof t.width=="number"?`${t.width}px`:t.width),t.height&&(n.style.height=typeof t.height=="number"?`${t.height}px`:t.height)),o&&t.caption!==void 0&&(o.textContent=t.caption),t.align&&e.setAttribute("data-align",t.align)}};function xt(e,t,n=""){let o=e.querySelector("img");const r=e.querySelector(".cb-image-container");if(!o&&r){const a=r.querySelector(".cb-image-placeholder");a&&a.remove();const s=document.createElement("div");s.className="cb-image-resizable",o=document.createElement("img"),o.className="cb-image-element",s.appendChild(o),vn(s),r.appendChild(s)}o&&(o.src=t,o.alt=n)}function yn(e,t){e.setAttribute("data-align",t)}function kn(e){return new Promise((t,n)=>{if(!e.type.startsWith("image/")){n(new Error("File is not an image"));return}const o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error),o.readAsDataURL(e)})}function ic(e,t,n,o){return new Promise((r,a)=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>{const d=document.createElement("canvas"),w=d.getContext("2d");if(!w){a(new Error("Could not get canvas context"));return}const H=s.naturalWidth/n,D=s.naturalHeight/o,L=t.x*H,_=t.y*D,T=t.width*H,$=t.height*D;d.width=T,d.height=$,w.drawImage(s,L,_,T,$,0,0,T,$),r(d.toDataURL("image/png"))},s.onerror=()=>a(new Error("Failed to load image")),s.src=e})}function sc(e,t,n){var me,Ne,J,ke,He;const o=document.createElement("div");o.className="cb-crop-modal",o.innerHTML=`
39
46
  <div class="cb-crop-modal-backdrop"></div>
40
47
  <div class="cb-crop-modal-content">
41
48
  <div class="cb-crop-modal-header">
@@ -76,37 +83,43 @@
76
83
  <button type="button" class="cb-crop-save-btn">Apply Crop</button>
77
84
  </div>
78
85
  </div>
79
- `;let c={x:50,y:50,width:200,height:200},r=null,i=!1,a=!1,d=null,w=0,x=0,m={...c},T=0,A=0,C=!1;const M=o.querySelector(".cb-crop-image-wrapper"),$=o.querySelector(".cb-crop-image"),U=o.querySelector(".cb-crop-area"),D=30;$.onload=()=>{T=$.offsetWidth,A=$.offsetHeight,M.style.width=`${T}px`,M.style.height=`${A}px`;const v=T*.8,H=A*.8;c={x:(T-v)/2,y:(A-H)/2,width:v,height:H},ee()};const ee=()=>{U.style.left=`${c.x}px`,U.style.top=`${c.y}px`,U.style.width=`${c.width}px`,U.style.height=`${c.height}px`},N=v=>{let H=Math.max(0,v.x),R=Math.max(0,v.y),z=Math.max(D,v.width),_=Math.max(D,v.height);return H+z>T&&(z>T?(z=T,H=0):H=T-z),R+_>A&&(_>A?(_=A,R=0):R=A-_),{x:H,y:R,width:z,height:_}},le=v=>{v.target.classList.contains("cb-crop-handle")||(i=!0,w=v.clientX,x=v.clientY,m={...c},v.preventDefault())};U.addEventListener("mousedown",le);const te=v=>{const H=v.currentTarget;a=!0,d=H.dataset.handle||null,w=v.clientX,x=v.clientY,m={...c},v.preventDefault(),v.stopPropagation()};o.querySelectorAll(".cb-crop-handle").forEach(v=>{v.addEventListener("mousedown",te)});const ne=v=>{if(!i&&!a)return;const H=v.clientX-w,R=v.clientY-x;if(i)c=N({x:m.x+H,y:m.y+R,width:m.width,height:m.height}),ee();else if(a&&d){let z=m.x,_=m.y,Y=m.width,Z=m.height;if(d.includes("e")&&(Y=m.width+H),d.includes("w")){const J=m.width-D,P=Math.min(H,J);z=m.x+P,Y=m.width-P,z<0&&(Y=Y+z,z=0)}if(d.includes("s")&&(Z=m.height+R),d.includes("n")){const J=m.height-D,P=Math.min(R,J);_=m.y+P,Z=m.height-P,_<0&&(Z=Z+_,_=0)}if(r!==null)if(d==="e"||d==="w")Z=Y/r;else if(d==="n"||d==="s")Y=Z*r;else{const J=Y/r,P=Z*r;Math.abs(Y-P)<Math.abs(Z-J)?Y=P:Z=J}Y=Math.max(D,Math.min(Y,T-z)),Z=Math.max(D,Math.min(Z,A-_)),r!==null&&(Y/Z>r?Y=Z*r:Z=Y/r),c={x:z,y:_,width:Y,height:Z},ee()}},ke=()=>{i=!1,a=!1,d=null},Ce=v=>{v.key==="Escape"&&(v.preventDefault(),ae())};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",ke),document.addEventListener("keydown",Ce);const ie=()=>{document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",ke),document.removeEventListener("keydown",Ce)},ae=()=>{C||(C=!0,ie(),o.parentNode&&o.parentNode.removeChild(o))};return o.querySelectorAll(".cb-crop-aspect-btn").forEach(v=>{v.addEventListener("click",H=>{H.preventDefault(),H.stopPropagation(),o.querySelectorAll(".cb-crop-aspect-btn").forEach(z=>z.classList.remove("active")),v.classList.add("active");const R=v.dataset.aspect;if(R==="free")r=null;else if(R){const[z,_]=R.split(":").map(Number);r=z/_;const Y=c.x+c.width/2,Z=c.y+c.height/2;let J=c.width,P=J/r;P>c.height&&(P=c.height,J=P*r),J>T&&(J=T,P=J/r),P>A&&(P=A,J=P*r);let se=Y-J/2,ge=Z-P/2;se=Math.max(0,Math.min(se,T-J)),ge=Math.max(0,Math.min(ge,A-P)),c={x:se,y:ge,width:J,height:P},ee()}})}),(oe=o.querySelector(".cb-crop-modal-close"))==null||oe.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),ae()}),(he=o.querySelector(".cb-crop-modal-backdrop"))==null||he.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),ae()}),(S=o.querySelector(".cb-crop-cancel-btn"))==null||S.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),ae()}),(B=o.querySelector(".cb-crop-save-btn"))==null||B.addEventListener("click",async v=>{if(v.preventDefault(),v.stopPropagation(),!C)try{const H=await pc($.src,c,T,A);ae(),t(H)}catch(H){console.error("Failed to crop image:",H)}}),(W=o.querySelector(".cb-crop-modal-content"))==null||W.addEventListener("click",v=>{v.stopPropagation()}),o}const Ve={youtube:/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,vimeo:/vimeo\.com\/(?:video\/)?(\d+)/,dailymotion:/dailymotion\.com\/(?:video|embed\/video)\/([a-zA-Z0-9]+)/},bn={name:"video",tag:"figure",editable:!1,allowedChildren:[],className:"cb-video",icon:"video",label:"Video",create(e){const t=document.createElement("figure");t.className="cb-video",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","video");const n=document.createElement("div");if(n.className="cb-video-container",e!=null&&e.src){const c=Ie(e.src);if(c){const r=document.createElement("iframe");r.className="cb-video-iframe",r.src=c,r.setAttribute("frameborder","0"),r.setAttribute("allowfullscreen","true"),r.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.width&&(r.style.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height&&(r.style.height=typeof e.height=="number"?`${e.height}px`:e.height),n.appendChild(r)}else{const r=document.createElement("video");r.className="cb-video-element",r.src=e.src,r.controls=!0,e.poster&&(r.poster=e.poster),e.width&&(r.style.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height&&(r.style.height=typeof e.height=="number"?`${e.height}px`:e.height),n.appendChild(r)}}else{const c=document.createElement("div");c.className="cb-video-placeholder",c.innerHTML=`
86
+ `;let r={x:50,y:50,width:200,height:200},a=null,s=!1,d=!1,w=null,H=0,D=0,L={...r},_=0,T=0,$=!1;const x=o.querySelector(".cb-crop-image-wrapper"),z=o.querySelector(".cb-crop-image"),re=o.querySelector(".cb-crop-area"),Z=30;z.onload=()=>{_=z.offsetWidth,T=z.offsetHeight,x.style.width=`${_}px`,x.style.height=`${T}px`;const Y=_*.8,he=T*.8;r={x:(_-Y)/2,y:(T-he)/2,width:Y,height:he},te()};const te=()=>{re.style.left=`${r.x}px`,re.style.top=`${r.y}px`,re.style.width=`${r.width}px`,re.style.height=`${r.height}px`},A=Y=>{let he=Math.max(0,Y.x),Ce=Math.max(0,Y.y),Ee=Math.max(Z,Y.width),Ae=Math.max(Z,Y.height);return he+Ee>_&&(Ee>_?(Ee=_,he=0):he=_-Ee),Ce+Ae>T&&(Ae>T?(Ae=T,Ce=0):Ce=T-Ae),{x:he,y:Ce,width:Ee,height:Ae}},fe=Y=>{Y.target.classList.contains("cb-crop-handle")||(s=!0,H=Y.clientX,D=Y.clientY,L={...r},Y.preventDefault())};re.addEventListener("mousedown",fe);const ve=Y=>{const he=Y.currentTarget;d=!0,w=he.dataset.handle||null,H=Y.clientX,D=Y.clientY,L={...r},Y.preventDefault(),Y.stopPropagation()};o.querySelectorAll(".cb-crop-handle").forEach(Y=>{Y.addEventListener("mousedown",ve)});const ue=Y=>{if(!s&&!d)return;const he=Y.clientX-H,Ce=Y.clientY-D;if(s)r=A({x:L.x+he,y:L.y+Ce,width:L.width,height:L.height}),te();else if(d&&w){let Ee=L.x,Ae=L.y,xe=L.width,we=L.height;if(w.includes("e")&&(xe=L.width+he),w.includes("w")){const pe=L.width-Z,N=Math.min(he,pe);Ee=L.x+N,xe=L.width-N,Ee<0&&(xe=xe+Ee,Ee=0)}if(w.includes("s")&&(we=L.height+Ce),w.includes("n")){const pe=L.height-Z,N=Math.min(Ce,pe);Ae=L.y+N,we=L.height-N,Ae<0&&(we=we+Ae,Ae=0)}if(a!==null)if(w==="e"||w==="w")we=xe/a;else if(w==="n"||w==="s")xe=we*a;else{const pe=xe/a,N=we*a;Math.abs(xe-N)<Math.abs(we-pe)?xe=N:we=pe}xe=Math.max(Z,Math.min(xe,_-Ee)),we=Math.max(Z,Math.min(we,T-Ae)),a!==null&&(xe/we>a?xe=we*a:we=xe/a),r={x:Ee,y:Ae,width:xe,height:we},te()}},G=()=>{s=!1,d=!1,w=null},ae=Y=>{Y.key==="Escape"&&(Y.preventDefault(),ye())};document.addEventListener("mousemove",ue),document.addEventListener("mouseup",G),document.addEventListener("keydown",ae);const be=()=>{document.removeEventListener("mousemove",ue),document.removeEventListener("mouseup",G),document.removeEventListener("keydown",ae)},ye=()=>{$||($=!0,be(),o.parentNode&&o.parentNode.removeChild(o))};return o.querySelectorAll(".cb-crop-aspect-btn").forEach(Y=>{Y.addEventListener("click",he=>{he.preventDefault(),he.stopPropagation(),o.querySelectorAll(".cb-crop-aspect-btn").forEach(Ee=>Ee.classList.remove("active")),Y.classList.add("active");const Ce=Y.dataset.aspect;if(Ce==="free")a=null;else if(Ce){const[Ee,Ae]=Ce.split(":").map(Number);a=Ee/Ae;const xe=r.x+r.width/2,we=r.y+r.height/2;let pe=r.width,N=pe/a;N>r.height&&(N=r.height,pe=N*a),pe>_&&(pe=_,N=pe/a),N>T&&(N=T,pe=N*a);let V=xe-pe/2,ie=we-N/2;V=Math.max(0,Math.min(V,_-pe)),ie=Math.max(0,Math.min(ie,T-N)),r={x:V,y:ie,width:pe,height:N},te()}})}),(me=o.querySelector(".cb-crop-modal-close"))==null||me.addEventListener("click",Y=>{Y.preventDefault(),Y.stopPropagation(),ye()}),(Ne=o.querySelector(".cb-crop-modal-backdrop"))==null||Ne.addEventListener("click",Y=>{Y.preventDefault(),Y.stopPropagation(),ye()}),(J=o.querySelector(".cb-crop-cancel-btn"))==null||J.addEventListener("click",Y=>{Y.preventDefault(),Y.stopPropagation(),ye()}),(ke=o.querySelector(".cb-crop-save-btn"))==null||ke.addEventListener("click",async Y=>{if(Y.preventDefault(),Y.stopPropagation(),!$)try{const he=await ic(z.src,r,_,T);ye(),t(he)}catch(he){console.error("Failed to crop image:",he)}}),(He=o.querySelector(".cb-crop-modal-content"))==null||He.addEventListener("click",Y=>{Y.stopPropagation()}),o}const ft={youtube:/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,vimeo:/vimeo\.com\/(?:video\/)?(\d+)/,dailymotion:/dailymotion\.com\/(?:video|embed\/video)\/([a-zA-Z0-9]+)/},xn={name:"video",tag:"figure",editable:!1,allowedChildren:[],className:"cb-video",icon:"video",label:"Video",create(e){const t=document.createElement("figure");t.className="cb-video",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","video");const n=document.createElement("div");if(n.className="cb-video-container",e!=null&&e.src){const r=ot(e.src);if(r){const a=document.createElement("iframe");a.className="cb-video-iframe",a.src=r,a.setAttribute("frameborder","0"),a.setAttribute("allowfullscreen","true"),a.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),n.appendChild(a)}else{const a=document.createElement("video");a.className="cb-video-element",a.src=e.src,a.controls=!0,e.poster&&(a.poster=e.poster),n.appendChild(a)}}else{const r=document.createElement("div");r.className="cb-video-placeholder",r.innerHTML=`
80
87
  <div class="cb-video-placeholder-content">
81
- <svg width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
82
- <path d="m22 8-6 4 6 4V8Z"/>
83
- <rect width="14" height="12" x="2" y="6" rx="2" ry="2"/>
84
- </svg>
85
- <span>Embed a video from YouTube, Vimeo, or upload</span>
86
- <span class="cb-video-placeholder-hint">Paste a URL below and press Enter</span>
87
- <input type="text" class="cb-video-url-input" placeholder="https://youtube.com/watch?v=... or vimeo.com/..." />
88
+ <div class="cb-video-placeholder-icon">
89
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
90
+ <path d="m22 8-6 4 6 4V8Z"/>
91
+ <rect width="14" height="12" x="2" y="6" rx="2" ry="2"/>
92
+ </svg>
93
+ </div>
94
+ <div class="cb-video-placeholder-text">
95
+ <span class="cb-video-placeholder-title">Embed video from YouTube or Vimeo</span>
96
+ <span class="cb-video-placeholder-hint">Paste URL below and press Enter</span>
97
+ </div>
98
+ </div>
99
+ <div class="cb-video-url-wrapper" contenteditable="false">
100
+ <input type="url" class="cb-video-url-input" placeholder="https://youtube.com/watch?v=... or vimeo.com/..." />
88
101
  </div>
89
- `,n.appendChild(c)}t.appendChild(n);const o=document.createElement("figcaption");return o.className="cb-video-caption",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Add a caption..."),e!=null&&e.caption&&(o.textContent=e.caption),t.appendChild(o),t},getData(e){const t=e.querySelector("iframe"),n=e.querySelector("video"),o=e.querySelector("figcaption");return{id:e.getAttribute("data-block-id")||F(),type:"video",src:(t==null?void 0:t.src)||(n==null?void 0:n.src)||"",poster:(n==null?void 0:n.poster)||void 0,caption:(o==null?void 0:o.textContent)||void 0,width:(t==null?void 0:t.style.width)||(n==null?void 0:n.style.width)||void 0,height:(t==null?void 0:t.style.height)||(n==null?void 0:n.style.height)||void 0}},update(e,t){if(t.src){const n=e.querySelector(".cb-video-container");if(n){n.innerHTML="";const o=Ie(t.src);if(o){const c=document.createElement("iframe");c.className="cb-video-iframe",c.src=o,c.setAttribute("frameborder","0"),c.setAttribute("allowfullscreen","true"),n.appendChild(c)}else{const c=document.createElement("video");c.className="cb-video-element",c.src=t.src,c.controls=!0,t.poster&&(c.poster=t.poster),n.appendChild(c)}}}if(t.caption!==void 0){const n=e.querySelector("figcaption");n&&(n.textContent=t.caption)}}};function Ie(e){const t=e.match(Ve.youtube);if(t)return`https://www.youtube.com/embed/${t[1]}`;const n=e.match(Ve.vimeo);if(n)return`https://player.vimeo.com/video/${n[1]}`;const o=e.match(Ve.dailymotion);return o?`https://www.dailymotion.com/embed/video/${o[1]}`:e.includes("youtube.com/embed/")||e.includes("player.vimeo.com/")||e.includes("dailymotion.com/embed/")?e:null}function gn(e,t){const n=e.querySelector(".cb-video-container");if(!n)return;n.innerHTML="";const o=Ie(t);if(o){const c=document.createElement("iframe");c.className="cb-video-iframe",c.src=o,c.setAttribute("frameborder","0"),c.setAttribute("allowfullscreen","true"),c.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),n.appendChild(c)}else if(t){const c=document.createElement("video");c.className="cb-video-element",c.src=t,c.controls=!0,n.appendChild(c)}}const bt={name:"divider",tag:"hr",editable:!1,allowedChildren:[],className:"cb-divider",icon:"minus",label:"Divider",shortcut:"Ctrl+Shift+-",create(e){const t=document.createElement("div");t.className="cb-divider-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","divider"),t.setAttribute("contenteditable","false");const n=document.createElement("hr");return n.className="cb-divider",e!=null&&e.style&&(n.setAttribute("data-style",e.style),t.setAttribute("data-divider-style",e.style)),t.appendChild(n),t},getData(e){const t=e.querySelector("hr");return{id:e.getAttribute("data-block-id")||F(),type:"divider",style:(t==null?void 0:t.getAttribute("data-style"))||e.getAttribute("data-divider-style")||"solid"}},update(e,t){if(t.style){const n=e.querySelector("hr");n&&n.setAttribute("data-style",t.style),e.setAttribute("data-divider-style",t.style)}}};function bc(e,t){const n=e.querySelector("hr");n&&n.setAttribute("data-style",t),e.setAttribute("data-divider-style",t)}const ve={info:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',error:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',success:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',note:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>'},mn={name:"callout",tag:"aside",editable:!0,allowedChildren:["text","inline"],className:"cb-callout",icon:"alertCircle",label:"Callout",create(e){const t=(e==null?void 0:e.calloutType)||"info",n=document.createElement("aside");n.className=`cb-callout cb-callout-${t}`,n.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),n.setAttribute("data-block-type","callout"),n.setAttribute("data-callout-type",t);const o=document.createElement("div");o.className="cb-callout-icon",o.innerHTML=ve[t],n.appendChild(o);const c=document.createElement("div");if(c.className="cb-callout-content",e!=null&&e.title){const a=document.createElement("div");a.className="cb-callout-title",a.setAttribute("contenteditable","true"),a.textContent=e.title,c.appendChild(a)}const r=document.createElement("div");r.className="cb-callout-body",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder","Type callout content..."),e!=null&&e.content&&(r.innerHTML=e.content),c.appendChild(r),n.appendChild(c);const i=document.createElement("div");return i.className="cb-callout-type-selector",i.innerHTML=`
102
+ `,n.appendChild(r)}t.appendChild(n);const o=document.createElement("figcaption");return o.className="cb-video-caption",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Add a caption..."),e!=null&&e.caption&&(o.textContent=e.caption),t.appendChild(o),t},getData(e){const t=e.querySelector("iframe"),n=e.querySelector("video"),o=e.querySelector("figcaption");return{id:e.getAttribute("data-block-id")||le(),type:"video",src:(t==null?void 0:t.src)||(n==null?void 0:n.src)||"",poster:(n==null?void 0:n.poster)||void 0,caption:(o==null?void 0:o.textContent)||void 0}},update(e,t){if(t.src){const n=e.querySelector(".cb-video-container");if(n){n.innerHTML="";const o=ot(t.src);if(o){const r=document.createElement("iframe");r.className="cb-video-iframe",r.src=o,r.setAttribute("frameborder","0"),r.setAttribute("allowfullscreen","true"),n.appendChild(r)}else{const r=document.createElement("video");r.className="cb-video-element",r.src=t.src,r.controls=!0,t.poster&&(r.poster=t.poster),n.appendChild(r)}}}if(t.caption!==void 0){const n=e.querySelector("figcaption");n&&(n.textContent=t.caption)}}};function ot(e){const t=e.match(ft.youtube);if(t)return`https://www.youtube.com/embed/${t[1]}`;const n=e.match(ft.vimeo);if(n)return`https://player.vimeo.com/video/${n[1]}`;const o=e.match(ft.dailymotion);return o?`https://www.dailymotion.com/embed/video/${o[1]}`:e.includes("youtube.com/embed/")||e.includes("player.vimeo.com/")||e.includes("dailymotion.com/embed/")?e:null}function wn(e,t){const n=e.querySelector(".cb-video-container");if(!n)return;n.innerHTML="";const o=ot(t);if(o){const r=document.createElement("iframe");r.className="cb-video-iframe",r.src=o,r.setAttribute("frameborder","0"),r.setAttribute("allowfullscreen","true"),r.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),n.appendChild(r)}else if(t){const r=document.createElement("video");r.className="cb-video-element",r.src=t,r.controls=!0,n.appendChild(r)}}const Ft={name:"divider",tag:"hr",editable:!1,allowedChildren:[],className:"cb-divider",icon:"minus",label:"Divider",shortcut:"Ctrl+Shift+-",create(e){const t=document.createElement("div");t.className="cb-divider-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","divider"),t.setAttribute("contenteditable","false");const n=document.createElement("hr");return n.className="cb-divider",e!=null&&e.style&&(n.setAttribute("data-style",e.style),t.setAttribute("data-divider-style",e.style)),t.appendChild(n),t},getData(e){const t=e.querySelector("hr");return{id:e.getAttribute("data-block-id")||le(),type:"divider",style:(t==null?void 0:t.getAttribute("data-style"))||e.getAttribute("data-divider-style")||"solid"}},update(e,t){if(t.style){const n=e.querySelector("hr");n&&n.setAttribute("data-style",t.style),e.setAttribute("data-divider-style",t.style)}}};function dc(e,t){const n=e.querySelector("hr");n&&n.setAttribute("data-style",t),e.setAttribute("data-divider-style",t)}const _e={info:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',error:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',success:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',note:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>'},Cn={name:"callout",tag:"aside",editable:!0,allowedChildren:["text","inline"],className:"cb-callout",icon:"alertCircle",label:"Callout",create(e){const t=(e==null?void 0:e.calloutType)||"info",n=document.createElement("aside");n.className=`cb-callout cb-callout-${t}`,n.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),n.setAttribute("data-block-type","callout"),n.setAttribute("data-callout-type",t);const o=document.createElement("div");o.className="cb-callout-icon",o.innerHTML=_e[t],n.appendChild(o);const r=document.createElement("div");if(r.className="cb-callout-content",e!=null&&e.title){const d=document.createElement("div");d.className="cb-callout-title",d.setAttribute("contenteditable","true"),d.textContent=e.title,r.appendChild(d)}const a=document.createElement("div");a.className="cb-callout-body",a.setAttribute("contenteditable","true"),a.setAttribute("data-placeholder","Type callout content..."),e!=null&&e.content&&(a.innerHTML=e.content),r.appendChild(a),n.appendChild(r);const s=document.createElement("div");return s.className="cb-callout-type-selector",s.innerHTML=`
90
103
  <button type="button" data-type="info" title="Info" class="${t==="info"?"active":""}">
91
- ${ve.info}
104
+ ${_e.info}
92
105
  </button>
93
106
  <button type="button" data-type="success" title="Success" class="${t==="success"?"active":""}">
94
- ${ve.success}
107
+ ${_e.success}
95
108
  </button>
96
109
  <button type="button" data-type="warning" title="Warning" class="${t==="warning"?"active":""}">
97
- ${ve.warning}
110
+ ${_e.warning}
98
111
  </button>
99
112
  <button type="button" data-type="error" title="Error" class="${t==="error"?"active":""}">
100
- ${ve.error}
113
+ ${_e.error}
101
114
  </button>
102
115
  <button type="button" data-type="note" title="Note" class="${t==="note"?"active":""}">
103
- ${ve.note}
116
+ ${_e.note}
104
117
  </button>
105
- `,n.appendChild(i),n},getData(e){const t=e.querySelector(".cb-callout-title"),n=e.querySelector(".cb-callout-body");return{id:e.getAttribute("data-block-id")||F(),type:"callout",calloutType:e.getAttribute("data-callout-type")||"info",title:(t==null?void 0:t.textContent)||void 0,content:(n==null?void 0:n.innerHTML)||""}},update(e,t){if(t.calloutType&&gt(e,t.calloutType),t.title!==void 0){let n=e.querySelector(".cb-callout-title");if(t.title){if(!n){n=document.createElement("div"),n.className="cb-callout-title",n.setAttribute("contenteditable","true");const o=e.querySelector(".cb-callout-content"),c=e.querySelector(".cb-callout-body");o&&c&&o.insertBefore(n,c)}n.textContent=t.title}else n&&n.remove()}if(t.content!==void 0){const n=e.querySelector(".cb-callout-body");n&&(n.innerHTML=t.content)}}};function gt(e,t){e.className=`cb-callout cb-callout-${t}`,e.setAttribute("data-callout-type",t);const n=e.querySelector(".cb-callout-icon");n&&(n.innerHTML=ve[t]);const o=e.querySelector(".cb-callout-type-selector");o&&o.querySelectorAll("button").forEach(c=>{c.classList.toggle("active",c.getAttribute("data-type")===t)})}function gc(e,t){let n=e.querySelector(".cb-callout-title");if(!n){n=document.createElement("div"),n.className="cb-callout-title",n.setAttribute("contenteditable","true");const o=e.querySelector(".cb-callout-content"),c=e.querySelector(".cb-callout-body");o&&c&&o.insertBefore(n,c)}n.textContent=t}const fn={name:"accordion",tag:"details",editable:!0,allowedChildren:["text","inline","block"],className:"cb-accordion",icon:"chevronDown",label:"Accordion",create(e){const t=document.createElement("details");t.className="cb-accordion",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","accordion"),e!=null&&e.open&&(t.open=!0);const n=document.createElement("summary");n.className="cb-accordion-title";const o=document.createElement("span");o.className="cb-accordion-title-text",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Accordion title..."),e!=null&&e.title&&(o.textContent=e.title);const c=document.createElement("span");c.className="cb-accordion-chevron",c.innerHTML=`
118
+ `,n.appendChild(s),n},getData(e){const t=e.querySelector(".cb-callout-title"),n=e.querySelector(".cb-callout-body");return{id:e.getAttribute("data-block-id")||le(),type:"callout",calloutType:e.getAttribute("data-callout-type")||"info",title:(t==null?void 0:t.textContent)||void 0,content:(n==null?void 0:n.innerHTML)||""}},update(e,t){if(t.calloutType&&Ot(e,t.calloutType),t.title!==void 0){let n=e.querySelector(".cb-callout-title");if(t.title){if(!n){n=document.createElement("div"),n.className="cb-callout-title",n.setAttribute("contenteditable","true");const o=e.querySelector(".cb-callout-content"),r=e.querySelector(".cb-callout-body");o&&r&&o.insertBefore(n,r)}n.textContent=t.title}else n&&n.remove()}if(t.content!==void 0){const n=e.querySelector(".cb-callout-body");n&&(n.innerHTML=t.content)}}};function Ot(e,t){e.className=`cb-callout cb-callout-${t}`,e.setAttribute("data-callout-type",t);const n=e.querySelector(".cb-callout-icon");n&&(n.innerHTML=_e[t]);const o=e.querySelector(".cb-callout-type-selector");o&&o.querySelectorAll("button").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-type")===t)})}function uc(e,t){let n=e.querySelector(".cb-callout-title");if(!n){n=document.createElement("div"),n.className="cb-callout-title",n.setAttribute("contenteditable","true");const o=e.querySelector(".cb-callout-content"),r=e.querySelector(".cb-callout-body");o&&r&&o.insertBefore(n,r)}n.textContent=t}const Sn={name:"accordion",tag:"details",editable:!0,allowedChildren:["text","inline","block"],className:"cb-accordion",icon:"chevronDown",label:"Accordion",create(e){const t=document.createElement("details");t.className="cb-accordion",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","accordion"),e!=null&&e.open&&(t.open=!0);const n=document.createElement("summary");n.className="cb-accordion-title";const o=document.createElement("span");o.className="cb-accordion-title-text",o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder","Accordion title..."),e!=null&&e.title&&(o.textContent=e.title);const r=document.createElement("span");r.className="cb-accordion-chevron",r.innerHTML=`
106
119
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
107
120
  <path d="m6 9 6 6 6-6"/>
108
121
  </svg>
109
- `,n.appendChild(o),n.appendChild(c),t.appendChild(n);const r=document.createElement("div");return r.className="cb-accordion-content",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder","Accordion content..."),e!=null&&e.content&&(r.innerHTML=e.content),t.appendChild(r),t},getData(e){const t=e,n=e.querySelector(".cb-accordion-title-text"),o=e.querySelector(".cb-accordion-content");return{id:e.getAttribute("data-block-id")||F(),type:"accordion",title:(n==null?void 0:n.textContent)||"",content:(o==null?void 0:o.innerHTML)||"",open:t.open}},update(e,t){const n=e;if(t.title!==void 0){const o=e.querySelector(".cb-accordion-title-text");o&&(o.textContent=t.title)}if(t.content!==void 0){const o=e.querySelector(".cb-accordion-content");o&&(o.innerHTML=t.content)}t.open!==void 0&&(n.open=t.open)}};function mc(e){const t=e;return t.open=!t.open,t.open}function fc(e,t){const n=e;n.open=t}const yn={name:"table",tag:"table",editable:!0,allowedChildren:["text","inline"],className:"cb-table",icon:"table",label:"Table",create(e){const t=document.createElement("div");t.className="cb-table-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||F()),t.setAttribute("data-block-type","table");const n=document.createElement("table");n.className="cb-table";const o=(e==null?void 0:e.rows)||[{cells:[{content:""},{content:""},{content:""}]},{cells:[{content:""},{content:""},{content:""}]},{cells:[{content:""},{content:""},{content:""}]}],c=(e==null?void 0:e.hasHeader)??!0;o.forEach((i,a)=>{const d=document.createElement("tr");d.className="cb-table-row",i.cells.forEach(w=>{const x=c&&a===0?"th":"td",m=document.createElement(x);m.className="cb-table-cell",m.setAttribute("contenteditable","true"),m.innerHTML=w.content||"",w.align&&(m.style.textAlign=w.align),w.colSpan&&w.colSpan>1&&(m.colSpan=w.colSpan),w.rowSpan&&w.rowSpan>1&&(m.rowSpan=w.rowSpan),d.appendChild(m)}),n.appendChild(d)}),t.appendChild(n);const r=document.createElement("div");return r.className="cb-table-controls",r.innerHTML=`
122
+ `,n.appendChild(o),n.appendChild(r),t.appendChild(n);const a=document.createElement("div");return a.className="cb-accordion-content",a.setAttribute("contenteditable","true"),a.setAttribute("data-placeholder","Accordion content..."),e!=null&&e.content&&(a.innerHTML=e.content),t.appendChild(a),t},getData(e){const t=e,n=e.querySelector(".cb-accordion-title-text"),o=e.querySelector(".cb-accordion-content");return{id:e.getAttribute("data-block-id")||le(),type:"accordion",title:(n==null?void 0:n.textContent)||"",content:(o==null?void 0:o.innerHTML)||"",open:t.open}},update(e,t){const n=e;if(t.title!==void 0){const o=e.querySelector(".cb-accordion-title-text");o&&(o.textContent=t.title)}if(t.content!==void 0){const o=e.querySelector(".cb-accordion-content");o&&(o.innerHTML=t.content)}t.open!==void 0&&(n.open=t.open)}};function bc(e){const t=e;return t.open=!t.open,t.open}function pc(e,t){const n=e;n.open=t}function ct(e){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],o=t[e.getDay()],r=e.getDate(),a=n[e.getMonth()],s=e.getFullYear();return`${o}, ${r} ${a} ${s}`}function wt(e){return e instanceof Date?e:new Date(e)}function En(){const e=new Date;return e.setHours(0,0,0,0),e}function mc(){const e=new Date;return e.setDate(e.getDate()+1),e.setHours(0,0,0,0),e}function gc(){const e=new Date;return e.setDate(e.getDate()-1),e.setHours(0,0,0,0),e}const An={name:"date",tag:"span",editable:!1,allowedChildren:[],className:"cb-date",icon:"calendar",label:"Date",create(e){const t=document.createElement("span");t.className="cb-date-inline",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","date"),t.setAttribute("contenteditable","false");const n=e!=null&&e.date?wt(e.date):En();return t.setAttribute("data-date",n.toISOString()),t.textContent=ct(n),t},getData(e){const t=e.getAttribute("data-date")||new Date().toISOString();return{id:e.getAttribute("data-block-id")||le(),type:"date",date:t}},update(e,t){if(t.date!==void 0){const n=wt(t.date);e.setAttribute("data-date",n.toISOString()),e.textContent=ct(n)}}};function fc(e,t){e.setAttribute("data-date",t.toISOString()),e.textContent=ct(t)}const Nn={name:"table",tag:"table",editable:!0,allowedChildren:["text","inline"],className:"cb-table",icon:"table",label:"Table",create(e){const t=document.createElement("div");t.className="cb-table-wrapper",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","table");const n=document.createElement("table");n.className="cb-table";const o=(e==null?void 0:e.rows)||[{cells:[{content:""},{content:""},{content:""}]},{cells:[{content:""},{content:""},{content:""}]},{cells:[{content:""},{content:""},{content:""}]}],r=(e==null?void 0:e.hasHeader)??!0;o.forEach((s,d)=>{const w=document.createElement("tr");w.className="cb-table-row",s.cells.forEach(H=>{const D=r&&d===0?"th":"td",L=document.createElement(D);L.className="cb-table-cell",L.setAttribute("contenteditable","true"),L.innerHTML=H.content||"",H.align&&(L.style.textAlign=H.align),H.colSpan&&H.colSpan>1&&(L.colSpan=H.colSpan),H.rowSpan&&H.rowSpan>1&&(L.rowSpan=H.rowSpan),w.appendChild(L)}),n.appendChild(w)}),t.appendChild(n);const a=document.createElement("div");return a.className="cb-table-controls",a.innerHTML=`
110
123
  <button type="button" class="cb-table-btn" data-action="addRow" title="Add row">
111
124
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
112
125
  <path d="M12 5v14"/><path d="M5 12h14"/>
@@ -131,7 +144,7 @@
131
144
  </svg>
132
145
  Column
133
146
  </button>
134
- `,t.appendChild(r),t},getData(e){const t=e.querySelector("table"),n=[];let o=!1;return t==null||t.querySelectorAll("tr").forEach((c,r)=>{const i=[];c.querySelectorAll("th, td").forEach(a=>{a.tagName==="TH"&&(o=!0),i.push({content:a.innerHTML,align:a.style.textAlign||void 0,colSpan:a.colSpan>1?a.colSpan:void 0,rowSpan:a.rowSpan>1?a.rowSpan:void 0})}),n.push({cells:i})}),{id:e.getAttribute("data-block-id")||F(),type:"table",rows:n,hasHeader:o}},update(e,t){if(t.rows){const n=e.querySelector("table");n&&(n.innerHTML="",t.rows.forEach((o,c)=>{const r=document.createElement("tr");r.className="cb-table-row",o.cells.forEach(i=>{const a=t.hasHeader&&c===0?"th":"td",d=document.createElement(a);d.className="cb-table-cell",d.setAttribute("contenteditable","true"),d.innerHTML=i.content||"",i.align&&(d.style.textAlign=i.align),i.colSpan&&(d.colSpan=i.colSpan),i.rowSpan&&(d.rowSpan=i.rowSpan),r.appendChild(d)}),n.appendChild(r)}))}}};function Ge(e,t){var i;const n=e.querySelector("table");if(!n)return;const o=n.querySelectorAll("tr"),c=((i=o[0])==null?void 0:i.querySelectorAll("th, td").length)||3,r=document.createElement("tr");r.className="cb-table-row";for(let a=0;a<c;a++){const d=document.createElement("td");d.className="cb-table-cell",d.setAttribute("contenteditable","true"),r.appendChild(d)}t!==void 0&&o[t]?o[t].after(r):n.appendChild(r)}function kn(e,t){const n=e.querySelector("table");n&&n.querySelectorAll("tr").forEach((o,c)=>{var d;const r=o.querySelectorAll("th, td"),i=c===0&&((d=r[0])==null?void 0:d.tagName)==="TH",a=document.createElement(i?"th":"td");a.className="cb-table-cell",a.setAttribute("contenteditable","true"),t!==void 0&&r[t]?r[t].after(a):o.appendChild(a)})}function Xe(e,t){var c;const n=e.querySelector("table");if(!n)return!1;const o=n.querySelectorAll("tr");return o.length<=1?!1:((c=o[t])==null||c.remove(),!0)}function Ze(e,t){var r;const n=e.querySelector("table");if(!n)return!1;const o=n.querySelectorAll("tr");return(((r=o[0])==null?void 0:r.querySelectorAll("th, td").length)||0)<=1?!1:(o.forEach(i=>{var d;(d=i.querySelectorAll("th, td")[t])==null||d.remove()}),!0)}function yc(e,t){e.style.textAlign=t}function Je(e){const t=document.activeElement;return t&&e.contains(t)?t.closest("td, th"):null}function Qe(e){const t=e.parentElement;if(!t)return null;const n=t.closest("table");if(!n)return null;const c=Array.from(n.querySelectorAll("tr")).indexOf(t),i=Array.from(t.querySelectorAll("th, td")).indexOf(e);return{row:c,col:i}}const We=new Map;function kc(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function mt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}async function Wt(e){var t;if(We.has(e))return We.get(e)||null;try{const n=mt(e);if(!kc(n))return null;const o=new URL(n),c={url:n,siteName:o.hostname.replace("www.",""),title:((t=o.pathname.split("/").filter(Boolean).pop())==null?void 0:t.replace(/-/g," "))||o.hostname};return We.set(e,c),c}catch(n){return console.error("Failed to fetch link preview:",n),null}}function _t(e){try{return new URL(mt(e)).hostname.replace("www.","")}catch{return e}}function vc(e){try{return`https://www.google.com/s2/favicons?domain=${new URL(mt(e)).hostname}&sz=32`}catch{return""}}function Ne(e){const t=document.createElement("div");if(t.className="cb-link-preview",t.setAttribute("data-url",e.url||""),t.contentEditable="false",e.loading)t.innerHTML=`
147
+ `,t.appendChild(a),t},getData(e){const t=e.querySelector("table"),n=[];let o=!1;return t==null||t.querySelectorAll("tr").forEach((r,a)=>{const s=[];r.querySelectorAll("th, td").forEach(d=>{d.tagName==="TH"&&(o=!0),s.push({content:d.innerHTML,align:d.style.textAlign||void 0,colSpan:d.colSpan>1?d.colSpan:void 0,rowSpan:d.rowSpan>1?d.rowSpan:void 0})}),n.push({cells:s})}),{id:e.getAttribute("data-block-id")||le(),type:"table",rows:n,hasHeader:o}},update(e,t){if(t.rows){const n=e.querySelector("table");n&&(n.innerHTML="",t.rows.forEach((o,r)=>{const a=document.createElement("tr");a.className="cb-table-row",o.cells.forEach(s=>{const d=t.hasHeader&&r===0?"th":"td",w=document.createElement(d);w.className="cb-table-cell",w.setAttribute("contenteditable","true"),w.innerHTML=s.content||"",s.align&&(w.style.textAlign=s.align),s.colSpan&&(w.colSpan=s.colSpan),s.rowSpan&&(w.rowSpan=s.rowSpan),a.appendChild(w)}),n.appendChild(a)}))}}};function Ct(e,t){var s;const n=e.querySelector("table");if(!n)return;const o=n.querySelectorAll("tr"),r=((s=o[0])==null?void 0:s.querySelectorAll("th, td").length)||3,a=document.createElement("tr");a.className="cb-table-row";for(let d=0;d<r;d++){const w=document.createElement("td");w.className="cb-table-cell",w.setAttribute("contenteditable","true"),a.appendChild(w)}t!==void 0&&o[t]?o[t].after(a):n.appendChild(a)}function Tn(e,t){const n=e.querySelector("table");n&&n.querySelectorAll("tr").forEach((o,r)=>{var w;const a=o.querySelectorAll("th, td"),s=r===0&&((w=a[0])==null?void 0:w.tagName)==="TH",d=document.createElement(s?"th":"td");d.className="cb-table-cell",d.setAttribute("contenteditable","true"),t!==void 0&&a[t]?a[t].after(d):o.appendChild(d)})}function St(e,t){var r;const n=e.querySelector("table");if(!n)return!1;const o=n.querySelectorAll("tr");return o.length<=1?!1:((r=o[t])==null||r.remove(),!0)}function Et(e,t){var a;const n=e.querySelector("table");if(!n)return!1;const o=n.querySelectorAll("tr");return(((a=o[0])==null?void 0:a.querySelectorAll("th, td").length)||0)<=1?!1:(o.forEach(s=>{var w;(w=s.querySelectorAll("th, td")[t])==null||w.remove()}),!0)}function hc(e,t){e.style.textAlign=t}function At(e){const t=document.activeElement;return t&&e.contains(t)?t.closest("td, th"):null}function Nt(e){const t=e.parentElement;if(!t)return null;const n=t.closest("table");if(!n)return null;const r=Array.from(n.querySelectorAll("tr")).indexOf(t),s=Array.from(t.querySelectorAll("th, td")).indexOf(e);return{row:r,col:s}}const ht=new Map;function vc(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Ut(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}async function Zt(e){var t;if(ht.has(e))return ht.get(e)||null;try{const n=Ut(e);if(!vc(n))return null;const o=new URL(n),r={url:n,siteName:o.hostname.replace("www.",""),title:((t=o.pathname.split("/").filter(Boolean).pop())==null?void 0:t.replace(/-/g," "))||o.hostname};return ht.set(e,r),r}catch(n){return console.error("Failed to fetch link preview:",n),null}}function en(e){try{return new URL(Ut(e)).hostname.replace("www.","")}catch{return e}}function yc(e){try{return`https://www.google.com/s2/favicons?domain=${new URL(Ut(e)).hostname}&sz=32`}catch{return""}}function Qe(e){const t=document.createElement("div");if(t.className="cb-link-preview",t.setAttribute("data-url",e.url||""),t.contentEditable="false",e.loading)t.innerHTML=`
135
148
  <div class="cb-link-preview-loading">
136
149
  <div class="cb-link-preview-spinner">
137
150
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -140,7 +153,7 @@
140
153
  </div>
141
154
  <span>Loading preview...</span>
142
155
  </div>
143
- `;else if(e.preview){const n=e.preview,o=_t(e.url||""),c=vc(e.url||"");t.innerHTML=`
156
+ `;else if(e.preview){const n=e.preview,o=en(e.url||""),r=yc(e.url||"");t.innerHTML=`
144
157
  <a href="${n.url}" target="_blank" rel="noopener noreferrer" class="cb-link-preview-card">
145
158
  ${n.image?`
146
159
  <div class="cb-link-preview-image">
@@ -149,7 +162,7 @@
149
162
  `:""}
150
163
  <div class="cb-link-preview-content">
151
164
  <div class="cb-link-preview-header">
152
- ${c?`<img src="${c}" alt="" class="cb-link-preview-favicon" />`:""}
165
+ ${r?`<img src="${r}" alt="" class="cb-link-preview-favicon" />`:""}
153
166
  <span class="cb-link-preview-domain">${o}</span>
154
167
  </div>
155
168
  ${n.title?`
@@ -191,16 +204,37 @@
191
204
  <a href="${e.url}" target="_blank" rel="noopener noreferrer" class="cb-link-preview-simple-url">
192
205
  ${e.url}
193
206
  </a>
194
- <span class="cb-link-preview-simple-domain">${_t(e.url||"")}</span>
207
+ <span class="cb-link-preview-simple-domain">${en(e.url||"")}</span>
195
208
  </div>
196
209
  </div>
197
- `;return t}const vn={name:"linkPreview",tag:"div",editable:!1,allowedChildren:[],className:"cb-link-preview",label:"Link Preview",icon:"link",create:e=>{const t={id:(e==null?void 0:e.id)||F(),url:(e==null?void 0:e.url)||"",loading:!0},n=Ne(t);return t.url&&Wt(t.url).then(o=>{if(o){t.preview=o,t.loading=!1;const c=Ne(t);n.innerHTML=c.innerHTML}else{t.loading=!1;const c=Ne(t);n.innerHTML=c.innerHTML}}),n},getData:e=>({url:e.getAttribute("data-url")||""}),update:(e,t)=>{if(t.url){e.setAttribute("data-url",t.url);const n=Ne({...t,loading:!0});e.innerHTML=n.innerHTML,Wt(t.url).then(o=>{if(o){const c=Ne({...t,preview:o,loading:!1});e.innerHTML=c.innerHTML}})}}},ft=[ct,rt,lt,it,cn,rn,ln,st,dt,sn,ut,pt,ht,bn,bt,mn,fn,yn,vn],xc=[ct,rt,lt,it,st,dt,ut,pt,ht,bt],xn=new Map(ft.map(e=>[e.name,e]));function wc(e){return xn.get(e)}const Cc=new Set(["p","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","code","hr","br","table","thead","tbody","tr","th","td","figure","figcaption","details","summary","strong","b","em","i","u","s","del","a","span","mark","sub","sup","img","video","audio","iframe"]),Sc={b:"strong",i:"em",strike:"s",del:"s",div:"p"},ze={"*":new Set(["class","id"]),a:new Set(["href","target","rel","title"]),img:new Set(["src","alt","title","width","height"]),video:new Set(["src","poster","controls","width","height"]),audio:new Set(["src","controls"]),iframe:new Set(["src","width","height","frameborder","allowfullscreen"]),td:new Set(["colspan","rowspan"]),th:new Set(["colspan","rowspan","scope"]),ol:new Set(["start","type"]),pre:new Set(["data-language"]),code:new Set(["data-language"]),span:new Set(["style"])},wn=new Set(["onclick","onmouseover","onmouseout","onmousedown","onmouseup","onkeydown","onkeyup","onkeypress","onload","onerror","onsubmit","onfocus","onblur","onchange","oninput","onscroll","onresize"]),Ec=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","vertical-align"]),Lc={allowIframes:!0,allowTables:!0,allowImages:!0,allowVideos:!0,additionalTags:[],stripStyles:!1,stripClasses:!1,keepClassPrefix:"cb-",maxDepth:10};function Cn(e,t={}){const n={...Lc,...t},o=document.createElement("div");return o.innerHTML=e,et(o,n,0),o.innerHTML}function et(e,t,n){if(n>(t.maxDepth||10)){e.textContent=e.textContent;return}const o=[],c=[];e.childNodes.forEach(r=>{if(r.nodeType===Node.TEXT_NODE)return;if(r.nodeType===Node.COMMENT_NODE){o.push(r);return}if(r.nodeType!==Node.ELEMENT_NODE){o.push(r);return}const i=r,a=i.tagName.toLowerCase(),d=Sc[a];if(d){const x=document.createElement(d);x.innerHTML=i.innerHTML,Tc(i,x),c.push({old:i,new:x}),et(x,t,n+1);return}const w=new Set([...Cc,...t.additionalTags||[]]);if(a==="iframe"&&!t.allowIframes){o.push(i);return}if(a==="table"&&!t.allowTables){const x=document.createTextNode(i.textContent||"");c.push({old:i,new:x});return}if(a==="img"&&!t.allowImages){o.push(i);return}if((a==="video"||a==="audio")&&!t.allowVideos){o.push(i);return}if(!w.has(a)){if(i.childNodes.length>0){const x=document.createDocumentFragment();for(;i.firstChild;)x.appendChild(i.firstChild);c.push({old:i,new:x})}else o.push(i);return}Ac(i,a,t),et(i,t,n+1)}),o.forEach(r=>{var i;return(i=r.parentNode)==null?void 0:i.removeChild(r)}),c.forEach(({old:r,new:i})=>{var a;(a=r.parentNode)==null||a.replaceChild(i,r)})}function Ac(e,t,n){const o=ze["*"]||new Set,c=ze[t]||new Set,r=new Set([...o,...c]);Array.from(e.attributes).forEach(a=>{const d=a.name.toLowerCase();if(wn.has(d)||d.startsWith("on")){e.removeAttribute(a.name);return}if(d.startsWith("data-")&&d!=="data-language"){e.removeAttribute(a.name);return}if(d==="class"){if(n.stripClasses)e.removeAttribute("class");else if(n.keepClassPrefix){const x=a.value.split(/\s+/).filter(m=>m.startsWith(n.keepClassPrefix)||m.startsWith("cb-"));x.length>0?e.className=x.join(" "):e.removeAttribute("class")}return}if(d==="style"){n.stripStyles?e.removeAttribute("style"):Mc(e);return}if(!r.has(d)){e.removeAttribute(a.name);return}if(d==="href"||d==="src"){const w=a.value.trim().toLowerCase();(w.startsWith("javascript:")||w.startsWith("vbscript:")||w.startsWith("data:text/html"))&&e.removeAttribute(a.name)}})}function Mc(e){e.style;const t=e.getAttribute("style")||"",n=[];t.split(";").forEach(o=>{const[c,r]=o.split(":").map(i=>i.trim());if(c&&r&&Ec.has(c.toLowerCase())){const i=r.toLowerCase();!i.includes("url(")&&!i.includes("expression(")&&!i.includes("javascript:")&&n.push(`${c}: ${r}`)}}),n.length>0?e.setAttribute("style",n.join("; ")):e.removeAttribute("style")}function Tc(e,t,n){const o=t.tagName.toLowerCase(),c=ze["*"]||new Set,r=ze[o]||new Set,i=new Set([...c,...r]);Array.from(e.attributes).forEach(a=>{const d=a.name.toLowerCase();i.has(d)&&!wn.has(d)&&t.setAttribute(a.name,a.value)})}function Sn(e,t={}){let n=e.getData("text/html");if(n)return n=Nc(n),Cn(n,t);const o=e.getData("text/plain");return o?En(o):""}function Nc(e){return e=e.replace(/<\/?o:[^>]*>/gi,""),e=e.replace(/<\/?w:[^>]*>/gi,""),e=e.replace(/<\/?m:[^>]*>/gi,""),e=e.replace(/<\/?st1:[^>]*>/gi,""),e=e.replace(/\s*xmlns:[a-z]+="[^"]*"/gi,""),e=e.replace(/mso-[^;:"']+:[^;:"']+;?/gi,""),e=e.replace(/class="?Mso[^">\s]*/gi,""),e=e.replace(/<span[^>]*>\s*<\/span>/gi,""),e=e.replace(/id="docs-internal-guid-[^"]*"/gi,""),e=e.replace(/\s{2,}/g," "),e}function En(e){return e?e.split(/\n\n+/).map(n=>{const o=n.trim().replace(/\n/g,"<br>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");return o?`<p>${o}</p>`:""}).filter(Boolean).join(""):""}function Bc(e){const t=document.createElement("div");t.innerHTML=e;const n=document.createDocumentFragment();let o=null;t.childNodes.forEach(r=>{var i;if(r.nodeType===Node.TEXT_NODE){const a=(i=r.textContent)==null?void 0:i.trim();a&&(o||(o=document.createElement("p")),o.appendChild(document.createTextNode(a)))}else r.nodeType===Node.ELEMENT_NODE&&($c(r.tagName)?(o&&(n.appendChild(o),o=null),n.appendChild(r.cloneNode(!0))):(o||(o=document.createElement("p")),o.appendChild(r.cloneNode(!0))))}),o&&n.appendChild(o);const c=document.createElement("div");return c.appendChild(n),c.innerHTML}function $c(e){return new Set(["P","H1","H2","H3","H4","H5","H6","UL","OL","LI","BLOCKQUOTE","PRE","TABLE","HR","DIV","FIGURE","DETAILS"]).has(e.toUpperCase())}const Yt=50,Kt=10;function Ln(e){const{container:t,handleSelector:n="[data-drag-handle]"}=e;let o={isDragging:!1,draggedElement:null,placeholder:null,startY:0,currentY:0,scrollInterval:null};function c(){const A=document.createElement("div");return A.className="cb-drag-placeholder",A.style.cssText=`
198
- height: 4px;
199
- background: var(--cb-primary, #3b82f6);
200
- border-radius: 2px;
201
- margin: 4px 0;
202
- transition: opacity 0.2s;
203
- `,A}function r(){return Array.from(t.querySelectorAll("[data-block-id]"))}function i(A){const C=r().filter($=>$!==o.draggedElement);for(const $ of C){const U=$.getBoundingClientRect(),D=U.top+U.height/2;if(A<D)return{element:$,position:"before"}}return{element:C[C.length-1]||null,position:"after"}}function a(A,C){var M,$;!o.placeholder||!A||(C==="before"?(M=A.parentNode)==null||M.insertBefore(o.placeholder,A):($=A.parentNode)==null||$.insertBefore(o.placeholder,A.nextSibling))}function d(A){const C=t.getBoundingClientRect();o.scrollInterval&&(clearInterval(o.scrollInterval),o.scrollInterval=null),A<C.top+Yt?o.scrollInterval=window.setInterval(()=>{t.scrollTop-=Kt},16):A>C.bottom-Yt&&(o.scrollInterval=window.setInterval(()=>{t.scrollTop+=Kt},16))}function w(A){var D,ee;const M=A.target.closest(n);if(!M)return;const $=ye(M);if(!$)return;A.preventDefault();const U="touches"in A?A.touches[0].clientY:A.clientY;o={...o,isDragging:!0,draggedElement:$,placeholder:c(),startY:U,currentY:U},$.style.opacity="0.5",$.style.pointerEvents="none",(D=$.parentNode)==null||D.insertBefore(o.placeholder,$.nextSibling),document.addEventListener("mousemove",x),document.addEventListener("mouseup",m),document.addEventListener("touchmove",x,{passive:!1}),document.addEventListener("touchend",m),(ee=e.onDragStart)==null||ee.call(e,$)}function x(A){var U;if(!o.isDragging||!o.draggedElement)return;A.preventDefault();const C="touches"in A?A.touches[0].clientY:A.clientY;o.currentY=C,d(C);const{element:M,position:$}=i(C);a(M,$),(U=e.onDragMove)==null||U.call(e,o.draggedElement,M,$)}function m(A){var D,ee;if(!o.isDragging||!o.draggedElement){T();return}const{element:C,position:M}=i(o.currentY);C&&((D=o.placeholder)!=null&&D.parentNode)&&o.placeholder.parentNode.insertBefore(o.draggedElement,o.placeholder);const U=r().indexOf(o.draggedElement);o.draggedElement.style.opacity="",o.draggedElement.style.pointerEvents="",(ee=e.onDragEnd)==null||ee.call(e,o.draggedElement,U),T()}function T(){var A;(A=o.placeholder)==null||A.remove(),o.scrollInterval&&clearInterval(o.scrollInterval),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",m),o={isDragging:!1,draggedElement:null,placeholder:null,startY:0,currentY:0,scrollInterval:null}}return t.addEventListener("mousedown",w),t.addEventListener("touchstart",w,{passive:!1}),()=>{t.removeEventListener("mousedown",w),t.removeEventListener("touchstart",w),T()}}function Hc(){const e=document.createElement("button");return e.type="button",e.className="cb-drag-handle",e.setAttribute("data-drag-handle","true"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-label","Drag to reorder"),e.innerHTML=`
210
+ `;return t}const Ln={name:"linkPreview",tag:"div",editable:!1,allowedChildren:[],className:"cb-link-preview",label:"Link Preview",icon:"link",create:e=>{const t={id:(e==null?void 0:e.id)||le(),url:(e==null?void 0:e.url)||"",loading:!0},n=Qe(t);return t.url&&Zt(t.url).then(o=>{if(o){t.preview=o,t.loading=!1;const r=Qe(t);n.innerHTML=r.innerHTML}else{t.loading=!1;const r=Qe(t);n.innerHTML=r.innerHTML}}),n},getData:e=>({url:e.getAttribute("data-url")||""}),update:(e,t)=>{if(t.url){e.setAttribute("data-url",t.url);const n=Qe({...t,loading:!0});e.innerHTML=n.innerHTML,Zt(t.url).then(o=>{if(o){const r=Qe({...t,preview:o,loading:!1});e.innerHTML=r.innerHTML}})}}},jn={name:"excalidraw",tag:"div",editable:!1,allowedChildren:[],className:"cb-excalidraw",icon:"pen-tool",label:"Excalidraw",create(e){const t=document.createElement("div");if(t.className="cb-excalidraw",t.setAttribute("data-block-id",(e==null?void 0:e.id)||le()),t.setAttribute("data-block-type","excalidraw"),e!=null&&e.imageDataUrl){if(e.elements)try{const a=JSON.stringify(e.elements);a.length>1e6?(console.error("Excalidraw elements data too large (>1MB). Data may not be saved correctly."),t.setAttribute("data-excalidraw-error","Data too large")):t.setAttribute("data-excalidraw-elements",a)}catch(a){console.error("Failed to serialize Excalidraw elements:",a),t.setAttribute("data-excalidraw-error","Serialization failed")}if(e.appState)try{const a=JSON.stringify(e.appState);a.length>5e5?console.error("Excalidraw appState data too large (>500KB)."):t.setAttribute("data-excalidraw-appstate",a)}catch(a){console.error("Failed to serialize Excalidraw appState:",a)}const n=document.createElement("div");n.className="cb-excalidraw-wrapper";const o=document.createElement("img");o.className="cb-excalidraw-image",o.src=e.imageDataUrl,o.alt="Excalidraw drawing";const r=document.createElement("button");r.className="cb-excalidraw-edit-btn",r.type="button",r.innerHTML=`
211
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
212
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
213
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
214
+ </svg>
215
+ <span>Edit Drawing</span>
216
+ `,r.title="Edit Excalidraw drawing",n.appendChild(o),n.appendChild(r),t.appendChild(n)}else{const n=document.createElement("div");n.className="cb-excalidraw-placeholder",n.innerHTML=`
217
+ <div class="cb-excalidraw-placeholder-content">
218
+ <div class="cb-excalidraw-placeholder-icon">
219
+ <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
220
+ <path d="M12 19l7-7 3 3-7 7-3-3z"></path>
221
+ <path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"></path>
222
+ <path d="M2 2l7.586 7.586"></path>
223
+ <circle cx="11" cy="11" r="2"></circle>
224
+ </svg>
225
+ </div>
226
+ <div class="cb-excalidraw-placeholder-text">
227
+ <span class="cb-excalidraw-placeholder-title">Click to create a drawing</span>
228
+ <span class="cb-excalidraw-placeholder-hint">Use Excalidraw to create diagrams, sketches, and illustrations</span>
229
+ </div>
230
+ </div>
231
+ `,t.appendChild(n)}return t},getData(e){const t=e.getAttribute("data-block-id")||void 0,n=e.querySelector(".cb-excalidraw-image"),o=(n==null?void 0:n.src)||void 0;let r,a;try{const s=e.getAttribute("data-excalidraw-elements");s&&(r=JSON.parse(s))}catch(s){console.error("Failed to parse Excalidraw elements:",s);const d=e.getAttribute("data-excalidraw-error");d&&console.error("Stored error:",d)}try{const s=e.getAttribute("data-excalidraw-appstate");s&&(a=JSON.parse(s))}catch(s){console.error("Failed to parse Excalidraw appState:",s)}return{id:t,imageDataUrl:o,elements:r,appState:a}},update(e,t){if(t.imageDataUrl){let n=e.querySelector(".cb-excalidraw-wrapper");if(n){const o=n.querySelector(".cb-excalidraw-image");o&&(o.src=t.imageDataUrl)}else{const o=e.querySelector(".cb-excalidraw-placeholder");o&&o.remove(),n=document.createElement("div"),n.className="cb-excalidraw-wrapper";const r=document.createElement("img");r.className="cb-excalidraw-image",r.src=t.imageDataUrl,r.alt="Excalidraw drawing";const a=document.createElement("button");a.className="cb-excalidraw-edit-btn",a.type="button",a.innerHTML=`
232
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
233
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
234
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
235
+ </svg>
236
+ <span>Edit Drawing</span>
237
+ `,a.title="Edit Excalidraw drawing",n.appendChild(r),n.appendChild(a),e.appendChild(n)}if(t.elements)try{const o=JSON.stringify(t.elements);o.length>1e6?(console.error("Excalidraw elements data too large (>1MB). Data may not be saved correctly."),e.setAttribute("data-excalidraw-error","Data too large")):(e.setAttribute("data-excalidraw-elements",o),e.removeAttribute("data-excalidraw-error"))}catch(o){console.error("Failed to serialize Excalidraw elements:",o),e.setAttribute("data-excalidraw-error","Serialization failed")}if(t.appState)try{const o=JSON.stringify(t.appState);o.length>5e5?console.error("Excalidraw appState data too large (>500KB)."):e.setAttribute("data-excalidraw-appstate",o)}catch(o){console.error("Failed to serialize Excalidraw appState:",o)}}}},Wt=[Mt,Dt,Bt,Rt,bn,pn,mn,Ht,qt,fn,It,zt,Pt,xn,Ft,Cn,Sn,An,Nn,Ln,jn],kc=[Mt,Dt,Bt,Rt,Ht,qt,It,zt,Pt,Ft],Mn=new Map(Wt.map(e=>[e.name,e]));function xc(e){return Mn.get(e)}const wc=new Set(["p","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","code","hr","br","table","thead","tbody","tr","th","td","figure","figcaption","details","summary","strong","b","em","i","u","s","del","a","span","mark","sub","sup","img","video","audio","iframe"]),Cc={b:"strong",i:"em",strike:"s",del:"s",div:"p"},rt={"*":new Set(["class","id"]),a:new Set(["href","target","rel","title"]),img:new Set(["src","alt","title","width","height"]),video:new Set(["src","poster","controls","width","height"]),audio:new Set(["src","controls"]),iframe:new Set(["src","width","height","frameborder","allowfullscreen"]),td:new Set(["colspan","rowspan"]),th:new Set(["colspan","rowspan","scope"]),ol:new Set(["start","type"]),pre:new Set(["data-language"]),code:new Set(["data-language"]),span:new Set(["style"])},Dn=new Set(["onclick","onmouseover","onmouseout","onmousedown","onmouseup","onkeydown","onkeyup","onkeypress","onload","onerror","onsubmit","onfocus","onblur","onchange","oninput","onscroll","onresize"]),Sc=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","vertical-align"]),Ec={allowIframes:!0,allowTables:!0,allowImages:!0,allowVideos:!0,additionalTags:[],stripStyles:!1,stripClasses:!1,keepClassPrefix:"cb-",maxDepth:10};function Bn(e,t={}){const n={...Ec,...t},o=document.createElement("div");return o.innerHTML=e,Tt(o,n,0),o.innerHTML}function Tt(e,t,n){if(n>(t.maxDepth||10)){e.textContent=e.textContent;return}const o=[],r=[];e.childNodes.forEach(a=>{if(a.nodeType===Node.TEXT_NODE)return;if(a.nodeType===Node.COMMENT_NODE){o.push(a);return}if(a.nodeType!==Node.ELEMENT_NODE){o.push(a);return}const s=a,d=s.tagName.toLowerCase(),w=Cc[d];if(w){const D=document.createElement(w);D.innerHTML=s.innerHTML,Tc(s,D),r.push({old:s,new:D}),Tt(D,t,n+1);return}const H=new Set([...wc,...t.additionalTags||[]]);if(d==="iframe"&&!t.allowIframes){o.push(s);return}if(d==="table"&&!t.allowTables){const D=document.createTextNode(s.textContent||"");r.push({old:s,new:D});return}if(d==="img"&&!t.allowImages){o.push(s);return}if((d==="video"||d==="audio")&&!t.allowVideos){o.push(s);return}if(!H.has(d)){if(s.childNodes.length>0){const D=document.createDocumentFragment();for(;s.firstChild;)D.appendChild(s.firstChild);r.push({old:s,new:D})}else o.push(s);return}Ac(s,d,t),Tt(s,t,n+1)}),o.forEach(a=>{var s;return(s=a.parentNode)==null?void 0:s.removeChild(a)}),r.forEach(({old:a,new:s})=>{var d;(d=a.parentNode)==null||d.replaceChild(s,a)})}function Ac(e,t,n){const o=rt["*"]||new Set,r=rt[t]||new Set,a=new Set([...o,...r]);Array.from(e.attributes).forEach(d=>{const w=d.name.toLowerCase();if(Dn.has(w)||w.startsWith("on")){e.removeAttribute(d.name);return}if(w.startsWith("data-")&&w!=="data-language"){e.removeAttribute(d.name);return}if(w==="class"){if(n.stripClasses)e.removeAttribute("class");else if(n.keepClassPrefix){const D=d.value.split(/\s+/).filter(L=>L.startsWith(n.keepClassPrefix)||L.startsWith("cb-"));D.length>0?e.className=D.join(" "):e.removeAttribute("class")}return}if(w==="style"){n.stripStyles?e.removeAttribute("style"):Nc(e);return}if(!a.has(w)){e.removeAttribute(d.name);return}if(w==="href"||w==="src"){const H=d.value.trim().toLowerCase();(H.startsWith("javascript:")||H.startsWith("vbscript:")||H.startsWith("data:text/html"))&&e.removeAttribute(d.name)}})}function Nc(e){e.style;const t=e.getAttribute("style")||"",n=[];t.split(";").forEach(o=>{const[r,a]=o.split(":").map(s=>s.trim());if(r&&a&&Sc.has(r.toLowerCase())){const s=a.toLowerCase();!s.includes("url(")&&!s.includes("expression(")&&!s.includes("javascript:")&&n.push(`${r}: ${a}`)}}),n.length>0?e.setAttribute("style",n.join("; ")):e.removeAttribute("style")}function Tc(e,t,n){const o=t.tagName.toLowerCase(),r=rt["*"]||new Set,a=rt[o]||new Set,s=new Set([...r,...a]);Array.from(e.attributes).forEach(d=>{const w=d.name.toLowerCase();s.has(w)&&!Dn.has(w)&&t.setAttribute(d.name,d.value)})}function Rn(e,t={}){let n=e.getData("text/html");if(n)return n=Lc(n),Bn(n,t);const o=e.getData("text/plain");return o?$n(o):""}function Lc(e){return e=e.replace(/<\/?o:[^>]*>/gi,""),e=e.replace(/<\/?w:[^>]*>/gi,""),e=e.replace(/<\/?m:[^>]*>/gi,""),e=e.replace(/<\/?st1:[^>]*>/gi,""),e=e.replace(/\s*xmlns:[a-z]+="[^"]*"/gi,""),e=e.replace(/mso-[^;:"']+:[^;:"']+;?/gi,""),e=e.replace(/class="?Mso[^">\s]*/gi,""),e=e.replace(/<span[^>]*>\s*<\/span>/gi,""),e=e.replace(/id="docs-internal-guid-[^"]*"/gi,""),e=e.replace(/\s{2,}/g," "),e}function $n(e){return e?e.split(/\n\n+/).map(n=>{const o=n.trim().replace(/\n/g,"<br>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");return o?`<p>${o}</p>`:""}).filter(Boolean).join(""):""}function jc(e){const t=document.createElement("div");t.innerHTML=e;const n=document.createDocumentFragment();let o=null;t.childNodes.forEach(a=>{var s;if(a.nodeType===Node.TEXT_NODE){const d=(s=a.textContent)==null?void 0:s.trim();d&&(o||(o=document.createElement("p")),o.appendChild(document.createTextNode(d)))}else a.nodeType===Node.ELEMENT_NODE&&(Mc(a.tagName)?(o&&(n.appendChild(o),o=null),n.appendChild(a.cloneNode(!0))):(o||(o=document.createElement("p")),o.appendChild(a.cloneNode(!0))))}),o&&n.appendChild(o);const r=document.createElement("div");return r.appendChild(n),r.innerHTML}function Mc(e){return new Set(["P","H1","H2","H3","H4","H5","H6","UL","OL","LI","BLOCKQUOTE","PRE","TABLE","HR","DIV","FIGURE","DETAILS"]).has(e.toUpperCase())}const tn=50,nn=10;function Hn(e){const{container:t,handleSelector:n="[data-drag-handle]"}=e;let o={isDragging:!1,draggedElement:null,draggedElements:[],placeholder:null,startY:0,currentY:0,scrollInterval:null};function r(){const T=document.createElement("div");return T.className="cb-drag-placeholder",T.style.height="4px",T.style.minHeight="4px",T.style.maxHeight="4px",T.style.lineHeight="4px",T.style.fontSize="0",T.style.overflow="hidden",T.style.display="block",T.style.background="var(--cb-primary, #3b82f6)",T.style.borderRadius="2px",T.style.margin="4px 0",T.style.padding="0",T.style.border="none",T.style.transition="opacity 0.2s",T.style.pointerEvents="none",T.style.flex="none",T.style.flexShrink="0",T.style.flexGrow="0",T}function a(){return Array.from(t.querySelectorAll("[data-block-id]"))}function s(T){const $=a().filter(z=>!o.draggedElements.includes(z)&&z!==o.draggedElement);for(const z of $){const re=z.getBoundingClientRect(),Z=re.top+re.height/2;if(T<Z)return{element:z,position:"before"}}return{element:$[$.length-1]||null,position:"after"}}function d(T,$){var x,z;!o.placeholder||!T||($==="before"?(x=T.parentNode)==null||x.insertBefore(o.placeholder,T):(z=T.parentNode)==null||z.insertBefore(o.placeholder,T.nextSibling))}function w(T){const $=t.getBoundingClientRect();o.scrollInterval&&(clearInterval(o.scrollInterval),o.scrollInterval=null),T<$.top+tn?o.scrollInterval=window.setInterval(()=>{t.scrollTop-=nn},16):T>$.bottom-tn&&(o.scrollInterval=window.setInterval(()=>{t.scrollTop+=nn},16))}function H(T){var ue,G,ae;const x=T.target.closest(n);if(!x||"shiftKey"in T&&T.shiftKey)return;const z=Ue(x);if(!z)return;T.preventDefault();const re="touches"in T?T.touches[0].clientY:T.clientY,Z=((ue=e.getSelectedBlocks)==null?void 0:ue.call(e))||[],te=z.getAttribute("data-block-id"),A=Z.some(be=>be.getAttribute("data-block-id")===te);let fe=[];if(A&&Z.length>1){console.log("🎯 Group drag: dragging",Z.length,"selected blocks");const be=a();fe=Z.sort((ye,me)=>be.indexOf(ye)-be.indexOf(me)),console.log("📋 Blocks to drag in order:",fe.map(ye=>ye.getAttribute("data-block-id")))}else fe=[z],console.log("📦 Single block drag:",te);o={...o,isDragging:!0,draggedElement:z,draggedElements:fe,placeholder:r(),startY:re,currentY:re},fe.forEach((be,ye)=>{be.style.opacity="0.5",be.style.pointerEvents="none",console.log(` ${ye+1}. Styling block:`,be.getAttribute("data-block-id"))});const ve=fe[fe.length-1];(G=ve.parentNode)==null||G.insertBefore(o.placeholder,ve.nextSibling),document.addEventListener("mousemove",D),document.addEventListener("mouseup",L),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("touchend",L),(ae=e.onDragStart)==null||ae.call(e,z)}function D(T){var re;if(!o.isDragging||!o.draggedElement)return;T.preventDefault();const $="touches"in T?T.touches[0].clientY:T.clientY;o.currentY=$,w($);const{element:x,position:z}=s($);d(x,z),(re=e.onDragMove)==null||re.call(e,o.draggedElement,x,z)}function L(T){var re,Z,te;if(!o.isDragging||!o.draggedElement){_();return}if(console.log("🎯 Drag end - analyzing drop position"),console.log(" Blocks to move:",o.draggedElements.map(A=>A.getAttribute("data-block-id"))),o.draggedElements.length>1&&((re=o.placeholder)!=null&&re.parentNode)){const A=Array.from(o.placeholder.parentNode.children),fe=A.indexOf(o.placeholder);console.log(" 📍 Placeholder at index:",fe,"of",A.length,"children");const ve=A[fe-1],ue=A[fe+1],G=ve&&o.draggedElements.includes(ve),ae=ue&&o.draggedElements.includes(ue);if(console.log(" 📊 Before placeholder:",ve==null?void 0:ve.getAttribute("data-block-id"),"isDragged:",G),console.log(" 📊 After placeholder:",ue==null?void 0:ue.getAttribute("data-block-id"),"isDragged:",ae),G&&ae){console.log(" ⚠️ Cannot split selected blocks - canceling drag"),o.draggedElements.forEach(be=>{be.style.opacity="",be.style.pointerEvents=""}),o.placeholder&&(o.placeholder.remove(),o.placeholder=null),_();return}console.log(" ✅ Valid drop position - moving all blocks")}if((Z=o.placeholder)!=null&&Z.parentNode){const A=o.placeholder.parentNode;console.log(" Inserting blocks before placeholder...");const fe=document.createDocumentFragment();o.draggedElements.forEach((ve,ue)=>{fe.appendChild(ve),console.log(` ${ue+1}. Added to fragment:`,ve.getAttribute("data-block-id"))}),A.insertBefore(fe,o.placeholder),console.log("✅ All blocks moved successfully (maintaining order)")}const z=a().indexOf(o.draggedElement);console.log("📍 New index:",z),o.draggedElements.forEach(A=>{A.style.opacity="",A.style.pointerEvents=""}),o.placeholder&&(o.placeholder.remove(),o.placeholder=null),(te=e.onDragEnd)==null||te.call(e,o.draggedElement,z),_()}function _(){var T;(T=o.placeholder)==null||T.remove(),o.scrollInterval&&clearInterval(o.scrollInterval),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",L),document.removeEventListener("touchmove",D),document.removeEventListener("touchend",L),o={isDragging:!1,draggedElement:null,draggedElements:[],placeholder:null,startY:0,currentY:0,scrollInterval:null}}return t.addEventListener("mousedown",H),t.addEventListener("touchstart",H,{passive:!1}),()=>{t.removeEventListener("mousedown",H),t.removeEventListener("touchstart",H),_()}}function Dc(){const e=document.createElement("button");return e.type="button",e.className="cb-drag-handle",e.setAttribute("data-drag-handle","true"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-label","Drag to reorder"),e.innerHTML=`
204
238
  <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
205
239
  <circle cx="5" cy="3" r="1.5"/>
206
240
  <circle cx="11" cy="3" r="1.5"/>
@@ -209,362 +243,7 @@
209
243
  <circle cx="5" cy="13" r="1.5"/>
210
244
  <circle cx="11" cy="13" r="1.5"/>
211
245
  </svg>
212
- `,e}function qc(){return"draggable"in document.createElement("div")}function An(){const e=window.getSelection();if(!e||e.rangeCount===0)return{range:null,anchorNode:null,focusNode:null,anchorOffset:0,focusOffset:0,isCollapsed:!0,block:null};const t=e.getRangeAt(0),n=ye(t.commonAncestorContainer);return{range:t.cloneRange(),anchorNode:e.anchorNode,focusNode:e.focusNode,anchorOffset:e.anchorOffset,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,block:n}}function jc(){return An()}function Rc(e){if(!e.range)return!1;try{const t=window.getSelection();if(t)return t.removeAllRanges(),t.addRange(e.range),!0}catch{}return!1}function Dc(){const e=window.getSelection();return(e==null?void 0:e.toString())||""}function Ic(){const e=window.getSelection();if(!e||e.rangeCount===0)return"";const t=e.getRangeAt(0),n=document.createElement("div");return n.appendChild(t.cloneContents()),n.innerHTML}function zc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function Pc(e){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0),o=ye(n.startContainer),c=ye(n.endContainer);return o!==c}function Oc(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Fc(){const e=window.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}function Uc(){const e=window.getSelection();e&&!e.isCollapsed&&e.collapseToEnd()}function Vc(e,t){var r;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let o=0,c;for(;c=n.nextNode();){const i=((r=c.textContent)==null?void 0:r.length)||0;if(o+i>=t){const a=document.createRange();a.setStart(c,t-o),a.collapse(!0);const d=window.getSelection();if(d)return d.removeAllRanges(),d.addRange(a),!0}o+=i}return!1}function Wc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return 0;const n=t.getRangeAt(0),o=n.cloneRange();return o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),o.toString().length}function De(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!n.collapsed)return!1;const o=n.cloneRange();return o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),o.toString().length===0}function Mn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!n.collapsed)return!1;const o=n.cloneRange();return o.selectNodeContents(e),o.setStart(n.endContainer,n.endOffset),o.toString().length===0}function be(e){const t=document.createRange(),n=window.getSelection(),c=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null).nextNode();c?t.setStart(c,0):t.setStart(e,0),t.collapse(!0),n&&(n.removeAllRanges(),n.addRange(t))}function xe(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!1),n&&(n.removeAllRanges(),n.addRange(t))}function Tn(e,t){const n=window.getSelection();if(!n||n.rangeCount===0||n.isCollapsed)return null;const o=n.getRangeAt(0),c=document.createElement(e);if(t)for(const[r,i]of Object.entries(t))c.setAttribute(r,i);try{return o.surroundContents(c),c}catch{const r=o.extractContents();return c.appendChild(r),o.insertNode(c),c}}function Nn(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Bn(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return[];const o=n.getRangeAt(0),c=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>a instanceof HTMLElement&&a.tagName.toLowerCase()===e.toLowerCase()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let i;for(;i=r.nextNode();)i instanceof HTMLElement&&o.intersectsNode(i)&&c.push(i);return c}/**
213
- * @license lucide-react v0.294.0 - ISC
214
- *
215
- * This source code is licensed under the ISC license.
216
- * See the LICENSE file in the root directory of this source tree.
217
- */var _c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
218
- * @license lucide-react v0.294.0 - ISC
219
- *
220
- * This source code is licensed under the ISC license.
221
- * See the LICENSE file in the root directory of this source tree.
222
- */const Yc=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),L=(e,t)=>{const n=h.forwardRef(({color:o="currentColor",size:c=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:a="",children:d,...w},x)=>h.createElement("svg",{ref:x,..._c,width:c,height:c,stroke:o,strokeWidth:i?Number(r)*24/Number(c):r,className:["lucide",`lucide-${Yc(e)}`,a].join(" "),...w},[...t.map(([m,T])=>h.createElement(m,T)),...Array.isArray(d)?d:[d]]));return n.displayName=`${e}`,n};/**
223
- * @license lucide-react v0.294.0 - ISC
224
- *
225
- * This source code is licensed under the ISC license.
226
- * See the LICENSE file in the root directory of this source tree.
227
- */const yt=L("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
228
- * @license lucide-react v0.294.0 - ISC
229
- *
230
- * This source code is licensed under the ISC license.
231
- * See the LICENSE file in the root directory of this source tree.
232
- */const Kc=L("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
233
- * @license lucide-react v0.294.0 - ISC
234
- *
235
- * This source code is licensed under the ISC license.
236
- * See the LICENSE file in the root directory of this source tree.
237
- */const $n=L("AlignCenter",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"17",x2:"7",y1:"12",y2:"12",key:"rsh8ii"}],["line",{x1:"19",x2:"5",y1:"18",y2:"18",key:"1t0tuv"}]]);/**
238
- * @license lucide-react v0.294.0 - ISC
239
- *
240
- * This source code is licensed under the ISC license.
241
- * See the LICENSE file in the root directory of this source tree.
242
- */const Gc=L("AlignJustify",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["line",{x1:"3",x2:"21",y1:"18",y2:"18",key:"kwyyxn"}]]);/**
243
- * @license lucide-react v0.294.0 - ISC
244
- *
245
- * This source code is licensed under the ISC license.
246
- * See the LICENSE file in the root directory of this source tree.
247
- */const Hn=L("AlignLeft",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}],["line",{x1:"17",x2:"3",y1:"18",y2:"18",key:"1awlsn"}]]);/**
248
- * @license lucide-react v0.294.0 - ISC
249
- *
250
- * This source code is licensed under the ISC license.
251
- * See the LICENSE file in the root directory of this source tree.
252
- */const qn=L("AlignRight",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}],["line",{x1:"21",x2:"7",y1:"18",y2:"18",key:"1g9eri"}]]);/**
253
- * @license lucide-react v0.294.0 - ISC
254
- *
255
- * This source code is licensed under the ISC license.
256
- * See the LICENSE file in the root directory of this source tree.
257
- */const jn=L("Bold",[["path",{d:"M14 12a4 4 0 0 0 0-8H6v8",key:"v2sylx"}],["path",{d:"M15 20a4 4 0 0 0 0-8H6v8Z",key:"1ef5ya"}]]);/**
258
- * @license lucide-react v0.294.0 - ISC
259
- *
260
- * This source code is licensed under the ISC license.
261
- * See the LICENSE file in the root directory of this source tree.
262
- */const Rn=L("Calendar",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2",key:"eu3xkr"}],["line",{x1:"16",x2:"16",y1:"2",y2:"6",key:"m3sa8f"}],["line",{x1:"8",x2:"8",y1:"2",y2:"6",key:"18kwsl"}],["line",{x1:"3",x2:"21",y1:"10",y2:"10",key:"xt86sb"}]]);/**
263
- * @license lucide-react v0.294.0 - ISC
264
- *
265
- * This source code is licensed under the ISC license.
266
- * See the LICENSE file in the root directory of this source tree.
267
- */const Xc=L("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
268
- * @license lucide-react v0.294.0 - ISC
269
- *
270
- * This source code is licensed under the ISC license.
271
- * See the LICENSE file in the root directory of this source tree.
272
- */const kt=L("CheckSquare",[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]]);/**
273
- * @license lucide-react v0.294.0 - ISC
274
- *
275
- * This source code is licensed under the ISC license.
276
- * See the LICENSE file in the root directory of this source tree.
277
- */const Zc=L("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
278
- * @license lucide-react v0.294.0 - ISC
279
- *
280
- * This source code is licensed under the ISC license.
281
- * See the LICENSE file in the root directory of this source tree.
282
- */const tt=L("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
283
- * @license lucide-react v0.294.0 - ISC
284
- *
285
- * This source code is licensed under the ISC license.
286
- * See the LICENSE file in the root directory of this source tree.
287
- */const Jc=L("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
288
- * @license lucide-react v0.294.0 - ISC
289
- *
290
- * This source code is licensed under the ISC license.
291
- * See the LICENSE file in the root directory of this source tree.
292
- */const Qc=L("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/**
293
- * @license lucide-react v0.294.0 - ISC
294
- *
295
- * This source code is licensed under the ISC license.
296
- * See the LICENSE file in the root directory of this source tree.
297
- */const er=L("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
298
- * @license lucide-react v0.294.0 - ISC
299
- *
300
- * This source code is licensed under the ISC license.
301
- * See the LICENSE file in the root directory of this source tree.
302
- */const vt=L("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
303
- * @license lucide-react v0.294.0 - ISC
304
- *
305
- * This source code is licensed under the ISC license.
306
- * See the LICENSE file in the root directory of this source tree.
307
- */const tr=L("Columns",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}]]);/**
308
- * @license lucide-react v0.294.0 - ISC
309
- *
310
- * This source code is licensed under the ISC license.
311
- * See the LICENSE file in the root directory of this source tree.
312
- */const Dn=L("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
313
- * @license lucide-react v0.294.0 - ISC
314
- *
315
- * This source code is licensed under the ISC license.
316
- * See the LICENSE file in the root directory of this source tree.
317
- */const In=L("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
318
- * @license lucide-react v0.294.0 - ISC
319
- *
320
- * This source code is licensed under the ISC license.
321
- * See the LICENSE file in the root directory of this source tree.
322
- */const zn=L("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/**
323
- * @license lucide-react v0.294.0 - ISC
324
- *
325
- * This source code is licensed under the ISC license.
326
- * See the LICENSE file in the root directory of this source tree.
327
- */const nr=L("ExternalLink",[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]]);/**
328
- * @license lucide-react v0.294.0 - ISC
329
- *
330
- * This source code is licensed under the ISC license.
331
- * See the LICENSE file in the root directory of this source tree.
332
- */const Pn=L("FileCode",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 13-2 2 2 2",key:"17smn8"}],["path",{d:"m14 17 2-2-2-2",key:"14mezr"}]]);/**
333
- * @license lucide-react v0.294.0 - ISC
334
- *
335
- * This source code is licensed under the ISC license.
336
- * See the LICENSE file in the root directory of this source tree.
337
- */const Le=L("FileText",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["line",{x1:"16",x2:"8",y1:"13",y2:"13",key:"14keom"}],["line",{x1:"16",x2:"8",y1:"17",y2:"17",key:"17nazh"}],["line",{x1:"10",x2:"8",y1:"9",y2:"9",key:"1a5vjj"}]]);/**
338
- * @license lucide-react v0.294.0 - ISC
339
- *
340
- * This source code is licensed under the ISC license.
341
- * See the LICENSE file in the root directory of this source tree.
342
- */const or=L("File",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]);/**
343
- * @license lucide-react v0.294.0 - ISC
344
- *
345
- * This source code is licensed under the ISC license.
346
- * See the LICENSE file in the root directory of this source tree.
347
- */const On=L("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
348
- * @license lucide-react v0.294.0 - ISC
349
- *
350
- * This source code is licensed under the ISC license.
351
- * See the LICENSE file in the root directory of this source tree.
352
- */const xt=L("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/**
353
- * @license lucide-react v0.294.0 - ISC
354
- *
355
- * This source code is licensed under the ISC license.
356
- * See the LICENSE file in the root directory of this source tree.
357
- */const wt=L("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/**
358
- * @license lucide-react v0.294.0 - ISC
359
- *
360
- * This source code is licensed under the ISC license.
361
- * See the LICENSE file in the root directory of this source tree.
362
- */const Ct=L("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/**
363
- * @license lucide-react v0.294.0 - ISC
364
- *
365
- * This source code is licensed under the ISC license.
366
- * See the LICENSE file in the root directory of this source tree.
367
- */const cr=L("Heading4",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v4h4",key:"13sv97"}],["path",{d:"M21 10v8",key:"1kdml4"}]]);/**
368
- * @license lucide-react v0.294.0 - ISC
369
- *
370
- * This source code is licensed under the ISC license.
371
- * See the LICENSE file in the root directory of this source tree.
372
- */const rr=L("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/**
373
- * @license lucide-react v0.294.0 - ISC
374
- *
375
- * This source code is licensed under the ISC license.
376
- * See the LICENSE file in the root directory of this source tree.
377
- */const lr=L("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/**
378
- * @license lucide-react v0.294.0 - ISC
379
- *
380
- * This source code is licensed under the ISC license.
381
- * See the LICENSE file in the root directory of this source tree.
382
- */const Fn=L("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/**
383
- * @license lucide-react v0.294.0 - ISC
384
- *
385
- * This source code is licensed under the ISC license.
386
- * See the LICENSE file in the root directory of this source tree.
387
- */const Oe=L("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
388
- * @license lucide-react v0.294.0 - ISC
389
- *
390
- * This source code is licensed under the ISC license.
391
- * See the LICENSE file in the root directory of this source tree.
392
- */const ir=L("Indent",[["polyline",{points:"3 8 7 12 3 16",key:"f3rxhf"}],["line",{x1:"21",x2:"11",y1:"12",y2:"12",key:"1fxxak"}],["line",{x1:"21",x2:"11",y1:"6",y2:"6",key:"asgu94"}],["line",{x1:"21",x2:"11",y1:"18",y2:"18",key:"13dsj7"}]]);/**
393
- * @license lucide-react v0.294.0 - ISC
394
- *
395
- * This source code is licensed under the ISC license.
396
- * See the LICENSE file in the root directory of this source tree.
397
- */const ar=L("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
398
- * @license lucide-react v0.294.0 - ISC
399
- *
400
- * This source code is licensed under the ISC license.
401
- * See the LICENSE file in the root directory of this source tree.
402
- */const Un=L("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
403
- * @license lucide-react v0.294.0 - ISC
404
- *
405
- * This source code is licensed under the ISC license.
406
- * See the LICENSE file in the root directory of this source tree.
407
- */const sr=L("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
408
- * @license lucide-react v0.294.0 - ISC
409
- *
410
- * This source code is licensed under the ISC license.
411
- * See the LICENSE file in the root directory of this source tree.
412
- */const $e=L("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
413
- * @license lucide-react v0.294.0 - ISC
414
- *
415
- * This source code is licensed under the ISC license.
416
- * See the LICENSE file in the root directory of this source tree.
417
- */const St=L("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
418
- * @license lucide-react v0.294.0 - ISC
419
- *
420
- * This source code is licensed under the ISC license.
421
- * See the LICENSE file in the root directory of this source tree.
422
- */const Et=L("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/**
423
- * @license lucide-react v0.294.0 - ISC
424
- *
425
- * This source code is licensed under the ISC license.
426
- * See the LICENSE file in the root directory of this source tree.
427
- */const dr=L("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
428
- * @license lucide-react v0.294.0 - ISC
429
- *
430
- * This source code is licensed under the ISC license.
431
- * See the LICENSE file in the root directory of this source tree.
432
- */const Lt=L("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
433
- * @license lucide-react v0.294.0 - ISC
434
- *
435
- * This source code is licensed under the ISC license.
436
- * See the LICENSE file in the root directory of this source tree.
437
- */const ur=L("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
438
- * @license lucide-react v0.294.0 - ISC
439
- *
440
- * This source code is licensed under the ISC license.
441
- * See the LICENSE file in the root directory of this source tree.
442
- */const Vn=L("MoreHorizontal",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
443
- * @license lucide-react v0.294.0 - ISC
444
- *
445
- * This source code is licensed under the ISC license.
446
- * See the LICENSE file in the root directory of this source tree.
447
- */const Wn=L("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/**
448
- * @license lucide-react v0.294.0 - ISC
449
- *
450
- * This source code is licensed under the ISC license.
451
- * See the LICENSE file in the root directory of this source tree.
452
- */const _n=L("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/**
453
- * @license lucide-react v0.294.0 - ISC
454
- *
455
- * This source code is licensed under the ISC license.
456
- * See the LICENSE file in the root directory of this source tree.
457
- */const pr=L("Outdent",[["polyline",{points:"7 8 3 12 7 16",key:"2j60jr"}],["line",{x1:"21",x2:"11",y1:"12",y2:"12",key:"1fxxak"}],["line",{x1:"21",x2:"11",y1:"6",y2:"6",key:"asgu94"}],["line",{x1:"21",x2:"11",y1:"18",y2:"18",key:"13dsj7"}]]);/**
458
- * @license lucide-react v0.294.0 - ISC
459
- *
460
- * This source code is licensed under the ISC license.
461
- * See the LICENSE file in the root directory of this source tree.
462
- */const Yn=L("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",key:"1xcu5"}],["circle",{cx:"17.5",cy:"10.5",r:".5",key:"736e4u"}],["circle",{cx:"8.5",cy:"7.5",r:".5",key:"clrty"}],["circle",{cx:"6.5",cy:"12.5",r:".5",key:"1s4xz9"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
463
- * @license lucide-react v0.294.0 - ISC
464
- *
465
- * This source code is licensed under the ISC license.
466
- * See the LICENSE file in the root directory of this source tree.
467
- */const hr=L("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",key:"ymcmye"}]]);/**
468
- * @license lucide-react v0.294.0 - ISC
469
- *
470
- * This source code is licensed under the ISC license.
471
- * See the LICENSE file in the root directory of this source tree.
472
- */const Kn=L("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
473
- * @license lucide-react v0.294.0 - ISC
474
- *
475
- * This source code is licensed under the ISC license.
476
- * See the LICENSE file in the root directory of this source tree.
477
- */const At=L("Quote",[["path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z",key:"4rm80e"}],["path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z",key:"10za9r"}]]);/**
478
- * @license lucide-react v0.294.0 - ISC
479
- *
480
- * This source code is licensed under the ISC license.
481
- * See the LICENSE file in the root directory of this source tree.
482
- */const Gn=L("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/**
483
- * @license lucide-react v0.294.0 - ISC
484
- *
485
- * This source code is licensed under the ISC license.
486
- * See the LICENSE file in the root directory of this source tree.
487
- */const br=L("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
488
- * @license lucide-react v0.294.0 - ISC
489
- *
490
- * This source code is licensed under the ISC license.
491
- * See the LICENSE file in the root directory of this source tree.
492
- */const gr=L("Rows",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}]]);/**
493
- * @license lucide-react v0.294.0 - ISC
494
- *
495
- * This source code is licensed under the ISC license.
496
- * See the LICENSE file in the root directory of this source tree.
497
- */const mr=L("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
498
- * @license lucide-react v0.294.0 - ISC
499
- *
500
- * This source code is licensed under the ISC license.
501
- * See the LICENSE file in the root directory of this source tree.
502
- */const fr=L("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
503
- * @license lucide-react v0.294.0 - ISC
504
- *
505
- * This source code is licensed under the ISC license.
506
- * See the LICENSE file in the root directory of this source tree.
507
- */const yr=L("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
508
- * @license lucide-react v0.294.0 - ISC
509
- *
510
- * This source code is licensed under the ISC license.
511
- * See the LICENSE file in the root directory of this source tree.
512
- */const Xn=L("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
513
- * @license lucide-react v0.294.0 - ISC
514
- *
515
- * This source code is licensed under the ISC license.
516
- * See the LICENSE file in the root directory of this source tree.
517
- */const kr=L("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
518
- * @license lucide-react v0.294.0 - ISC
519
- *
520
- * This source code is licensed under the ISC license.
521
- * See the LICENSE file in the root directory of this source tree.
522
- */const Mt=L("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
523
- * @license lucide-react v0.294.0 - ISC
524
- *
525
- * This source code is licensed under the ISC license.
526
- * See the LICENSE file in the root directory of this source tree.
527
- */const vr=L("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]);/**
528
- * @license lucide-react v0.294.0 - ISC
529
- *
530
- * This source code is licensed under the ISC license.
531
- * See the LICENSE file in the root directory of this source tree.
532
- */const Tt=L("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
533
- * @license lucide-react v0.294.0 - ISC
534
- *
535
- * This source code is licensed under the ISC license.
536
- * See the LICENSE file in the root directory of this source tree.
537
- */const Fe=L("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
538
- * @license lucide-react v0.294.0 - ISC
539
- *
540
- * This source code is licensed under the ISC license.
541
- * See the LICENSE file in the root directory of this source tree.
542
- */const Zn=L("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
543
- * @license lucide-react v0.294.0 - ISC
544
- *
545
- * This source code is licensed under the ISC license.
546
- * See the LICENSE file in the root directory of this source tree.
547
- */const Jn=L("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/**
548
- * @license lucide-react v0.294.0 - ISC
549
- *
550
- * This source code is licensed under the ISC license.
551
- * See the LICENSE file in the root directory of this source tree.
552
- */const xr=L("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
553
- * @license lucide-react v0.294.0 - ISC
554
- *
555
- * This source code is licensed under the ISC license.
556
- * See the LICENSE file in the root directory of this source tree.
557
- */const Nt=L("Video",[["path",{d:"m22 8-6 4 6 4V8Z",key:"50v9me"}],["rect",{width:"14",height:"12",x:"2",y:"6",rx:"2",ry:"2",key:"1rqjg6"}]]);/**
558
- * @license lucide-react v0.294.0 - ISC
559
- *
560
- * This source code is licensed under the ISC license.
561
- * See the LICENSE file in the root directory of this source tree.
562
- */const wr=L("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
563
- * @license lucide-react v0.294.0 - ISC
564
- *
565
- * This source code is licensed under the ISC license.
566
- * See the LICENSE file in the root directory of this source tree.
567
- */const Ae=L("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Qn={bold:"strong",italic:"em",underline:"u",strikethrough:"s",code:"code",link:"a",textColor:"span",highlight:"mark"};function eo(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;let c=n.getRangeAt(0).commonAncestorContainer;const r=Qn[e].toUpperCase();for(;c&&c!==t;){if(c instanceof HTMLElement&&c.tagName===r)return!0;c=c.parentNode}return!1}function to(e,t,n){const o=window.getSelection();if(!o||o.rangeCount===0)return;const c=Qn[e],r=eo(e,t);o.isCollapsed||(r?Bn(c,t).forEach(a=>Nn(a)):Tn(c,n))}function Bt(e){document.execCommand("bold",!1)}function $t(e){document.execCommand("italic",!1)}function Ht(e){document.execCommand("underline",!1)}function qt(e){document.execCommand("strikeThrough",!1)}function jt(e){to("code",e)}function Rt(e,t,n){var r;const o=window.getSelection();if(!o||!o.rangeCount)return;const c=o.getRangeAt(0);if(o.isCollapsed&&n){const i=document.createElement("a");i.href=t,i.textContent=n,i.className="cb-link",c.insertNode(i);const a=document.createRange();a.setStartAfter(i),a.collapse(!0),o.removeAllRanges(),o.addRange(a)}else if(!o.isCollapsed){let i=c.commonAncestorContainer;for(;i&&i!==e;){if(i instanceof HTMLAnchorElement){i.href=t;return}i=i.parentNode}const a=document.createElement("a");a.href=t,a.className="cb-link";try{const d=c.extractContents();a.appendChild(d),c.insertNode(a);const w=document.createRange();w.selectNodeContents(a),o.removeAllRanges(),o.addRange(w)}catch{document.execCommand("createLink",!1,t);const w=(r=c.commonAncestorContainer.parentElement)==null?void 0:r.closest("a");w&&(w.className="cb-link")}}}function Dt(e){const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0);let o=n.commonAncestorContainer;for(;o&&o!==e;){if(o instanceof HTMLAnchorElement){const c=o.parentNode;if(!c)return;const r=document.createDocumentFragment();for(;o.firstChild;)r.appendChild(o.firstChild);c.replaceChild(r,o),t.removeAllRanges(),t.addRange(n);return}o=o.parentNode}document.execCommand("unlink",!1)}function It(e,t){document.execCommand("foreColor",!1,t)}function zt(e,t){document.execCommand("hiliteColor",!1,t)}function fe(e,t){e.style.textAlign=t}function Pt(e){document.execCommand("removeFormat",!1)}function no(e,t,n,o){const c=de.createBlock(t);if(!c)return null;o?n==="before"?nn(c,o):Pe(c,o):e.appendChild(c);const r=c.querySelector('[contenteditable="true"]')||(c.hasAttribute("contenteditable")?c:null);return r instanceof HTMLElement&&(r.focus(),be(r)),c}function oo(e,t){const n=Array.from(t.querySelectorAll("[data-block-id]")),o=n.indexOf(e),c=n[o-1],r=n[o+1];e.remove();const i=r||c;if(i){const a=i.querySelector('[contenteditable="true"]')||(i.hasAttribute("contenteditable")?i:null);a instanceof HTMLElement&&(a.focus(),r?be(a):xe(a))}if(n.length<=1){const a=de.createBlock(de.getDefaultBlock());if(a)return t.appendChild(a),a}return i||null}function co(e,t){const n=e.previousElementSibling;return n&&n instanceof HTMLElement?(t.insertBefore(e,n),!0):!1}function ro(e,t){const n=e.nextElementSibling;return n&&n instanceof HTMLElement?(t.insertBefore(n,e),!0):!1}function lo(e){const t=e.cloneNode(!0),n=`cb-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,9)}`;return t.setAttribute("data-block-id",n),Pe(t,e),t}function io(e,t,n){var r;const o=de.transformBlock(e,t);if(!o)return null;(r=e.parentNode)==null||r.replaceChild(o,e);const c=o.querySelector('[contenteditable="true"]')||(o.hasAttribute("contenteditable")?o:null);return c instanceof HTMLElement&&c.focus(),o}function ao(e,t){const n=e.innerHTML,o=t.querySelector('[contenteditable="true"]')||t;o instanceof HTMLElement&&(o.innerHTML+=n,xe(o)),e.remove()}function so(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const o=n.getRangeAt(0),c=document.createRange();c.setStart(o.endContainer,o.endOffset),c.setEndAfter(e.lastChild||e);const r=c.extractContents(),i=de.getBlockType(e)||"paragraph",a=de.createBlock(i);if(!a)return null;const d=a.querySelector('[contenteditable="true"]')||a;return d instanceof HTMLElement&&d.appendChild(r),Pe(a,e),d instanceof HTMLElement&&(d.focus(),be(d)),a}function uo(e){const t=de.getBlockType(e);if(t!=="bulletList"&&t!=="numberedList")return!1;const n=parseInt(e.style.marginLeft||"0",10);return e.style.marginLeft=`${n+24}px`,!0}function po(e){const t=de.getBlockType(e);if(t!=="bulletList"&&t!=="numberedList")return!1;const n=parseInt(e.style.marginLeft||"0",10);return n>0?(e.style.marginLeft=`${Math.max(0,n-24)}px`,!0):!1}function Cr(e){return{bold:()=>Bt(e.container),italic:()=>$t(e.container),underline:()=>Ht(e.container),strikethrough:()=>qt(e.container),inlineCode:()=>jt(e.container),link:(t,n)=>Rt(e.container,t,n),unlink:()=>Dt(e.container),textColor:t=>It(e.container,t),highlight:t=>zt(e.container,t),clearFormat:()=>Pt(e.container),alignLeft:t=>fe(t,"left"),alignCenter:t=>fe(t,"center"),alignRight:t=>fe(t,"right"),alignJustify:t=>fe(t,"justify"),insertBlock:(t,n,o)=>no(e.container,t,n,o),deleteBlock:t=>oo(t,e.container),moveUp:t=>co(t,e.container),moveDown:t=>ro(t,e.container),duplicate:t=>lo(t),transform:(t,n)=>io(t,n,e.container),merge:(t,n)=>ao(t,n),split:t=>so(t,e.container),indent:t=>uo(t),outdent:t=>po(t)}}const nt=({editor:e,className:t="",darkMode:n=!1})=>{const[o,c]=h.useState(null),[r,i]=h.useState({x:0,y:0}),[a,d]=h.useState(""),[w,x]=h.useState({bold:!1,italic:!1,underline:!1,strikethrough:!1}),[m,T]=h.useState(null),A=h.useRef(null),C=h.useRef(null),M=h.useRef(null),$=h.useRef(null),U=h.useRef(null),D=h.useRef(null);h.useEffect(()=>{const S=()=>{const B=window.getSelection();if(!B||!B.rangeCount)return;const W=B.getRangeAt(0),v=e==null?void 0:e.container;!v||!v.contains(W.commonAncestorContainer)||x({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikethrough:document.queryCommandState("strikeThrough")})};return document.addEventListener("selectionchange",S),()=>document.removeEventListener("selectionchange",S)},[e]);const ee=[{color:"#000000",label:"Black"},{color:"#374151",label:"Gray"},{color:"#dc2626",label:"Red"},{color:"#ea580c",label:"Orange"},{color:"#ca8a04",label:"Yellow"},{color:"#16a34a",label:"Green"},{color:"#0891b2",label:"Cyan"},{color:"#2563eb",label:"Blue"},{color:"#7c3aed",label:"Purple"},{color:"#db2777",label:"Pink"}],N=[{color:"#fef08a",label:"Yellow"},{color:"#bbf7d0",label:"Green"},{color:"#bfdbfe",label:"Blue"},{color:"#fecaca",label:"Red"},{color:"#e9d5ff",label:"Purple"},{color:"#fed7aa",label:"Orange"},{color:"#99f6e4",label:"Teal"},{color:"#fce7f3",label:"Pink"},{color:"#e5e7eb",label:"Gray"},{color:"transparent",label:"None"}];h.useEffect(()=>{const S=B=>{var W;C.current&&!C.current.contains(B.target)&&!((W=A.current)!=null&&W.contains(B.target))&&c(null),M.current&&!M.current.contains(B.target)&&T(null)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]),h.useEffect(()=>{if(!(e!=null&&e.container))return;const S=v=>{const H=v.target;D.current&&(window.clearTimeout(D.current),D.current=null);const R=H.closest("a.cb-link");R&&R.href&&(U.current&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{const z=R.getBoundingClientRect();T({url:R.href,element:R,position:{x:z.left+window.scrollX,y:z.bottom+window.scrollY+8}})},300))},B=v=>{var _;const H=v.target,R=v.relatedTarget;H.closest("a.cb-link")&&(U.current&&(window.clearTimeout(U.current),U.current=null),(_=R==null?void 0:R.closest)!=null&&_.call(R,".cb-link-preview")||(D.current=window.setTimeout(()=>{T(null)},200)))},W=()=>{T(null),D.current&&(window.clearTimeout(D.current),D.current=null)};return e.container.addEventListener("mouseover",S),e.container.addEventListener("mouseout",B),window.addEventListener("scroll",W,!0),()=>{e.container.removeEventListener("mouseover",S),e.container.removeEventListener("mouseout",B),window.removeEventListener("scroll",W,!0),U.current&&window.clearTimeout(U.current),D.current&&window.clearTimeout(D.current)}},[e]);const le=h.useCallback((S,B)=>{var z;if(o===S){c(null);return}const W=window.getSelection();W&&W.rangeCount>0&&($.current=W.getRangeAt(0).cloneRange());const H=B.currentTarget.getBoundingClientRect(),R=(z=A.current)==null?void 0:z.getBoundingClientRect();i({x:H.left-((R==null?void 0:R.left)||0),y:H.bottom-((R==null?void 0:R.top)||0)+8}),c(S),d("")},[o]),te=h.useCallback(()=>{if(a&&(e!=null&&e.container)){if($.current){const S=window.getSelection();S&&(S.removeAllRanges(),S.addRange($.current))}Rt(e.container,a),c(null),d(""),$.current=null}},[a,e]),ne=h.useCallback(S=>{e!=null&&e.container&&(It(e.container,S),c(null))},[e]),ke=h.useCallback(S=>{e!=null&&e.container&&(S==="transparent"?document.execCommand("removeFormat",!1):zt(e.container,S),c(null))},[e]),Ce=h.useCallback(()=>{var S;if(m){const B=m.url;d(B);const W=window.getSelection();if(W){const R=document.createRange();R.selectNodeContents(m.element),W.removeAllRanges(),W.addRange(R),$.current=R.cloneRange()}T(null),c("link");const v=m.element.getBoundingClientRect(),H=(S=A.current)==null?void 0:S.getBoundingClientRect();i({x:v.left-((H==null?void 0:H.left)||0),y:v.bottom-((H==null?void 0:H.top)||0)+8})}},[m]);h.useCallback(()=>{m&&window.open(m.url,"_blank","noopener,noreferrer")},[m]);const ie=h.useCallback(()=>{if(m&&(e!=null&&e.container)){const S=window.getSelection();if(S){const B=document.createRange();B.selectNodeContents(m.element),S.removeAllRanges(),S.addRange(B)}Dt(e.container),T(null)}},[m,e]),ae=h.useCallback(S=>{if(!e)return;const B=e.getHTML();let W,v,H;S==="html"?(W=`<!DOCTYPE html>
246
+ `,e}function Bc(){return"draggable"in document.createElement("div")}function qn(){const e=window.getSelection();if(!e||e.rangeCount===0)return{range:null,anchorNode:null,focusNode:null,anchorOffset:0,focusOffset:0,isCollapsed:!0,block:null};const t=e.getRangeAt(0),n=Ue(t.commonAncestorContainer);return{range:t.cloneRange(),anchorNode:e.anchorNode,focusNode:e.focusNode,anchorOffset:e.anchorOffset,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,block:n}}function Rc(){return qn()}function $c(e){if(!e.range)return!1;try{const t=window.getSelection();if(t)return t.removeAllRanges(),t.addRange(e.range),!0}catch{}return!1}function Hc(){const e=window.getSelection();return(e==null?void 0:e.toString())||""}function qc(){const e=window.getSelection();if(!e||e.rangeCount===0)return"";const t=e.getRangeAt(0),n=document.createElement("div");return n.appendChild(t.cloneContents()),n.innerHTML}function Ic(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function zc(e){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0),o=Ue(n.startContainer),r=Ue(n.endContainer);return o!==r}function Pc(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function Fc(){const e=window.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}function Oc(){const e=window.getSelection();e&&!e.isCollapsed&&e.collapseToEnd()}function Uc(e,t){var a;if(!e||t<0)return!1;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let o=0,r;for(;r=n.nextNode();){const s=((a=r.textContent)==null?void 0:a.length)||0;if(o+s>=t){const d=document.createRange(),w=t-o,H=Math.min(w,s);d.setStart(r,H),d.collapse(!0);const D=window.getSelection();if(D)return D.removeAllRanges(),D.addRange(d),!0}o+=s}if(t>=o&&e.childNodes.length>0){const s=document.createRange();s.selectNodeContents(e),s.collapse(!1);const d=window.getSelection();if(d)return d.removeAllRanges(),d.addRange(s),!0}return!1}function Wc(e){const t=window.getSelection();if(!t||t.rangeCount===0)return 0;const n=t.getRangeAt(0),o=n.cloneRange();return o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),o.toString().length}function nt(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!n.collapsed)return!1;const o=n.cloneRange();return o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),o.toString().length===0}function In(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!n.collapsed)return!1;const o=n.cloneRange();return o.selectNodeContents(e),o.setStart(n.endContainer,n.endOffset),o.toString().length===0}function ze(e){const t=document.createRange(),n=window.getSelection(),r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null).nextNode();r?t.setStart(r,0):t.setStart(e,0),t.collapse(!0),n&&(n.removeAllRanges(),n.addRange(t))}function Ie(e){const t=document.createRange(),n=window.getSelection();t.selectNodeContents(e),t.collapse(!1),n&&(n.removeAllRanges(),n.addRange(t))}function zn(e,t){const n=window.getSelection();if(!n||n.rangeCount===0||n.isCollapsed)return null;const o=n.getRangeAt(0),r=document.createElement(e);if(t)for(const[a,s]of Object.entries(t))r.setAttribute(a,s);try{return o.surroundContents(r),r}catch{const a=o.extractContents();return r.appendChild(a),o.insertNode(r),r}}function Pn(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Fn(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return[];const o=n.getRangeAt(0),r=[],a=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:d=>d instanceof HTMLElement&&d.tagName.toLowerCase()===e.toLowerCase()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let s;for(;s=a.nextNode();)s instanceof HTMLElement&&o.intersectsNode(s)&&r.push(s);return r}const On={bold:"strong",italic:"em",underline:"u",strikethrough:"s",code:"code",link:"a",textColor:"span",highlight:"mark"};function Un(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;let r=n.getRangeAt(0).commonAncestorContainer;const a=On[e].toUpperCase();for(;r&&r!==t;){if(r instanceof HTMLElement&&r.tagName===a)return!0;r=r.parentNode}return!1}function Wn(e,t,n){const o=window.getSelection();if(!o||o.rangeCount===0)return;const r=On[e],a=Un(e,t);o.isCollapsed||(a?Fn(r,t).forEach(d=>Pn(d)):zn(r,n))}function at(e){document.execCommand("bold",!1)}function it(e){document.execCommand("italic",!1)}function st(e){document.execCommand("underline",!1)}function dt(e){document.execCommand("strikeThrough",!1)}function ut(e){Wn("code",e)}function bt(e,t,n){var s;if(!t||typeof t!="string"){console.warn("insertLink: Invalid URL provided");return}if(t=t.trim(),!t){console.warn("insertLink: Empty URL provided");return}/^[a-z][a-z0-9+.-]*:/i.test(t)||(t="https://"+t);const r=window.getSelection();if(!r||!r.rangeCount)return;const a=r.getRangeAt(0);if(r.isCollapsed&&n){const d=document.createElement("a");d.href=t,d.textContent=n,d.className="cb-link",a.insertNode(d);const w=document.createRange();w.setStartAfter(d),w.collapse(!0),r.removeAllRanges(),r.addRange(w)}else if(!r.isCollapsed){let d=a.commonAncestorContainer;for(;d&&d!==e;){if(d instanceof HTMLAnchorElement){d.href=t;return}d=d.parentNode}const w=document.createElement("a");w.href=t,w.className="cb-link";try{const H=a.extractContents();w.appendChild(H),a.insertNode(w);const D=document.createRange();D.selectNodeContents(w),r.removeAllRanges(),r.addRange(D)}catch{document.execCommand("createLink",!1,t);const D=(s=a.commonAncestorContainer.parentElement)==null?void 0:s.closest("a");D&&(D.className="cb-link")}}}function Xt(e){const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0);let o=n.commonAncestorContainer;for(;o&&o!==e;){if(o instanceof HTMLAnchorElement){const r=o.parentNode;if(!r)return;const a=document.createDocumentFragment();for(;o.firstChild;)a.appendChild(o.firstChild);r.replaceChild(a,o),t.removeAllRanges(),t.addRange(n);return}o=o.parentNode}document.execCommand("unlink",!1)}function pt(e,t){document.execCommand("foreColor",!1,t)}function mt(e,t){document.execCommand("hiliteColor",!1,t)}function _t(e,t){document.execCommand("fontName",!1,t)}function Kt(e,t){const n=window.getSelection();if(!n||n.rangeCount===0||n.isCollapsed)return;const o=n.getRangeAt(0);try{const r=document.createElement("span");r.style.fontSize=t;const a=o.extractContents();r.appendChild(a),o.insertNode(r);const s=document.createRange();s.selectNodeContents(r),n.removeAllRanges(),n.addRange(s)}catch(r){console.warn("setFontSize: Failed to apply font size",r)}}function Oe(e,t){e.style.textAlign=t}function Yt(e){document.execCommand("removeFormat",!1)}function Xn(e,t,n,o){const r=Re.createBlock(t);if(!r)return null;o?n==="before"?dn(r,o):lt(r,o):e.appendChild(r);const a=r.querySelector('[contenteditable="true"]')||(r.hasAttribute("contenteditable")?r:null);return a instanceof HTMLElement&&(a.focus(),ze(a)),r}function _n(e,t){const n=Array.from(t.querySelectorAll("[data-block-id]")),o=n.indexOf(e),r=n[o-1],a=n[o+1];e.remove();const s=a||r;if(s){const d=s.querySelector('[contenteditable="true"]')||(s.hasAttribute("contenteditable")?s:null);d instanceof HTMLElement&&(d.focus(),a?ze(d):Ie(d))}if(n.length<=1){const d=Re.createBlock(Re.getDefaultBlock());if(d)return t.appendChild(d),d}return s||null}function Kn(e,t){const n=e.previousElementSibling;return n&&n instanceof HTMLElement?(t.insertBefore(e,n),!0):!1}function Yn(e,t){const n=e.nextElementSibling;return n&&n instanceof HTMLElement?(t.insertBefore(n,e),!0):!1}function Vn(e){const t=e.cloneNode(!0),n=`cb-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,9)}`;return t.setAttribute("data-block-id",n),lt(t,e),t}function Jn(e,t,n){var a;const o=Re.transformBlock(e,t);if(!o)return null;(a=e.parentNode)==null||a.replaceChild(o,e);const r=o.querySelector('[contenteditable="true"]')||(o.hasAttribute("contenteditable")?o:null);return r instanceof HTMLElement&&r.focus(),o}function Gn(e,t){const n=e.innerHTML,o=t.querySelector('[contenteditable="true"]')||t;o instanceof HTMLElement&&(o.innerHTML+=n,Ie(o)),e.remove()}function Qn(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const o=n.getRangeAt(0),r=document.createRange();r.setStart(o.endContainer,o.endOffset),r.setEndAfter(e.lastChild||e);const a=r.extractContents(),s=Re.getBlockType(e)||"paragraph",d=Re.createBlock(s);if(!d)return null;const w=d.querySelector('[contenteditable="true"]')||d;return w instanceof HTMLElement&&w.appendChild(a),lt(d,e),w instanceof HTMLElement&&(w.focus(),ze(w)),d}function Zn(e){const t=Re.getBlockType(e);if(t!=="bulletList"&&t!=="numberedList")return!1;const n=parseInt(e.style.marginLeft||"0",10);return e.style.marginLeft=`${n+24}px`,!0}function eo(e){const t=Re.getBlockType(e);if(t!=="bulletList"&&t!=="numberedList")return!1;const n=parseInt(e.style.marginLeft||"0",10);return n>0?(e.style.marginLeft=`${Math.max(0,n-24)}px`,!0):!1}function Xc(e){return{bold:()=>at(e.container),italic:()=>it(e.container),underline:()=>st(e.container),strikethrough:()=>dt(e.container),inlineCode:()=>ut(e.container),link:(t,n)=>bt(e.container,t,n),unlink:()=>Xt(e.container),textColor:t=>pt(e.container,t),highlight:t=>mt(e.container,t),fontFamily:t=>_t(e.container,t),fontSize:t=>Kt(e.container,t),clearFormat:()=>Yt(e.container),alignLeft:t=>Oe(t,"left"),alignCenter:t=>Oe(t,"center"),alignRight:t=>Oe(t,"right"),alignJustify:t=>Oe(t,"justify"),insertBlock:(t,n,o)=>Xn(e.container,t,n,o),deleteBlock:t=>_n(t,e.container),moveUp:t=>Kn(t,e.container),moveDown:t=>Yn(t,e.container),duplicate:t=>Vn(t),transform:(t,n)=>Jn(t,n,e.container),merge:(t,n)=>Gn(t,n),split:t=>Qn(t,e.container),indent:t=>Zn(t),outdent:t=>eo(t)}}const Lt=({editor:e,className:t="",darkMode:n=!1})=>{const[o,r]=m.useState(null),[a,s]=m.useState({x:0,y:0}),[d,w]=m.useState(""),[H,D]=m.useState({bold:!1,italic:!1,underline:!1,strikethrough:!1}),[L,_]=m.useState(null),[T,$]=m.useState(null),[x,z]=m.useState({hour:12,minute:0,period:"AM",timezone:"IST"}),[re,Z]=m.useState(null),te=m.useRef(null),A=m.useRef(null),fe=m.useRef(null),ve=m.useRef(null),ue=m.useRef(null),G=m.useRef(null),ae=m.useRef(null),be=m.useRef(null),ye=m.useRef(null),me=m.useRef(null),Ne=m.useRef(null),J=m.useRef(null);m.useEffect(()=>{const i=()=>{const g=window.getSelection();if(!g||!g.rangeCount)return;const j=g.getRangeAt(0),I=e==null?void 0:e.container;!I||!I.contains(j.commonAncestorContainer)||D({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikethrough:document.queryCommandState("strikeThrough")})};return document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const ke=[{color:"#000000",label:"Black"},{color:"#374151",label:"Gray"},{color:"#dc2626",label:"Red"},{color:"#ea580c",label:"Orange"},{color:"#ca8a04",label:"Yellow"},{color:"#16a34a",label:"Green"},{color:"#0891b2",label:"Cyan"},{color:"#2563eb",label:"Blue"},{color:"#7c3aed",label:"Purple"},{color:"#db2777",label:"Pink"}],He=[{color:"#fef08a",label:"Yellow"},{color:"#bbf7d0",label:"Green"},{color:"#bfdbfe",label:"Blue"},{color:"#fecaca",label:"Red"},{color:"#e9d5ff",label:"Purple"},{color:"#fed7aa",label:"Orange"},{color:"#99f6e4",label:"Teal"},{color:"#fce7f3",label:"Pink"},{color:"#e5e7eb",label:"Gray"},{color:"transparent",label:"None"}];m.useEffect(()=>{const i=g=>{var j;A.current&&!A.current.contains(g.target)&&!((j=te.current)!=null&&j.contains(g.target))&&(r(null),setTimeout(()=>{if(G.current&&(e!=null&&e.container))try{const I=window.getSelection();if(I){I.removeAllRanges(),I.addRange(G.current);const X=G.current.commonAncestorContainer;let S=null;for(X.nodeType===Node.ELEMENT_NODE?S=X:S=X.parentElement;S&&S!==e.container;){if(S.getAttribute("contenteditable")==="true"){S.focus();break}S=S.parentElement}}}catch(I){console.error("Failed to restore selection:",I)}finally{G.current=null}},0)),fe.current&&!fe.current.contains(g.target)&&_(null),ve.current&&!ve.current.contains(g.target)&&$(null)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[e]),m.useEffect(()=>{if(!(e!=null&&e.container))return;const i=I=>{const X=I.target;be.current&&(window.clearTimeout(be.current),be.current=null);const S=X.closest("a.cb-link");S&&S.href&&(ae.current&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{const R=S.getBoundingClientRect();_({url:S.href,element:S,position:{x:R.left+window.scrollX,y:R.bottom+window.scrollY+8}})},300))},g=I=>{var ee;const X=I.target,S=I.relatedTarget;X.closest("a.cb-link")&&(ae.current&&(window.clearTimeout(ae.current),ae.current=null),(ee=S==null?void 0:S.closest)!=null&&ee.call(S,".cb-link-preview")||(be.current=window.setTimeout(()=>{_(null)},200)))},j=()=>{_(null),be.current&&(window.clearTimeout(be.current),be.current=null)};return e.container.addEventListener("mouseover",i),e.container.addEventListener("mouseout",g),window.addEventListener("scroll",j,!0),()=>{e.container.removeEventListener("mouseover",i),e.container.removeEventListener("mouseout",g),window.removeEventListener("scroll",j,!0),ae.current&&window.clearTimeout(ae.current),be.current&&window.clearTimeout(be.current)}},[e]),m.useEffect(()=>{if(!(e!=null&&e.container))return;const i=I=>{const X=I.target;me.current&&(window.clearTimeout(me.current),me.current=null);const S=X.closest(".cb-date-inline");S&&(ye.current&&window.clearTimeout(ye.current),ye.current=window.setTimeout(()=>{const ee=S.getBoundingClientRect(),ce=S.getAttribute("data-date")||new Date().toISOString(),ge=new Date(ce);$({date:ge,element:S,position:{x:ee.left+window.scrollX,y:ee.bottom+window.scrollY+8}})},300));const R=X.closest(".cb-time-inline");R&&(Ne.current&&window.clearTimeout(Ne.current),Ne.current=window.setTimeout(()=>{const ee=R.getBoundingClientRect(),ce=parseInt(R.getAttribute("data-hour")||"12",10),ge=parseInt(R.getAttribute("data-minute")||"0",10),Q=R.getAttribute("data-period")||"AM",Me=R.getAttribute("data-timezone")||"IST";z({hour:ce,minute:ge,period:Q,timezone:Me}),Z({element:R,position:{x:ee.left+window.scrollX,y:ee.bottom+window.scrollY+8}})},300))},g=I=>{var ce,ge;const X=I.target,S=I.relatedTarget;X.closest(".cb-date-inline")&&(ye.current&&(window.clearTimeout(ye.current),ye.current=null),(ce=S==null?void 0:S.closest)!=null&&ce.call(S,".cb-date-calendar")||(me.current=window.setTimeout(()=>{$(null)},200))),X.closest(".cb-time-inline")&&(Ne.current&&(window.clearTimeout(Ne.current),Ne.current=null),(ge=S==null?void 0:S.closest)!=null&&ge.call(S,".cb-time-picker-hover")||(J.current=window.setTimeout(()=>{Z(null)},200)))},j=()=>{$(null),Z(null),me.current&&(window.clearTimeout(me.current),me.current=null),J.current&&(window.clearTimeout(J.current),J.current=null)};return e.container.addEventListener("mouseover",i),e.container.addEventListener("mouseout",g),window.addEventListener("scroll",j,!0),()=>{e.container.removeEventListener("mouseover",i),e.container.removeEventListener("mouseout",g),window.removeEventListener("scroll",j,!0),ye.current&&window.clearTimeout(ye.current),me.current&&window.clearTimeout(me.current),Ne.current&&window.clearTimeout(Ne.current),J.current&&window.clearTimeout(J.current)}},[e]),m.useEffect(()=>()=>{[ae,be,ye,me,Ne,J].forEach(g=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)})},[]);const Y=m.useCallback((i,g)=>{var S;if(o===i){r(null);return}const I=g.currentTarget.getBoundingClientRect(),X=(S=te.current)==null?void 0:S.getBoundingClientRect();s({x:I.left-((X==null?void 0:X.left)||0),y:I.bottom-((X==null?void 0:X.top)||0)+8}),r(i),w("")},[o]),he=m.useCallback(()=>{r(null),setTimeout(()=>{if(G.current&&(e!=null&&e.container))try{const i=window.getSelection();if(i){i.removeAllRanges(),i.addRange(G.current);const g=G.current.commonAncestorContainer;let j=null;for(g.nodeType===Node.ELEMENT_NODE?j=g:j=g.parentElement;j&&j!==e.container;){if(j.getAttribute("contenteditable")==="true"){j.focus();break}j=j.parentElement}}}catch(i){console.error("Failed to restore selection:",i)}finally{G.current=null}},0)},[e]),Ce=m.useCallback(()=>{if(d&&(e!=null&&e.container)){if(G.current){const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(G.current))}bt(e.container,d),r(null),w(""),G.current=null}},[d,e]),Ee=m.useCallback(i=>{if(e!=null&&e.container){if(G.current){const g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(G.current))}pt(e.container,i),r(null),G.current=null}},[e]),Ae=m.useCallback(i=>{if(e!=null&&e.container){if(G.current){const g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(G.current))}i==="transparent"?document.execCommand("removeFormat",!1):mt(e.container,i),r(null),G.current=null}},[e]),xe=m.useCallback(()=>{var i;if(L){const g=L.url;w(g);const j=window.getSelection();if(j){const S=document.createRange();S.selectNodeContents(L.element),j.removeAllRanges(),j.addRange(S),G.current=S.cloneRange()}_(null),r("link");const I=L.element.getBoundingClientRect(),X=(i=te.current)==null?void 0:i.getBoundingClientRect();s({x:I.left-((X==null?void 0:X.left)||0),y:I.bottom-((X==null?void 0:X.top)||0)+8})}},[L]);m.useCallback(()=>{L&&window.open(L.url,"_blank","noopener,noreferrer")},[L]);const we=m.useCallback(()=>{if(L&&(e!=null&&e.container)){const i=window.getSelection();if(i){const g=document.createRange();g.selectNodeContents(L.element),i.removeAllRanges(),i.addRange(g)}Xt(e.container),_(null)}},[L,e]),pe=m.useCallback(i=>{if(!e)return;const g=e.getHTML();let j,I,X;i==="html"?(j=`<!DOCTYPE html>
568
247
  <html>
569
248
  <head>
570
249
  <meta charset="UTF-8">
@@ -581,9 +260,108 @@
581
260
  </style>
582
261
  </head>
583
262
  <body>
584
- ${B}
263
+ ${g}
585
264
  </body>
586
- </html>`,v="document.html",H="text/html"):(W=JSON.stringify({content:B},null,2),v="document.json",H="application/json");const R=new Blob([W],{type:H}),z=URL.createObjectURL(R),_=document.createElement("a");_.href=z,_.download=v,_.click(),URL.revokeObjectURL(z)},[e]);if(!e)return null;const oe=(S,B)=>{var _;const W=document.activeElement,v=W==null?void 0:W.closest(".cb-block"),H=v==null?void 0:v.getAttribute("data-block-id"),R=v==null?void 0:v.getAttribute("data-block-type"),z=v==null?void 0:v.querySelector('[contenteditable="true"]');H&&R==="paragraph"&&z&&!((_=z.textContent)!=null&&_.trim())?e.transformBlock(v,S,B):e.insertBlock(S,B)},he=[{name:"history",buttons:[{icon:Jn,label:"Undo",action:()=>e.undo(),shortcut:"Ctrl+Z"},{icon:Gn,label:"Redo",action:()=>e.redo(),shortcut:"Ctrl+Y"}]},{name:"formatting",buttons:[{icon:jn,label:"Bold",action:()=>Bt(e.container),isActive:()=>w.bold,shortcut:"Ctrl+B"},{icon:Un,label:"Italic",action:()=>$t(e.container),isActive:()=>w.italic,shortcut:"Ctrl+I"},{icon:Zn,label:"Underline",action:()=>Ht(e.container),isActive:()=>w.underline,shortcut:"Ctrl+U"},{icon:Xn,label:"Strikethrough",action:()=>qt(e.container),isActive:()=>w.strikethrough},{icon:vt,label:"Inline Code",action:()=>jt(e.container)}]},{name:"richtext",buttons:[{icon:$e,label:"Insert Link",action:S=>le("link",S)},{icon:Fn,label:"Highlight",action:S=>le("highlight",S)},{icon:Yn,label:"Text Color",action:S=>le("textColor",S)}]},{name:"alignment",buttons:[{icon:Hn,label:"Align Left",action:()=>{const S=ye(document.activeElement);S&&fe(S,"left")}},{icon:$n,label:"Align Center",action:()=>{const S=ye(document.activeElement);S&&fe(S,"center")}},{icon:qn,label:"Align Right",action:()=>{const S=ye(document.activeElement);S&&fe(S,"right")}}]},{name:"headings",buttons:[{icon:xt,label:"Heading 1",action:()=>oe("heading",{level:1}),shortcut:"Ctrl+1"},{icon:wt,label:"Heading 2",action:()=>oe("heading",{level:2}),shortcut:"Ctrl+2"},{icon:Ct,label:"Heading 3",action:()=>oe("heading",{level:3}),shortcut:"Ctrl+3"}]},{name:"blocks",buttons:[{icon:Et,label:"Bullet List",action:()=>oe("bulletList")},{icon:St,label:"Numbered List",action:()=>oe("numberedList")},{icon:kt,label:"Checklist",action:()=>oe("checkList")},{icon:At,label:"Quote",action:()=>oe("quote")},{icon:Pn,label:"Code Block",action:()=>oe("code")}]},{name:"media",buttons:[{icon:Oe,label:"Image",action:()=>e.insertBlock("image")},{icon:Nt,label:"Video",action:()=>e.insertBlock("video")},{icon:Mt,label:"Table",action:()=>e.insertBlock("table")},{icon:yt,label:"Callout",action:()=>oe("callout")},{icon:Lt,label:"Divider",action:()=>e.insertBlock("divider")}]},{name:"utils",buttons:[{icon:zn,label:"Clear Formatting",action:()=>Pt(e.container)},{icon:In,label:"Export HTML",action:()=>ae("html")}]}];return l.jsxs("div",{ref:A,className:`cb-toolbar ${t} ${n?"cb-toolbar-dark":""}`,role:"toolbar","aria-label":"Editor formatting options",onMouseDown:S=>{S.target.closest(".cb-popover")||S.preventDefault()},children:[he.map(S=>l.jsx("div",{className:"cb-toolbar-group",role:"group",children:S.buttons.map(B=>{var W,v;return l.jsx("button",{type:"button",className:`cb-toolbar-btn ${(W=B.isActive)!=null&&W.call(B)?"cb-toolbar-btn-active":""}`,onClick:B.action,title:`${B.label}${B.shortcut?` (${B.shortcut})`:""}`,"aria-label":B.label,"aria-pressed":(v=B.isActive)==null?void 0:v.call(B),children:l.jsx(B.icon,{size:18})},B.label)})},S.name)),o&&l.jsxs("div",{ref:C,className:"cb-popover",style:{position:"absolute",left:r.x,top:r.y,zIndex:1e3},children:[o==="link"&&l.jsxs("div",{className:"cb-popover-content cb-link-popover",children:[l.jsxs("div",{className:"cb-popover-header",children:[l.jsx("span",{children:"Insert Link"}),l.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>c(null),children:l.jsx(Ae,{size:14})})]}),l.jsxs("div",{className:"cb-popover-body",children:[l.jsx("input",{type:"url",value:a,onChange:S=>d(S.target.value),placeholder:"https://example.com",className:"cb-popover-input",autoFocus:!0,onKeyDown:S=>{S.key==="Enter"&&te(),S.key==="Escape"&&c(null)}}),l.jsx("button",{type:"button",className:"cb-popover-btn-primary",onClick:te,disabled:!a,children:"Insert Link"})]})]}),o==="highlight"&&l.jsxs("div",{className:"cb-popover-content cb-color-popover",children:[l.jsxs("div",{className:"cb-popover-header",children:[l.jsx("span",{children:"Highlight Color"}),l.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>c(null),children:l.jsx(Ae,{size:14})})]}),l.jsx("div",{className:"cb-color-grid",children:N.map(({color:S,label:B})=>l.jsx("button",{type:"button",className:"cb-color-swatch",style:{backgroundColor:S==="transparent"?"#fff":S,border:S==="transparent"?"2px dashed #ccc":void 0},onClick:()=>ke(S),title:B,children:S==="transparent"&&l.jsx(Ae,{size:12})},S))})]}),o==="textColor"&&l.jsxs("div",{className:"cb-popover-content cb-color-popover",children:[l.jsxs("div",{className:"cb-popover-header",children:[l.jsx("span",{children:"Text Color"}),l.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>c(null),children:l.jsx(Ae,{size:14})})]}),l.jsx("div",{className:"cb-color-grid",children:ee.map(({color:S,label:B})=>l.jsx("button",{type:"button",className:"cb-color-swatch",style:{backgroundColor:S},onClick:()=>ne(S),title:B},S))})]})]}),m&&typeof document<"u"&&No.createPortal(l.jsx("div",{ref:M,className:"cb-link-preview",style:{position:"absolute",left:m.position.x,top:m.position.y,zIndex:1e4},onMouseEnter:()=>{D.current&&(window.clearTimeout(D.current),D.current=null)},onMouseLeave:()=>{D.current=window.setTimeout(()=>{T(null)},200)},children:l.jsxs("div",{className:"cb-link-preview-content",children:[l.jsx("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",className:"cb-link-preview-url",title:m.url,children:m.url}),l.jsx("div",{className:"cb-link-preview-divider"}),l.jsxs("div",{className:"cb-link-preview-actions",children:[l.jsx("button",{type:"button",className:"cb-link-preview-btn",onClick:Ce,title:"Edit link",children:l.jsx(hr,{size:16})}),l.jsx("button",{type:"button",className:"cb-link-preview-btn cb-link-preview-btn-danger",onClick:ie,title:"Remove link",children:l.jsx(Tt,{size:16})})]})]})}),document.body)]})},Sr=[{type:"paragraph",label:"Paragraph",description:"Plain text paragraph",icon:Fe,keywords:["text","paragraph","p"]},{type:"heading",label:"Heading 1",description:"Large section heading",icon:xt,keywords:["h1","heading","title","header"],data:{level:1}},{type:"heading",label:"Heading 2",description:"Medium section heading",icon:wt,keywords:["h2","heading","subtitle"],data:{level:2}},{type:"heading",label:"Heading 3",description:"Small section heading",icon:Ct,keywords:["h3","heading"],data:{level:3}},{type:"bulletList",label:"Bullet List",description:"Create a bulleted list",icon:Et,keywords:["bullet","list","ul","unordered"]},{type:"numberedList",label:"Numbered List",description:"Create a numbered list",icon:St,keywords:["number","list","ol","ordered"]},{type:"checkList",label:"Checklist",description:"Track tasks with checkboxes",icon:kt,keywords:["check","todo","task","checkbox"]},{type:"quote",label:"Quote",description:"Capture a quote",icon:At,keywords:["quote","blockquote","citation"]},{type:"code",label:"Code Block",description:"Display code with syntax highlighting",icon:vt,keywords:["code","pre","syntax","programming"]},{type:"image",label:"Image",description:"Upload or embed an image",icon:Oe,keywords:["image","picture","photo","img"]},{type:"video",label:"Video",description:"Embed a video from YouTube, Vimeo, etc.",icon:Nt,keywords:["video","youtube","vimeo","embed"]},{type:"divider",label:"Divider",description:"Visual separator between sections",icon:Lt,keywords:["divider","hr","line","separator"]},{type:"callout",label:"Callout",description:"Highlight important information",icon:yt,keywords:["callout","alert","info","warning","note"]},{type:"accordion",label:"Accordion",description:"Collapsible content section",icon:tt,keywords:["accordion","collapse","toggle","details"]},{type:"table",label:"Table",description:"Add a table",icon:Mt,keywords:["table","grid","rows","columns"]},{type:"linkPreview",label:"Link Preview",description:"Rich preview card for URLs",icon:$e,keywords:["link","url","preview","embed","opengraph"]}],ho=({editor:e,position:t,onSelect:n,onClose:o})=>{const[c,r]=h.useState(""),[i,a]=h.useState(0),d=h.useRef(null),w=h.useRef(null),x=h.useRef(new Map),m=Sr.filter(C=>{if(!c)return!0;const M=c.toLowerCase();return C.label.toLowerCase().includes(M)||C.description.toLowerCase().includes(M)||C.keywords.some($=>$.includes(M))});h.useEffect(()=>{a(0)},[c]),h.useEffect(()=>{const C=x.current.get(i);C&&C.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[i]),h.useEffect(()=>{var C;(C=w.current)==null||C.focus()},[]),h.useEffect(()=>{const C=M=>{d.current&&!d.current.contains(M.target)&&o()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o]);const T=h.useCallback(C=>{switch(C.key){case"ArrowDown":C.preventDefault(),a(M=>M<m.length-1?M+1:0);break;case"ArrowUp":C.preventDefault(),a(M=>M>0?M-1:m.length-1);break;case"Enter":if(C.preventDefault(),m[i]){const M=m[i];n(M.type,M.data)}break;case"Escape":C.preventDefault(),o();break}},[m,i,n,o]),A={position:"fixed",left:Math.min(t.x,window.innerWidth-320),top:Math.min(t.y,window.innerHeight-400),zIndex:1e3};return l.jsxs("div",{ref:d,className:"cb-block-menu",style:A,role:"listbox","aria-label":"Insert block",children:[l.jsx("div",{className:"cb-block-menu-search",children:l.jsx("input",{ref:w,type:"text",value:c,onChange:C=>r(C.target.value),onKeyDown:T,placeholder:"Search blocks...",className:"cb-block-menu-input","aria-label":"Search blocks"})}),l.jsx("div",{className:"cb-block-menu-list",children:m.length===0?l.jsx("div",{className:"cb-block-menu-empty",children:"No matching blocks"}):m.map((C,M)=>l.jsxs("button",{ref:$=>{$?x.current.set(M,$):x.current.delete(M)},type:"button",className:`cb-block-menu-item ${M===i?"cb-block-menu-item-selected":""}`,onClick:()=>n(C.type,C.data),onMouseEnter:()=>a(M),role:"option","aria-selected":M===i,children:[l.jsx("div",{className:"cb-block-menu-item-icon",children:l.jsx(C.icon,{size:20})}),l.jsxs("div",{className:"cb-block-menu-item-content",children:[l.jsx("span",{className:"cb-block-menu-item-label",children:C.label}),l.jsx("span",{className:"cb-block-menu-item-description",children:C.description})]})]},`${C.type}-${C.label}`))}),l.jsxs("div",{className:"cb-block-menu-footer",children:[l.jsx("span",{children:"↑↓ Navigate"}),l.jsx("span",{children:"↵ Select"}),l.jsx("span",{children:"Esc Close"})]})]})};function bo(e){return e===0?0:e/200}function Er(e){if(e===0)return"0 min read";if(e<1)return"< 1 min read";const t=Math.ceil(e);if(t===1)return"1 min read";if(t<60)return`${t} min read`;const n=Math.floor(t/60),o=t%60;return o===0?n===1?"1 hour read":`${n} hours read`:`${n}h ${o}m read`}function Lr(e){const n=new Date().getTime()-e.getTime(),o=Math.floor(n/1e3),c=Math.floor(o/60),r=Math.floor(c/60),i=Math.floor(r/24);if(o<10)return"Just now";if(o<60)return`${o}s ago`;if(c<60)return`${c}m ago`;if(r<24)return`${r}h ago`;if(i===1)return"Yesterday";if(i<7)return`${i} days ago`;const a={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return e.toLocaleDateString("en-US",a)}const go=({wordCount:e,charCount:t,readingTime:n,lastSaved:o,className:c="",darkMode:r=!1})=>l.jsxs("div",{className:`cb-status-bar ${c} ${r?"cb-dark":""}`,role:"status","aria-label":"Editor statistics",children:[l.jsxs("div",{className:"cb-status-item",title:"Word count",children:[l.jsx(Fe,{size:14,className:"cb-status-icon"}),l.jsxs("span",{className:"cb-status-label",children:[e.toLocaleString()," ",e===1?"word":"words"]})]}),l.jsxs("div",{className:"cb-status-item",title:"Character count",children:[l.jsx(Le,{size:14,className:"cb-status-icon"}),l.jsxs("span",{className:"cb-status-label",children:[t.toLocaleString()," ",t===1?"char":"chars"]})]}),l.jsxs("div",{className:"cb-status-item",title:"Estimated reading time",children:[l.jsx(er,{size:14,className:"cb-status-icon"}),l.jsx("span",{className:"cb-status-label",children:Er(n)})]}),o&&l.jsxs("div",{className:"cb-status-item",title:`Saved on ${o.toLocaleString()}`,children:[l.jsx(Rn,{size:14,className:"cb-status-icon"}),l.jsxs("span",{className:"cb-status-label",children:["Saved ",Lr(o)]})]})]}),Ar=(e,t)=>{const{initialContent:n="",blocks:o,placeholder:c='Type "/" for commands...',readOnly:r=!1,classPrefix:i="cb",className:a="",style:d,showToolbar:w=!0,toolbarPosition:x="top",darkMode:m=!1,autoFocus:T=!1,spellCheck:A=!0,onChange:C,onSave:M,onFocus:$,onBlur:U,onReady:D}=e,ee=h.useRef(null),N=h.useRef(null),le=h.useRef(!1),te=h.useRef([]),ne=h.useRef([]),[ke,Ce]=h.useState(!1),[ie,ae]=h.useState(null),[oe,he]=h.useState(!1),[S,B]=h.useState({x:0,y:0}),[W,v]=h.useState(null),[H,R]=h.useState(0),[z,_]=h.useState({blocks:[],activeBlock:null,selection:null,undoStack:[],redoStack:[],wordCount:0,charCount:0,isDirty:!1});h.useEffect(()=>{ft.forEach(s=>{de.register(s)})},[]),h.useEffect(()=>{Ce(!0)},[]),h.useEffect(()=>{const s=()=>{var u;const p=window.getSelection();p&&((u=N.current)!=null&&u.contains(p.anchorNode))&&R(b=>b+1)};return document.addEventListener("selectionchange",s),()=>document.removeEventListener("selectionchange",s)},[]);const Y=h.useCallback((s,p)=>{const u=(p==null?void 0:p.id)||F(),b=document.createElement("div");b.className="cb-block",b.setAttribute("data-block-id",u),b.setAttribute("data-block-type",s);const y=document.createElement("div");y.className="cb-block-controls",y.innerHTML=`
265
+ </html>`,I="document.html",X="text/html"):(j=JSON.stringify({content:g},null,2),I="document.json",X="application/json");const S=new Blob([j],{type:X}),R=URL.createObjectURL(S),ee=document.createElement("a");ee.href=R,ee.download=I,ee.click(),URL.revokeObjectURL(R)},[e]),N=m.useCallback(()=>{var I,X;if(!e)return;const i=e.getHTML(),g=document.createElement("iframe");g.style.position="absolute",g.style.width="0",g.style.height="0",g.style.border="none",document.body.appendChild(g);const j=(I=g.contentWindow)==null?void 0:I.document;if(!j){document.body.removeChild(g);return}j.open(),j.write(`
266
+ <!DOCTYPE html>
267
+ <html>
268
+ <head>
269
+ <meta charset="UTF-8">
270
+ <title>Document</title>
271
+ <style>
272
+ @page {
273
+ size: A4;
274
+ margin: 1.5cm;
275
+ }
276
+ @media print {
277
+ body {
278
+ margin: 0;
279
+ padding: 0;
280
+ }
281
+ }
282
+ body {
283
+ font-family: system-ui, -apple-system, sans-serif;
284
+ max-width: 100%;
285
+ margin: 0;
286
+ padding: 0;
287
+ line-height: 1.6;
288
+ color: #111827;
289
+ font-size: 11pt;
290
+ }
291
+ h1 { font-size: 24pt; margin: 12pt 0; font-weight: 700; }
292
+ h2 { font-size: 20pt; margin: 10pt 0; font-weight: 600; }
293
+ h3 { font-size: 16pt; margin: 8pt 0; font-weight: 600; }
294
+ h4 { font-size: 14pt; margin: 6pt 0; font-weight: 600; }
295
+ h5 { font-size: 12pt; margin: 6pt 0; font-weight: 600; }
296
+ h6 { font-size: 11pt; margin: 6pt 0; font-weight: 600; }
297
+ p { margin: 6pt 0; }
298
+ ul, ol { margin: 6pt 0; padding-left: 20pt; }
299
+ li { margin: 3pt 0; }
300
+ img { max-width: 100%; height: auto; page-break-inside: avoid; }
301
+ pre {
302
+ background: #f3f4f6;
303
+ padding: 8pt;
304
+ border-radius: 4pt;
305
+ overflow-x: auto;
306
+ font-family: 'Courier New', monospace;
307
+ font-size: 9pt;
308
+ page-break-inside: avoid;
309
+ }
310
+ code {
311
+ font-family: 'Courier New', monospace;
312
+ background: #f3f4f6;
313
+ padding: 2pt 4pt;
314
+ border-radius: 2pt;
315
+ font-size: 9pt;
316
+ }
317
+ blockquote {
318
+ border-left: 3pt solid #3b82f6;
319
+ margin: 8pt 0;
320
+ padding: 4pt 12pt;
321
+ background: #f8fafc;
322
+ page-break-inside: avoid;
323
+ }
324
+ table {
325
+ border-collapse: collapse;
326
+ width: 100%;
327
+ margin: 8pt 0;
328
+ page-break-inside: avoid;
329
+ }
330
+ th, td {
331
+ border: 1pt solid #e5e7eb;
332
+ padding: 4pt 6pt;
333
+ text-align: left;
334
+ }
335
+ th {
336
+ background: #f9fafb;
337
+ font-weight: 600;
338
+ }
339
+ hr {
340
+ border: none;
341
+ border-top: 1pt solid #e5e7eb;
342
+ margin: 12pt 0;
343
+ }
344
+ a {
345
+ color: #2563eb;
346
+ text-decoration: underline;
347
+ }
348
+ strong { font-weight: 700; }
349
+ em { font-style: italic; }
350
+ .cb-hashtag {
351
+ background: #dbeafe;
352
+ border: 1pt solid #93c5fd;
353
+ border-radius: 2pt;
354
+ padding: 1pt 3pt;
355
+ color: #1e40af;
356
+ font-weight: 500;
357
+ }
358
+ </style>
359
+ </head>
360
+ <body>
361
+ ${i}
362
+ </body>
363
+ </html>
364
+ `),j.close(),(X=g.contentWindow)==null||X.focus(),setTimeout(()=>{var S;(S=g.contentWindow)==null||S.print(),setTimeout(()=>{document.body.removeChild(g)},1e3)},250)},[e]),V=m.useCallback(i=>{if(!(e!=null&&e.container))return;let g;if(G.current){const S=window.getSelection();S&&(S.removeAllRanges(),S.addRange(G.current)),g=G.current}else{const S=window.getSelection();if(!S||!S.rangeCount)return;g=S.getRangeAt(0)}const j=window.getSelection();if(!j)return;const I=S=>{const R=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ee=["January","February","March","April","May","June","July","August","September","October","November","December"],ce=R[S.getDay()],ge=S.getDate(),Q=ee[S.getMonth()],Me=S.getFullYear();return`${ce}, ${ge} ${Q} ${Me}`},X=document.createElement("span");X.className="cb-date-inline",X.setAttribute("data-date",i.toISOString()),X.setAttribute("contenteditable","false"),X.textContent=I(i),g.deleteContents(),g.insertNode(X),g.setStartAfter(X),g.setEndAfter(X),j.removeAllRanges(),j.addRange(g),r(null),G.current=null},[e]),ie=m.useCallback((i,g,j,I)=>{if(!(e!=null&&e.container))return;let X;if(G.current){const ce=window.getSelection();ce&&(ce.removeAllRanges(),ce.addRange(G.current)),X=G.current}else{const ce=window.getSelection();if(!ce||!ce.rangeCount)return;X=ce.getRangeAt(0)}const S=window.getSelection();if(!S)return;const R=`${i}:${g.toString().padStart(2,"0")} ${j} ${I}`,ee=document.createElement("span");ee.className="cb-time-inline",ee.setAttribute("data-time",R),ee.setAttribute("data-hour",i.toString()),ee.setAttribute("data-minute",g.toString()),ee.setAttribute("data-period",j),ee.setAttribute("data-timezone",I),ee.setAttribute("contenteditable","false"),ee.textContent=R,X.deleteContents(),X.insertNode(ee),X.setStartAfter(ee),X.setEndAfter(ee),S.removeAllRanges(),S.addRange(X),r(null),G.current=null},[e]),oe=m.useCallback(i=>{if(!(e!=null&&e.container))return;if(G.current){const ge=window.getSelection();ge&&(ge.removeAllRanges(),ge.addRange(G.current))}const g=window.getSelection();if(!g||!g.rangeCount)return;const j=g.getRangeAt(0);if(j.collapsed)return;const I=j.toString();if(!I)return;const X=j.commonAncestorContainer,S=X.nodeType===Node.TEXT_NODE?X.parentElement:X,R=S==null?void 0:S.getAttribute("data-text-case");if(R===i){const ge=S==null?void 0:S.getAttribute("data-original-text");if(ge){const Q=document.createTextNode(ge);j.deleteContents(),j.insertNode(Q),S==null||S.removeAttribute("data-text-case"),S==null||S.removeAttribute("data-original-text"),r(null),G.current=null;return}}let ee=I;switch(i){case"lowercase":ee=I.toLowerCase();break;case"uppercase":ee=I.toUpperCase();break;case"capitalize":ee=I.split(" ").map(ge=>ge.charAt(0).toUpperCase()+ge.slice(1).toLowerCase()).join(" ");break}R||S==null||S.setAttribute("data-original-text",I),S==null||S.setAttribute("data-text-case",i);const ce=document.createTextNode(ee);j.deleteContents(),j.insertNode(ce),j.selectNodeContents(ce),g.removeAllRanges(),g.addRange(j),r(null),G.current=null},[e]),De=m.useCallback(i=>{if(!T)return;const g=I=>{const X=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],R=X[I.getDay()],ee=I.getDate(),ce=S[I.getMonth()],ge=I.getFullYear();return`${R}, ${ee} ${ce} ${ge}`},j=T.element;j.setAttribute("data-date",i.toISOString()),j.textContent=g(i),$(null)},[T]),Pe=m.useCallback((i,g,j,I)=>{if(!re)return;const X=`${i}:${g.toString().padStart(2,"0")} ${j} ${I}`,S=re.element;S.setAttribute("data-time",X),S.setAttribute("data-hour",i.toString()),S.setAttribute("data-minute",g.toString()),S.setAttribute("data-period",j),S.setAttribute("data-timezone",I),S.textContent=X,Z(null)},[re]);if(!e)return null;const Te=(i,g)=>{var ee;const j=document.activeElement,I=j==null?void 0:j.closest(".cb-block"),X=I==null?void 0:I.getAttribute("data-block-id"),S=I==null?void 0:I.getAttribute("data-block-type"),R=I==null?void 0:I.querySelector('[contenteditable="true"]');X&&S==="paragraph"&&R&&!((ee=R.textContent)!=null&&ee.trim())?e.transformBlock(I,i,g):e.insertBlock(i,g)},Ye=[{name:"history",buttons:[{icon:u.Undo,label:"Undo",action:()=>e.undo(),shortcut:"Ctrl+Z"},{icon:u.Redo,label:"Redo",action:()=>e.redo(),shortcut:"Ctrl+Y"}]},{name:"formatting",buttons:[{icon:u.Bold,label:"Bold",action:()=>at(e.container),isActive:()=>H.bold,shortcut:"Ctrl+B"},{icon:u.Italic,label:"Italic",action:()=>it(e.container),isActive:()=>H.italic,shortcut:"Ctrl+I"},{icon:u.Underline,label:"Underline",action:()=>st(e.container),isActive:()=>H.underline,shortcut:"Ctrl+U"},{icon:u.Strikethrough,label:"Strikethrough",action:()=>dt(e.container),isActive:()=>H.strikethrough},{icon:u.Code,label:"Inline Code",action:()=>ut(e.container)}]},{name:"richtext",buttons:[{icon:u.Link,label:"Insert Link",action:i=>Y("link",i)},{icon:u.Highlighter,label:"Highlight",action:i=>Y("highlight",i)},{icon:u.Palette,label:"Text Color",action:i=>Y("textColor",i)},{icon:u.CaseSensitive,label:"Text Case",action:i=>Y("textCase",i)},{icon:u.Calendar,label:"Insert Date",action:i=>Y("date",i)},{icon:u.Clock,label:"Insert Time",action:i=>Y("time",i)}]},{name:"alignment",buttons:[{icon:u.AlignLeft,label:"Align Left",action:()=>{const i=Ue(document.activeElement);i&&Oe(i,"left")}},{icon:u.AlignCenter,label:"Align Center",action:()=>{const i=Ue(document.activeElement);i&&Oe(i,"center")}},{icon:u.AlignRight,label:"Align Right",action:()=>{const i=Ue(document.activeElement);i&&Oe(i,"right")}}]},{name:"headings",buttons:[{icon:u.Heading1,label:"Heading 1",action:()=>Te("heading",{level:1}),shortcut:"Ctrl+1"},{icon:u.Heading2,label:"Heading 2",action:()=>Te("heading",{level:2}),shortcut:"Ctrl+2"},{icon:u.Heading3,label:"Heading 3",action:()=>Te("heading",{level:3}),shortcut:"Ctrl+3"}]},{name:"blocks",buttons:[{icon:u.List,label:"Bullet List",action:()=>Te("bulletList")},{icon:u.ListOrdered,label:"Numbered List",action:()=>Te("numberedList")},{icon:u.CheckSquare,label:"Checklist",action:()=>Te("checkList")},{icon:u.Quote,label:"Quote",action:()=>Te("quote")},{icon:u.FileCode,label:"Code Block",action:()=>Te("code")}]},{name:"media",buttons:[{icon:u.Image,label:"Image",action:()=>e.insertBlock("image")},{icon:u.Video,label:"Video",action:()=>e.insertBlock("video")},{icon:u.PenTool,label:"Excalidraw",action:()=>e.insertBlock("excalidraw")},{icon:u.Table,label:"Table",action:()=>e.insertBlock("table")},{icon:u.AlertCircle,label:"Callout",action:()=>Te("callout")},{icon:u.ChevronDown,label:"Accordion",action:()=>Te("accordion")},{icon:u.Minus,label:"Divider",action:()=>e.insertBlock("divider")}]},{name:"utils",buttons:[{icon:u.Eraser,label:"Clear Formatting",action:()=>Yt(e.container)},{icon:u.Download,label:"Export HTML",action:()=>pe("html")},{icon:u.FileText,label:"Export PDF",action:()=>N()}]}];return c.jsxs("div",{ref:te,className:`cb-toolbar ${t} ${n?"cb-toolbar-dark":""}`,role:"toolbar","aria-label":"Editor formatting options",onMouseDown:i=>{const g=i.target,j=window.getSelection();if(j&&j.rangeCount>0){const I=j.getRangeAt(0);e!=null&&e.container&&e.container.contains(I.commonAncestorContainer)&&(G.current=I.cloneRange())}g.tagName==="INPUT"||g.tagName==="SELECT"||g.closest(".cb-popover")||i.preventDefault()},children:[Ye.map(i=>c.jsx("div",{className:"cb-toolbar-group",role:"group",children:i.buttons.map(g=>{var j,I;return c.jsx("button",{type:"button",className:`cb-toolbar-btn ${(j=g.isActive)!=null&&j.call(g)?"cb-toolbar-btn-active":""}`,onClick:g.action,title:`${g.label}${g.shortcut?` (${g.shortcut})`:""}`,"aria-label":g.label,"aria-pressed":(I=g.isActive)==null?void 0:I.call(g),children:c.jsx(g.icon,{size:18})},g.label)})},i.name)),o&&c.jsxs("div",{ref:A,className:"cb-popover",style:{position:"absolute",left:a.x,top:a.y,zIndex:1e3},children:[o==="link"&&c.jsxs("div",{className:"cb-popover-content cb-link-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Insert Link"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>r(null),children:c.jsx(u.X,{size:14})})]}),c.jsxs("div",{className:"cb-popover-body",children:[c.jsx("input",{type:"url",value:d,onChange:i=>w(i.target.value),placeholder:"https://example.com",className:"cb-popover-input",autoFocus:!0,onKeyDown:i=>{i.key==="Enter"&&Ce(),i.key==="Escape"&&he()}}),c.jsx("button",{type:"button",className:"cb-popover-btn-primary",onClick:Ce,disabled:!d,children:"Insert Link"})]})]}),o==="highlight"&&c.jsxs("div",{className:"cb-popover-content cb-color-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Highlight Color"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>r(null),children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-color-grid",children:He.map(({color:i,label:g})=>c.jsx("button",{type:"button",className:"cb-color-swatch",style:{backgroundColor:i==="transparent"?"#fff":i,border:i==="transparent"?"2px dashed #ccc":void 0},onClick:()=>Ae(i),title:g,children:i==="transparent"&&c.jsx(u.X,{size:12})},i))})]}),o==="textColor"&&c.jsxs("div",{className:"cb-popover-content cb-color-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Text Color"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:()=>r(null),children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-color-grid",children:ke.map(({color:i,label:g})=>c.jsx("button",{type:"button",className:"cb-color-swatch",style:{backgroundColor:i},onClick:()=>Ee(i),title:g},i))})]}),o==="date"&&c.jsxs("div",{className:"cb-popover-content cb-date-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Insert Date"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:he,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-popover-body",children:c.jsxs("div",{className:"cb-date-quick-options",children:[c.jsx("button",{type:"button",className:"cb-date-option-btn",onClick:()=>{const i=new Date;i.setHours(0,0,0,0),V(i)},children:"Today"}),c.jsx("button",{type:"button",className:"cb-date-option-btn",onClick:()=>{const i=new Date;i.setDate(i.getDate()+1),i.setHours(0,0,0,0),V(i)},children:"Tomorrow"}),c.jsx("button",{type:"button",className:"cb-date-option-btn",onClick:()=>{const i=new Date;i.setDate(i.getDate()-1),i.setHours(0,0,0,0),V(i)},children:"Yesterday"})]})})]}),o==="time"&&c.jsxs("div",{className:"cb-popover-content cb-time-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Set Time"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:he,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-popover-body",children:c.jsxs("div",{className:"cb-time-picker-compact",children:[c.jsxs("div",{className:"cb-time-input-group-compact",children:[c.jsxs("div",{className:"cb-time-input-box-compact",children:[c.jsx("input",{type:"text",maxLength:2,value:x.hour.toString().padStart(2,"0"),onChange:i=>{const g=i.target.value.replace(/\D/g,"");let j=parseInt(g,10);g===""?z({...x,hour:12}):j>=1&&j<=12&&z({...x,hour:j})},onKeyDown:i=>{if(i.key==="ArrowUp"){i.preventDefault();const g=x.hour===12?1:x.hour+1;z({...x,hour:g})}else if(i.key==="ArrowDown"){i.preventDefault();const g=x.hour===1?12:x.hour-1;z({...x,hour:g})}},onFocus:i=>i.target.select(),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),className:"cb-time-input-compact"}),c.jsxs("div",{className:"cb-time-arrows-compact",children:[c.jsx("button",{type:"button",onClick:()=>{const i=x.hour===12?1:x.hour+1;z({...x,hour:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronUp,{size:10})}),c.jsx("button",{type:"button",onClick:()=>{const i=x.hour===1?12:x.hour-1;z({...x,hour:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronDown,{size:10})})]})]}),c.jsx("span",{className:"cb-time-colon-compact",children:":"}),c.jsxs("div",{className:"cb-time-input-box-compact",children:[c.jsx("input",{type:"text",maxLength:2,value:x.minute.toString().padStart(2,"0"),onChange:i=>{const g=i.target.value.replace(/\D/g,"");let j=parseInt(g,10);g===""?z({...x,minute:0}):j>=0&&j<=59&&z({...x,minute:j})},onKeyDown:i=>{if(i.key==="ArrowUp"){i.preventDefault();const g=(x.minute+1)%60;z({...x,minute:g})}else if(i.key==="ArrowDown"){i.preventDefault();const g=(x.minute-1+60)%60;z({...x,minute:g})}},onFocus:i=>i.target.select(),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),className:"cb-time-input-compact"}),c.jsxs("div",{className:"cb-time-arrows-compact",children:[c.jsx("button",{type:"button",onClick:()=>{const i=(x.minute+1)%60;z({...x,minute:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronUp,{size:10})}),c.jsx("button",{type:"button",onClick:()=>{const i=(x.minute-1+60)%60;z({...x,minute:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronDown,{size:10})})]})]}),c.jsx("button",{type:"button",className:"cb-time-period-compact",onClick:()=>{z({...x,period:x.period==="AM"?"PM":"AM"})},children:x.period}),c.jsx("button",{type:"button",className:"cb-time-now-icon-compact",onClick:()=>{const i=new Date;let g=i.getHours();const j=g>=12?"PM":"AM";g=g%12||12;const I=i.getMinutes();z({...x,hour:g,minute:I,period:j})},title:"Set current time",children:c.jsx(u.Circle,{size:6,fill:"currentColor",className:"cb-pulse-dot"})})]}),c.jsxs("div",{className:"cb-time-bottom-row",children:[c.jsxs("select",{className:"cb-time-zone-compact",value:x.timezone,onChange:i=>{z({...x,timezone:i.target.value})},onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[c.jsx("option",{value:"IST",children:"🇮🇳 IST - India"}),c.jsx("option",{value:"UTC",children:"🌍 UTC - Universal"}),c.jsx("option",{value:"EST",children:"🇺🇸 EST - Eastern"}),c.jsx("option",{value:"PST",children:"🇺🇸 PST - Pacific"}),c.jsx("option",{value:"CST",children:"🇺🇸 CST - Central"}),c.jsx("option",{value:"JST",children:"🇯🇵 JST - Japan"})]}),c.jsx("button",{type:"button",className:"cb-time-insert-icon-compact",onClick:()=>{ie(x.hour,x.minute,x.period,x.timezone)},title:"Insert time",children:c.jsx(u.ArrowRight,{size:16})})]})]})})]}),o==="textCase"&&c.jsxs("div",{className:"cb-popover-content cb-case-popover",children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{children:"Text Case"}),c.jsx("button",{type:"button",className:"cb-popover-close",onClick:he,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-popover-body",children:c.jsxs("div",{className:"cb-case-options",children:[c.jsxs("button",{type:"button",className:"cb-case-option-btn",onClick:()=>oe("lowercase"),children:[c.jsx("span",{children:"abc"}),c.jsx("span",{className:"cb-case-label",children:"lowercase"})]}),c.jsxs("button",{type:"button",className:"cb-case-option-btn",onClick:()=>oe("uppercase"),children:[c.jsx("span",{children:"ABC"}),c.jsx("span",{className:"cb-case-label",children:"UPPERCASE"})]}),c.jsxs("button",{type:"button",className:"cb-case-option-btn",onClick:()=>oe("capitalize"),children:[c.jsx("span",{children:"Abc"}),c.jsx("span",{className:"cb-case-label",children:"Capitalize"})]})]})})]})]}),L&&typeof document<"u"&&Ze.createPortal(c.jsx("div",{ref:fe,className:"cb-link-preview",style:{position:"absolute",left:L.position.x,top:L.position.y,zIndex:1e4},onMouseEnter:()=>{be.current&&(window.clearTimeout(be.current),be.current=null)},onMouseLeave:()=>{be.current=window.setTimeout(()=>{_(null)},200)},children:c.jsxs("div",{className:"cb-link-preview-content",children:[c.jsx("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"cb-link-preview-url",title:L.url,children:L.url}),c.jsx("div",{className:"cb-link-preview-divider"}),c.jsxs("div",{className:"cb-link-preview-actions",children:[c.jsx("button",{type:"button",className:"cb-link-preview-btn",onClick:xe,title:"Edit link",children:c.jsx(u.Edit3,{size:16})}),c.jsx("button",{type:"button",className:"cb-link-preview-btn cb-link-preview-btn-danger",onClick:we,title:"Remove link",children:c.jsx(u.Trash2,{size:16})})]})]})}),document.body),T&&typeof document<"u"&&Ze.createPortal(c.jsx("div",{ref:ve,className:`cb-date-calendar ${n?"cb-dark":""}`,style:{position:"absolute",left:T.position.x,top:T.position.y,zIndex:1e4},onMouseEnter:()=>{me.current&&(window.clearTimeout(me.current),me.current=null)},onMouseLeave:()=>{me.current=window.setTimeout(()=>{$(null)},200)},children:c.jsxs("div",{className:"cb-calendar-content",children:[c.jsxs("div",{className:"cb-calendar-header",children:[c.jsx("button",{type:"button",className:"cb-calendar-nav-btn",onClick:()=>{const i=new Date(T.date);i.setMonth(i.getMonth()-1),$({...T,date:i})},children:"‹"}),c.jsxs("div",{className:"cb-calendar-month-year",children:[c.jsx("span",{className:"cb-calendar-month",children:T.date.toLocaleDateString("en-US",{month:"long"})}),c.jsx("select",{className:"cb-calendar-year-select",value:T.date.getFullYear(),onChange:i=>{const g=new Date(T.date);g.setFullYear(parseInt(i.target.value,10)),$({...T,date:g})},onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:(()=>{const i=new Date().getFullYear(),g=[];for(let j=i-100;j<=i+100;j++)g.push(c.jsx("option",{value:j,children:j},j));return g})()})]}),c.jsx("button",{type:"button",className:"cb-calendar-nav-btn",onClick:()=>{const i=new Date(T.date);i.setMonth(i.getMonth()+1),$({...T,date:i})},children:"›"})]}),c.jsxs("div",{className:"cb-calendar-grid",children:[c.jsx("div",{className:"cb-calendar-weekdays",children:["S","M","T","W","T","F","S"].map((i,g)=>c.jsx("div",{className:"cb-calendar-weekday",children:i},g))}),c.jsx("div",{className:"cb-calendar-days",children:(()=>{const i=T.date.getFullYear(),g=T.date.getMonth(),j=new Date(i,g,1),I=new Date(i,g+1,0),X=j.getDay(),S=I.getDate(),R=new Date;R.setHours(0,0,0,0);const ee=[];for(let ce=0;ce<X;ce++)ee.push(c.jsx("div",{className:"cb-calendar-day-empty"},`empty-${ce}`));for(let ce=1;ce<=S;ce++){const ge=new Date(i,g,ce);ge.setHours(0,0,0,0);const Q=ge.getTime()===R.getTime(),Me=ge.getTime()===new Date(T.date).setHours(0,0,0,0);ee.push(c.jsx("button",{type:"button",className:`cb-calendar-day ${Q?"cb-calendar-day-today":""} ${Me?"cb-calendar-day-selected":""}`,onClick:()=>De(ge),children:ce},ce))}return ee})()})]})]})}),document.body),re&&typeof document<"u"&&Ze.createPortal(c.jsx("div",{ref:ue,className:`cb-time-picker-hover ${n?"cb-dark":""}`,style:{position:"absolute",left:re.position.x,top:re.position.y,zIndex:1e4},onMouseEnter:()=>{J.current&&(window.clearTimeout(J.current),J.current=null)},onMouseLeave:()=>{J.current=window.setTimeout(()=>{Z(null)},200)},children:c.jsxs("div",{className:"cb-time-picker-hover-content",children:[c.jsx("div",{className:"cb-time-hover-header",children:"Edit Time"}),c.jsxs("div",{className:"cb-time-input-group-compact",children:[c.jsxs("div",{className:"cb-time-input-box-compact",children:[c.jsx("input",{type:"text",maxLength:2,value:x.hour.toString().padStart(2,"0"),onChange:i=>{const g=i.target.value.replace(/\D/g,"");let j=parseInt(g,10);g===""?z({...x,hour:12}):j>=1&&j<=12&&z({...x,hour:j})},onKeyDown:i=>{if(i.key==="ArrowUp"){i.preventDefault();const g=x.hour===12?1:x.hour+1;z({...x,hour:g})}else if(i.key==="ArrowDown"){i.preventDefault();const g=x.hour===1?12:x.hour-1;z({...x,hour:g})}},onFocus:i=>i.target.select(),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),className:"cb-time-input-compact"}),c.jsxs("div",{className:"cb-time-arrows-compact",children:[c.jsx("button",{type:"button",onClick:()=>{const i=x.hour===12?1:x.hour+1;z({...x,hour:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronUp,{size:10})}),c.jsx("button",{type:"button",onClick:()=>{const i=x.hour===1?12:x.hour-1;z({...x,hour:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronDown,{size:10})})]})]}),c.jsx("span",{className:"cb-time-colon-compact",children:":"}),c.jsxs("div",{className:"cb-time-input-box-compact",children:[c.jsx("input",{type:"text",maxLength:2,value:x.minute.toString().padStart(2,"0"),onChange:i=>{const g=i.target.value.replace(/\D/g,"");let j=parseInt(g,10);g===""?z({...x,minute:0}):j>=0&&j<=59&&z({...x,minute:j})},onKeyDown:i=>{if(i.key==="ArrowUp"){i.preventDefault();const g=(x.minute+1)%60;z({...x,minute:g})}else if(i.key==="ArrowDown"){i.preventDefault();const g=(x.minute-1+60)%60;z({...x,minute:g})}},onFocus:i=>i.target.select(),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),className:"cb-time-input-compact"}),c.jsxs("div",{className:"cb-time-arrows-compact",children:[c.jsx("button",{type:"button",onClick:()=>{const i=(x.minute+1)%60;z({...x,minute:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronUp,{size:10})}),c.jsx("button",{type:"button",onClick:()=>{const i=(x.minute-1+60)%60;z({...x,minute:i})},className:"cb-time-arrow-compact",children:c.jsx(u.ChevronDown,{size:10})})]})]}),c.jsx("button",{type:"button",className:"cb-time-period-compact",onClick:()=>{z({...x,period:x.period==="AM"?"PM":"AM"})},children:x.period}),c.jsx("button",{type:"button",className:"cb-time-now-icon-compact",onClick:()=>{const i=new Date;let g=i.getHours();const j=g>=12?"PM":"AM";g=g%12||12;const I=i.getMinutes();z({...x,hour:g,minute:I,period:j})},title:"Set current time",children:c.jsx(u.Circle,{size:6,fill:"currentColor",className:"cb-pulse-dot"})})]}),c.jsxs("div",{className:"cb-time-bottom-row",children:[c.jsxs("select",{className:"cb-time-zone-compact",value:x.timezone,onChange:i=>{z({...x,timezone:i.target.value})},onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[c.jsx("option",{value:"IST",children:"🇮🇳 IST - India"}),c.jsx("option",{value:"UTC",children:"🌍 UTC - Universal"}),c.jsx("option",{value:"EST",children:"🇺🇸 EST - Eastern"}),c.jsx("option",{value:"PST",children:"🇺🇸 PST - Pacific"}),c.jsx("option",{value:"CST",children:"🇺🇸 CST - Central"}),c.jsx("option",{value:"JST",children:"🇯🇵 JST - Japan"})]}),c.jsx("button",{type:"button",className:"cb-time-insert-icon-compact",onClick:()=>{Pe(x.hour,x.minute,x.period,x.timezone)},title:"Update time",children:c.jsx(u.ArrowRight,{size:16})})]})]})}),document.body)]})},_c=({editor:e,darkMode:t=!1})=>{const[n,o]=m.useState(!1),[r,a]=m.useState({top:0,left:0}),[s,d]=m.useState(null),[w,H]=m.useState(""),D=m.useRef(null),L=m.useRef(null),_=m.useRef(null),T=m.useRef(!1),$=[{color:"#000000",label:"Black"},{color:"#374151",label:"Gray"},{color:"#dc2626",label:"Red"},{color:"#ea580c",label:"Orange"},{color:"#ca8a04",label:"Yellow"},{color:"#16a34a",label:"Green"},{color:"#0891b2",label:"Cyan"},{color:"#2563eb",label:"Blue"},{color:"#7c3aed",label:"Purple"},{color:"#db2777",label:"Pink"}],x=[{color:"#fef08a",label:"Yellow"},{color:"#bbf7d0",label:"Green"},{color:"#bfdbfe",label:"Blue"},{color:"#fecaca",label:"Red"},{color:"#e9d5ff",label:"Purple"},{color:"#fed7aa",label:"Orange"},{color:"#99f6e4",label:"Teal"},{color:"#fce7f3",label:"Pink"},{color:"#e5e7eb",label:"Gray"},{color:"transparent",label:"None"}],z=[{value:"inherit",label:"Default"},{value:"Arial, sans-serif",label:"Arial"},{value:'"Times New Roman", serif',label:"Times New Roman"},{value:'"Courier New", monospace',label:"Courier New"},{value:"Georgia, serif",label:"Georgia"},{value:"Verdana, sans-serif",label:"Verdana"},{value:'"Comic Sans MS", cursive',label:"Comic Sans"},{value:"Impact, sans-serif",label:"Impact"},{value:'"Trebuchet MS", sans-serif',label:"Trebuchet"},{value:"Tahoma, sans-serif",label:"Tahoma"}],re=[{value:"0.75rem",label:"12px"},{value:"0.875rem",label:"14px"},{value:"1rem",label:"16px"},{value:"1.125rem",label:"18px"},{value:"1.25rem",label:"20px"},{value:"1.5rem",label:"24px"},{value:"1.875rem",label:"30px"},{value:"2.25rem",label:"36px"},{value:"3rem",label:"48px"}],Z=m.useCallback(()=>{const N=window.getSelection();if(N&&N.rangeCount>0){const V=N.getRangeAt(0);e!=null&&e.container&&e.container.contains(V.commonAncestorContainer)&&(_.current=V.cloneRange())}},[e]),te=m.useCallback(()=>{if(_.current&&(e!=null&&e.container)){const N=window.getSelection();if(N){N.removeAllRanges(),N.addRange(_.current);const V=_.current.commonAncestorContainer;let ie=V.nodeType===Node.ELEMENT_NODE?V:V.parentElement;for(;ie&&ie!==e.container;){if(ie.getAttribute("contenteditable")==="true"){ie.focus();break}ie=ie.parentElement}}}},[e]),A=m.useCallback(()=>{if(T.current)return;const N=window.getSelection();if(!N||N.isCollapsed||!N.rangeCount){o(!1),d(null),_.current=null;return}const V=N.getRangeAt(0);if(!(e!=null&&e.container)||!e.container.contains(V.commonAncestorContainer)){o(!1),d(null),_.current=null;return}const ie=V.getBoundingClientRect(),oe=ie.top+window.scrollY-50,De=ie.left+window.scrollX+ie.width/2;a({top:oe,left:De}),o(!0),Z()},[e,Z]);m.useEffect(()=>{let N=null;const V=()=>{N||(N=requestAnimationFrame(()=>{N=null,A()}))};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),N&&cancelAnimationFrame(N)}},[A]),m.useEffect(()=>{const N=()=>{T.current=!0},V=()=>{T.current=!1,setTimeout(()=>{T.current||A()},100)},ie=D.current,oe=L.current;return ie&&(ie.addEventListener("mouseenter",N),ie.addEventListener("mouseleave",V)),oe&&(oe.addEventListener("mouseenter",N),oe.addEventListener("mouseleave",V)),()=>{ie&&(ie.removeEventListener("mouseenter",N),ie.removeEventListener("mouseleave",V)),oe&&(oe.removeEventListener("mouseenter",N),oe.removeEventListener("mouseleave",V))}},[A,s]),m.useEffect(()=>{const N=V=>{var ie;L.current&&!L.current.contains(V.target)&&!((ie=D.current)!=null&&ie.contains(V.target))&&d(null)};if(s)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]),m.useEffect(()=>{const N=V=>{V.key==="Escape"&&s&&(V.preventDefault(),d(null),te())};if(s)return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[s,te]);const fe=N=>{N.preventDefault(),Z(),setTimeout(()=>{te(),e!=null&&e.container&&at(e.container)},0)},ve=N=>{N.preventDefault(),Z(),setTimeout(()=>{te(),e!=null&&e.container&&it(e.container)},0)},ue=N=>{N.preventDefault(),Z(),setTimeout(()=>{te(),e!=null&&e.container&&st(e.container)},0)},G=N=>{N.preventDefault(),Z(),setTimeout(()=>{te(),e!=null&&e.container&&dt(e.container)},0)},ae=N=>{N.preventDefault(),Z(),setTimeout(()=>{te(),e!=null&&e.container&&ut(e.container)},0)},be=N=>{N.preventDefault(),Z(),d(s==="textColor"?null:"textColor")},ye=N=>{te(),e!=null&&e.container&&pt(e.container,N),d(null)},me=N=>{N.preventDefault(),Z(),d(s==="highlight"?null:"highlight")},Ne=N=>{te(),e!=null&&e.container&&mt(e.container,N),d(null)},J=N=>{N.preventDefault(),Z();const V=window.getSelection();if(V&&V.rangeCount>0){let oe=V.getRangeAt(0).commonAncestorContainer;for(;oe&&oe!==(e==null?void 0:e.container);){if(oe instanceof HTMLAnchorElement){H(oe.href);break}oe=oe.parentNode}}d(s==="link"?null:"link")},ke=()=>{te(),e!=null&&e.container&&w&&bt(e.container,w),H(""),d(null)},He=N=>{N.preventDefault(),Z(),d(s==="align"?null:"align")},Y=N=>{if(te(),_.current){const V=Ue(_.current.commonAncestorContainer);V&&Oe(V,N)}d(null)},he=N=>{N.preventDefault(),Z(),d(s==="textCase"?null:"textCase")},Ce=N=>{te();const V=window.getSelection();if(V&&V.rangeCount>0){const oe=V.getRangeAt(0).toString();let De=oe;switch(N){case"uppercase":De=oe.toUpperCase();break;case"lowercase":De=oe.toLowerCase();break;case"capitalize":De=oe.split(" ").map(Pe=>Pe.charAt(0).toUpperCase()+Pe.slice(1).toLowerCase()).join(" ");break}document.execCommand("insertText",!1,De)}d(null)},Ee=N=>{N.preventDefault(),Z(),d(s==="fontFamily"?null:"fontFamily")},Ae=N=>{te(),e!=null&&e.container&&_t(e.container,N),d(null)},xe=N=>{N.preventDefault(),Z(),d(s==="fontSize"?null:"fontSize")},we=N=>{te(),e!=null&&e.container&&Kt(e.container,N),d(null)},pe=()=>{d(null),setTimeout(()=>{te()},0)};return n?Ze.createPortal(c.jsxs("div",{ref:D,className:`cb-selection-toolbar ${t?"cb-dark":""}`,style:{position:"absolute",top:`${r.top}px`,left:`${r.left}px`,transform:"translateX(-50%)",zIndex:1e4},onMouseDown:N=>{N.preventDefault(),Z()},children:[c.jsxs("div",{className:"cb-selection-toolbar-content",children:[c.jsx("button",{className:"cb-toolbar-btn",onClick:fe,title:"Bold (Ctrl+B)","aria-label":"Bold",children:c.jsx(u.Bold,{size:16})}),c.jsx("button",{className:"cb-toolbar-btn",onClick:ve,title:"Italic (Ctrl+I)","aria-label":"Italic",children:c.jsx(u.Italic,{size:16})}),c.jsx("button",{className:"cb-toolbar-btn",onClick:ue,title:"Underline (Ctrl+U)","aria-label":"Underline",children:c.jsx(u.Underline,{size:16})}),c.jsx("button",{className:"cb-toolbar-btn",onClick:G,title:"Strikethrough","aria-label":"Strikethrough",children:c.jsx(u.Strikethrough,{size:16})}),c.jsx("button",{className:"cb-toolbar-btn",onClick:ae,title:"Inline Code","aria-label":"Inline Code",children:c.jsx(u.Code,{size:16})}),c.jsx("div",{className:"cb-selection-toolbar-divider"}),c.jsx("button",{className:`cb-toolbar-btn ${s==="fontFamily"?"cb-toolbar-btn-active":""}`,onClick:Ee,title:"Font Family","aria-label":"Font Family",children:c.jsx(u.Type,{size:16})}),c.jsx("button",{className:`cb-toolbar-btn ${s==="fontSize"?"cb-toolbar-btn-active":""}`,onClick:xe,title:"Font Size","aria-label":"Font Size",children:c.jsx(u.TextCursorInput,{size:16})}),c.jsx("div",{className:"cb-selection-toolbar-divider"}),c.jsx("button",{className:`cb-toolbar-btn ${s==="textColor"?"cb-toolbar-btn-active":""}`,onClick:be,title:"Text Color","aria-label":"Text Color",children:c.jsx(u.Palette,{size:16})}),c.jsx("button",{className:`cb-toolbar-btn ${s==="highlight"?"cb-toolbar-btn-active":""}`,onClick:me,title:"Highlight","aria-label":"Highlight",children:c.jsx(u.Highlighter,{size:16})}),c.jsx("div",{className:"cb-selection-toolbar-divider"}),c.jsx("button",{className:`cb-toolbar-btn ${s==="link"?"cb-toolbar-btn-active":""}`,onClick:J,title:"Insert Link","aria-label":"Insert Link",children:c.jsx(u.Link,{size:16})}),c.jsx("button",{className:`cb-toolbar-btn ${s==="align"?"cb-toolbar-btn-active":""}`,onClick:He,title:"Alignment","aria-label":"Alignment",children:c.jsx(u.AlignLeft,{size:16})}),c.jsx("button",{className:`cb-toolbar-btn ${s==="textCase"?"cb-toolbar-btn-active":""}`,onClick:he,title:"Text Case","aria-label":"Text Case",children:c.jsx(u.CaseSensitive,{size:16})})]}),s==="textColor"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Text Color"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-color-grid",children:$.map(({color:N,label:V})=>c.jsx("button",{className:"cb-color-swatch",style:{backgroundColor:N},onClick:()=>ye(N),title:V,"aria-label":`Set text color to ${V}`},N))})]}),s==="highlight"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Highlight"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-color-grid",children:x.map(({color:N,label:V})=>c.jsx("button",{className:"cb-color-swatch",style:{backgroundColor:N},onClick:()=>Ne(N),title:V,"aria-label":`Set highlight to ${V}`},N))})]}),s==="link"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Insert Link"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsxs("div",{className:"cb-popover-content",children:[c.jsx("input",{type:"url",className:"cb-popover-input",placeholder:"Enter URL...",value:w,onChange:N=>H(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),ke())},autoFocus:!0}),c.jsx("button",{className:"cb-popover-btn cb-popover-btn-primary",onClick:ke,children:"Insert"})]})]}),s==="align"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Alignment"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsxs("div",{className:"cb-popover-menu",children:[c.jsxs("button",{className:"cb-popover-menu-item cb-popover-menu-item-align",onClick:()=>Y("left"),children:[c.jsx(u.AlignLeft,{size:16}),c.jsx("span",{children:"Align Left"})]}),c.jsxs("button",{className:"cb-popover-menu-item cb-popover-menu-item-align",onClick:()=>Y("center"),children:[c.jsx(u.AlignCenter,{size:16}),c.jsx("span",{children:"Align Center"})]}),c.jsxs("button",{className:"cb-popover-menu-item cb-popover-menu-item-align",onClick:()=>Y("right"),children:[c.jsx(u.AlignRight,{size:16}),c.jsx("span",{children:"Align Right"})]}),c.jsxs("button",{className:"cb-popover-menu-item cb-popover-menu-item-align",onClick:()=>Y("justify"),children:[c.jsx(u.AlignJustify,{size:16}),c.jsx("span",{children:"Justify"})]})]})]}),s==="textCase"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Text Case"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsxs("div",{className:"cb-popover-menu",children:[c.jsx("button",{className:"cb-popover-menu-item",onClick:()=>Ce("uppercase"),children:"UPPERCASE"}),c.jsx("button",{className:"cb-popover-menu-item",onClick:()=>Ce("lowercase"),children:"lowercase"}),c.jsx("button",{className:"cb-popover-menu-item",onClick:()=>Ce("capitalize"),children:"Capitalize Each Word"})]})]}),s==="fontFamily"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Font Family"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-popover-menu",children:z.map(({value:N,label:V})=>c.jsx("button",{className:"cb-popover-menu-item",onClick:()=>Ae(N),style:{fontFamily:N},children:V},N))})]}),s==="fontSize"&&c.jsxs("div",{ref:L,className:"cb-selection-toolbar-popover cb-popover",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:"8px"},children:[c.jsxs("div",{className:"cb-popover-header",children:[c.jsx("span",{className:"cb-popover-title",children:"Font Size"}),c.jsx("button",{className:"cb-popover-close-btn",onClick:pe,children:c.jsx(u.X,{size:14})})]}),c.jsx("div",{className:"cb-popover-menu",children:re.map(({value:N,label:V})=>c.jsx("button",{className:"cb-popover-menu-item",onClick:()=>we(N),children:V},N))})]})]}),document.body):null},Kc=[{type:"paragraph",label:"Paragraph",description:"Plain text paragraph",icon:u.Type,keywords:["text","paragraph","p"]},{type:"heading",label:"Heading 1",description:"Large section heading",icon:u.Heading1,keywords:["h1","heading","title","header"],data:{level:1}},{type:"heading",label:"Heading 2",description:"Medium section heading",icon:u.Heading2,keywords:["h2","heading","subtitle"],data:{level:2}},{type:"heading",label:"Heading 3",description:"Small section heading",icon:u.Heading3,keywords:["h3","heading"],data:{level:3}},{type:"bulletList",label:"Bullet List",description:"Create a bulleted list",icon:u.List,keywords:["bullet","list","ul","unordered"]},{type:"numberedList",label:"Numbered List",description:"Create a numbered list",icon:u.ListOrdered,keywords:["number","list","ol","ordered"]},{type:"checkList",label:"Checklist",description:"Track tasks with checkboxes",icon:u.CheckSquare,keywords:["check","todo","task","checkbox"]},{type:"quote",label:"Quote",description:"Capture a quote",icon:u.Quote,keywords:["quote","blockquote","citation"]},{type:"code",label:"Code Block",description:"Display code with syntax highlighting",icon:u.Code,keywords:["code","pre","syntax","programming"]},{type:"image",label:"Image",description:"Upload or embed an image",icon:u.Image,keywords:["image","picture","photo","img"]},{type:"video",label:"Video",description:"Embed a video from YouTube, Vimeo, etc.",icon:u.Video,keywords:["video","youtube","vimeo","embed"]},{type:"divider",label:"Divider",description:"Visual separator between sections",icon:u.Minus,keywords:["divider","hr","line","separator"]},{type:"callout",label:"Callout",description:"Highlight important information",icon:u.AlertCircle,keywords:["callout","alert","info","warning","note"]},{type:"accordion",label:"Accordion",description:"Collapsible content section",icon:u.ChevronDown,keywords:["accordion","collapse","toggle","details"]},{type:"date",label:"Date",description:"Insert formatted date",icon:u.Calendar,keywords:["date","time","calendar","today"],inline:!0},{type:"table",label:"Table",description:"Add a table",icon:u.Table,keywords:["table","grid","rows","columns"]},{type:"linkPreview",label:"Link Preview",description:"Rich preview card for URLs",icon:u.Link,keywords:["link","url","preview","embed","opengraph"]}],to=({editor:e,position:t,onSelect:n,onClose:o})=>{const[r,a]=m.useState(""),[s,d]=m.useState(0),w=m.useRef(null),H=m.useRef(null),D=m.useRef(new Map),L=Kc.filter($=>{if(!r)return!0;const x=r.toLowerCase();return $.label.toLowerCase().includes(x)||$.description.toLowerCase().includes(x)||$.keywords.some(z=>z.includes(x))});m.useEffect(()=>{d(0)},[r]),m.useEffect(()=>{const $=D.current.get(s);$&&$.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[s]),m.useEffect(()=>{var $;($=H.current)==null||$.focus()},[]),m.useEffect(()=>{const $=x=>{w.current&&!w.current.contains(x.target)&&o()};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[o]);const _=m.useCallback($=>{switch($.key){case"ArrowDown":$.preventDefault(),d(x=>x<L.length-1?x+1:0);break;case"ArrowUp":$.preventDefault(),d(x=>x>0?x-1:L.length-1);break;case"Enter":if($.preventDefault(),L[s]){const x=L[s];n(x.type,x.data,x.inline)}break;case"Escape":$.preventDefault(),o();break}},[L,s,n,o]),T={position:"fixed",left:Math.min(t.x,window.innerWidth-320),top:Math.min(t.y,window.innerHeight-400),zIndex:1e3};return c.jsxs("div",{ref:w,className:"cb-block-menu",style:T,role:"listbox","aria-label":"Insert block",children:[c.jsx("div",{className:"cb-block-menu-search",children:c.jsx("input",{ref:H,type:"text",value:r,onChange:$=>a($.target.value),onKeyDown:_,placeholder:"Search blocks...",className:"cb-block-menu-input","aria-label":"Search blocks"})}),c.jsx("div",{className:"cb-block-menu-list",children:L.length===0?c.jsx("div",{className:"cb-block-menu-empty",children:"No matching blocks"}):L.map(($,x)=>c.jsxs("button",{ref:z=>{z?D.current.set(x,z):D.current.delete(x)},type:"button",className:`cb-block-menu-item ${x===s?"cb-block-menu-item-selected":""}`,onClick:()=>n($.type,$.data,$.inline),onMouseEnter:()=>d(x),role:"option","aria-selected":x===s,children:[c.jsx("div",{className:"cb-block-menu-item-icon",children:c.jsx($.icon,{size:20})}),c.jsxs("div",{className:"cb-block-menu-item-content",children:[c.jsx("span",{className:"cb-block-menu-item-label",children:$.label}),c.jsx("span",{className:"cb-block-menu-item-description",children:$.description})]})]},`${$.type}-${$.label}`))}),c.jsxs("div",{className:"cb-block-menu-footer",children:[c.jsx("span",{children:"↑↓ Navigate"}),c.jsx("span",{children:"↵ Select"}),c.jsx("span",{children:"Esc Close"})]})]})};function no(e){return e===0?0:e/200}function Yc(e){if(e===0)return"0 min read";if(e<1)return"< 1 min read";const t=Math.ceil(e);if(t===1)return"1 min read";if(t<60)return`${t} min read`;const n=Math.floor(t/60),o=t%60;return o===0?n===1?"1 hour read":`${n} hours read`:`${n}h ${o}m read`}function Vc(e){const n=new Date().getTime()-e.getTime(),o=Math.floor(n/1e3),r=Math.floor(o/60),a=Math.floor(r/60),s=Math.floor(a/24);if(o<10)return"Just now";if(o<60)return`${o}s ago`;if(r<60)return`${r}m ago`;if(a<24)return`${a}h ago`;if(s===1)return"Yesterday";if(s<7)return`${s} days ago`;const d={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return e.toLocaleDateString("en-US",d)}const oo=({wordCount:e,charCount:t,readingTime:n,lastSaved:o,selectedBlockCount:r=0,className:a="",darkMode:s=!1})=>c.jsxs("div",{className:`cb-status-bar ${a} ${s?"cb-dark":""}`,role:"status","aria-label":"Editor statistics",children:[r>0&&c.jsxs("div",{className:"cb-status-item cb-status-highlight",title:"Selected blocks",children:[c.jsx(u.CheckSquare,{size:14,className:"cb-status-icon"}),c.jsxs("span",{className:"cb-status-label",children:[r," ",r===1?"block":"blocks"," selected"]})]}),c.jsxs("div",{className:"cb-status-item",title:"Word count",children:[c.jsx(u.Type,{size:14,className:"cb-status-icon"}),c.jsxs("span",{className:"cb-status-label",children:[e.toLocaleString()," ",e===1?"word":"words"]})]}),c.jsxs("div",{className:"cb-status-item",title:"Character count",children:[c.jsx(u.FileText,{size:14,className:"cb-status-icon"}),c.jsxs("span",{className:"cb-status-label",children:[t.toLocaleString()," ",t===1?"char":"chars"]})]}),c.jsxs("div",{className:"cb-status-item",title:"Estimated reading time",children:[c.jsx(u.Clock,{size:14,className:"cb-status-icon"}),c.jsx("span",{className:"cb-status-label",children:Yc(n)})]}),o&&c.jsxs("div",{className:"cb-status-item",title:`Saved on ${o.toLocaleString()}`,children:[c.jsx(u.Calendar,{size:14,className:"cb-status-icon"}),c.jsxs("span",{className:"cb-status-label",children:["Saved ",Vc(o)]})]})]}),Jc=({isOpen:e,onClose:t,onSave:n,initialElements:o=[],initialAppState:r={},darkMode:a=!1})=>{const[s,d]=m.useState(null),[w,H]=m.useState(!1);m.useEffect(()=>()=>{s&&d(null)},[s]);const D={...r,collaborators:void 0,selectedElementIds:void 0,hoveredElementIds:void 0,viewBackgroundColor:r.viewBackgroundColor||"#ffffff",theme:a?"dark":"light"},L=m.useCallback(async()=>{if(s){H(!0);try{const _=s.getSceneElements(),T=s.getAppState(),$=s.getFiles();if(JSON.stringify(_).length>1e6){console.error("Excalidraw drawing is too large (>1MB). Consider simplifying your drawing."),alert("Drawing is too large to save. Please simplify your drawing and try again."),H(!1);return}const z=await Qt.exportToBlob({elements:_,appState:{...T,exportBackground:!0,exportWithDarkMode:a},files:$,getDimensions:()=>({width:1200,height:800})}),re=new FileReader;re.onloadend=()=>{const Z=re.result;n(Z,_,T),t()},re.onerror=()=>{console.error("Failed to read exported image"),alert("Failed to save drawing. Please try again."),H(!1)},re.readAsDataURL(z)}catch(_){console.error("Failed to export Excalidraw:",_),alert("Failed to save drawing. Please try again."),H(!1)}}},[s,n,t,a]);return e?Ze.createPortal(c.jsxs("div",{className:`cb-excalidraw-modal ${a?"cb-dark":""}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e5,backgroundColor:a?"#1f2937":"#ffffff",display:"flex",flexDirection:"column"},children:[c.jsxs("div",{className:"cb-excalidraw-modal-header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"1rem 1.5rem",borderBottom:`1px solid ${a?"#374151":"#e5e7eb"}`,backgroundColor:a?"#111827":"#f9fafb"},children:[c.jsx("h2",{style:{margin:0,fontSize:"1.125rem",fontWeight:600,color:a?"#f9fafb":"#111827"},children:"Excalidraw Drawing"}),c.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[c.jsxs("button",{className:"cb-excalidraw-modal-btn cb-excalidraw-modal-btn-primary",onClick:L,disabled:w,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#ffffff",backgroundColor:"#3b82f6",border:"none",borderRadius:"0.375rem",cursor:w?"not-allowed":"pointer",opacity:w?.6:1},children:[c.jsx(u.Check,{size:16}),w?"Saving...":"Save"]}),c.jsxs("button",{className:"cb-excalidraw-modal-btn",onClick:t,disabled:w,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:a?"#f9fafb":"#374151",backgroundColor:a?"#374151":"#ffffff",border:`1px solid ${a?"#4b5563":"#d1d5db"}`,borderRadius:"0.375rem",cursor:w?"not-allowed":"pointer",opacity:w?.6:1},children:[c.jsx(u.X,{size:16}),"Cancel"]})]})]}),c.jsx("div",{className:"cb-excalidraw-modal-canvas",style:{flex:1,overflow:"hidden",position:"relative",width:"100%",height:"100%"},children:c.jsx(Qt.Excalidraw,{excalidrawAPI:_=>d(_),initialData:{elements:o,appState:D},theme:a?"dark":"light"})})]}),document.body):null},Gc=(e,t)=>{const{initialContent:n="",blocks:o,placeholder:r='Type "/" for commands...',readOnly:a=!1,classPrefix:s="cb",className:d="",style:w,showToolbar:H=!0,toolbarPosition:D="top",darkMode:L=!1,autoFocus:_=!1,spellCheck:T=!0,onChange:$,onSave:x,onFocus:z,onBlur:re,onReady:Z}=e,te=m.useRef(null),A=m.useRef(null),fe=m.useRef(!1),ve=m.useRef(null),ue=m.useRef([]),G=m.useRef([]),ae=m.useRef(new Set),[be,ye]=m.useState(!1),[me,Ne]=m.useState(null),[J,ke]=m.useState(new Set),[He,Y]=m.useState(!1),[he,Ce]=m.useState({x:0,y:0}),[Ee,Ae]=m.useState(null),[xe,we]=m.useState(0),[pe,N]=m.useState({blocks:[],activeBlock:null,selection:null,undoStack:[],redoStack:[],wordCount:0,charCount:0,isDirty:!1}),[V,ie]=m.useState({isOpen:!1,blockId:null,initialElements:[],initialAppState:{}});m.useEffect(()=>{Wt.forEach(l=>{Re.register(l)})},[]),m.useEffect(()=>{ye(!0)},[]),m.useEffect(()=>{ae.current=J},[J]),m.useEffect(()=>{let l=null,p=0;const b=100,k=()=>{if(l)return;const h=Date.now()-p;h<b?l=requestAnimationFrame(()=>{l=null,setTimeout(()=>{var E;p=Date.now();const v=window.getSelection();v&&((E=A.current)!=null&&E.contains(v.anchorNode))&&we(M=>M+1)},b-h)}):l=requestAnimationFrame(()=>{var E;l=null,p=Date.now();const v=window.getSelection();v&&((E=A.current)!=null&&E.contains(v.anchorNode))&&we(M=>M+1)})};return document.addEventListener("selectionchange",k),()=>{document.removeEventListener("selectionchange",k),l&&cancelAnimationFrame(l)}},[]),m.useEffect(()=>{A.current&&(A.current.querySelectorAll(".cb-block").forEach(l=>{l.classList.remove("cb-block-selected")}),J.forEach(l=>{var b;const p=(b=A.current)==null?void 0:b.querySelector(`[data-block-id="${l}"]`);p&&p.classList.add("cb-block-selected")}))},[J]);const oe=m.useCallback((l,p)=>{const b=(p==null?void 0:p.id)||le(),k=document.createElement("div");k.className="cb-block",k.setAttribute("data-block-id",b),k.setAttribute("data-block-type",l);const C=document.createElement("div");C.className="cb-block-controls",C.innerHTML=`
587
365
  <button type="button" class="cb-block-btn cb-block-add" data-action="add" title="Add block below">
588
366
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
589
367
  <path d="M12 5v14M5 12h14"/>
@@ -596,7 +374,7 @@ ${B}
596
374
  <circle cx="9" cy="19" r="1.5"/><circle cx="15" cy="19" r="1.5"/>
597
375
  </svg>
598
376
  </button>
599
- `;const k=document.createElement("div");k.className="cb-block-actions",k.innerHTML=`
377
+ `;const h=document.createElement("div");h.className="cb-block-actions",h.innerHTML=`
600
378
  <button type="button" class="cb-block-btn" data-action="moveup" title="Move up">
601
379
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
602
380
  <path d="m18 15-6-6-6 6"/>
@@ -612,11 +390,21 @@ ${B}
612
390
  <path d="M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/>
613
391
  </svg>
614
392
  </button>
615
- `;const f=document.createElement("div");f.className="cb-block-content";const g=de.createBlock(s,{...p,id:u});return g&&(g.removeAttribute("data-block-id"),g.removeAttribute("data-block-type"),f.appendChild(g)),b.appendChild(y),b.appendChild(f),b.appendChild(k),b},[]);h.useEffect(()=>{if(!(!N.current||le.current)){if(le.current=!0,N.current.innerHTML="",n&&n.trim()){const s=document.createElement("div");s.innerHTML=n,Array.from(s.children).forEach(p=>{var u;if(p instanceof HTMLElement){const b=Z(p),y=J(p,b),k=Y(b,y);(u=N.current)==null||u.appendChild(k)}})}if(N.current.children.length===0){const s=Y("paragraph");N.current.appendChild(s)}ce(),!r&&N.current&&Ln({container:N.current,handleSelector:"[data-drag-handle]",onDragEnd:()=>{ce(),q()}})}},[r]),h.useEffect(()=>{T&&N.current&&setTimeout(()=>{var p;const s=(p=N.current)==null?void 0:p.querySelector('[contenteditable="true"]');s instanceof HTMLElement&&s.focus()},100)},[T]);const Z=s=>{const p=s.tagName.toLowerCase(),u=s.className||"";switch(p){case"h1":return"heading";case"h2":return"heading";case"h3":return"heading";case"h4":return"heading";case"h5":return"heading";case"h6":return"heading";case"ul":return u.includes("checklist")||s.querySelector('input[type="checkbox"]')?"checkList":"bulletList";case"ol":return"numberedList";case"blockquote":return"quote";case"pre":return"code";case"figure":return s.querySelector("img")?"image":s.querySelector("video, iframe")?"video":"paragraph";case"hr":return"divider";case"table":return"table";case"aside":return"callout";case"details":return"accordion";case"div":return u.includes("code")?"code":u.includes("callout")?"callout":u.includes("divider")?"divider":u.includes("table")?"table":u.includes("link-preview")?"linkPreview":"paragraph";default:return"paragraph"}},J=(s,p)=>{var b,y,k,f;const u={type:p};switch(p){case"heading":const g=parseInt(s.tagName.charAt(1))||2;u.level=g,u.content=s.innerHTML;break;case"paragraph":u.content=s.innerHTML;break;case"bulletList":case"numberedList":case"checkList":const E=[];s.querySelectorAll(":scope > li").forEach(Q=>{var X;E.push({id:F(),content:Q.innerHTML,checked:(X=Q.querySelector('input[type="checkbox"]'))==null?void 0:X.hasAttribute("checked")})}),u.items=E;break;case"quote":u.content=s.innerHTML;break;case"code":const O=s.querySelector("code")||s;u.content=O.textContent||"",u.language=s.getAttribute("data-language")||"plaintext";break;case"image":const j=s.querySelector("img");u.src=(j==null?void 0:j.src)||"",u.alt=(j==null?void 0:j.alt)||"",u.caption=((b=s.querySelector("figcaption"))==null?void 0:b.textContent)||"";break;case"divider":u.style="solid";break;case"callout":u.calloutType=s.getAttribute("data-callout-type")||"info",u.content=((y=s.querySelector(".cb-callout-body"))==null?void 0:y.innerHTML)||s.innerHTML;break;case"accordion":u.title=((k=s.querySelector("summary"))==null?void 0:k.textContent)||"",u.content=((f=s.querySelector(".cb-accordion-content"))==null?void 0:f.innerHTML)||"",u.open=s.open;break;case"table":const K=[];s.querySelectorAll("tr").forEach(Q=>{const X=[];Q.querySelectorAll("th, td").forEach(G=>{X.push({content:G.innerHTML})}),K.push({cells:X})}),u.rows=K;break;case"linkPreview":u.url=s.getAttribute("data-url")||"";break}return u},P=h.useCallback(()=>{if(!N.current)return"";let s="";return N.current.querySelectorAll(".cb-block").forEach(p=>{const u=p.getAttribute("data-block-type"),b=p.querySelector(".cb-block-content");if(!b)return;const y=b.firstElementChild;if(!y)return;const k=y.cloneNode(!0);switch(k.removeAttribute("data-placeholder"),k.removeAttribute("contenteditable"),k.querySelectorAll("[data-placeholder]").forEach(f=>f.removeAttribute("data-placeholder")),k.querySelectorAll("[contenteditable]").forEach(f=>f.removeAttribute("contenteditable")),k.querySelectorAll(".cb-code-toolbar, .cb-image-controls, .cb-table-controls, .cb-callout-type-selector").forEach(f=>f.remove()),u){case"code":const f=k.querySelector("code"),g=k.querySelector("pre");if(f&&g){const E=k.getAttribute("data-language")||"plaintext";s+=`<pre data-language="${E}"><code>${f.textContent}</code></pre>
616
- `}else s+=k.outerHTML+`
617
- `;break;case"divider":s+=`<hr>
618
- `;break;default:s+=k.outerHTML+`
619
- `}}),s.trim()},[]),se=h.useCallback((s,p=!1)=>{if(!N.current)return;N.current.innerHTML="";const u=document.createElement("div");if(u.innerHTML=s,Array.from(u.children).forEach(b=>{var y;if(b instanceof HTMLElement){const k=Z(b),f=J(b,k),g=Y(k,f);(y=N.current)==null||y.appendChild(g)}}),N.current.children.length===0){const b=Y("paragraph");N.current.appendChild(b)}p&&setTimeout(()=>{var y;const b=(y=N.current)==null?void 0:y.querySelector('[contenteditable="true"]');b instanceof HTMLElement&&b.focus()},0)},[Y]),ge=h.useCallback(()=>{var s;return((s=N.current)==null?void 0:s.textContent)||""},[]),He=h.useCallback(()=>{var p;const s=(p=N.current)==null?void 0:p.querySelector('[contenteditable="true"]');s instanceof HTMLElement&&s.focus()},[]),qe=h.useCallback(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},[]),ce=h.useCallback(()=>{if(!N.current)return;const s=N.current.textContent||"";_(p=>({...p,wordCount:Xt(s),charCount:Zt(s)}))},[]),q=h.useCallback(Gt(()=>{C&&C(P())},300),[C,P]),I=h.useCallback(()=>{const s=P();te.current=[...te.current.slice(-49),s],ne.current=[],_(p=>({...p,undoStack:te.current,redoStack:[],isDirty:!0}))},[P]),je=h.useCallback(()=>{if(te.current.length===0)return;const s=P(),p=te.current[te.current.length-1];te.current=te.current.slice(0,-1),ne.current=[...ne.current,s],_(u=>({...u,undoStack:te.current,redoStack:ne.current})),se(p,!0)},[P,se]),Me=h.useCallback(()=>{if(ne.current.length===0)return;const s=P(),p=ne.current[ne.current.length-1];ne.current=ne.current.slice(0,-1),te.current=[...te.current,s],_(u=>({...u,redoStack:ne.current,undoStack:te.current})),se(p,!0)},[P,se]),pe=h.useCallback((s,p,u)=>{if(!N.current)return null;I();const b=Y(s,u);if(p){const y=N.current.querySelector(`[data-block-id="${p}"]`);y?y.after(b):N.current.appendChild(b)}else N.current.appendChild(b);return setTimeout(()=>{const k=b.querySelector('.cb-code[contenteditable="true"]')||b.querySelector('[contenteditable="true"]');k instanceof HTMLElement&&(k.focus(),be(k))},50),ce(),q(),b},[Y,I,ce,q]),Se=h.useCallback(s=>{var f;if(!N.current)return;const p=N.current.querySelectorAll(".cb-block");if(p.length<=1){const g=(f=p[0])==null?void 0:f.querySelector('[contenteditable="true"]');g instanceof HTMLElement&&(g.innerHTML="",g.focus());return}I();const u=N.current.querySelector(`[data-block-id="${s}"]`);if(!u)return;const b=u.previousElementSibling,y=u.nextElementSibling;u.remove();const k=y||b;if(k){const g=k.querySelector('[contenteditable="true"]');g instanceof HTMLElement&&(g.focus(),y||xe(g))}ce(),q()},[I,ce,q]),Te=h.useCallback((s,p)=>{if(!N.current)return;const u=N.current.querySelector(`[data-block-id="${s}"]`);u&&(I(),p==="up"&&u.previousElementSibling?u.previousElementSibling.before(u):p==="down"&&u.nextElementSibling&&u.nextElementSibling.after(u),ce(),q())},[I,ce,q]),me=h.useCallback((s,p,u)=>{if(!N.current)return;const b=N.current.querySelector(`[data-block-id="${s}"]`);if(!b||b.getAttribute("data-block-type")===p&&!u)return;I();const k=b.querySelector('[contenteditable="true"]'),g={content:(k==null?void 0:k.innerHTML)||"",...u},E=Y(p,g);b.replaceWith(E),setTimeout(()=>{const j=E.querySelector('.cb-code[contenteditable="true"]')||E.querySelector('[contenteditable="true"]');j instanceof HTMLElement&&(j.focus(),be(j))},50),ce(),q()},[Y,I,ce,q]),Ot=h.useRef(z);Ot.current=z;const Ue=h.useRef(ie);Ue.current=ie;const ue=h.useMemo(()=>!ke||!ee.current||!N.current?null:{container:N.current,config:e,get state(){return Ot.current},getHTML:P,setHTML:se,getText:ge,insertBlock:(s,p)=>pe(s,Ue.current||void 0,p),deleteBlock:s=>{const p=s.getAttribute("data-block-id");p&&Se(p)},moveBlock:(s,p)=>{const u=s.getAttribute("data-block-id");u&&Te(u,p)},transformBlock:(s,p,u)=>{const b=s.getAttribute("data-block-id");return b&&me(b,p,u),s},toggleFormat:s=>{switch(s){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break}q()},isFormatActive:s=>{switch(s){case"bold":return document.queryCommandState("bold");case"italic":return document.queryCommandState("italic");case"underline":return document.queryCommandState("underline");case"strikethrough":return document.queryCommandState("strikeThrough");default:return!1}},selectionVersion:H,undo:je,redo:Me,focus:He,blur:qe,destroy:()=>{},registerBlock:s=>de.register(s),registerCommand:()=>{},executeCommand:()=>{}},[ke,H,e,P,se,ge,pe,Se,Te,me,je,Me,He,qe,q]);h.useImperativeHandle(t,()=>({getHTML:P,setHTML:se,getText:ge,focus:He,blur:qe,insertBlock:(s,p)=>pe(s,Ue.current||void 0,p),getEditor:()=>ue}),[P,se,ge,He,qe,pe,ue]),h.useEffect(()=>{D&&ue&&D(ue)},[D,ue]);const Ft=h.useCallback(async s=>{var y;const p=s.target,u=(y=p.files)==null?void 0:y[0];if(!u)return;const b=p.closest("figure.cb-image");if(b){I();try{const k=await hn(u);Ke(b,k,u.name);let f=b.querySelector(".cb-image-controls");if(!f){f=document.createElement("div"),f.className="cb-image-controls",f.innerHTML=`
393
+ `;const v=document.createElement("div");v.className="cb-block-content";const E=Re.createBlock(l,{...p,id:b});return E&&(E.removeAttribute("data-block-id"),E.removeAttribute("data-block-type"),v.appendChild(E)),k.appendChild(C),k.appendChild(v),k.appendChild(h),k},[]);m.useEffect(()=>{if(!(!A.current||fe.current)){if(fe.current=!0,A.current.innerHTML="",n&&n.trim()){const l=document.createElement("div");l.innerHTML=n,Array.from(l.children).forEach(p=>{var b;if(p instanceof HTMLElement){const k=De(p),C=Pe(p,k),h=oe(k,C);(b=A.current)==null||b.appendChild(h)}})}if(A.current.children.length===0){const l=oe("paragraph");A.current.appendChild(l)}S(),setTimeout(()=>{ve.current&&ve.current()},100),!a&&A.current&&Hn({container:A.current,handleSelector:"[data-drag-handle]",getSelectedBlocks:()=>A.current?Array.from(A.current.querySelectorAll(".cb-block")).filter(p=>{const b=p.getAttribute("data-block-id");return b&&ae.current.has(b)}):[],onDragEnd:()=>{ve.current&&ve.current(),S(),R()}})}},[a]),m.useEffect(()=>{_&&A.current&&setTimeout(()=>{var p;const l=(p=A.current)==null?void 0:p.querySelector('[contenteditable="true"]');l instanceof HTMLElement&&l.focus()},100)},[_]);const De=l=>{const p=l.tagName.toLowerCase(),b=l.className||"";switch(p){case"h1":return"heading";case"h2":return"heading";case"h3":return"heading";case"h4":return"heading";case"h5":return"heading";case"h6":return"heading";case"ul":return b.includes("checklist")||l.querySelector('input[type="checkbox"]')?"checkList":"bulletList";case"ol":return"numberedList";case"blockquote":return"quote";case"pre":return"code";case"figure":return l.querySelector("img")?"image":l.querySelector("video, iframe")?"video":"paragraph";case"hr":return"divider";case"table":return"table";case"aside":return"callout";case"details":return"accordion";case"div":return b.includes("code")?"code":b.includes("callout")?"callout":b.includes("divider")?"divider":b.includes("table")?"table":b.includes("link-preview")?"linkPreview":"paragraph";default:return"paragraph"}},Pe=(l,p)=>{var k,C,h,v;const b={type:p};switch(p){case"heading":const E=parseInt(l.tagName.charAt(1))||2;b.level=E,b.content=l.innerHTML;break;case"paragraph":b.content=l.innerHTML;break;case"bulletList":case"numberedList":case"checkList":const M=[];l.querySelectorAll(":scope > li").forEach(W=>{var P;M.push({id:le(),content:W.innerHTML,checked:(P=W.querySelector('input[type="checkbox"]'))==null?void 0:P.hasAttribute("checked")})}),b.items=M;break;case"quote":b.content=l.innerHTML;break;case"code":const q=l.querySelector("code")||l;b.content=q.textContent||"",b.language=l.getAttribute("data-language")||"plaintext";break;case"image":const B=l.querySelector("img");b.src=(B==null?void 0:B.src)||"",b.alt=(B==null?void 0:B.alt)||"",b.caption=((k=l.querySelector("figcaption"))==null?void 0:k.textContent)||"";break;case"divider":b.style="solid";break;case"callout":b.calloutType=l.getAttribute("data-callout-type")||"info",b.content=((C=l.querySelector(".cb-callout-body"))==null?void 0:C.innerHTML)||l.innerHTML;break;case"accordion":b.title=((h=l.querySelector("summary"))==null?void 0:h.textContent)||"",b.content=((v=l.querySelector(".cb-accordion-content"))==null?void 0:v.innerHTML)||"",b.open=l.open;break;case"table":const U=[];l.querySelectorAll("tr").forEach(W=>{const P=[];W.querySelectorAll("th, td").forEach(f=>{P.push({content:f.innerHTML})}),U.push({cells:P})}),b.rows=U;break;case"linkPreview":b.url=l.getAttribute("data-url")||"";break}return b},Te=m.useCallback(()=>A.current?A.current.innerHTML:"",[]),Ye=m.useCallback(l=>{A.current&&(A.current.innerHTML=l)},[]),i=m.useCallback(()=>{if(!A.current)return"";let l="";return A.current.querySelectorAll(".cb-block").forEach(p=>{const b=p.getAttribute("data-block-type"),k=p.querySelector(".cb-block-content");if(!k)return;const C=k.firstElementChild;if(!C)return;const h=C.cloneNode(!0);switch(h.removeAttribute("data-placeholder"),h.removeAttribute("contenteditable"),h.querySelectorAll("[data-placeholder]").forEach(v=>v.removeAttribute("data-placeholder")),h.querySelectorAll("[contenteditable]").forEach(v=>v.removeAttribute("contenteditable")),h.querySelectorAll(".cb-code-toolbar, .cb-image-controls, .cb-table-controls, .cb-callout-type-selector").forEach(v=>v.remove()),b){case"code":const v=h.querySelector("code"),E=h.querySelector("pre");if(v&&E){const M=h.getAttribute("data-language")||"plaintext";l+=`<pre data-language="${M}"><code>${v.textContent}</code></pre>
394
+ `}else l+=h.outerHTML+`
395
+ `;break;case"divider":l+=`<hr>
396
+ `;break;default:l+=h.outerHTML+`
397
+ `}}),l.trim()},[]),g=m.useCallback((l,p=!1)=>{if(!A.current)return;A.current.innerHTML="";const b=document.createElement("div");if(b.innerHTML=l,Array.from(b.children).forEach(k=>{var C;if(k instanceof HTMLElement){const h=De(k),v=Pe(k,h),E=oe(h,v);(C=A.current)==null||C.appendChild(E)}}),A.current.children.length===0){const k=oe("paragraph");A.current.appendChild(k)}p&&setTimeout(()=>{var C;const k=(C=A.current)==null?void 0:C.querySelector('[contenteditable="true"]');k instanceof HTMLElement&&k.focus()},0)},[oe]),j=m.useCallback(()=>{var l;return((l=A.current)==null?void 0:l.textContent)||""},[]),I=m.useCallback(()=>{var p;const l=(p=A.current)==null?void 0:p.querySelector('[contenteditable="true"]');l instanceof HTMLElement&&l.focus()},[]),X=m.useCallback(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},[]),S=m.useCallback(()=>{if(!A.current)return;const l=A.current.textContent||"";N(p=>({...p,wordCount:on(l),charCount:cn(l)}))},[]),R=m.useCallback(yt(()=>{$&&$(i())},300),[$,i]),ee=m.useCallback(()=>{if(!A.current)return"";const l=window.getSelection();if(!l||!l.rangeCount)return"";if(J.size>0){let v="";return Array.from(A.current.querySelectorAll(".cb-block")).forEach(M=>{var f;const q=M.getAttribute("data-block-id");if(!q||!J.has(q))return;const B=M.getAttribute("data-block-type"),U=M.querySelector(".cb-block-content");if(!U)return;const W=U.firstElementChild;if(!W)return;const P=W.cloneNode(!0);switch(P.querySelectorAll(".cb-block-controls, .cb-block-actions, .cb-block-btn, .cb-block-add, .cb-block-drag, .cb-block-delete, .cb-image-controls, .cb-image-align, .cb-image-crop, .cb-image-resize-handle, .cb-crop-handle, .cb-crop-overlay, .cb-crop-toolbar, .cb-table-controls, .cb-code-toolbar, .cb-callout-type-selector, svg, button").forEach(y=>y.remove()),P.removeAttribute("data-placeholder"),P.removeAttribute("contenteditable"),P.removeAttribute("data-block-id"),P.removeAttribute("data-block-type"),P.querySelectorAll("[data-placeholder]").forEach(y=>y.removeAttribute("data-placeholder")),P.querySelectorAll("[contenteditable]").forEach(y=>y.removeAttribute("contenteditable")),P.querySelectorAll("[data-block-id]").forEach(y=>y.removeAttribute("data-block-id")),P.querySelectorAll("[data-block-type]").forEach(y=>y.removeAttribute("data-block-type")),P.querySelectorAll("[style]").forEach(y=>{const O=y;O.tagName.match(/^(IMG|VIDEO|IFRAME)$/i)||O.removeAttribute("style")}),B){case"code":const y=P.querySelector("code"),O=P.querySelector("pre");if(y&&O){const se=P.getAttribute("data-language")||"plaintext";v+=`<pre data-language="${se}"><code>${y.textContent}</code></pre>
398
+ `}else v+=P.outerHTML+`
399
+ `;break;case"divider":v+=`<hr>
400
+ `;break;case"image":const F=P.querySelector("img"),K=P.querySelector("figcaption");F&&(v+="<figure>",v+=`<img src="${F.src}" alt="${F.alt||""}" />`,K&&((f=K.textContent)!=null&&f.trim())&&(v+=`<figcaption>${K.textContent}</figcaption>`),v+=`</figure>
401
+ `);break;default:v+=P.outerHTML+`
402
+ `}}),v.trim()}const b=l.getRangeAt(0).cloneContents(),k=document.createElement("div");k.appendChild(b);const C=k.querySelectorAll(".cb-block");if(C.length===0){const v=k.cloneNode(!0);return v.querySelectorAll(".cb-block-controls, .cb-block-actions, .cb-block-btn, .cb-block-add, .cb-block-drag, .cb-block-delete, .cb-image-controls, .cb-image-align, .cb-image-crop, .cb-image-resize-handle, .cb-crop-handle, .cb-crop-overlay, .cb-crop-toolbar, .cb-table-controls, .cb-code-toolbar, .cb-callout-type-selector, svg, button").forEach(E=>E.remove()),v.querySelectorAll("[data-placeholder]").forEach(E=>E.removeAttribute("data-placeholder")),v.querySelectorAll("[contenteditable]").forEach(E=>E.removeAttribute("contenteditable")),v.querySelectorAll("[data-block-id]").forEach(E=>E.removeAttribute("data-block-id")),v.querySelectorAll("[data-block-type]").forEach(E=>E.removeAttribute("data-block-type")),v.innerHTML.trim()}let h="";return C.forEach(v=>{var U;const E=v.getAttribute("data-block-type"),M=v.querySelector(".cb-block-content");if(!M)return;const q=M.firstElementChild;if(!q)return;const B=q.cloneNode(!0);switch(B.querySelectorAll(".cb-block-controls, .cb-block-actions, .cb-block-btn, .cb-block-add, .cb-block-drag, .cb-block-delete, .cb-image-controls, .cb-image-align, .cb-image-crop, .cb-image-resize-handle, .cb-crop-handle, .cb-crop-overlay, .cb-crop-toolbar, .cb-table-controls, .cb-code-toolbar, .cb-callout-type-selector, svg, button").forEach(W=>W.remove()),B.removeAttribute("data-placeholder"),B.removeAttribute("contenteditable"),B.querySelectorAll("[data-placeholder]").forEach(W=>W.removeAttribute("data-placeholder")),B.querySelectorAll("[contenteditable]").forEach(W=>W.removeAttribute("contenteditable")),B.querySelectorAll("[style]").forEach(W=>{const P=W;P.tagName.match(/^(IMG|VIDEO|IFRAME)$/i)||P.removeAttribute("style")}),E){case"code":const W=B.querySelector("code"),P=B.querySelector("pre");if(W&&P){const O=B.getAttribute("data-language")||"plaintext";h+=`<pre data-language="${O}"><code>${W.textContent}</code></pre>
403
+ `}else h+=B.outerHTML+`
404
+ `;break;case"divider":h+=`<hr>
405
+ `;break;case"image":const f=B.querySelector("img"),y=B.querySelector("figcaption");f&&(h+="<figure>",h+=`<img src="${f.src}" alt="${f.alt||""}" />`,y&&((U=y.textContent)!=null&&U.trim())&&(h+=`<figcaption>${y.textContent}</figcaption>`),h+=`</figure>
406
+ `);break;default:h+=B.outerHTML+`
407
+ `}}),h.trim()},[J]),ce=m.useCallback(()=>{var k;const l=window.getSelection();if(!l||!l.rangeCount)return null;const p=l.getRangeAt(0);let b=p.startContainer;for(;b&&b!==A.current;){if(b instanceof HTMLElement&&((k=b.classList)!=null&&k.contains("cb-block"))){const C=b.getAttribute("data-block-id"),h=b.querySelector('[contenteditable="true"]');if(!h)return{blockId:C,offset:0,isCollapsed:l.isCollapsed};let v=0;try{const E=document.createRange();E.selectNodeContents(h),E.setEnd(p.startContainer,p.startOffset),v=E.toString().length}catch{v=0}return{blockId:C,offset:v,isCollapsed:l.isCollapsed}}b=b.parentNode}return null},[]),ge=m.useCallback(l=>{var k;if(!l||!l.blockId||!A.current)return;const p=A.current.querySelector(`[data-block-id="${l.blockId}"]`);if(!p){const C=A.current.querySelector('.cb-block [contenteditable="true"]');C&&C.focus();return}const b=p.querySelector('[contenteditable="true"]');if(b)try{const C=document.createRange(),h=window.getSelection();if(!h)return;const v=document.createTreeWalker(b,NodeFilter.SHOW_TEXT,null);let E=0,M=!1,q=v.nextNode();for(;q;){const B=((k=q.textContent)==null?void 0:k.length)||0;if(E+B>=l.offset){const U=l.offset-E;C.setStart(q,Math.min(U,B)),C.setEnd(q,Math.min(U,B)),M=!0;break}E+=B,q=v.nextNode()}M||(C.selectNodeContents(b),C.collapse(!1)),h.removeAllRanges(),h.addRange(C),b.focus()}catch{b.focus()}},[]),Q=m.useCallback(()=>{const l=Te(),p=ce(),b=ue.current[ue.current.length-1];if(b&&b.html===l)return;const k={html:l,cursorPosition:p,selectedBlockIds:Array.from(J)};ue.current=[...ue.current.slice(-49),k],G.current=[],N(C=>({...C,undoStack:ue.current,redoStack:[],isDirty:!0}))},[Te,ce,J]);ve.current=Q;const Me=m.useMemo(()=>yt(()=>{Q()},1e3),[Q]),Fe=m.useCallback(()=>{Me()},[Me]),Ve=m.useCallback(()=>{if(ue.current.length===0){console.log("🔙 Undo: No history available");return}console.log("🔙 Undo: Stack size =",ue.current.length),Me.cancel();const l=Te(),p=ce(),b={html:l,cursorPosition:p,selectedBlockIds:Array.from(J)},k=ue.current[ue.current.length-1];ue.current=ue.current.slice(0,-1),G.current=[...G.current,b].slice(-50),N(C=>({...C,undoStack:ue.current,redoStack:G.current})),Ye(k.html),requestAnimationFrame(()=>{ge(k.cursorPosition),k.selectedBlockIds&&k.selectedBlockIds.length>0?ke(new Set(k.selectedBlockIds)):ke(new Set)})},[Te,Ye,ce,ge,Me,J]),We=m.useCallback(()=>{if(G.current.length===0){console.log("🔜 Redo: No redo history available");return}console.log("🔜 Redo: Stack size =",G.current.length),Me.cancel();const l=Te(),p=ce(),b={html:l,cursorPosition:p,selectedBlockIds:Array.from(J)},k=G.current[G.current.length-1];G.current=G.current.slice(0,-1),ue.current=[...ue.current,b].slice(-50),N(C=>({...C,redoStack:G.current,undoStack:ue.current})),Ye(k.html),requestAnimationFrame(()=>{ge(k.cursorPosition),k.selectedBlockIds&&k.selectedBlockIds.length>0?ke(new Set(k.selectedBlockIds)):ke(new Set)})},[Te,Ye,ce,ge,Me,J]),$e=m.useCallback((l,p,b)=>{if(!A.current)return null;Q();const k=oe(l,b);if(p){const C=A.current.querySelector(`[data-block-id="${p}"]`);C?C.after(k):A.current.appendChild(k)}else A.current.appendChild(k);return setTimeout(()=>{const h=k.querySelector('.cb-code[contenteditable="true"]')||k.querySelector('[contenteditable="true"]');h instanceof HTMLElement&&(h.focus(),ze(h))},50),S(),R(),k},[oe,Q,S,R]),Xe=m.useCallback(l=>{var v;if(!A.current)return;const p=A.current.querySelectorAll(".cb-block");if(p.length<=1){const E=(v=p[0])==null?void 0:v.querySelector('[contenteditable="true"]');E instanceof HTMLElement&&(E.innerHTML="",E.focus());return}Q();const b=A.current.querySelector(`[data-block-id="${l}"]`);if(!b)return;const k=b.previousElementSibling,C=b.nextElementSibling;b.remove();const h=C||k;if(h){const E=h.querySelector('[contenteditable="true"]');E instanceof HTMLElement&&(E.focus(),C||Ie(E))}S(),R()},[Q,S,R]),Ge=m.useCallback((l,p)=>{if(!A.current)return;const b=A.current.querySelector(`[data-block-id="${l}"]`);b&&(Q(),p==="up"&&b.previousElementSibling?b.previousElementSibling.before(b):p==="down"&&b.nextElementSibling&&b.nextElementSibling.after(b),S(),R())},[Q,S,R]),je=m.useCallback((l,p,b)=>{if(!A.current)return;const k=A.current.querySelector(`[data-block-id="${l}"]`);if(!k||k.getAttribute("data-block-type")===p&&!b)return;Q();const h=k.querySelector('[contenteditable="true"]'),E={content:(h==null?void 0:h.innerHTML)||"",...b},M=oe(p,E);k.replaceWith(M),setTimeout(()=>{const B=M.querySelector('.cb-code[contenteditable="true"]')||M.querySelector('[contenteditable="true"]');B instanceof HTMLElement&&(B.focus(),Ie(B))},50),S(),R()},[oe,Q,S,R]),Vt=m.useRef(pe);Vt.current=pe;const gt=m.useRef(me);gt.current=me;const Be=m.useMemo(()=>!be||!te.current||!A.current?null:{container:A.current,config:e,get state(){return Vt.current},getHTML:i,setHTML:g,getText:j,insertBlock:(l,p)=>$e(l,gt.current||void 0,p),deleteBlock:l=>{const p=l.getAttribute("data-block-id");p&&Xe(p)},moveBlock:(l,p)=>{const b=l.getAttribute("data-block-id");b&&Ge(b,p)},transformBlock:(l,p,b)=>{const k=l.getAttribute("data-block-id");return k&&je(k,p,b),l},toggleFormat:l=>{switch(l){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break}R()},isFormatActive:l=>{switch(l){case"bold":return document.queryCommandState("bold");case"italic":return document.queryCommandState("italic");case"underline":return document.queryCommandState("underline");case"strikethrough":return document.queryCommandState("strikeThrough");default:return!1}},selectionVersion:xe,undo:Ve,redo:We,focus:I,blur:X,destroy:()=>{},registerBlock:l=>Re.register(l),registerCommand:()=>{},executeCommand:()=>{}},[be,xe,e,i,g,j,$e,Xe,Ge,je,Ve,We,I,X,R]);m.useImperativeHandle(t,()=>({getHTML:i,setHTML:g,getText:j,focus:I,blur:X,insertBlock:(l,p)=>$e(l,gt.current||void 0,p),getEditor:()=>Be}),[i,g,j,I,X,$e,Be]),m.useEffect(()=>{Z&&Be&&Z(Be)},[Z,Be]);const Jt=m.useCallback(async l=>{var C;const p=l.target,b=(C=p.files)==null?void 0:C[0];if(!b)return;const k=p.closest("figure.cb-image");if(k){Q();try{const h=await kn(b);xt(k,h,b.name);let v=k.querySelector(".cb-image-controls");if(!v){v=document.createElement("div"),v.className="cb-image-controls",v.innerHTML=`
620
408
  <button type="button" class="cb-image-align" data-align="left" title="Align left">
621
409
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
622
410
  <line x1="17" x2="3" y1="10" y2="10"/><line x1="21" x2="3" y1="6" y2="6"/><line x1="21" x2="3" y1="14" y2="14"/><line x1="17" x2="3" y1="18" y2="18"/>
@@ -638,7 +426,7 @@ ${B}
638
426
  <path d="M6 2v14a2 2 0 0 0 2 2h14"/><path d="M18 22V8a2 2 0 0 0-2-2H2"/>
639
427
  </svg>
640
428
  </button>
641
- `;const g=b.querySelector("figcaption");g?b.insertBefore(f,g):b.appendChild(f)}q()}catch(k){console.error("Failed to load image:",k)}}},[I,q]);h.useEffect(()=>{if(!N.current)return;const s=b=>{Ft(b)},p=b=>{const y=b.target.closest("[data-align]");if(!y)return;const k=y.getAttribute("data-align"),f=y.closest("figure.cb-image");f&&k&&(I(),pn(f,k),q())},u=N.current;u.addEventListener("change",b=>{b.target.matches(".cb-image-input")&&s(b)}),u.addEventListener("click",b=>{const y=b.target;if(y.closest(".cb-image-align")&&p(b),y.closest(".cb-image-crop")){if(b.preventDefault(),b.stopPropagation(),document.querySelector(".cb-crop-modal"))return;const k=y.closest("figure.cb-image"),f=k==null?void 0:k.querySelector("img");if(k&&f&&f.src){const g=hc(f.src,E=>{I(),f.src=E,q()});document.body.appendChild(g)}}if(y.classList.contains("cb-checkbox")){const k=y,f=k.closest(".cb-list-item");f&&(I(),f.classList.toggle("cb-checked",k.checked),q())}}),u.addEventListener("keydown",b=>{const y=b.target;if(y.classList.contains("cb-video-url-input")&&b.key==="Enter"){b.preventDefault();const f=y.value.trim();if(f){const g=y.closest("figure.cb-video");g&&(I(),gn(g,f),q())}}if(y.classList.contains("cb-image-url-input")&&b.key==="Enter"){b.preventDefault();const f=y.value.trim();if(f){const g=y.closest("figure.cb-image");if(g){I(),Ke(g,f);let E=g.querySelector(".cb-image-controls");if(!E){E=document.createElement("div"),E.className="cb-image-controls",E.innerHTML=`
429
+ `;const E=k.querySelector("figcaption");E?k.insertBefore(v,E):k.appendChild(v)}R()}catch(h){console.error("Failed to load image:",h)}}},[Q,R]),lo=m.useCallback((l,p,b)=>{if(!V.blockId||!A.current)return;const k=A.current.querySelector(`[data-block-id="${V.blockId}"]`);if(!k)return;const C=k.querySelector(".cb-excalidraw");if(!C)return;Q();const h=Re.get("excalidraw");h&&h.update(C,{imageDataUrl:l,elements:p,appState:b}),R(),ie({isOpen:!1,blockId:null,initialElements:[],initialAppState:{}})},[V.blockId,Q,R]),ao=m.useCallback(()=>{ie({isOpen:!1,blockId:null,initialElements:[],initialAppState:{}})},[]);m.useEffect(()=>{if(!A.current)return;const l=M=>{Jt(M)},p=M=>{const q=M.target.closest("[data-align]");if(!q)return;const B=q.getAttribute("data-align"),U=q.closest("figure.cb-image");U&&B&&(Q(),yn(U,B),R())},b=A.current,k=M=>{M.target.matches(".cb-image-input")&&l(M)},C=M=>{const q=M.target;if(q.tagName==="INPUT"||q.tagName==="TEXTAREA"){console.log("🎯 Click on input field, allowing default behavior:",q.className);return}if(q.closest(".cb-image-align")&&p(M),q.closest(".cb-image-crop")){if(M.preventDefault(),M.stopPropagation(),document.querySelector(".cb-crop-modal"))return;const B=q.closest("figure.cb-image"),U=B==null?void 0:B.querySelector("img");if(B&&U&&U.src){const W=sc(U.src,P=>{Q(),U.src=P,R()});document.body.appendChild(W)}}if(q.classList.contains("cb-checkbox")){const B=q,U=B.closest(".cb-list-item");U&&(Q(),U.classList.toggle("cb-checked",B.checked),R())}if(q.closest(".cb-excalidraw-placeholder")){M.preventDefault(),M.stopPropagation();const B=q.closest(".cb-block");if(B){const U=B.getAttribute("data-block-id");U&&ie({isOpen:!0,blockId:U,initialElements:[],initialAppState:{}})}}if(q.closest(".cb-excalidraw-edit-btn")){M.preventDefault(),M.stopPropagation();const B=q.closest(".cb-block");if(B){const U=B.getAttribute("data-block-id");if(U){const W=B.querySelector(".cb-excalidraw");if(!W)return;let P=[],f={};try{const y=W.getAttribute("data-excalidraw-elements");y&&(P=JSON.parse(y))}catch(y){console.warn("Failed to parse Excalidraw elements:",y),console.error("Excalidraw data may be corrupted. Please try creating a new drawing.")}try{const y=W.getAttribute("data-excalidraw-appstate");y&&(f=JSON.parse(y))}catch(y){console.warn("Failed to parse Excalidraw appState:",y)}ie({isOpen:!0,blockId:U,initialElements:P,initialAppState:f})}}}},h=M=>{const q=M.target,B=M;if(q.classList.contains("cb-video-url-input")&&B.key==="Enter"){B.preventDefault();const W=q.value.trim();if(W){const P=q.closest("figure.cb-video");P&&(Q(),wn(P,W),R())}}if(q.classList.contains("cb-image-url-input")&&B.key==="Enter"){B.preventDefault();const W=q.value.trim();if(W){const P=q.closest("figure.cb-image");if(P){Fe(),xt(P,W);let f=P.querySelector(".cb-image-controls");if(!f){f=document.createElement("div"),f.className="cb-image-controls",f.innerHTML=`
642
430
  <button type="button" class="cb-image-align" data-align="left" title="Align left">
643
431
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
644
432
  <line x1="17" x2="3" y1="10" y2="10"/><line x1="21" x2="3" y1="6" y2="6"/><line x1="21" x2="3" y1="14" y2="14"/><line x1="17" x2="3" y1="18" y2="18"/>
@@ -660,17 +448,21 @@ ${B}
660
448
  <path d="M6 2v14a2 2 0 0 0 2 2h14"/><path d="M18 22V8a2 2 0 0 0-2-2H2"/>
661
449
  </svg>
662
450
  </button>
663
- `;const O=g.querySelector("figcaption");O?g.insertBefore(E,O):g.appendChild(E)}q()}}}}),u.addEventListener("click",b=>{const y=b.target.closest(".cb-callout-type-selector button[data-type]");if(y){b.preventDefault(),b.stopPropagation();const k=y.getAttribute("data-type"),f=y.closest(".cb-callout");f&&k&&(I(),gt(f,k),q())}})},[Ft,I,q]),h.useEffect(()=>{if(!N.current||r)return;const s=N.current;let p=!1,u=0,b=0,y=null,k=null,f=null;const g=j=>{const K=j.target.closest(".cb-image-resize-handle");K&&(j.preventDefault(),j.stopPropagation(),k=K.closest(".cb-image-resizable"),y=k==null?void 0:k.querySelector("img"),f=K.getAttribute("data-handle"),!(!y||!k)&&(p=!0,u=j.clientX,b=y.offsetWidth,k.classList.add("resizing"),document.body.style.cursor=K.style.cursor||"se-resize",document.body.style.userSelect="none",I()))},E=j=>{if(!p||!y||!f)return;j.preventDefault();const K=j.clientX-u;let Q;f==="w"||f==="sw"||f==="nw"?Q=b-K:Q=b+K;const X=s.offsetWidth-100;Q=Math.max(50,Math.min(Q,X)),y.style.width=`${Q}px`,y.style.height="auto"},O=()=>{p&&(p=!1,k&&k.classList.remove("resizing"),document.body.style.cursor="",document.body.style.userSelect="",y=null,k=null,f=null,q())};return s.addEventListener("mousedown",g),document.addEventListener("mousemove",E),document.addEventListener("mouseup",O),()=>{s.removeEventListener("mousedown",g),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",O)}},[r,I,q]);const yo=h.useCallback(s=>{const u=s.target.closest("[data-action]");if(!u)return;const b=u.getAttribute("data-action"),y=u.closest(".cb-block"),k=y==null?void 0:y.getAttribute("data-block-id");if(!(!k&&!(b!=null&&b.startsWith("add"))&&!(b!=null&&b.startsWith("delete"))))switch(s.preventDefault(),s.stopPropagation(),b){case"add":if(k){I();const f=Y("paragraph");y.after(f);const g=f.querySelector('[contenteditable="true"]');g&&g.focus();const E=f.getAttribute("data-block-id");E&&(ae(E),setTimeout(()=>{const O=f.getBoundingClientRect();B({x:O.left,y:O.bottom+8}),he(!0)},50)),ce(),q()}break;case"delete":k&&Se(k);break;case"moveup":k&&Te(k,"up");break;case"movedown":k&&Te(k,"down");break;case"addRow":{const f=u.closest(".cb-table-wrapper");f&&(I(),Ge(f),q());break}case"addCol":{const f=u.closest(".cb-table-wrapper");f&&(I(),kn(f),q());break}case"deleteRow":{const f=u.closest(".cb-table-wrapper");if(f){const g=Je(f);if(g){const E=Qe(g);E&&(I(),Xe(f,E.row),q())}else{const E=f.querySelector("table"),O=E==null?void 0:E.querySelectorAll("tr");O&&O.length>1&&(I(),Xe(f,O.length-1),q())}}break}case"deleteCol":{const f=u.closest(".cb-table-wrapper");if(f){const g=Je(f);if(g){const E=Qe(g);E&&(I(),Ze(f,E.col),q())}else{const E=f.querySelector("table"),O=E==null?void 0:E.querySelector("tr"),j=O==null?void 0:O.querySelectorAll("th, td");j&&j.length>1&&(I(),Ze(f,j.length-1),q())}}break}}},[Se,Te,I,q]),ko=h.useCallback(s=>{var k,f;if(r||oe)return;const p=s.target,u=p.closest(".cb-block"),b=u==null?void 0:u.getAttribute("data-block-id"),y=u==null?void 0:u.getAttribute("data-block-type");if(s.ctrlKey||s.metaKey)switch(s.key.toLowerCase()){case"b":s.preventDefault(),document.execCommand("bold"),q();return;case"i":s.preventDefault(),document.execCommand("italic"),q();return;case"u":s.preventDefault(),document.execCommand("underline"),q();return;case"s":s.preventDefault(),M&&M(P());return;case"z":s.preventDefault(),s.shiftKey?Me():je();return;case"y":s.preventDefault(),Me();return;case"1":case"2":case"3":if(b){s.preventDefault(),I();const g=parseInt(s.key),E=p.innerHTML,O=u;O.setAttribute("data-block-type","heading");const j=O.querySelector(".cb-block-content");if(j){j.innerHTML=`<h${g} class="cb-heading cb-h${g}" contenteditable="true">${E}</h${g}>`;const K=j.querySelector("[contenteditable]");K&&(K.focus(),xe(K))}q()}return}if(s.key==="Tab"&&y==="code"){s.preventDefault();const g=window.getSelection(),E=g==null?void 0:g.getRangeAt(0);if(E){const j=document.createTextNode(" ");E.insertNode(j),E.setStartAfter(j),E.setEndAfter(j),g==null||g.removeAllRanges(),g==null||g.addRange(E),q()}return}if(s.key==="Tab"&&y==="table"){s.preventDefault();const g=p.closest("td, th");if(!g)return;const E=g.parentElement,O=E.closest("table");if(!E||!O)return;const j=Array.from(E.querySelectorAll("th, td")),K=j.indexOf(g),Q=Array.from(O.querySelectorAll("tr")),X=Q.indexOf(E);let G=null;if(s.shiftKey){if(K>0)G=j[K-1];else if(X>0){const V=Q[X-1].querySelectorAll("th, td");G=V[V.length-1]}}else if(K<j.length-1)G=j[K+1];else if(X<Q.length-1)G=Q[X+1].querySelectorAll("th, td")[0];else{const re=p.closest(".cb-table-wrapper");if(re){I(),Ge(re);const V=O.querySelector("tr:last-child"),Ee=V==null?void 0:V.querySelectorAll("td");G=Ee==null?void 0:Ee[0],q()}}if(G){G.focus();const re=document.createRange();re.selectNodeContents(G);const V=window.getSelection();V==null||V.removeAllRanges(),V==null||V.addRange(re)}return}if(s.key==="Enter"&&!s.shiftKey){if(y==="code")return;if(y==="bulletList"||y==="numberedList"||y==="checkList"){const g=p.closest("li");if(!g)return;const E=y==="checkList"?g.querySelector(".cb-checklist-content"):g;if((((k=E==null?void 0:E.textContent)==null?void 0:k.trim())||"")===""){s.preventDefault(),I();const G=g.closest("ul, ol");if((f=g.parentElement)==null?void 0:f.classList.contains("cb-nested-list")){const V=g.parentElement,Ee=V.parentElement,Ut=Ee.parentElement;if(Ut){Ut.insertBefore(g,Ee.nextSibling),V.children.length===0&&V.remove();const Vt=y==="checkList"?g.querySelector(".cb-checklist-content"):g;Vt&&Vt.focus()}}else{const V=G==null?void 0:G.querySelectorAll(":scope > li");V&&V.length===1?b&&me(b,"paragraph"):(g.remove(),pe("paragraph",b||void 0))}q();return}s.preventDefault(),I();const j=window.getSelection(),K=j==null?void 0:j.getRangeAt(0);let Q="";if(K&&E){const G=document.createRange();G.setStart(K.endContainer,K.endOffset),G.setEndAfter(E.lastChild||E);const re=G.extractContents(),V=document.createElement("div");V.appendChild(re),Q=V.innerHTML}const X=document.createElement("li");if(X.className="cb-list-item",X.setAttribute("data-item-id",F()),y==="checkList"){const G=document.createElement("div");G.className="cb-checklist-wrapper";const re=document.createElement("input");re.type="checkbox",re.className="cb-checkbox",re.setAttribute("tabindex","-1");const V=document.createElement("span");V.className="cb-checklist-content",V.setAttribute("contenteditable","true"),V.innerHTML=Q,G.appendChild(re),G.appendChild(V),X.appendChild(G),g.after(X),V.focus(),be(V)}else X.setAttribute("contenteditable","true"),X.innerHTML=Q,g.after(X),X.focus(),be(X);q();return}s.preventDefault(),I(),pe("paragraph",b||void 0);return}if(s.key==="Backspace"&&De(p)){if(y&&y!=="paragraph"&&y!=="divider"){s.preventDefault(),b&&me(b,"paragraph");return}const g=u==null?void 0:u.previousElementSibling;if(g&&g.classList.contains("cb-block")){const E=g.getAttribute("data-block-type");if(E!=="divider"&&E!=="image"&&E!=="video"){s.preventDefault(),I();const O=g.querySelector('[contenteditable="true"]'),j=p.innerHTML;O&&j&&(O.innerHTML+=j),O&&(xe(O),O.focus()),b&&Se(b)}}return}if(s.key==="/"&&De(p)&&p.textContent===""){s.preventDefault();const g=u.getBoundingClientRect();B({x:g.left,y:g.bottom+8}),he(!0),b&&ae(b);return}if(s.key==="ArrowUp"&&De(p)){const g=u==null?void 0:u.previousElementSibling;if(g&&g.classList.contains("cb-block")){s.preventDefault();const E=g.querySelector('[contenteditable="true"]');E&&(E.focus(),xe(E))}return}if(s.key==="ArrowDown"&&Mn(p)){const g=u==null?void 0:u.nextElementSibling;if(g&&g.classList.contains("cb-block")){s.preventDefault();const E=g.querySelector('[contenteditable="true"]');E&&(E.focus(),be(E))}return}},[r,I,pe,Se,me,je,Me,M,P,q]),vo=h.useCallback(()=>{ce(),q()},[ce,q]),xo=h.useCallback(s=>{if(r)return;s.preventDefault(),I();const p=Sn(s.clipboardData);document.execCommand("insertHTML",!1,p),ce(),q()},[r,I,ce,q]),wo=h.useCallback(s=>{const p=s.target.closest(".cb-block"),u=p==null?void 0:p.getAttribute("data-block-id");ae(u),$&&$()},[$]),Co=h.useCallback(s=>{var p;(p=ee.current)!=null&&p.contains(s.relatedTarget)||(ae(null),U&&U())},[U]),So=h.useCallback((s,p)=>{var u,b;if(he(!1),ie){const y=(u=N.current)==null?void 0:u.querySelector(`[data-block-id="${ie}"]`),k=y==null?void 0:y.querySelector('[contenteditable="true"]');k&&((b=k.textContent)==null?void 0:b.trim())===""?s==="heading"&&(p!=null&&p.level)?me(ie,s,p):me(ie,s):pe(s,ie,p)}else pe(s,void 0,p)},[ie,me,pe]),Eo=h.useCallback(s=>{const p=s.target.closest(".cb-block"),u=p==null?void 0:p.getAttribute("data-block-id");v(u)},[]),Lo=h.useCallback(()=>{v(null)},[]),Ao=[`${i}-editor`,m?`${i}-dark`:`${i}-light`,r?`${i}-readonly`:"",a].filter(Boolean).join(" ");return l.jsxs("div",{ref:ee,className:Ao,style:d,"data-editor-root":!0,children:[w&&x==="top"&&ue&&l.jsx(nt,{editor:ue,darkMode:m}),l.jsx("div",{ref:N,className:`${i}-content`,onClick:yo,onKeyDown:ko,onInput:vo,onPaste:xo,onFocus:wo,onBlur:Co,onMouseOver:Eo,onMouseOut:Lo,"data-placeholder":c,spellCheck:A,role:"textbox","aria-multiline":"true","aria-label":"Content editor"}),w&&x==="bottom"&&ue&&l.jsx(nt,{editor:ue,darkMode:m}),oe&&ue&&l.jsx(ho,{editor:ue,position:S,onSelect:So,onClose:()=>he(!1)}),l.jsx(go,{wordCount:z.wordCount,charCount:z.charCount,readingTime:bo(z.wordCount),darkMode:m})]})},Mr=h.forwardRef(Ar);function Tr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Nr(e,t){if(!e)return"";const o=new DOMParser().parseFromString(e,"text/html");return t.enableHeadingIds&&o.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((r,i)=>{r.id||(r.id=`heading-${i}`)}),t.enableCodeCopy&&o.querySelectorAll("pre").forEach((r,i)=>{var x;if((x=r.parentElement)!=null&&x.classList.contains("cbr-code-wrapper"))return;const a=r.querySelector("code"),d=(a==null?void 0:a.textContent)||r.textContent||"",w=o.createElement("div");w.className="cbr-code-wrapper",w.innerHTML=`
451
+ `;const y=P.querySelector("figcaption");y?P.insertBefore(f,y):P.appendChild(f)}R()}}}},v=M=>{var U,W;const q=M.target,B=M;console.log("🎯 DOM handleInputPaste triggered:",{tagName:q.tagName,className:q.className,hasClipboardData:!!B.clipboardData,clipboardText:(W=(U=B.clipboardData)==null?void 0:U.getData("text/plain"))==null?void 0:W.substring(0,50)})},E=M=>{const q=M.target.closest(".cb-callout-type-selector button[data-type]");if(q){M.preventDefault(),M.stopPropagation();const B=q.getAttribute("data-type"),U=q.closest(".cb-callout");U&&B&&(Fe(),Ot(U,B),R())}};return b.addEventListener("change",k),b.addEventListener("click",C),b.addEventListener("keydown",h),b.addEventListener("click",E),b.addEventListener("paste",v,!0),()=>{b&&(b.removeEventListener("change",k),b.removeEventListener("click",C),b.removeEventListener("keydown",h),b.removeEventListener("click",E),b.removeEventListener("paste",v,!0))}},[Jt,Fe,Q,R,ie]),m.useEffect(()=>{if(!A.current||a)return;const l=A.current;let p=!1,b=0,k=0,C=null,h=null,v=null,E=null;const M=U=>{const W=U.target.closest(".cb-image-resize-handle");W&&(U.preventDefault(),U.stopPropagation(),h=W.closest(".cb-image-resizable"),C=h==null?void 0:h.querySelector("img"),v=W.getAttribute("data-handle"),!(!C||!h)&&(p=!0,b=U.clientX,k=C.offsetWidth,h.classList.add("resizing"),document.body.style.cursor=W.style.cursor||"se-resize",document.body.style.userSelect="none",Fe()))},q=U=>{!p||!C||!v||(U.preventDefault(),E===null&&(E=requestAnimationFrame(()=>{if(E=null,!C||!p)return;const W=U.clientX-b;let P;v==="w"||v==="sw"||v==="nw"?P=k-W:P=k+W;const f=l.offsetWidth-100;P=Math.max(50,Math.min(P,f)),C.style.width=`${P}px`,C.style.height="auto"})))},B=()=>{p&&(p=!1,E!==null&&(cancelAnimationFrame(E),E=null),h&&h.classList.remove("resizing"),document.body.style.cursor="",document.body.style.userSelect="",C=null,h=null,v=null,R())};return l.addEventListener("mousedown",M),document.addEventListener("mousemove",q),document.addEventListener("mouseup",B),()=>{l&&l.removeEventListener("mousedown",M),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",B)}},[a,Q,R]);const io=m.useCallback(l=>{const p=l.target;if(p.closest(".cb-block-drag")){console.log("🖱️ Drag handle clicked, shiftKey:",l.shiftKey);const v=p.closest(".cb-block"),E=v==null?void 0:v.getAttribute("data-block-id");if(!E)return;if(console.log("📦 Block ID:",E),l.shiftKey)l.preventDefault(),l.stopPropagation(),console.log("✅ Shift+Click detected, toggling selection"),ke(M=>{const q=new Set(M);return q.has(E)?(q.delete(E),console.log("➖ Removed from selection, new size:",q.size)):(q.add(E),console.log("➕ Added to selection, new size:",q.size)),ae.current=q,q});else if(J.size>0){console.log("🧹 Clearing selection");const M=new Set;ae.current=M,ke(M)}return}const k=p.closest(".cb-block");if(!k)return;const C=k.getAttribute("data-block-type"),h=k.getAttribute("data-block-id");if(C==="divider"||C==="image"||C==="video"){if(p.closest("button, input, .cb-image-controls, .cb-table-controls"))return;if(console.log("🎯 Clicked on non-editable block:",C),l.shiftKey&&h)l.preventDefault(),ke(v=>{const E=new Set(v);return E.has(h)?E.delete(h):E.add(h),ae.current=E,E});else if(h){const v=new Set([h]);ae.current=v,ke(v),Ne(h)}}else if(J.size>0&&!l.shiftKey){console.log("🧹 Clearing selection");const v=new Set;ae.current=v,ke(v)}},[J]),so=m.useCallback(l=>{const b=l.target.closest("[data-action]");if(!b)return;const k=b.getAttribute("data-action"),C=b.closest(".cb-block"),h=C==null?void 0:C.getAttribute("data-block-id");if(!(!h&&!(k!=null&&k.startsWith("add"))&&!(k!=null&&k.startsWith("delete"))))switch(l.preventDefault(),l.stopPropagation(),k){case"add":if(h){Q();const v=oe("paragraph");C.after(v);const E=v.querySelector('[contenteditable="true"]');E&&E.focus();const M=v.getAttribute("data-block-id");M&&(Ne(M),setTimeout(()=>{const q=v.getBoundingClientRect();Ce({x:q.left,y:q.bottom+8}),Y(!0)},50)),S(),R()}break;case"delete":h&&Xe(h);break;case"moveup":h&&Ge(h,"up");break;case"movedown":h&&Ge(h,"down");break;case"addRow":{const v=b.closest(".cb-table-wrapper");v&&(Q(),Ct(v),R());break}case"addCol":{const v=b.closest(".cb-table-wrapper");v&&(Q(),Tn(v),R());break}case"deleteRow":{const v=b.closest(".cb-table-wrapper");if(v){const E=At(v);if(E){const M=Nt(E);M&&(Q(),St(v,M.row),R())}else{const M=v.querySelector("table"),q=M==null?void 0:M.querySelectorAll("tr");q&&q.length>1&&(Q(),St(v,q.length-1),R())}}break}case"deleteCol":{const v=b.closest(".cb-table-wrapper");if(v){const E=At(v);if(E){const M=Nt(E);M&&(Q(),Et(v,M.col),R())}else{const M=v.querySelector("table"),q=M==null?void 0:M.querySelector("tr"),B=q==null?void 0:q.querySelectorAll("th, td");B&&B.length>1&&(Q(),Et(v,B.length-1),R())}}break}}},[Xe,Ge,Q,R]),uo=m.useCallback(l=>{var v,E,M,q,B,U,W,P;if(a||He)return;if(J.size>0){if(l.key==="Backspace"||l.key==="Delete"){l.preventDefault(),console.log("🗑️ Deleting",J.size,"selected blocks"),Q();const y=Array.from(((v=A.current)==null?void 0:v.querySelectorAll(".cb-block"))||[]).find(F=>J.has(F.getAttribute("data-block-id")||""));J.forEach(F=>{var se;const K=(se=A.current)==null?void 0:se.querySelector(`[data-block-id="${F}"]`);K==null||K.remove()});const O=new Set;if(ae.current=O,ke(O),A.current&&A.current.children.length===0){const F=oe("paragraph");A.current.appendChild(F),setTimeout(()=>{const K=F.querySelector('[contenteditable="true"]');K==null||K.focus()},0)}else if(y){const F=(E=y.parentElement)==null?void 0:E.querySelector(".cb-block");F&&setTimeout(()=>{const K=F.querySelector('[contenteditable="true"]');K==null||K.focus()},0)}S(),R();return}if((l.ctrlKey||l.metaKey)&&l.key.toLowerCase()==="d"){l.preventDefault(),console.log("📋 Duplicating",J.size,"selected blocks"),Q(),Array.from(((M=A.current)==null?void 0:M.querySelectorAll(".cb-block"))||[]).filter(F=>J.has(F.getAttribute("data-block-id")||"")).forEach(F=>{const K=F.cloneNode(!0);K.setAttribute("data-block-id",le()),F.after(K)});const O=new Set;ae.current=O,ke(O),S(),R();return}}const p=l.target,b=p.closest(".cb-block"),k=b==null?void 0:b.getAttribute("data-block-id"),C=b==null?void 0:b.getAttribute("data-block-type");if(l.ctrlKey||l.metaKey)switch(l.key.toLowerCase()){case"b":l.preventDefault(),document.execCommand("bold"),R();return;case"i":l.preventDefault(),document.execCommand("italic"),R();return;case"u":l.preventDefault(),document.execCommand("underline"),R();return;case"a":l.preventDefault();const f=window.getSelection();if(!f)return;const y=p.closest('[contenteditable="true"]');if(!y)return;const O=f.rangeCount>0?f.getRangeAt(0):null,F=O&&O.startContainer===y&&O.endContainer===y&&O.toString().trim()===((q=y.textContent)==null?void 0:q.trim()),K=f.toString(),se=y.textContent||"",Se=K.trim()===se.trim()&&K.length>0;if(F||Se){if(A.current){const ne=document.createRange();ne.selectNodeContents(A.current),f.removeAllRanges(),f.addRange(ne)}}else{const ne=document.createRange();ne.selectNodeContents(y),f.removeAllRanges(),f.addRange(ne)}return;case"s":l.preventDefault(),x&&x(i());return;case"z":l.preventDefault(),l.shiftKey?We():Ve();return;case"y":l.preventDefault(),We();return;case"1":case"2":case"3":if(k){l.preventDefault(),Q();const ne=parseInt(l.key),Le=p.innerHTML,de=b;de.setAttribute("data-block-type","heading");const qe=de.querySelector(".cb-block-content");if(qe){qe.innerHTML=`<h${ne} class="cb-heading cb-h${ne}" contenteditable="true">${Le}</h${ne}>`;const Je=qe.querySelector("[contenteditable]");Je&&(Je.focus(),Ie(Je))}R()}return}const h=window.getSelection();if(h&&h.rangeCount>0){const f=h.getRangeAt(0);let y=f.startContainer,O=null;for(;y&&y!==A.current;){if(y instanceof HTMLElement&&y.tagName==="CODE"){O=y;break}y=y.parentNode}if(O&&h.isCollapsed&&f.startOffset===(((B=f.startContainer.textContent)==null?void 0:B.length)||0)&&f.startContainer===O.lastChild&&(l.key==="ArrowRight"||l.key===" ")){l.preventDefault();let K=O.nextSibling;if(!K||K.nodeType!==Node.TEXT_NODE){const Se=document.createTextNode(l.key===" "?" ":"​");(U=O.parentNode)==null||U.insertBefore(Se,O.nextSibling),K=Se}else l.key===" "&&K.nodeType===Node.TEXT_NODE&&(K.textContent=" "+(K.textContent||""));const se=document.createRange();l.key===" "?(se.setStart(K,1),se.setEnd(K,1)):(se.setStartAfter(O),se.setEndAfter(O)),h.removeAllRanges(),h.addRange(se),l.key===" "&&R();return}}if(l.key==="Tab"&&(C==="bulletList"||C==="numberedList"||C==="checkList")){l.preventDefault();const f=p.closest("li");if(!f)return;if(Q(),l.shiftKey){const y=f.parentElement;if(y==null?void 0:y.classList.contains("cb-nested-list")){const F=y.parentElement,K=F==null?void 0:F.parentElement;if(K){K.insertBefore(f,F.nextSibling),y.children.length===0&&y.remove();const se=C==="checkList"?f.querySelector(".cb-checklist-content"):f;se&&setTimeout(()=>{se.focus(),Ie(se)},0)}}}else{const y=f.previousElementSibling;if(y&&y.tagName==="LI"){let O=y.querySelector(":scope > ul, :scope > ol");if(!O){const K=C==="numberedList"?"ol":"ul";O=document.createElement(K),O.className="cb-list cb-nested-list",y.appendChild(O)}O.appendChild(f);const F=C==="checkList"?f.querySelector(".cb-checklist-content"):f;F&&setTimeout(()=>{F.focus(),Ie(F)},0)}}R();return}if(l.key==="Tab"&&C==="code"){l.preventDefault();const f=window.getSelection(),y=f==null?void 0:f.getRangeAt(0);if(y){const F=document.createTextNode(" ");y.insertNode(F),y.setStartAfter(F),y.setEndAfter(F),f==null||f.removeAllRanges(),f==null||f.addRange(y),R()}return}if(l.key==="Tab"&&C==="table"){l.preventDefault();const f=p.closest("td, th");if(!f)return;const y=f.parentElement,O=y.closest("table");if(!y||!O)return;const F=Array.from(y.querySelectorAll("th, td")),K=F.indexOf(f),se=Array.from(O.querySelectorAll("tr")),Se=se.indexOf(y);let ne=null;if(l.shiftKey){if(K>0)ne=F[K-1];else if(Se>0){const de=se[Se-1].querySelectorAll("th, td");ne=de[de.length-1]}}else if(K<F.length-1)ne=F[K+1];else if(Se<se.length-1)ne=se[Se+1].querySelectorAll("th, td")[0];else{const Le=p.closest(".cb-table-wrapper");if(Le){Fe(),Ct(Le);const de=O.querySelector("tr:last-child"),qe=de==null?void 0:de.querySelectorAll("td");ne=qe==null?void 0:qe[0],R()}}if(ne){ne.focus();const Le=document.createRange();Le.selectNodeContents(ne);const de=window.getSelection();de==null||de.removeAllRanges(),de==null||de.addRange(Le)}return}if(l.key==="Enter"&&l.shiftKey&&(C==="bulletList"||C==="numberedList"||C==="checkList")){l.preventDefault();const f=p.closest("li");if(!f)return;Q();let y=f.querySelector(":scope > ul, :scope > ol");if(!y){const F=C==="numberedList"?"ol":"ul";y=document.createElement(F),y.className="cb-list cb-nested-list",f.appendChild(y)}const O=document.createElement("li");if(O.className="cb-list-item",O.setAttribute("data-item-id",le()),C==="checkList"){const F=document.createElement("div");F.className="cb-checklist-wrapper";const K=document.createElement("input");K.type="checkbox",K.className="cb-checkbox",K.setAttribute("tabindex","-1");const se=document.createElement("span");se.className="cb-checklist-content",se.setAttribute("contenteditable","true"),F.appendChild(K),F.appendChild(se),O.appendChild(F),y.appendChild(O),se.focus(),ze(se)}else O.setAttribute("contenteditable","true"),y.appendChild(O),O.focus(),ze(O);R();return}if(l.key==="Enter"&&!l.shiftKey){if(C==="code")return;if(C==="bulletList"||C==="numberedList"||C==="checkList"){const f=p.closest("li");if(!f)return;const y=C==="checkList"?f.querySelector(".cb-checklist-content"):f;if((((W=y==null?void 0:y.textContent)==null?void 0:W.trim())||"")===""){l.preventDefault(),Q();const ne=f.closest("ul, ol");if((P=f.parentElement)==null?void 0:P.classList.contains("cb-nested-list")){const de=f.parentElement,qe=de.parentElement,Je=qe.parentElement;if(Je){Je.insertBefore(f,qe.nextSibling),de.children.length===0&&de.remove();const Gt=C==="checkList"?f.querySelector(".cb-checklist-content"):f;Gt&&Gt.focus()}}else{const de=ne==null?void 0:ne.querySelectorAll(":scope > li");de&&de.length===1?k&&je(k,"paragraph"):(f.remove(),$e("paragraph",k||void 0))}R();return}l.preventDefault(),Q();const F=window.getSelection(),K=F==null?void 0:F.getRangeAt(0);let se="";if(K&&y){const ne=document.createRange();ne.setStart(K.endContainer,K.endOffset),ne.setEndAfter(y.lastChild||y);const Le=ne.extractContents(),de=document.createElement("div");de.appendChild(Le),se=de.innerHTML}const Se=document.createElement("li");if(Se.className="cb-list-item",Se.setAttribute("data-item-id",le()),C==="checkList"){const ne=document.createElement("div");ne.className="cb-checklist-wrapper";const Le=document.createElement("input");Le.type="checkbox",Le.className="cb-checkbox",Le.setAttribute("tabindex","-1");const de=document.createElement("span");de.className="cb-checklist-content",de.setAttribute("contenteditable","true"),de.innerHTML=se,ne.appendChild(Le),ne.appendChild(de),Se.appendChild(ne),f.after(Se),de.focus(),ze(de)}else Se.setAttribute("contenteditable","true"),Se.innerHTML=se,f.after(Se),Se.focus(),ze(Se);R();return}l.preventDefault(),Fe(),$e("paragraph",k||void 0);return}if(l.key==="Backspace"&&nt(p)){if(C&&C!=="paragraph"&&C!=="divider"){l.preventDefault(),k&&je(k,"paragraph");return}const f=b==null?void 0:b.previousElementSibling;if(f&&f.classList.contains("cb-block")){const y=f.getAttribute("data-block-type");if(y!=="divider"&&y!=="image"&&y!=="video"){l.preventDefault(),Q();const O=f.querySelector('[contenteditable="true"]'),F=p.innerHTML;O&&F&&(O.innerHTML+=F),O&&(Ie(O),O.focus()),k&&Xe(k)}}return}if(l.key==="Backspace"||l.key==="Delete"){const f=window.getSelection();if(!f||!A.current)return;const y=f.rangeCount>0?f.getRangeAt(0):null;if(y&&y.startContainer===A.current&&y.endContainer===A.current&&y.startOffset===0&&y.endOffset===A.current.childNodes.length){l.preventDefault(),Q(),A.current.innerHTML="";const O=oe("paragraph");A.current.appendChild(O),setTimeout(()=>{const F=O.querySelector('[contenteditable="true"]');F&&F.focus()},0),S(),R();return}}if(l.key==="/"&&nt(p)&&p.textContent===""){l.preventDefault();const f=b.getBoundingClientRect();Ce({x:f.left,y:f.bottom+8}),Y(!0),k&&Ne(k);return}if(l.key==="ArrowUp"&&nt(p)){const f=b==null?void 0:b.previousElementSibling;if(f&&f.classList.contains("cb-block")){l.preventDefault();const y=f.querySelector('[contenteditable="true"]');y&&(y.focus(),Ie(y))}return}if(l.key==="ArrowDown"&&In(p)){const f=b==null?void 0:b.nextElementSibling;if(f&&f.classList.contains("cb-block")){l.preventDefault();const y=f.querySelector('[contenteditable="true"]');y&&(y.focus(),ze(y))}return}},[a,He,J,Q,oe,S,R,$e,Xe,je,Ve,We,x,i]),bo=m.useCallback(l=>{if(!l||l.getAttribute("contenteditable")!=="true")return;const p=window.getSelection();if(!p||!p.rangeCount)return;const b=p.getRangeAt(0),k=b.startContainer,C=b.startOffset;let h=0,v=-1;const E=f=>{var y,O;if(f===k)return v=h+C,!0;if(f.nodeType===Node.TEXT_NODE)h+=((y=f.textContent)==null?void 0:y.length)||0;else if(f.nodeType===Node.ELEMENT_NODE){if(f instanceof HTMLElement&&f.classList.contains("cb-hashtag"))return h+=((O=f.textContent)==null?void 0:O.length)||0,!1;for(let F=0;F<f.childNodes.length;F++)if(E(f.childNodes[F]))return!0}return!1};E(l);const M=f=>{if(f.nodeType===Node.TEXT_NODE)return f.textContent||"";if(f.nodeType===Node.ELEMENT_NODE){const y=f;if(y.tagName==="CODE"||y.tagName==="A"||y.classList.contains("cb-hashtag"))return y.textContent||"";let O="";for(let F=0;F<f.childNodes.length;F++)O+=M(f.childNodes[F]);return O}return""},q=M(l),B=/#[\w\d_]+(?=\s|[.,!?;:]|$)/g,U=Array.from(q.matchAll(B));if(U.length===0){l.querySelectorAll(".cb-hashtag").forEach(y=>{var F;const O=document.createTextNode(y.textContent||"");(F=y.parentNode)==null||F.replaceChild(O,y)});return}const W=[];let P=0;if(U.forEach(f=>{const y=f[0],O=f.index;O>P&&W.push(q.substring(P,O));const F=document.createElement("span");F.className="cb-hashtag",F.textContent=y,W.push(F),P=O+y.length}),P<q.length&&W.push(q.substring(P)),l.innerHTML="",W.forEach(f=>{typeof f=="string"?l.appendChild(document.createTextNode(f)):l.appendChild(f)}),v>=0)try{let f=0,y=null,O=0;const F=K=>{var se,Se;if(K.nodeType===Node.TEXT_NODE){const ne=((se=K.textContent)==null?void 0:se.length)||0;if(f+ne>=v)return y=K,O=v-f,!0;f+=ne}else if(K.nodeType===Node.ELEMENT_NODE){if(K instanceof HTMLElement&&K.classList.contains("cb-hashtag")){const ne=((Se=K.textContent)==null?void 0:Se.length)||0;return f+ne>=v?(y=K.nextSibling||K.parentNode,O=0,!0):(f+=ne,!1)}for(let ne=0;ne<K.childNodes.length;ne++)if(F(K.childNodes[ne]))return!0}return!1};if(F(l)&&y){const K=document.createRange();K.setStart(y,O),K.collapse(!0),p.removeAllRanges(),p.addRange(K)}}catch(f){console.warn("Failed to restore cursor:",f)}},[]),po=m.useCallback(l=>{if((l==null?void 0:l.target)instanceof HTMLElement){const p=l.target,b=p.closest(".cb-block"),k=b==null?void 0:b.getAttribute("data-block-type"),C=b==null?void 0:b.getAttribute("data-block-id");if(k==="paragraph"&&C){const h=p.textContent||"";if(h.startsWith("- ")||h.startsWith("* ")){const E=(h.startsWith("- "),h.slice(2));p.textContent="",je(C,"bulletList",{content:E});return}const v=h.match(/^(\d+)\.\s(.*)$/);if(v){const E=v[2]||"";p.textContent="",je(C,"numberedList",{content:E});return}if(h.startsWith("[] ")){const E=h.slice(3);p.textContent="",je(C,"checkList",{content:E});return}if(h.startsWith("> ")){const E=h.slice(2);p.textContent="",je(C,"quote",{content:E});return}if(h.startsWith("# ")&&!h.startsWith("## ")){const E=h.slice(2);p.textContent="",je(C,"heading",{level:1,content:E});return}if(h.startsWith("## ")&&!h.startsWith("### ")){const E=h.slice(3);p.textContent="",je(C,"heading",{level:2,content:E});return}if(h.startsWith("### ")){const E=h.slice(4);p.textContent="",je(C,"heading",{level:3,content:E});return}}if((l==null?void 0:l.target)instanceof HTMLElement){const h=l.target;bo(h)}}S(),R(),Fe()},[S,R,Fe,je]),mo=m.useCallback(l=>{var p;if(!a){if(l.key==="Escape"&&J.size>0){l.preventDefault(),l.stopPropagation(),console.log("🧹 Escape pressed - clearing selection");const b=new Set;ae.current=b,ke(b);return}if(l.ctrlKey||l.metaKey){if(l.shiftKey&&l.key.toLowerCase()==="a"){l.preventDefault(),l.stopPropagation();const b=(p=A.current)==null?void 0:p.querySelectorAll(".cb-block");if(b&&b.length>0){const k=Array.from(b).map(h=>h.getAttribute("data-block-id")).filter(h=>h!==null),C=new Set(k);ae.current=C,ke(C),console.log("📦 Selected all",k.length,"blocks"),te.current&&te.current.focus()}return}if(l.key.toLowerCase()==="z"){l.preventDefault(),l.stopPropagation(),l.shiftKey?We():Ve();return}if(l.key.toLowerCase()==="y"){l.preventDefault(),l.stopPropagation(),We();return}}}},[a,Ve,We,J]),go=m.useCallback(l=>{if(!te.current)return;const p=l.target,b=p.closest('[contenteditable="true"]'),k=p.closest(".cb-block"),C=p.closest(".cb-block-drag"),h=p.tagName==="INPUT"||p.tagName==="TEXTAREA";if(!l.shiftKey&&!k&&!C&&J.size>0){console.log("🧹 Clearing selection - clicked outside blocks");const v=new Set;ae.current=v,ke(v)}!b&&!h&&te.current.focus()},[J]),fo=m.useCallback(l=>{var h,v;if(J.size>0){l.preventDefault(),console.log("📋 Copying",J.size,"selected blocks");const E=ee(),B=Array.from(((h=A.current)==null?void 0:h.querySelectorAll(".cb-block"))||[]).filter(U=>J.has(U.getAttribute("data-block-id")||"")).map(U=>U.textContent||"").join(`
452
+
453
+ `);l.clipboardData.setData("text/html",E),l.clipboardData.setData("text/plain",B);return}const p=window.getSelection();if(!p||!p.rangeCount||p.isCollapsed)return;const b=p.getRangeAt(0);if(!((v=A.current)!=null&&v.contains(b.commonAncestorContainer)))return;l.preventDefault();const k=ee(),C=p.toString();l.clipboardData.setData("text/html",k),l.clipboardData.setData("text/plain",C)},[J,ee]),ho=m.useCallback(l=>{var h,v;if(J.size>0){l.preventDefault(),console.log("✂️ Cutting",J.size,"selected blocks");const E=ee(),B=Array.from(((h=A.current)==null?void 0:h.querySelectorAll(".cb-block"))||[]).filter(W=>J.has(W.getAttribute("data-block-id")||"")).map(W=>W.textContent||"").join(`
454
+
455
+ `);l.clipboardData.setData("text/html",E),l.clipboardData.setData("text/plain",B),Q(),J.forEach(W=>{var f;const P=(f=A.current)==null?void 0:f.querySelector(`[data-block-id="${W}"]`);P==null||P.remove()});const U=new Set;if(ae.current=U,ke(U),A.current&&A.current.children.length===0){const W=oe("paragraph");A.current.appendChild(W),setTimeout(()=>{const P=W.querySelector('[contenteditable="true"]');P==null||P.focus()},0)}S(),R();return}const p=window.getSelection();if(!p||!p.rangeCount||p.isCollapsed)return;const b=p.getRangeAt(0);if(!((v=A.current)!=null&&v.contains(b.commonAncestorContainer)))return;l.preventDefault();const k=ee(),C=p.toString();l.clipboardData.setData("text/html",k),l.clipboardData.setData("text/plain",C),Q(),document.execCommand("delete"),S(),R()},[J,ee,Fe,Q,S,R,oe]),vo=m.useCallback(l=>{var v,E;if(a)return;const p=l.target;if(console.log("🔍 PASTE EVENT DEBUG:",{tagName:p.tagName,className:p.className,isInput:p.tagName==="INPUT",isTextarea:p.tagName==="TEXTAREA"}),p.tagName==="INPUT"||p.tagName==="TEXTAREA"){console.log("✅ Allowing paste in input field:",p.className);return}console.log("🚫 Preventing default paste (not an input field)"),l.preventDefault(),Q();const b=l.clipboardData.getData("text/html"),k=l.clipboardData.getData("text/plain");if(!b&&!k)return;console.log("📥 Pasting content, HTML length:",b.length,"blocks selected:",J.size);const C=document.createElement("div");C.innerHTML=b||k.replace(/\n/g,"<br>");const h=C.querySelectorAll("h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, pre, hr, table, figure, details, aside, div.cb-callout, div.cb-code");if(h.length>0){console.log("📦 Pasting",h.length,"blocks");const M=(v=document.activeElement)==null?void 0:v.closest(".cb-block");let B=(M==null?void 0:M.getAttribute("data-block-id"))||void 0;if(h.forEach(U=>{if(!(U instanceof HTMLElement))return;const W=De(U),P=Pe(U,W),f=$e(W,B,P);f&&(B=f.getAttribute("data-block-id")||void 0)}),M){const U=M.querySelector('[contenteditable="true"]');if(U&&((E=U.textContent)==null?void 0:E.trim())===""){const W=M.getAttribute("data-block-id");W&&Xe(W)}}J.size>0&&(console.log("🧹 Clearing multi-block selection after paste"),ke(new Set))}else{const M=Rn(l.clipboardData);document.execCommand("insertHTML",!1,M)}S(),R()},[a,J,Q,$e,Xe,De,Pe,S,R]),yo=m.useCallback(l=>{const p=l.target.closest(".cb-block"),b=p==null?void 0:p.getAttribute("data-block-id");Ne(b),z&&z()},[z]),ko=m.useCallback(l=>{var p;(p=te.current)!=null&&p.contains(l.relatedTarget)||(Ne(null),re&&re())},[re]),xo=m.useCallback((l,p,b)=>{var k,C,h;if(Y(!1),b){if(l==="date"){const v=window.getSelection();if(!v||!v.rangeCount)return;const E=v.getRangeAt(0),M=new Date,q=U=>{const W=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],P=["January","February","March","April","May","June","July","August","September","October","November","December"],f=W[U.getDay()],y=U.getDate(),O=P[U.getMonth()],F=U.getFullYear();return`${f}, ${y} ${O} ${F}`},B=document.createElement("span");if(B.className="cb-date-inline",B.setAttribute("data-date",M.toISOString()),B.setAttribute("contenteditable","false"),B.textContent=q(M),me){const U=(k=A.current)==null?void 0:k.querySelector(`[data-block-id="${me}"]`),W=U==null?void 0:U.querySelector('[contenteditable="true"]');if(W){W.focus();const P=window.getSelection();if(P&&P.rangeCount>0){const f=P.getRangeAt(0);f.deleteContents(),f.insertNode(B);const y=document.createTextNode(" ");f.setStartAfter(B),f.insertNode(y),f.setStartAfter(y),f.setEndAfter(y),P.removeAllRanges(),P.addRange(f)}}}else E.deleteContents(),E.insertNode(B),E.setStartAfter(B),E.setEndAfter(B),v.removeAllRanges(),v.addRange(E)}return}if(me){const v=(C=A.current)==null?void 0:C.querySelector(`[data-block-id="${me}"]`),E=v==null?void 0:v.querySelector('[contenteditable="true"]');E&&((h=E.textContent)==null?void 0:h.trim())===""?l==="heading"&&(p!=null&&p.level)?je(me,l,p):je(me,l):$e(l,me,p)}else $e(l,void 0,p)},[me,je,$e]),wo=m.useCallback(l=>{const p=l.target.closest(".cb-block"),b=p==null?void 0:p.getAttribute("data-block-id");Ae(b)},[]),Co=m.useCallback(()=>{Ae(null)},[]);m.useEffect(()=>()=>{Me.cancel()},[Me]);const So=[`${s}-editor`,L?`${s}-dark`:`${s}-light`,a?`${s}-readonly`:"",d].filter(Boolean).join(" ");return c.jsxs("div",{ref:te,className:So,style:w,"data-editor-root":!0,tabIndex:0,onKeyDown:mo,onClick:go,children:[H&&D==="top"&&Be&&c.jsx(Lt,{editor:Be,darkMode:L}),c.jsx("div",{ref:A,className:`${s}-content`,onClick:l=>{io(l),so(l)},onKeyDown:uo,onInput:po,onCopy:fo,onCut:ho,onPaste:vo,onFocus:yo,onBlur:ko,onMouseOver:wo,onMouseOut:Co,"data-placeholder":r,spellCheck:T,role:"textbox","aria-multiline":"true","aria-label":"Content editor"}),H&&D==="bottom"&&Be&&c.jsx(Lt,{editor:Be,darkMode:L}),He&&Be&&c.jsx(to,{editor:Be,position:he,onSelect:xo,onClose:()=>Y(!1)}),c.jsx(oo,{wordCount:pe.wordCount,charCount:pe.charCount,readingTime:no(pe.wordCount),selectedBlockCount:J.size,darkMode:L}),Be&&c.jsx(_c,{editor:Be,darkMode:L}),c.jsx(Jc,{isOpen:V.isOpen,onClose:ao,onSave:lo,initialElements:V.initialElements,initialAppState:V.initialAppState,darkMode:L})]})},Qc=m.forwardRef(Gc);function Zc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function er(e,t){if(!e)return"";const o=new DOMParser().parseFromString(e,"text/html");return t.enableHeadingIds&&o.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((a,s)=>{a.id||(a.id=`heading-${s}`)}),t.enableCodeCopy&&o.querySelectorAll("pre").forEach((a,s)=>{var D;if((D=a.parentElement)!=null&&D.classList.contains("cbr-code-wrapper"))return;const d=a.querySelector("code"),w=(d==null?void 0:d.textContent)||a.textContent||"",H=o.createElement("div");H.className="cbr-code-wrapper",H.innerHTML=`
664
456
  <div class="cbr-code-toolbar">
665
457
  <span class="cbr-code-lang">Code</span>
666
- <button class="cbr-code-copy" data-code-index="${i}" onclick="
458
+ <button class="cbr-code-copy" data-code-index="${s}" onclick="
667
459
  navigator.clipboard.writeText(this.closest('.cbr-code-wrapper').querySelector('code').textContent);
668
460
  this.textContent = 'Copied!';
669
461
  setTimeout(() => this.textContent = 'Copy', 2000);
670
462
  ">Copy</button>
671
463
  </div>
672
- <pre class="cbr-code-block"><code>${Tr(d)}</code></pre>
673
- `,r.replaceWith(w)}),t.enableChecklistStyles&&o.querySelectorAll("li").forEach(r=>{const i=r.querySelector('input[type="checkbox"]');i&&i.checked&&r.classList.add("cbr-checked-item")}),o.querySelectorAll(".cb-image-controls, .cb-image-placeholder, .cb-video-placeholder, .cb-callout-type-selector, .cb-image-resize-handle").forEach(c=>c.remove()),o.body.innerHTML}function Br(e,t){const n=t,o=e?{bgSecondary:"#111827",bgTertiary:"#374151",text:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af",border:"#374151",borderLight:"#4b5563",primary:"#3b82f6",link:"#60a5fa",code:"#f472b6",codeBg:"rgba(255, 255, 255, 0.1)",quoteBg:"rgba(59, 130, 246, 0.1)",calloutInfo:"rgba(59, 130, 246, 0.1)",calloutInfoBorder:"rgba(59, 130, 246, 0.3)",calloutSuccess:"rgba(16, 185, 129, 0.1)",calloutSuccessBorder:"rgba(16, 185, 129, 0.3)",calloutWarning:"rgba(245, 158, 11, 0.1)",calloutWarningBorder:"rgba(245, 158, 11, 0.3)",calloutError:"rgba(239, 68, 68, 0.1)",calloutErrorBorder:"rgba(239, 68, 68, 0.3)",tableBg:"#374151"}:{bgSecondary:"#f9fafb",bgTertiary:"#f3f4f6",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",border:"#e5e7eb",borderLight:"#d1d5db",primary:"#3b82f6",link:"#2563eb",code:"#d63384",codeBg:"#f3f4f6",quoteBg:"#eff6ff",calloutInfo:"#eff6ff",calloutInfoBorder:"#bfdbfe",calloutSuccess:"#f0fdf4",calloutSuccessBorder:"#bbf7d0",calloutWarning:"#fffbeb",calloutWarningBorder:"#fde68a",calloutError:"#fef2f2",calloutErrorBorder:"#fecaca",tableBg:"#f9fafb"};return`
464
+ <pre class="cbr-code-block"><code>${Zc(w)}</code></pre>
465
+ `,a.replaceWith(H)}),t.enableChecklistStyles&&o.querySelectorAll("li").forEach(a=>{const s=a.querySelector('input[type="checkbox"]');s&&s.checked&&a.classList.add("cbr-checked-item")}),o.querySelectorAll(".cb-image-controls, .cb-image-placeholder, .cb-video-placeholder, .cb-callout-type-selector, .cb-image-resize-handle").forEach(r=>r.remove()),o.body.innerHTML}function tr(e,t){const n=t,o=e?{bgSecondary:"#111827",bgTertiary:"#374151",text:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af",border:"#374151",borderLight:"#4b5563",primary:"#3b82f6",link:"#60a5fa",code:"#f472b6",codeBg:"rgba(255, 255, 255, 0.1)",quoteBg:"rgba(59, 130, 246, 0.1)",calloutInfo:"rgba(59, 130, 246, 0.1)",calloutInfoBorder:"rgba(59, 130, 246, 0.3)",calloutSuccess:"rgba(16, 185, 129, 0.1)",calloutSuccessBorder:"rgba(16, 185, 129, 0.3)",calloutWarning:"rgba(245, 158, 11, 0.1)",calloutWarningBorder:"rgba(245, 158, 11, 0.3)",calloutError:"rgba(239, 68, 68, 0.1)",calloutErrorBorder:"rgba(239, 68, 68, 0.3)",tableBg:"#374151"}:{bgSecondary:"#f9fafb",bgTertiary:"#f3f4f6",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",border:"#e5e7eb",borderLight:"#d1d5db",primary:"#3b82f6",link:"#2563eb",code:"#d63384",codeBg:"#f3f4f6",quoteBg:"#eff6ff",calloutInfo:"#eff6ff",calloutInfoBorder:"#bfdbfe",calloutSuccess:"#f0fdf4",calloutSuccessBorder:"#bbf7d0",calloutWarning:"#fffbeb",calloutWarningBorder:"#fde68a",calloutError:"#fef2f2",calloutErrorBorder:"#fecaca",tableBg:"#f9fafb"};return`
674
466
  .${n} {
675
467
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
676
468
  line-height: 1.7;
@@ -874,7 +666,7 @@ ${B}
874
666
  .${n} [style*="text-align: right"], .${n} [data-align="right"] { text-align: right; }
875
667
  .${n} [style*="text-align: left"], .${n} [data-align="left"] { text-align: left; }
876
668
  .${n} [style*="text-align: justify"], .${n} [data-align="justify"] { text-align: justify; }
877
- `}const $r=({html:e,darkMode:t=!1,className:n="",style:o,enableCodeCopy:c=!0,enableChecklistStyles:r=!0,enableHeadingIds:i=!0,classPrefix:a="cbr-content"})=>{const d=h.useMemo(()=>Nr(e,{enableCodeCopy:c,enableChecklistStyles:r,enableHeadingIds:i}),[e,c,r,i]),w=h.useMemo(()=>Br(t,a),[t,a]);return e?l.jsxs("div",{className:`${a} ${n}`.trim(),style:o,children:[l.jsx("style",{children:w}),l.jsx("div",{dangerouslySetInnerHTML:{__html:d}})]}):l.jsxs("div",{className:`${a} ${n}`.trim(),style:o,children:[l.jsx("style",{children:w}),l.jsx("p",{style:{color:t?"#64748b":"#9ca3af"},children:"No content to display"})]})};function mo(e,t,n){if(!e)return[];const c=new DOMParser().parseFromString(e,"text/html"),r=[];for(let w=t;w<=n;w++)r.push(`h${w}`);const i=c.querySelectorAll(r.join(", ")),a=[],d=[];return i.forEach((w,x)=>{var M;const m=parseInt(w.tagName.charAt(1)),T=((M=w.textContent)==null?void 0:M.trim())||"";if(!T)return;const C={id:w.id||`heading-${x}`,text:T,level:m,children:[]};for(;d.length>0&&d[d.length-1].level>=m;)d.pop();d.length===0?a.push(C):d[d.length-1].item.children.push(C),d.push({level:m,item:C})}),a}function Hr(e){const t=e?{bgHover:"#334155",text:"#94a3b8",textHover:"#f1f5f9",border:"#334155",title:"#64748b"}:{bgHover:"#f1f5f9",text:"#64748b",textHover:"#0f172a",border:"#e2e8f0",title:"#94a3b8"};return`
669
+ `}const nr=({html:e,darkMode:t=!1,className:n="",style:o,enableCodeCopy:r=!0,enableChecklistStyles:a=!0,enableHeadingIds:s=!0,classPrefix:d="cbr-content"})=>{const w=m.useMemo(()=>er(e,{enableCodeCopy:r,enableChecklistStyles:a,enableHeadingIds:s}),[e,r,a,s]),H=m.useMemo(()=>tr(t,d),[t,d]);return e?c.jsxs("div",{className:`${d} ${n}`.trim(),style:o,children:[c.jsx("style",{children:H}),c.jsx("div",{dangerouslySetInnerHTML:{__html:w}})]}):c.jsxs("div",{className:`${d} ${n}`.trim(),style:o,children:[c.jsx("style",{children:H}),c.jsx("p",{style:{color:t?"#64748b":"#9ca3af"},children:"No content to display"})]})};function co(e,t,n){if(!e)return[];const r=new DOMParser().parseFromString(e,"text/html"),a=[];for(let H=t;H<=n;H++)a.push(`h${H}`);const s=r.querySelectorAll(a.join(", ")),d=[],w=[];return s.forEach((H,D)=>{var x;const L=parseInt(H.tagName.charAt(1)),_=((x=H.textContent)==null?void 0:x.trim())||"";if(!_)return;const $={id:H.id||`heading-${D}`,text:_,level:L,children:[]};for(;w.length>0&&w[w.length-1].level>=L;)w.pop();w.length===0?d.push($):w[w.length-1].item.children.push($),w.push({level:L,item:$})}),d}function or(e){const t=e?{bgHover:"#334155",text:"#94a3b8",textHover:"#f1f5f9",border:"#334155",title:"#64748b"}:{bgHover:"#f1f5f9",text:"#64748b",textHover:"#0f172a",border:"#e2e8f0",title:"#94a3b8"};return`
878
670
  .cbtoc {
879
671
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
880
672
  }
@@ -956,5 +748,5 @@ ${B}
956
748
  .cbtoc-content-expanded {
957
749
  max-height: 2000px;
958
750
  }
959
- `}const ot=({items:e,depth:t,onNavigate:n})=>e.length===0?null:l.jsx("ul",{className:`cbtoc-list ${t>0?"cbtoc-list-nested":""}`,children:e.map(o=>l.jsxs("li",{className:"cbtoc-item",children:[l.jsx("button",{className:`cbtoc-link cbtoc-link-h${o.level}`,onClick:()=>n(o.id,o),title:o.text,children:o.text}),o.children.length>0&&l.jsx(ot,{items:o.children,depth:t+1,onNavigate:n})]},o.id))}),qr=({html:e,darkMode:t=!1,className:n="",style:o,title:c="Table of Contents",minLevel:r=1,maxLevel:i=6,onNavigate:a,smoothScroll:d=!0,targetContainer:w=null,collapsible:x=!1,defaultCollapsed:m=!1})=>{const[T,A]=h.useState(m),C=h.useMemo(()=>mo(e,r,i),[e,r,i]),M=h.useMemo(()=>Hr(t),[t]),$=h.useCallback((D,ee)=>{if(a){a(D,ee);return}let N=null;if(w){const le=typeof w=="string"?document.querySelector(w):w;N=le==null?void 0:le.querySelector(`#${D}`)}else N=document.getElementById(D);N&&N.scrollIntoView({behavior:d?"smooth":"auto",block:"start"})},[a,d,w]),U=h.useCallback(()=>{A(D=>!D)},[]);return C.length===0?l.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[l.jsx("style",{children:M}),c&&l.jsx("h3",{className:"cbtoc-title",children:c}),l.jsx("p",{className:"cbtoc-empty",children:"No headings found"})]}):x?l.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[l.jsx("style",{children:M}),l.jsxs("button",{className:"cbtoc-toggle",onClick:U,children:[l.jsx("span",{className:"cbtoc-title",style:{margin:0},children:c}),l.jsx("svg",{className:`cbtoc-toggle-icon ${T?"cbtoc-toggle-icon-collapsed":""}`,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),l.jsx("div",{className:`cbtoc-content ${T?"cbtoc-content-collapsed":"cbtoc-content-expanded"}`,children:l.jsx("div",{style:{padding:"0.5rem"},children:l.jsx(ot,{items:C,depth:0,onNavigate:$})})})]}):l.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[l.jsx("style",{children:M}),c&&l.jsx("h3",{className:"cbtoc-title",children:c}),l.jsx(ot,{items:C,depth:0,onNavigate:$})]})},jr=({children:e,blockId:t,blockType:n,isActive:o=!1,onAddBlock:c,onDeleteBlock:r,onDuplicateBlock:i,onMoveUp:a,onMoveDown:d,onDragStart:w,className:x=""})=>{const[m,T]=h.useState(!1),A=h.useCallback(M=>{M.preventDefault(),M.stopPropagation(),T(!m)},[m]),C=h.useCallback(M=>$=>{$.preventDefault(),$.stopPropagation(),T(!1),M&&M()},[]);return l.jsxs("div",{className:`cb-block-wrapper ${o?"cb-block-wrapper-active":""} ${x}`,"data-block-wrapper":t,children:[l.jsxs("div",{className:"cb-block-controls cb-block-controls-left",children:[l.jsx("button",{type:"button",className:"cb-block-btn cb-block-add",onClick:C(()=>c==null?void 0:c("before")),title:"Add block above",tabIndex:-1,children:l.jsx(Kn,{size:14})}),l.jsx("button",{type:"button",className:"cb-block-btn cb-block-drag","data-drag-handle":!0,draggable:!0,onDragStart:w,title:"Drag to reorder",tabIndex:-1,children:l.jsx(On,{size:14})})]}),l.jsx("div",{className:"cb-block-content",children:e}),l.jsx("div",{className:"cb-block-controls cb-block-controls-right",children:l.jsxs("div",{className:"cb-block-menu-container",children:[l.jsx("button",{type:"button",className:"cb-block-btn cb-block-more",onClick:A,title:"More options",tabIndex:-1,children:l.jsx(Vn,{size:14})}),m&&l.jsxs("div",{className:"cb-block-dropdown",children:[l.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:C(i),children:[l.jsx(Dn,{size:14}),l.jsx("span",{children:"Duplicate"})]}),l.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:C(a),children:[l.jsx(_n,{size:14}),l.jsx("span",{children:"Move up"})]}),l.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:C(d),children:[l.jsx(Wn,{size:14}),l.jsx("span",{children:"Move down"})]}),l.jsx("div",{className:"cb-block-dropdown-divider"}),l.jsxs("button",{type:"button",className:"cb-block-dropdown-item cb-block-dropdown-item-danger",onClick:C(r),children:[l.jsx(Tt,{size:14}),l.jsx("span",{children:"Delete"})]})]})]})})]})},Rr=({metadata:e={},onChange:t,className:n=""})=>{const[o,c]=h.useState(e),[r,i]=h.useState("");h.useEffect(()=>{c(e)},[e]);const a=h.useCallback((x,m)=>{const T={...o,[x]:m};c(T),t&&t(T)},[o,t]),d=h.useCallback(x=>{if(x.key==="Enter"&&r.trim()){x.preventDefault();const m=o.tags||[],T=r.trim().toLowerCase();if(!m.includes(T)){const A={...o,tags:[...m,T]};c(A),t&&t(A)}i("")}},[o,r,t]),w=h.useCallback(x=>{const m={...o,tags:(o.tags||[]).filter(T=>T!==x)};c(m),t&&t(m)},[o,t]);return l.jsxs("div",{className:`cb-metadata-panel ${n}`,children:[l.jsxs("div",{className:"cb-metadata-header",children:[l.jsx(Le,{size:20}),l.jsx("h3",{children:"Post Metadata"})]}),l.jsxs("div",{className:"cb-metadata-content",children:[l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-title",className:"cb-metadata-label",children:[l.jsx(Le,{size:16}),l.jsx("span",{children:"Title"})]}),l.jsx("input",{id:"meta-title",type:"text",className:"cb-metadata-input",placeholder:"Enter post title...",value:o.title||"",onChange:x=>a("title",x.target.value)}),l.jsxs("span",{className:"cb-metadata-hint",children:[(o.title||"").length,"/60 characters"]})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-description",className:"cb-metadata-label",children:[l.jsx(Le,{size:16}),l.jsx("span",{children:"Description"})]}),l.jsx("textarea",{id:"meta-description",className:"cb-metadata-textarea",placeholder:"Brief description for SEO and social media...",rows:3,value:o.description||"",onChange:x=>a("description",x.target.value)}),l.jsxs("span",{className:"cb-metadata-hint",children:[(o.description||"").length,"/160 characters"]})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-slug",className:"cb-metadata-label",children:[l.jsx($e,{size:16}),l.jsx("span",{children:"URL Slug"})]}),l.jsx("input",{id:"meta-slug",type:"text",className:"cb-metadata-input",placeholder:"url-friendly-slug",value:o.slug||"",onChange:x=>a("slug",x.target.value)}),l.jsx("span",{className:"cb-metadata-hint",children:"Used in the post URL"})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-tags",className:"cb-metadata-label",children:[l.jsx(vr,{size:16}),l.jsx("span",{children:"Tags"})]}),o.tags&&o.tags.length>0&&l.jsx("div",{className:"cb-metadata-tags",children:o.tags.map(x=>l.jsxs("span",{className:"cb-metadata-tag",children:[x,l.jsx("button",{type:"button",onClick:()=>w(x),className:"cb-metadata-tag-remove","aria-label":`Remove ${x}`,children:l.jsx(Ae,{size:14})})]},x))}),l.jsx("input",{id:"meta-tags",type:"text",className:"cb-metadata-input",placeholder:"Type a tag and press Enter...",value:r,onChange:x=>i(x.target.value),onKeyDown:d})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-cover",className:"cb-metadata-label",children:[l.jsx(Oe,{size:16}),l.jsx("span",{children:"Cover Image URL"})]}),l.jsx("input",{id:"meta-cover",type:"url",className:"cb-metadata-input",placeholder:"https://example.com/image.jpg",value:o.coverImage||"",onChange:x=>a("coverImage",x.target.value)}),o.coverImage&&l.jsx("div",{className:"cb-metadata-preview",children:l.jsx("img",{src:o.coverImage,alt:"Cover preview",onError:x=>{x.target.style.display="none"}})})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-author",className:"cb-metadata-label",children:[l.jsx(Le,{size:16}),l.jsx("span",{children:"Author"})]}),l.jsx("input",{id:"meta-author",type:"text",className:"cb-metadata-input",placeholder:"Author name",value:o.author||"",onChange:x=>a("author",x.target.value)})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-date",className:"cb-metadata-label",children:[l.jsx(Rn,{size:16}),l.jsx("span",{children:"Publish Date"})]}),l.jsx("input",{id:"meta-date",type:"datetime-local",className:"cb-metadata-input",value:o.publishDate||"",onChange:x=>a("publishDate",x.target.value)})]}),l.jsxs("div",{className:"cb-metadata-field",children:[l.jsxs("label",{htmlFor:"meta-canonical",className:"cb-metadata-label",children:[l.jsx($e,{size:16}),l.jsx("span",{children:"Canonical URL"})]}),l.jsx("input",{id:"meta-canonical",type:"url",className:"cb-metadata-input",placeholder:"https://example.com/original-post",value:o.canonicalUrl||"",onChange:x=>a("canonicalUrl",x.target.value)}),l.jsx("span",{className:"cb-metadata-hint",children:"For cross-posted or syndicated content"})]})]})]})},fo={paragraph:Fe,heading1:xt,heading2:wt,heading3:Ct,heading4:cr,heading5:rr,heading6:lr,list:Et,listOrdered:St,checkList:kt,quote:At,code:vt,image:Oe,video:Nt,divider:Lt,callout:yt,accordion:tt,table:Mt,bold:jn,italic:Un,underline:Zn,strikethrough:Xn,link:$e,unlink:sr,highlight:Fn,textColor:Yn,alignLeft:Hn,alignCenter:$n,alignRight:qn,alignJustify:Gc,undo:Jn,redo:Gn,copy:Dn,cut:mr,paste:Qc,delete:Tt,plus:Kn,drag:On,more:Vn,chevronUp:Jc,chevronDown:tt,moveUp:_n,moveDown:Wn,maximize:dr,close:Ae,check:Zc,search:fr,settings:yr,sun:kr,moon:ur,document:Le,codeFile:Pn,download:In,upload:xr,externalLink:nr,info:ar,warning:Kc,error:wr,success:Xc,file:or,indent:ir,outdent:pr,clear:br,columns:tr,rows:gr,eraser:zn};function Dr(e){return fo[e]||Fe}exports.BlockMenu=ho;exports.BlockRegistry=on;exports.BlockWrapper=jr;exports.ContentBlocksEditor=Mr;exports.ContentBlocksRenderer=$r;exports.EventEmitter=tc;exports.LANGUAGES=dn;exports.MetadataPanel=Rr;exports.StatusBar=go;exports.TableOfContents=qr;exports.Toolbar=nt;exports.accordionBlock=fn;exports.addCalloutTitle=gc;exports.addCitation=ac;exports.addListItem=oc;exports.addTableColumn=kn;exports.addTableRow=Ge;exports.allBlocks=ft;exports.blockMap=xn;exports.blockRegistry=de;exports.bulletListBlock=st;exports.calculateReadingTime=bo;exports.calloutBlock=mn;exports.cancelFrame=Qo;exports.checkListBlock=sn;exports.clearFormatting=Pt;exports.codeBlock=pt;exports.collapseToEnd=Uc;exports.collapseToStart=Fc;exports.convertPlainTextToHtml=En;exports.countCharacters=Zt;exports.countWords=Xt;exports.createCommandExecutor=Cr;exports.createDragHandle=Hc;exports.createElement=Ko;exports.createHeading=nc;exports.createImageFromFile=hn;exports.debounce=Gt;exports.deepClone=_e;exports.defaultBlocks=xc;exports.deleteBlock=oo;exports.deleteTableColumn=Ze;exports.deleteTableRow=Xe;exports.dividerBlock=bt;exports.duplicateBlock=lo;exports.escapeHtml=Fo;exports.findElementsInSelection=Bn;exports.generateHeadingId=Po;exports.generateId=F;exports.getBlockDefinition=wc;exports.getBlockFromChild=ye;exports.getCellPosition=Qe;exports.getCode=uc;exports.getComputedStyleValue=Zo;exports.getCursorOffset=Wc;exports.getElementIndex=Wo;exports.getEmbedUrl=Ie;exports.getFocusedCell=Je;exports.getIcon=Dr;exports.getSelectedHtml=Ic;exports.getSelectedText=Dc;exports.getSelectionRange=Jt;exports.getSelectionState=An;exports.getTextContent=Ho;exports.heading1Block=rt;exports.heading2Block=lt;exports.heading3Block=it;exports.heading4Block=cn;exports.heading5Block=rn;exports.heading6Block=ln;exports.iconMap=fo;exports.imageBlock=ht;exports.indentBlock=uo;exports.indentListItem=lc;exports.initDragDrop=Ln;exports.insertAfter=Pe;exports.insertBefore=nn;exports.insertBlock=no;exports.insertLink=Rt;exports.isBlockElement=$o;exports.isCursorAtEnd=Mn;exports.isCursorAtStart=De;exports.isDragDropSupported=qc;exports.isElementEmpty=zo;exports.isFormatActive=eo;exports.isMobile=Go;exports.isMultiBlockSelection=Pc;exports.isSelectionCollapsed=qo;exports.isSelectionInElement=zc;exports.isTouchDevice=Xo;exports.linkPreviewBlock=vn;exports.matchesKeyCombo=Yo;exports.mergeBlocks=ao;exports.moveBlockDown=ro;exports.moveBlockUp=co;exports.moveCursorToEnd=xe;exports.moveCursorToStart=be;exports.nextFrame=Jo;exports.normalizeHtml=Bc;exports.numberedListBlock=dt;exports.outdentBlock=po;exports.outdentListItem=ic;exports.paragraphBlock=ct;exports.parseHeadings=mo;exports.parseHtml=Uo;exports.placeCursorAtEnd=Do;exports.placeCursorAtStart=Io;exports.quoteBlock=ut;exports.removeCitation=sc;exports.removeLink=Dt;exports.removeListItem=cc;exports.resetHeadingIds=Oo;exports.restoreSelection=Ro;exports.restoreSelectionState=Rc;exports.sanitizeHtml=Cn;exports.sanitizePaste=Sn;exports.saveSelection=jo;exports.saveSelectionState=jc;exports.selectAllInElement=Oc;exports.serializeElement=Vo;exports.setAccordionOpen=fc;exports.setAlignment=fe;exports.setCalloutType=gt;exports.setCellAlignment=yc;exports.setCursorPosition=Vc;exports.setDividerStyle=bc;exports.setHighlightColor=zt;exports.setImageAlign=pn;exports.setImageSrc=Ke;exports.setLanguage=dc;exports.setSelectionRange=Qt;exports.setTextColor=It;exports.setVideoSrc=gn;exports.slugify=tn;exports.splitBlock=so;exports.storage=ec;exports.stripHtml=en;exports.swapElements=_o;exports.tableBlock=yn;exports.throttle=Bo;exports.toggleAccordion=mc;exports.toggleBold=Bt;exports.toggleChecklistItem=rc;exports.toggleFormat=to;exports.toggleInlineCode=jt;exports.toggleItalic=$t;exports.toggleStrikethrough=qt;exports.toggleUnderline=Ht;exports.transformBlock=io;exports.unwrapElement=Nn;exports.videoBlock=bn;exports.wrapSelection=Tn;
751
+ `}const jt=({items:e,depth:t,onNavigate:n})=>e.length===0?null:c.jsx("ul",{className:`cbtoc-list ${t>0?"cbtoc-list-nested":""}`,children:e.map(o=>c.jsxs("li",{className:"cbtoc-item",children:[c.jsx("button",{className:`cbtoc-link cbtoc-link-h${o.level}`,onClick:()=>n(o.id,o),title:o.text,children:o.text}),o.children.length>0&&c.jsx(jt,{items:o.children,depth:t+1,onNavigate:n})]},o.id))}),cr=({html:e,darkMode:t=!1,className:n="",style:o,title:r="Table of Contents",minLevel:a=1,maxLevel:s=6,onNavigate:d,smoothScroll:w=!0,targetContainer:H=null,collapsible:D=!1,defaultCollapsed:L=!1})=>{const[_,T]=m.useState(L),$=m.useMemo(()=>co(e,a,s),[e,a,s]),x=m.useMemo(()=>or(t),[t]),z=m.useCallback((Z,te)=>{if(d){d(Z,te);return}let A=null;if(H){const fe=typeof H=="string"?document.querySelector(H):H;A=fe==null?void 0:fe.querySelector(`#${Z}`)}else A=document.getElementById(Z);A&&A.scrollIntoView({behavior:w?"smooth":"auto",block:"start"})},[d,w,H]),re=m.useCallback(()=>{T(Z=>!Z)},[]);return $.length===0?c.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[c.jsx("style",{children:x}),r&&c.jsx("h3",{className:"cbtoc-title",children:r}),c.jsx("p",{className:"cbtoc-empty",children:"No headings found"})]}):D?c.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[c.jsx("style",{children:x}),c.jsxs("button",{className:"cbtoc-toggle",onClick:re,children:[c.jsx("span",{className:"cbtoc-title",style:{margin:0},children:r}),c.jsx("svg",{className:`cbtoc-toggle-icon ${_?"cbtoc-toggle-icon-collapsed":""}`,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),c.jsx("div",{className:`cbtoc-content ${_?"cbtoc-content-collapsed":"cbtoc-content-expanded"}`,children:c.jsx("div",{style:{padding:"0.5rem"},children:c.jsx(jt,{items:$,depth:0,onNavigate:z})})})]}):c.jsxs("nav",{className:`cbtoc ${n}`.trim(),style:o,children:[c.jsx("style",{children:x}),r&&c.jsx("h3",{className:"cbtoc-title",children:r}),c.jsx(jt,{items:$,depth:0,onNavigate:z})]})},rr=({children:e,blockId:t,blockType:n,isActive:o=!1,onAddBlock:r,onDeleteBlock:a,onDuplicateBlock:s,onMoveUp:d,onMoveDown:w,onDragStart:H,className:D=""})=>{const[L,_]=m.useState(!1),T=m.useCallback(x=>{x.preventDefault(),x.stopPropagation(),_(!L)},[L]),$=m.useCallback(x=>z=>{z.preventDefault(),z.stopPropagation(),_(!1),x&&x()},[]);return c.jsxs("div",{className:`cb-block-wrapper ${o?"cb-block-wrapper-active":""} ${D}`,"data-block-wrapper":t,children:[c.jsxs("div",{className:"cb-block-controls cb-block-controls-left",children:[c.jsx("button",{type:"button",className:"cb-block-btn cb-block-add",onClick:$(()=>r==null?void 0:r("before")),title:"Add block above",tabIndex:-1,children:c.jsx(u.Plus,{size:14})}),c.jsx("button",{type:"button",className:"cb-block-btn cb-block-drag","data-drag-handle":!0,draggable:!0,onDragStart:H,title:"Drag to reorder",tabIndex:-1,children:c.jsx(u.GripVertical,{size:14})})]}),c.jsx("div",{className:"cb-block-content",children:e}),c.jsx("div",{className:"cb-block-controls cb-block-controls-right",children:c.jsxs("div",{className:"cb-block-menu-container",children:[c.jsx("button",{type:"button",className:"cb-block-btn cb-block-more",onClick:T,title:"More options",tabIndex:-1,children:c.jsx(u.MoreHorizontal,{size:14})}),L&&c.jsxs("div",{className:"cb-block-dropdown",children:[c.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:$(s),children:[c.jsx(u.Copy,{size:14}),c.jsx("span",{children:"Duplicate"})]}),c.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:$(d),children:[c.jsx(u.MoveUp,{size:14}),c.jsx("span",{children:"Move up"})]}),c.jsxs("button",{type:"button",className:"cb-block-dropdown-item",onClick:$(w),children:[c.jsx(u.MoveDown,{size:14}),c.jsx("span",{children:"Move down"})]}),c.jsx("div",{className:"cb-block-dropdown-divider"}),c.jsxs("button",{type:"button",className:"cb-block-dropdown-item cb-block-dropdown-item-danger",onClick:$(a),children:[c.jsx(u.Trash2,{size:14}),c.jsx("span",{children:"Delete"})]})]})]})})]})},lr=({metadata:e={},onChange:t,className:n=""})=>{const[o,r]=m.useState(e),[a,s]=m.useState("");m.useEffect(()=>{r(e)},[e]);const d=m.useCallback((D,L)=>{const _={...o,[D]:L};r(_),t&&t(_)},[o,t]),w=m.useCallback(D=>{if(D.key==="Enter"&&a.trim()){D.preventDefault();const L=o.tags||[],_=a.trim().toLowerCase();if(!L.includes(_)){const T={...o,tags:[...L,_]};r(T),t&&t(T)}s("")}},[o,a,t]),H=m.useCallback(D=>{const L={...o,tags:(o.tags||[]).filter(_=>_!==D)};r(L),t&&t(L)},[o,t]);return c.jsxs("div",{className:`cb-metadata-panel ${n}`,children:[c.jsxs("div",{className:"cb-metadata-header",children:[c.jsx(u.FileText,{size:20}),c.jsx("h3",{children:"Post Metadata"})]}),c.jsxs("div",{className:"cb-metadata-content",children:[c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-title",className:"cb-metadata-label",children:[c.jsx(u.FileText,{size:16}),c.jsx("span",{children:"Title"})]}),c.jsx("input",{id:"meta-title",type:"text",className:"cb-metadata-input",placeholder:"Enter post title...",value:o.title||"",onChange:D=>d("title",D.target.value)}),c.jsxs("span",{className:"cb-metadata-hint",children:[(o.title||"").length,"/60 characters"]})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-description",className:"cb-metadata-label",children:[c.jsx(u.FileText,{size:16}),c.jsx("span",{children:"Description"})]}),c.jsx("textarea",{id:"meta-description",className:"cb-metadata-textarea",placeholder:"Brief description for SEO and social media...",rows:3,value:o.description||"",onChange:D=>d("description",D.target.value)}),c.jsxs("span",{className:"cb-metadata-hint",children:[(o.description||"").length,"/160 characters"]})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-slug",className:"cb-metadata-label",children:[c.jsx(u.Link,{size:16}),c.jsx("span",{children:"URL Slug"})]}),c.jsx("input",{id:"meta-slug",type:"text",className:"cb-metadata-input",placeholder:"url-friendly-slug",value:o.slug||"",onChange:D=>d("slug",D.target.value)}),c.jsx("span",{className:"cb-metadata-hint",children:"Used in the post URL"})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-tags",className:"cb-metadata-label",children:[c.jsx(u.Tag,{size:16}),c.jsx("span",{children:"Tags"})]}),o.tags&&o.tags.length>0&&c.jsx("div",{className:"cb-metadata-tags",children:o.tags.map(D=>c.jsxs("span",{className:"cb-metadata-tag",children:[D,c.jsx("button",{type:"button",onClick:()=>H(D),className:"cb-metadata-tag-remove","aria-label":`Remove ${D}`,children:c.jsx(u.X,{size:14})})]},D))}),c.jsx("input",{id:"meta-tags",type:"text",className:"cb-metadata-input",placeholder:"Type a tag and press Enter...",value:a,onChange:D=>s(D.target.value),onKeyDown:w})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-cover",className:"cb-metadata-label",children:[c.jsx(u.Image,{size:16}),c.jsx("span",{children:"Cover Image URL"})]}),c.jsx("input",{id:"meta-cover",type:"url",className:"cb-metadata-input",placeholder:"https://example.com/image.jpg",value:o.coverImage||"",onChange:D=>d("coverImage",D.target.value)}),o.coverImage&&c.jsx("div",{className:"cb-metadata-preview",children:c.jsx("img",{src:o.coverImage,alt:"Cover preview",onError:D=>{D.target.style.display="none"}})})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-author",className:"cb-metadata-label",children:[c.jsx(u.FileText,{size:16}),c.jsx("span",{children:"Author"})]}),c.jsx("input",{id:"meta-author",type:"text",className:"cb-metadata-input",placeholder:"Author name",value:o.author||"",onChange:D=>d("author",D.target.value)})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-date",className:"cb-metadata-label",children:[c.jsx(u.Calendar,{size:16}),c.jsx("span",{children:"Publish Date"})]}),c.jsx("input",{id:"meta-date",type:"datetime-local",className:"cb-metadata-input",value:o.publishDate||"",onChange:D=>d("publishDate",D.target.value)})]}),c.jsxs("div",{className:"cb-metadata-field",children:[c.jsxs("label",{htmlFor:"meta-canonical",className:"cb-metadata-label",children:[c.jsx(u.Link,{size:16}),c.jsx("span",{children:"Canonical URL"})]}),c.jsx("input",{id:"meta-canonical",type:"url",className:"cb-metadata-input",placeholder:"https://example.com/original-post",value:o.canonicalUrl||"",onChange:D=>d("canonicalUrl",D.target.value)}),c.jsx("span",{className:"cb-metadata-hint",children:"For cross-posted or syndicated content"})]})]})]})},ro={paragraph:u.Type,heading1:u.Heading1,heading2:u.Heading2,heading3:u.Heading3,heading4:u.Heading4,heading5:u.Heading5,heading6:u.Heading6,list:u.List,listOrdered:u.ListOrdered,checkList:u.CheckSquare,quote:u.Quote,code:u.Code,image:u.Image,video:u.Video,divider:u.Minus,callout:u.AlertCircle,accordion:u.ChevronDown,table:u.Table,bold:u.Bold,italic:u.Italic,underline:u.Underline,strikethrough:u.Strikethrough,link:u.Link,unlink:u.Link2Off,highlight:u.Highlighter,textColor:u.Palette,alignLeft:u.AlignLeft,alignCenter:u.AlignCenter,alignRight:u.AlignRight,alignJustify:u.AlignJustify,undo:u.Undo,redo:u.Redo,copy:u.Copy,cut:u.Scissors,paste:u.ClipboardPaste,delete:u.Trash2,plus:u.Plus,drag:u.GripVertical,more:u.MoreHorizontal,chevronUp:u.ChevronUp,chevronDown:u.ChevronDown,moveUp:u.MoveUp,moveDown:u.MoveDown,maximize:u.Maximize2,close:u.X,check:u.Check,search:u.Search,settings:u.Settings,sun:u.Sun,moon:u.Moon,document:u.FileText,codeFile:u.FileCode,download:u.Download,upload:u.Upload,externalLink:u.ExternalLink,info:u.Info,warning:u.AlertTriangle,error:u.XCircle,success:u.CheckCircle,file:u.FileIcon,indent:u.Indent,outdent:u.Outdent,clear:u.RotateCcw,columns:u.Columns,rows:u.Rows,eraser:u.Eraser};function ar(e){return ro[e]||u.Type}exports.BlockMenu=to;exports.BlockRegistry=un;exports.BlockWrapper=rr;exports.ContentBlocksEditor=Qc;exports.ContentBlocksRenderer=nr;exports.EventEmitter=Go;exports.LANGUAGES=hn;exports.MetadataPanel=lr;exports.StatusBar=oo;exports.TableOfContents=cr;exports.Toolbar=Lt;exports.accordionBlock=Sn;exports.addCalloutTitle=uc;exports.addCitation=cc;exports.addListItem=Zo;exports.addTableColumn=Tn;exports.addTableRow=Ct;exports.allBlocks=Wt;exports.blockMap=Mn;exports.blockRegistry=Re;exports.bulletListBlock=Ht;exports.calculateReadingTime=no;exports.calloutBlock=Cn;exports.cancelFrame=Vo;exports.checkListBlock=fn;exports.clearFormatting=Yt;exports.codeBlock=zt;exports.collapseToEnd=Oc;exports.collapseToStart=Fc;exports.convertPlainTextToHtml=$n;exports.countCharacters=cn;exports.countWords=on;exports.createCommandExecutor=Xc;exports.createDragHandle=Dc;exports.createElement=Wo;exports.createHeading=Qo;exports.createImageFromFile=kn;exports.dateBlock=An;exports.debounce=yt;exports.deepClone=vt;exports.defaultBlocks=kc;exports.deleteBlock=_n;exports.deleteTableColumn=Et;exports.deleteTableRow=St;exports.dividerBlock=Ft;exports.duplicateBlock=Vn;exports.escapeHtml=Io;exports.excalidrawBlock=jn;exports.findElementsInSelection=Fn;exports.formatDate=ct;exports.generateHeadingId=Ho;exports.generateId=le;exports.getBlockDefinition=xc;exports.getBlockFromChild=Ue;exports.getCellPosition=Nt;exports.getCode=ac;exports.getComputedStyleValue=Ko;exports.getCursorOffset=Wc;exports.getElementIndex=Fo;exports.getEmbedUrl=ot;exports.getFocusedCell=At;exports.getIcon=ar;exports.getSelectedHtml=qc;exports.getSelectedText=Hc;exports.getSelectionRange=rn;exports.getSelectionState=qn;exports.getTextContent=Lo;exports.getToday=En;exports.getTomorrow=mc;exports.getYesterday=gc;exports.heading1Block=Dt;exports.heading2Block=Bt;exports.heading3Block=Rt;exports.heading4Block=bn;exports.heading5Block=pn;exports.heading6Block=mn;exports.iconMap=ro;exports.imageBlock=Pt;exports.indentBlock=Zn;exports.indentListItem=nc;exports.initDragDrop=Hn;exports.insertAfter=lt;exports.insertBefore=dn;exports.insertBlock=Xn;exports.insertLink=bt;exports.isBlockElement=To;exports.isCursorAtEnd=In;exports.isCursorAtStart=nt;exports.isDragDropSupported=Bc;exports.isElementEmpty=$o;exports.isFormatActive=Un;exports.isMobile=Xo;exports.isMultiBlockSelection=zc;exports.isSelectionCollapsed=jo;exports.isSelectionInElement=Ic;exports.isTouchDevice=_o;exports.linkPreviewBlock=Ln;exports.matchesKeyCombo=Uo;exports.mergeBlocks=Gn;exports.moveBlockDown=Yn;exports.moveBlockUp=Kn;exports.moveCursorToEnd=Ie;exports.moveCursorToStart=ze;exports.nextFrame=Yo;exports.normalizeHtml=jc;exports.numberedListBlock=qt;exports.outdentBlock=eo;exports.outdentListItem=oc;exports.paragraphBlock=Mt;exports.parseDate=wt;exports.parseHeadings=co;exports.parseHtml=zo;exports.placeCursorAtEnd=Bo;exports.placeCursorAtStart=Ro;exports.quoteBlock=It;exports.removeCitation=rc;exports.removeLink=Xt;exports.removeListItem=ec;exports.resetHeadingIds=qo;exports.restoreSelection=Do;exports.restoreSelectionState=$c;exports.sanitizeHtml=Bn;exports.sanitizePaste=Rn;exports.saveSelection=Mo;exports.saveSelectionState=Rc;exports.selectAllInElement=Pc;exports.serializeElement=Po;exports.setAccordionOpen=pc;exports.setAlignment=Oe;exports.setCalloutType=Ot;exports.setCellAlignment=hc;exports.setCursorPosition=Uc;exports.setDate=fc;exports.setDividerStyle=dc;exports.setFontFamily=_t;exports.setFontSize=Kt;exports.setHighlightColor=mt;exports.setImageAlign=yn;exports.setImageSrc=xt;exports.setLanguage=lc;exports.setSelectionRange=ln;exports.setTextColor=pt;exports.setVideoSrc=wn;exports.slugify=sn;exports.splitBlock=Qn;exports.storage=Jo;exports.stripHtml=an;exports.swapElements=Oo;exports.tableBlock=Nn;exports.throttle=No;exports.toggleAccordion=bc;exports.toggleBold=at;exports.toggleChecklistItem=tc;exports.toggleFormat=Wn;exports.toggleInlineCode=ut;exports.toggleItalic=it;exports.toggleStrikethrough=dt;exports.toggleUnderline=st;exports.transformBlock=Jn;exports.unwrapElement=Pn;exports.videoBlock=xn;exports.wrapSelection=zn;
960
752
  //# sourceMappingURL=index.cjs.js.map