@clepit/core 0.6.0-beta.396 → 0.6.0-beta.397

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.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./highlight-eQD0I7eW.js");var t=e=>{let t;const n=new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var n,a,o,i=(o?t(o):t)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((n=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),a={name:"clepit-store",version:0},(e,t,o)=>{const i=a.version??0,r=a.storage??("undefined"==typeof localStorage?void 0:localStorage),s=a.merge??((e,t)=>Object.assign({},t,e)),l=n(e,t,o);if(r){try{const e=r.getItem(a.name);if(e){const t=JSON.parse(e),n=t.version===i?t.state:a.migrate?a.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(l,s(n,l))}}catch{}o.subscribe(e=>{try{r.setItem(a.name,JSON.stringify({state:a.partialize?a.partialize(e):e,version:i}))}catch{}})}return l})))),r=["http:","https:"],s=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],l=["file","design","board","proto","slides","deck"],c=["document","spreadsheets","presentation"],d=/^[0-9a-f]{32}$/,p=/^[A-Za-z0-9]+$/,u={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function m(e,t){const n=u[e];return void 0!==n&&(t??[]).includes(n)}var h=(e,t="link")=>({embedUrl:null,provider:t,url:e});function g(e,t){return e===t||e.endsWith(`.${t}`)}function b(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(s.includes(n)){const t=function(e){if(g(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:h(a,"youtube")}if(g(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&l.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:h(a,"figma")}if(g(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:h(a,"miro")}if(g(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&p.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:h(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:h(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&c.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:h(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&d.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:h(a,"githubGist")}if(g(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:h(a,"airtable")}if(g(n,"diagrams.net")||g(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(g(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:h(a,"googleMaps")}return h(a)}function f(e,t){const n=function(e){try{const t=new URL(e);return r.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=b(n,t);return m(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function y(e,t,n,a){const o=i.getState().getInstance(e)?.config,r=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?Gr.replaceBlock(e,t,r):Gr.insertBlock(r,e,t+1);const s=Gr.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return s&&o?.resolveLink&&await v(e,s,o.resolveLink),s}async function v(e,t,n){if(!n)return;const a=Gr.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;Gr.updateBlockData(t,{...r,...o,url:a.url},e)}catch{Gr.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var x={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(91, 91, 255, 0.14)",codeString:"#0a7c3e",codeText:"#0a0a0a",codeType:"#953800",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",marker:"#ffe047",primary:"#5b5bff",primaryBg:"rgba(91, 91, 255, 0.08)",primaryHover:"#4747e6",selectionBg:"rgba(91, 91, 255, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},k={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",error:"--clepit-error",errorBg:"--clepit-error-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",marker:"--clepit-marker",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},w=(e,t,n)=>{const a=[];for(const o of Object.keys(k)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const r=k[o];void 0!==n&&void 0!==i?a.push(` ${r}: light-dark(${n}, ${i});`):a.push(` ${r}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},C=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(e,t){if(document.getElementById(e))return!1;const n=document.createElement("style");return n.id=e,n.textContent=t,document.head.appendChild(n),!0}static{this.themeRegistry=new Map}static{this.themeSubscribers=new Set}static registerEditor(t,n,a){const o=document.getElementById(t);o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute();const i=document.getElementById(`clepit-overrides-${t}`);if(i&&i.remove(),a){const n=w(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){const n=document.getElementById(`clepit-overrides-${t}`);n&&n.remove();const a=document.getElementById(t);a&&(a.removeAttribute("data-clepit-theme"),a.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},E="\n.clepit-embed {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",S=E,A=E,N=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=e}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},L={create:e=>new N(document.createElement(e)),createNS:(e,t)=>new N(document.createElementNS(e,t))},B=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),I=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),$=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;"),T=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(I(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(I(e))}toString(){const e=[...this.classes.length>0?[`class="${$(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${$(t)}"`)],t=[this.tag,...e].join(" ");return B.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},M=e=>({create:t=>new T(t,e),createNS:(t,n)=>new T(n,e)}),_=e=>String(e),D=e=>{if(!(e instanceof N))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function q(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function j(e,t){return`${e}-${t}`}function z(e){return!e||!e.trim()||"<br>"===e}function O(e){if(!e||z(e))return"";const t=document.createElement("div");t.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return e.cloneNode(!0);if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes)a.includes(e.name.toLowerCase())&&r.setAttribute(e.name,e.value);"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function H(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}function P(){C.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=q("div","clepit-invalid-data"),t=q("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var R={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function F(e){return R[e]||"Unknown"}var U=Object.fromEntries(Object.keys(e.GRAMMARS).map(e=>[e,{name:F(e)}])),V=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${C.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: 6px;\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${C.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${C.classNames.block.code.editor} .clepit-code-highlight,\n.${C.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre;\n overflow: auto;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${C.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${C.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${C.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${C.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${C.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,W="clepit-code-output-styles",K="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n overflow-x: auto;\n white-space: pre;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",G={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function J(e){return G[e]||"Unknown"}var X=Object.fromEntries(Object.keys(G).map(e=>[e,{name:J(e),theme:null}])),Y=`\n/* Custom Switch Container */\n.${C.classNames.switch.container} {\n --switch-blue: #0D7EFF;\n --switch-red: #FF0D0D;\n --switch-text: var(--clepit-bg);\n --switch-white: var(--clepit-bg);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.${C.classNames.switch.container} .tgl {\n display: none;\n}\n\n.${C.classNames.switch.container} .tgl,\n.${C.classNames.switch.container} .tgl:after,\n.${C.classNames.switch.container} .tgl:before,\n.${C.classNames.switch.container} .tgl *,\n.${C.classNames.switch.container} .tgl *:after,\n.${C.classNames.switch.container} .tgl *:before,\n.${C.classNames.switch.container} .tgl + .tgl-btn {\n box-sizing: border-box;\n}\n\n.${C.classNames.switch.container} .tgl::selection,\n.${C.classNames.switch.container} .tgl:after::selection,\n.${C.classNames.switch.container} .tgl:before::selection,\n.${C.classNames.switch.container} .tgl *::selection,\n.${C.classNames.switch.container} .tgl *:after::selection,\n.${C.classNames.switch.container} .tgl *:before::selection,\n.${C.classNames.switch.container} .tgl + .tgl-btn::selection {\n background: none;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn {\n outline: 0;\n display: block;\n width: 57px;\n height: 27px;\n position: relative;\n cursor: pointer;\n user-select: none;\n font-size: 12px;\n font-weight: 400;\n color: var(--switch-white);\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:after,\n.${C.classNames.switch.container} .tgl + .tgl-btn:before {\n position: relative;\n display: block;\n content: "";\n width: 44%;\n height: 100%;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:after {\n left: 0;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:before {\n display: inline;\n position: absolute;\n top: 3px;\n}\n\n.${C.classNames.switch.container} .tgl:checked + .tgl-btn:after {\n left: 56.5%;\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn {\n background: var(--switch-red);\n border-radius: 20rem;\n padding: 2px;\n transition: all 0.4s ease;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:after {\n border-radius: 2em;\n background: var(--switch-white);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:before {\n content: "No";\n left: 30px;\n color: var(--switch-text);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:active:after {\n padding-right: 0.4em;\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn {\n background: var(--switch-blue);\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active:after {\n margin-left: -0.4em;\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:before {\n content: "Yes";\n left: 6px;\n color: var(--switch-white);\n}\n\n.clepit-switch-label-text {\n font-size: 13px;\n display: flex;\n align-items: center;\n}\n`,Z=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,id:r=`switch-${Math.random().toString(36).substring(2,11)}`}=e;C.injectStyles("clepit-custom-switch-styles",Y);const s=C.createStyledElement("div",C.classNames.switch.container,{classNames:a?.container,styles:o?.container}),l=C.createStyledElement("input","tgl tgl-ios",{classNames:a?.input,styles:o?.input});l.type="checkbox",l.id=r,l.checked=t;const c=C.createStyledElement("label","tgl-btn",{classNames:a?.label,styles:o?.label});if(c.setAttribute("for",r),n&&l.addEventListener("change",e=>{const t=e.target;n(t.checked)}),s.appendChild(l),s.appendChild(c),i){const e=C.createStyledElement("span","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.textContent=i,s.appendChild(e)}return s}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t)}},Q=class t{static{this.placeholder="Enter code..."}static{this.supportedLanguages=U}static{this.supportedThemes=X}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=new WeakMap}static{this.dataMap=new WeakMap}static save(e){const n=e.querySelector(`.${C.classNames.block.code.container}`),a=n.querySelector(`.${C.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||t.defaultLanguage,i=n?.getAttribute("data-theme")||t.defaultTheme,r=!!a&&Z.getState(a),s=t.inputMap.get(n);if(s){const e=s.value,a=t.dataMap.get(n),l={code:e.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),t.dataMap.set(n,l),l}return{...t.dataMap.get(n)||{code:"",language:t.defaultLanguage,theme:t.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(e,n,a,o){C.injectStyles("clepit-code-input-styles",V);const r={code:"",language:o?.language||t.defaultLanguage,showCopy:!0,theme:o?.theme||t.defaultTheme},s=n?{...r,...n}:r,l=C.createStyledElement("div",C.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});l.setAttribute("data-language",s.language||t.defaultLanguage),l.setAttribute("data-theme",s.theme||t.defaultTheme);const c=C.createStyledElement("div",C.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=C.createStyledElement("div",C.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=U[s.language]?.name||F(t.defaultLanguage),u=X[s.theme]?.name||J(t.defaultTheme);d.textContent=t.getHeaderText(p,u);const m=C.createStyledElement("div",C.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});m.setAttribute("data-placeholder",t.placeholder);const h=e?i.getState().getInstance(e):null,g=h?.config.classNames?.switch,b=h?.config.styles?.switch,f=Z.create({checked:s.showCopy||!1,classNames:g,label:"Allow copy",onToggle:e=>{const n=t.dataMap.get(l)||{code:"",language:t.defaultLanguage,theme:t.defaultTheme};t.dataMap.set(l,{...n,showCopy:e}),Gr.saveBlockData(l)},styles:b});return c.appendChild(d),c.appendChild(f),l.appendChild(c),l.appendChild(m),t.mountEditor(l,m,s),l}static mountEditor(e,n,a){const o=a.language??t.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${F(o)} code`),s.placeholder=t.placeholder,n.replaceChildren(i,s),t.inputMap.set(e,s),t.dataMap.set(e,a),t.paint(e,r,s.value),s.addEventListener("input",()=>{t.paint(e,r,s.value);const n=t.dataMap.get(e)??{code:"",language:e.getAttribute("data-language")||t.defaultLanguage,theme:e.getAttribute("data-theme")||t.defaultTheme};t.dataMap.set(e,{...n,code:s.value}),Gr.saveBlockData(e)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>t.handleKeydown(e,s,n))}static paint(n,a,o){const i=n.getAttribute("data-language")||t.defaultLanguage;a.replaceChildren(...e.tokenizeCode(o.endsWith("\n")?`${o} `:o,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(e,n){const a=e.querySelector(`.${C.classNames.block.code.container}`);if(!a)return;const o=e.querySelector(`.${C.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${C.classNames.block.code.header}`),r=a.getAttribute("data-theme")||t.defaultTheme,s=J(r),l=F(n);i&&(i.textContent=t.getHeaderText(l,s));const c=t.inputMap.get(a);c&&t.mountEditor(a,o,{code:c.value,language:n,theme:r}),Gr.saveBlockData(a)}static updateTheme(e,n){const a=e.querySelector(`.${C.classNames.block.code.container}`);if(!a)return;const o=e.querySelector(`.${C.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${C.classNames.block.code.header}`),r=a.getAttribute("data-language")||t.defaultLanguage,s=F(r),l=J(n);i&&(i.textContent=t.getHeaderText(s,l));const c=t.inputMap.get(a);c&&t.mountEditor(a,o,{code:c.value,language:r,theme:n}),Gr.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${C.classNames.block.container}`);if(!a)return;const o=Gr.getEditorId(a);if(!o)return;const i=Gr.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void Gr.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?Gr.moveBlock(o,i,i-1):Gr.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?Gr.moveBlock(o,i,i+1):Gr.focusBlock(a.nextElementSibling))):void Gr.removeBlock(o,i):(n.preventDefault(),void Gr.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(e){const n=e.querySelector(`.${C.classNames.block.code.container}`);if(!n)return!0;const a=t.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return z(e.code)}static destroy(e){const n=document.getElementById(e);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",e);n.querySelectorAll(`.${C.classNames.block.code.container}`).forEach(e=>{t.inputMap.delete(e),t.dataMap.delete(e)})}},ee=".clepit-output-code-container",te=(t,n)=>[`${t} { background: ${n.background}; color: ${n.text}; }`,...e.CODE_TOKEN_GROUPS.map(e=>`${t} .clepit-code-${e} { color: ${n[e]};${(e=>"comment"===e?" font-style: italic;":"")(e)} }`)].join("\n"),ne=()=>[te(ee,e.resolveAutoTokens()),...Object.entries(e.CODE_THEME_TOKENS).map(([e,t])=>te(`${ee}[data-theme='${e}']`,t))].join("\n"),ae="clepit:code-variant-sync",oe=e=>`clepit.code-variant.${e}`,ie=(e,t)=>e.label?e.label:e.language?R[e.language]??e.language:`Tab ${t+1}`,re=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>ie(e,n)===t);return-1===n?0:n},se=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(oe(e))}catch{return null}};function le(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;C.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,C.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,C.applyStyling(s,{styles:o?.content});const c=document.createElement("div");c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,C.applyStyling(c,{styles:o?.arrow}),s.appendChild(c),i.appendChild(s),document.body.appendChild(i);const d=e.getBoundingClientRect(),p=s.offsetWidth,u=s.offsetHeight;let m,h=d.left+d.width/2-p/2;h=Math.max(8,Math.min(h,window.innerWidth-p-8));let g=n;"below"===n?(m=d.bottom+6+2,m+u>window.innerHeight-8&&(m=d.top-u-6-2,g="above")):(m=d.top-u-6-2,m<8&&(m=d.bottom+6+2,g="below")),c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${g} ${a?.arrow||""}`,i.style.left=`${h}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-u-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(l(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},l=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",l),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",l),l()}}var ce="http://www.w3.org/2000/svg",de=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],pe=class t{static{this.eventListenersMap=new WeakMap}static draw(n,a=L,o){if(!t.validate(n)||Q.isEmptyData(n))return null;const i=de(n),r=i.length>1,s=Math.min(Math.max(o?.activeVariant??0,0),i.length-1),l=a.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",n.theme??Q.defaultTheme),n.syncKey&&l.setAttribute("data-sync-key",n.syncKey);const c=a.create("div");if(c.addClass("clepit-output-code-header"),r){const e=a.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,n)=>{const o=a.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",n===s?"true":"false"),o.setAttribute("tabindex",n===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${n}`),o.setText(ie(t,n)),e.append(o)}),c.append(e)}else{const e=a.create("span");e.setText(R[n.language??"typescript"]??"TypeScript"),c.append(e)}if(n.showCopy){const e=a.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(ce,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(ce,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(a)),c.append(e)}l.append(c);const d=a.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((t,o)=>{const i=a.create("pre");i.addClass("clepit-output-code-pane"),i.setAttribute("data-variant-index",String(o)),o!==s&&i.setAttribute("hidden","");const r=a.create("code");for(const s of e.tokenizeCode(t.code??n.code,t.language??n.language??"plaintext")){const e=a.create("span");s.classes&&e.addClass(...s.classes.split(" ")),e.setText(s.text),r.append(e)}i.append(r),d.append(i)}),l.append(d),l}static render(e,n,a,o,i){if(C.injectStyles(W,K),C.injectStyles(`${W}-theme`,ne()),!t.validate(e))return P();if(Q.isEmptyData(e))return document.createElement("div");const r=de(e),s=r.length>1?re(r,se(e.syncKey)):0,l=D(t.draw(e,L,{activeVariant:s}));o?.container&&l.classList.add(o.container),a?.container&&Object.assign(l.style,a.container);const c=l.querySelector(".clepit-output-code-header");return c&&o?.header?.text&&c.classList.add(o.header.text),c&&a?.header?.text&&Object.assign(c.style,a.header.text),t.attach(l,e,s,i),l}static activate(e,n){if(!t.validate(n)||Q.isEmptyData(n))return()=>{};const a=de(n),o=a.length>1?re(a,se(n.syncKey)):0;return t.attach(e,n,o,void 0,!0)}static activateFromMarkup(e){const n=[...e.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...e.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=e.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==e.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?re(o,se(i)):0;return t.attach(e,r,s,void 0,!0)}static attach(e,n,a,o,r=!1){const s=de(n),l=o?document.getElementById(o):null,c=[...e.querySelectorAll(".clepit-output-code-tab")],d=[...e.querySelectorAll(".clepit-output-code-pane")];let p=a;const u=[];let m;const h=(e,n,a)=>{if(e.addEventListener(n,a),u.push({event:n,handler:a,target:e}),l){const o=t.eventListenersMap.get(l)??[];o.push({element:e,event:n,handler:a}),t.eventListenersMap.set(l,o)}},g=(e,t)=>{if(e<0||e>=s.length)return;if(p=e,c.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),d.forEach((t,n)=>{t.hidden=n!==e}),!t||!n.syncKey)return;const a=ie(s[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(oe(e),t)}catch{return}})(n.syncKey,a),window.dispatchEvent(new CustomEvent(ae,{detail:{label:a,syncKey:n.syncKey}}))};if(c.forEach((e,t)=>{h(e,"click",()=>g(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?s.length-1:0===a?-1:(t+a+s.length)%s.length;-1!==o&&(e.preventDefault(),g(o,!0),c[o]?.focus())})}),c.length>1&&n.syncKey){const e=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=s.findIndex((e,n)=>ie(e,n)===t.label);-1!==a&&a!==p&&g(a,!1)};if(window.addEventListener(ae,e),u.push({event:ae,handler:e,target:window}),l){const n=t.eventListenersMap.get(l)??[];n.push({element:window,event:ae,handler:e}),t.eventListenersMap.set(l,n)}}const b=()=>{for(const{event:e,handler:t,target:n}of u)n.removeEventListener(e,t);m?.()};r&&g(a,!1);const f=e.querySelector(".clepit-output-code-copy-btn");if(!f)return b;h(f,"click",()=>{t.copyCodeToClipboard(s[p]?.code??n.code),t.animateCopyButton(f)});const y=o?i.getState().getInstance(o):null;return m=le(f,"Copy code","above",y?.config.classNames?.tooltips,y?.config.styles?.tooltips),b}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(e){const n=document.getElementById(e);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",e);const a=t.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),t.eventListenersMap.delete(n))}},ue="inline-issue",me='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5b5bff);\n background: var(--clepit-primary-bg, rgba(91, 91, 255, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',he={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},ge={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},be={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function fe(e,t,n={}){let a=e?.[t]??he[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var ye=e=>ge[e]??e,ve="clepit-issue",xe=["todo","started","done","cancelled"],ke=["connect_tool","no_access","provider_unreachable"],we={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},Ce=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),Ee=(e,t)=>e.reason?fe(t,we[e.reason],{tool:ye(e.tool)}):null,Se=(e,t)=>e.stateName||fe(t,be[e.category]),Ae=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),Ne=class e{static build(t,n,a=L){const o=a.create("a");o.addClass(ve),t.reason&&o.addClass(`${ve}--reason`),o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${ve}__key`),i.setText(t.key||(t.title?"":ye(t.tool))),!t.key&&t.title||o.append(i);const r=Ee(t,n);if(r){const e=a.create("span");return e.addClass(`${ve}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${ve}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${ve}__state`),e.setAttribute("data-issue-category",t.category),e.setText(Se(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${ve}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(Ce(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return _(e.build(t,n,M(a)))}static create(t,n){return C.injectStyles(ue,me),D(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:xe.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:ke.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||e.getAttribute("href")||""}}static collect(e){return Array.from(e.querySelectorAll(`a.${ve}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Le=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,Be=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/&quot;/g,'"').replace(/&amp;/g,"&"),Ie=e=>{const t=t=>Be(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:xe.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:ke.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||Be(e,"href")}},$e=e=>Array.from(e.matchAll(Le),e=>Ie(e[0])),Te=(e,t,n,a,o)=>t||n?e.replace(Le,e=>{const i=Ie(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Ne.markup(r,a,o)}):e,Me=class e{static render(t,n){return C.injectStyles(ue,me),D(e.draw(t,L,n,!0))}static draw(t,n,a,o){const i=Ee(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText(Se(t,a)),s.append(c),r.append(s);const d=n.create("span");d.addClass("clepit-issue-card__meta");const p=n.create("span");if(p.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(Ce(t.assigneeName)),p.append(e),p.appendText(t.assigneeName)}else p.setText(fe(a,"unassigned"));if(d.append(p),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText(fe(a,"updatedRelative",{when:(u=t.updatedAt,u.length>=10?u.slice(0,10):u)})),d.append(e)}var u;return r.append(d),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||ye(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText(fe(a,"connectAction")),l.append(t)}return i.append(l),i}},_e="allow-scripts allow-same-origin allow-presentation allow-forms",De={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},qe={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function je(e,t,n={}){let a=e?.[t]??De[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var ze=new Set(Object.keys(R)),Oe={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function He(e){if(!e)return;const t=e.toLowerCase(),n=Oe[t];return n||(ze.has(t)?t:void 0)}var Pe={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},Re={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function Fe(e,t){const n=qe[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var Ue=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,Ve=class e{static render(t,n,a,o){if(C.injectStyles("embed-output",A),!e.validate(t))return P();if(t.issue)return Me.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=f(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return P();if(!Ue(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=Fe(t,i);if(!s)return r;const l=C.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),l.appendChild(r);const c=document.createElement("span");c.className="clepit-embed-card__reason",c.setAttribute("data-testid","embed-reason");const d=document.createElement("span");if(d.textContent=je(n?.embedLabels,Pe[s.reason],{tool:s.tool}),c.appendChild(d),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=je(n?.embedLabels,Re[s.action]),c.appendChild(e)}return l.appendChild(c),l}static draw(t,n=L,a){if(!e.validate(t))return null;if(t.issue)return Me.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=f(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!Ue(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=Fe(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(je(a?.embedLabels,Pe[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(je(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(je(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=pe.draw({code:i.content,language:He(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",_e),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=C.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=C.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",_e),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=C.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},We=/^[A-Z][A-Z0-9_]*-\d+$/,Ke=/^\d+$/,Ge=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),Je=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function Xe(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&We.test(t)?Je("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&Ke.test(a)?Je("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&Ke.test(t[0])&&Ke.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&Ke.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&Ke.test(t[2]))?Je("asana",""):null}if(Ge(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&We.test(o[1]))return Je("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&We.test(t)?Je("jira",t,e):null}return null}var Ye=new WeakMap,Ze=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?Ye.get(t):void 0)??{url:""}}static render(t,n,a){C.injectStyles("embed-input",S);const o=n??{url:""},r=i.getState().getInstance(t)?.config,s=Ve.render(o,{disabledEmbedProviders:r?.disabledEmbedProviders,embedLabels:r?.embedLabels},a?.styles,a?.classNames);return s.classList.add("clepit-embed--input"),s.setAttribute("contenteditable","false"),Ye.set(s,o),e.listenForActions(t,s),s}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),r=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=r;return Gr.updateBlockData(o,t,a)}case"embedShowCard":return Gr.updateBlockData(o,{...r,display:"card"},a);case"embedShowLink":{const e=Gr.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=r.url,t.textContent=r.url,Gr.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(r.url);case"embedShowChip":{const e=Gr.getBlockIndex(a,o);if(-1===e)return;const t=i.getState().getInstance(a)?.config,n=Xe(r.url,t?.jiraSites),s=r.issue??Ae(r.url,n?.tool??"",n?.key??""),l=Ne.create({...s,url:r.url},t?.issueLabels);return Gr.replaceBlock(a,e,{data:{html:`${l.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const r=t.querySelector(`.${C.classNames.block.content}`);if(!r)return;const s=i.getState().getInstance(n),l={classNames:s?.config.classNames?.blocks?.embed,styles:s?.config.styles?.blocks?.embed};r.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},l))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void i.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const r=o.getAttribute("data-embed-action"),s=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");if(!s)return;const l=i.getState().getInstance(t)?.config;"retry"===r?v(t,s,l?.resolveLink):l?.onEmbedAction?.(r,s)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function Qe(e,t){const n=i.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=Xe(a,n.jiraSites);e[a]={...Ae(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function et(e,t,n,a,o,r){const s=i.getState().getInstance(e)?.config,l=Ae(o,r.tool,r.key);if(a&&"on"===s?.issueCards){const t={data:{issue:l,url:o},type:"embed"};Gr.replaceBlock(e,n,t);const a=Gr.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await Qe(e,[n]))[n];if(!a)return;const o=Gr.getBlock(t);if(!o)return;const i=Ze.save(o);Gr.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const c=Ne.insertAtCaret(l,s?.issueLabels);if(!c)return;const d=c.closest('[contenteditable="true"]');d&&Gr.saveBlockData(d),await async function(e,t,n){const a=(await Qe(e,[n]))[n];if(!a||!t.isConnected)return;const o=i.getState().getInstance(e)?.config;Ne.refresh(t,a,o?.issueLabels);const r=t.closest('[contenteditable="true"]');r&&Gr.saveBlockData(r)}(e,c,o)}function tt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function nt(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function at(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function ot(e){return e.toLowerCase().includes("vimeo.com")}function it(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=at(t),a=ot(t);return{isImage:tt(t),isUrl:!0,isVideo:nt(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var rt=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),st=(e,t)=>{const n=it(t);if(!n.isUrl)return null;if(n.isImage)return rt(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return rt(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,Xe(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!rt(e,"embed"))return null;const r=function(e,t){const n=f(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null};function lt(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function ct(){return"mac"===lt()?"⌘":"Ctrl"}function dt(e){return"mac"===lt()?e.join(""):e.join(" + ")}var pt=e=>dt([ct(),e]),ut=e=>dt([ct(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),mt=()=>dt([ct(),"B"]),ht=()=>dt([ct(),"⌫"]),gt=()=>dt([ct(),"⌦"]),bt=()=>dt([ct(),"I"]),ft=()=>dt([ct(),"K"]),yt=e=>dt([ct(),"⇧",e]),vt=e=>dt([ct(),"⇧",{down:"↓",left:"←",right:"→",up:"↑"}[e]]),xt=()=>dt([ct(),"U"]),kt=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=mt()}static apply(e){C.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),Gr.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},wt=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=pt("`")}static apply(e,t,n){C.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&C.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),Gr.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&C.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},Ct=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=bt()}static apply(e){C.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),Gr.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Et="clepit-link-styles",St=`\n/* Link styles - simple and clean */\n.${C.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${C.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n`,At="clepit-dialogs-styles",Nt="\n/* Dialog Overlay */\n/* A native <dialog>. showModal() puts it in the top layer and paints a real\n * ::backdrop, so the full-screen scrim, the z-index and the manual centring are\n * the browser's job now. The non-modal branch below keeps the old flex overlay\n * for a DOM without showModal, where the element is an ordinary block. */\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(2px);\n}\n\n/* Fallback: no showModal, so the element is not in the top layer and paints no\n * backdrop of its own. */\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n backdrop-filter: blur(2px);\n}\n\n/* Dialog Container */\n.clepit-dialog {\n background: var(--clepit-bg);\n border-radius: 8px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);\n padding: 24px;\n min-width: 400px;\n max-width: 500px;\n max-height: 80vh;\n overflow-y: auto;\n position: relative;\n transform: scale(0.95);\n opacity: 0;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.95);\n opacity: 0;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n/* Dialog Title */\n.clepit-dialog-title {\n margin: 0 0 20px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--clepit-text);\n text-align: center;\n}\n\n/* Dialog Group */\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n/* Dialog Label */\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 14px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n/* Dialog Input */\n.clepit-dialog-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n font-size: 14px;\n color: var(--clepit-text);\n background: var(--clepit-bg);\n transition: border-color 0.2s ease, box-shadow 0.2s ease;\n box-sizing: border-box;\n}\n\n.clepit-dialog-input:focus {\n outline: none;\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Dialog Buttons */\n.clepit-dialog-buttons {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n/* Dialog Button */\n.clepit-dialog-button {\n padding: 10px 20px;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease;\n min-width: 80px;\n}\n\n.clepit-dialog-button--cancel {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-border);\n border-color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: white;\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n/* Responsive */\n@media (max-width: 640px) {\n .clepit-dialog {\n min-width: 320px;\n max-width: 90vw;\n margin: 20px;\n }\n\n .clepit-dialog-buttons {\n flex-direction: column;\n }\n\n .clepit-dialog-button {\n width: 100%;\n }\n}\n",Lt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.textInput?.value.trim()||"",t=this.urlInput?.value.trim()||"";e&&t&&(this.options.onConfirm(e,t),this.hide())}},this.options=e}show(){this.overlay||e.isOpen||(C.injectStyles(At,Nt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=q("h3","clepit-dialog-title");e.textContent="Insert Link",this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup("Text",this.options.text,"text");this.textInput=t.querySelector("input");const n=this.createInputGroup("URL",this.options.url,"url");this.urlInput=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none")}createInputGroup(e,t,n){const a=q("div","clepit-dialog-group");this.applyStyles(a,this.options.styles?.group),this.applyClassNames(a,this.options.classNames?.group);const o=q("label","clepit-dialog-label");o.textContent=e,this.applyStyles(o,this.options.styles?.label),this.applyClassNames(o,this.options.classNames?.label);const i=q("input","clepit-dialog-input");return i.type="url"===n?"url":"text",i.value=t,i.placeholder="url"===n?"https://example.com":"Link text",this.applyStyles(i,this.options.styles?.input),this.applyClassNames(i,this.options.classNames?.input),a.appendChild(o),a.appendChild(i),a}createButtonGroup(){const e=q("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=q("button","clepit-dialog-button clepit-dialog-button--cancel");t.textContent="Cancel",t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=q("button","clepit-dialog-button clepit-dialog-button--save");return n.textContent="Apply",n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.textInput?.value.trim()||"",this.urlInput?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.textInput&&this.textInput.addEventListener("keydown",this.handleInputKeyDown),this.urlInput&&this.urlInput.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.urlInput&&(this.urlInput.focus(),this.urlInput.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{void 0!==n&&e.style.setProperty(t,String(n))})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){document.removeEventListener("keydown",this.handleKeyDown),this.hide(),e.isOpen=!1}},Bt=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=ft()}static apply(t,n,a){C.injectStyles(Et,St);const o=t.toString().trim(),i=e.findLinkElement(t.commonAncestorContainer);let r=o,s="";i&&(r=i.textContent||o,s=i.href||"");const l=t.cloneRange();new Lt({classNames:n,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(l))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(a){if(a.removeAllRanges(),a.addRange(l),!n.trim())return void e.remove(l);if(t!==o){l.deleteContents();const e=document.createTextNode(t);l.insertNode(e),l.selectNode(e)}const i=C.createStyledElement("a",C.classNames.block.link);i.href=n,i.target="_blank",i.rel="noopener noreferrer";try{l.surroundContents(i)}catch{const e=l.extractContents();i.appendChild(e),l.insertNode(i)}const r=document.createRange();r.selectNodeContents(i),a.removeAllRanges(),a.addRange(r);const s=i.closest('[contenteditable="true"]');if(s){const e=new Event("input",{bubbles:!0});s.dispatchEvent(e)}}}catch(a){console.error("Failed to apply link:",a)}},styles:a,text:r||"Link text",url:s}).show(),Gr.updateStateFromRange(t)}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},It="clepit-marker-styles",$t="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",Tt=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static{this.shortcut=yt("M")}static apply(t,n,a){C.injectStyles(It,$t);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),Gr.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}Gr.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(C.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(C.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&C.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${C.classNames.editor.content}, .${C.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${C.classNames.block.content}`);if(!s)return;const l=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(l&&"initial"!==l&&"inherit"!==l){const t=e.createStrokeSVG(l);return void(n.style.background=t)}const c=window.getComputedStyle(s).backgroundColor;if(c&&"rgba(0, 0, 0, 0)"!==c&&"transparent"!==c){const t=e.createStrokeSVG(c);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},Mt="clepit-inline-status-styles",_t='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',Dt=["info","success","warning","error","plain"],qt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(C.injectStyles(At,Nt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const e=q("h3","clepit-dialog-title");e.textContent="Inline status",this.applyStyles(e,this.options.styles?.title),this.dialog.appendChild(e);const t=q("label","clepit-dialog-label");t.textContent="Label",this.applyStyles(t,this.options.styles?.label),this.dialog.appendChild(t),this.textInput=q("input","clepit-dialog-input"),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.placeholder="Status label",this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const n=q("label","clepit-dialog-label");n.textContent="Variant",this.applyStyles(n,this.options.styles?.label),this.dialog.appendChild(n);const a=q("div","clepit-status-dialog-variants");for(const c of Dt){const e=q("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${c}`);e.type="button",e.dataset.variant=c,e.textContent=c,e.dataset.selected=String(c===this.variant),e.addEventListener("click",()=>{this.variant=c;for(const e of Array.from(a.children))e.dataset.selected=String(e.dataset.variant===c)}),a.appendChild(e)}this.dialog.appendChild(a);const o=q("div","clepit-dialog-buttons");this.applyStyles(o,this.options.styles?.buttons);const i=q("button","clepit-dialog-button clepit-dialog-button--cancel");i.type="button",i.textContent="Cancel",i.addEventListener("click",()=>this.handleCancel()),this.applyStyles(i,this.options.styles?.cancelButton),o.appendChild(i);const r=q("button","clepit-dialog-button clepit-dialog-button--save");r.type="button",r.textContent="Apply",r.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(r,this.options.styles?.saveButton),o.appendChild(r),this.dialog.appendChild(o),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const s=this.overlay;"function"==typeof s.showModal?s.showModal():s.style.display="flex";const l=document.querySelector(".clepit-toolbar");l&&(l.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},jt="clepit-status",zt=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a){C.injectStyles(Mt,_t);const o=t.toString().trim(),i=e.findStatusElement(t.commonAncestorContainer),r=i?i.textContent??o:o,s=i?e.readVariant(i):"info",l=t.cloneRange();new qt({classNames:n,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(l))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(l),!t.trim())return void e.remove(l);if(e.unwrap(l),t!==o){l.deleteContents();const e=document.createTextNode(t);l.insertNode(e),l.selectNode(e)}const i=document.createElement("span");i.className=(e=>`${jt} ${jt}--${e}`)(n),i.dataset.statusVariant=n;try{l.surroundContents(i)}catch{const e=l.extractContents();i.appendChild(e),l.insertNode(i)}const r=document.createRange();r.selectNodeContents(i),a.removeAllRanges(),a.addRange(r);const s=i.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:r||"status",variant:s}).show(),Gr.updateStateFromRange(t)}static remove(t){e.unwrap(t),Gr.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${jt}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${jt}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(jt))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${jt}--${n}`))return n;return"info"}},Ot=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static{this.shortcut=yt("X")}static apply(e){C.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),Gr.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},Ht="clepit-tooltip-styles",Pt=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${C.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${C.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,Rt=class{constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(C.injectStyles(At,Nt),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=q("h3","clepit-dialog-title");e.textContent="Insert Tooltip",this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup("Text",this.options.text,"text");this.inputText=t.querySelector("input");const n=this.createInputGroup("Tooltip",this.options.tooltip,"text");this.inputTooltip=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n){const a=q("div","clepit-dialog-group");this.applyStyles(a,this.options.styles?.group),this.applyClassNames(a,this.options.classNames?.group);const o=q("label","clepit-dialog-label");o.textContent=e,this.applyStyles(o,this.options.styles?.label),this.applyClassNames(o,this.options.classNames?.label);const i=q("input","clepit-dialog-input");return i.type="url"===n?"url":"text",i.value=t,i.placeholder="Tooltip"===e?"Tooltip text":"Text",this.applyStyles(i,this.options.styles?.input),this.applyClassNames(i,this.options.classNames?.input),a.appendChild(o),a.appendChild(i),a}createButtonGroup(){const e=q("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=q("button","clepit-dialog-button clepit-dialog-button--cancel");t.textContent="Cancel",t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=q("button","clepit-dialog-button clepit-dialog-button--save");return n.textContent="Apply",n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},Ft=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static{this.shortcut=yt("T")}static apply(t,n,a){C.injectStyles(Ht,Pt);const o=t.toString(),i=t.cloneRange();let r="",s=o;const l=e.findTooltipSpan(t.commonAncestorContainer);l&&(r=l.getAttribute("data-tooltip")||"",s=l.textContent||""),new Rt({classNames:n.classNames,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(i))},onConfirm:(t,o)=>{const r=window.getSelection();if(!r)return;if(r.removeAllRanges(),r.addRange(i),!o.trim())return e.remove(i),void(t!==s&&(i.deleteContents(),i.insertNode(document.createTextNode(t))));if(l){const e=l.parentElement;if(e){const t=document.createTextNode(l.textContent||"");e.insertBefore(t,l),e.removeChild(l),i.selectNode(t)}}if(t!==s){i.deleteContents();const e=document.createTextNode(t);i.insertNode(e),i.selectNode(e)}const c=C.createStyledElement("span",C.classNames.block.tooltip);c.setAttribute("data-tooltip",o),a.classNames&&C.applyClassNames(c,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);c.style.setProperty(n,String(t))}});try{i.surroundContents(c)}catch{const e=i.extractContents();c.appendChild(e),i.insertNode(c)}t!==s&&c.textContent!==t&&(c.textContent=t),le(c,o,"above",n.classNames,n.styles);const d=c.closest('[contenteditable="true"]');d&&d.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:s,tooltip:r}).show(),Gr.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${C.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${C.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&C.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(le(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(C.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},Ut=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=xt()}static apply(e){C.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),Gr.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Gr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},Vt=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Wt=["improve","shorten","lengthen","simplify","fix_grammar"],Kt=()=>[kt,Ct,Ut,Ot,wt,Tt,zt,Bt,Ft],Gt="inline-toolbar",Jt=class e{static{this.eventListenersMap=new WeakMap}static{this.hideTimeoutMap=new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=i.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),C.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 8px;\n padding: 8px;\n box-shadow: var(--clepit-toolbar-shadow, 0 2px 8px rgba(0, 0, 0, 0.1));\n backdrop-filter: blur(8px);\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 0px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 14px;\n height: 14px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n transform: scale(1.05);\n}\n\n.clepit-toolbar-button:active {\n transform: scale(0.95);\n transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar-button.active {\n background: var(--clepit-toolbar-active-bg, var(--clepit-primary-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n font-weight: bold;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-bg);\n background-color: var(--clepit-text);\n padding: 6px 10px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-text);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), top 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=q("div","clepit-toolbar");o.id=`${t}-${Gt}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),C.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=i.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);if(!e.getElementFromContainerId(t))return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t);const o=((n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${C.classNames.block.container}`))?.getAttribute("data-tool"),r=e.getFilteredTools(o,a.config);r.forEach(a=>e.addButton(t,a,n)),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const s=n.getBoundingClientRect(),l=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!l)return;const c=((e=!1,t=Kt().length)=>({height:40,width:24*(t+(e?1:0))+16}))(Boolean(a.config.onInlineRewrite),r.length),d=s.left-l.left+s.width/2-c.width/2;let p=s.top-l.top-c.height-8;p<0&&(p=s.bottom-l.top+8),e.show(a.config.containerId,d,p)}static addRewriteButton(t,n){const a=i.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const r=e.getElementFromContainerId(t),s=document.getElementById(t);if(!r||!s)return;const l=q("button","clepit-toolbar-button",{type:"button"});l.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',l.setAttribute("data-tool","rewrite"),C.applyStyling(l,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const c=q("div","clepit-toolbar-rewrite-menu");c.style.display="none",c.setAttribute("data-rewrite-menu","true");for(const i of Wt){const t=q("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[i]??i,t.setAttribute("data-rewrite-action",i),e.addEventListener(s,t,"mousedown",e=>e.preventDefault()),e.addEventListener(s,t,"click",()=>{c.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,r=a.toString();r.trim()&&(l.classList.add("busy"),o(r,i).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),s.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(()=>{}).finally(()=>l.classList.remove("busy")))}),c.appendChild(t)}e.addEventListener(s,l,"mousedown",e=>e.preventDefault()),e.addEventListener(s,l,"click",()=>{c.style.display="none"===c.style.display?"flex":"none"}),r.appendChild(l),e.createTooltip(r,l,a.config.inlineRewriteTooltip??"rewrite"),r.appendChild(c)}static addButton(t,n,a){const o=i.getState().getInstance(t);if(!o)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const r=e.getElementFromContainerId(t);if(!r)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const s=q("button","clepit-toolbar-button",{type:"button"});s.innerHTML=n.icon,C.applyStyling(s,{classNames:o.config.classNames?.inlineToolbar?.button,styles:o.config.styles?.inlineToolbar?.button}),n.isActive(a)&&s.classList.add("active"),s.setAttribute("data-tool",n.label.toLowerCase());const l=document.getElementById(t);l&&(e.addEventListener(l,s,"mousedown",e=>e.preventDefault()),e.addEventListener(l,s,"click",()=>{try{const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,i=t&&!t.collapsed?t:a;if(i&&n.isActive(i))n.remove(i),s.classList.remove("active");else if(i){switch(n.label){case"italic":Ct.apply(i);break;case"bold":kt.apply(i);break;case"underline":Ut.apply(i);break;case"strikethrough":Ot.apply(i);break;case"inlineCode":wt.apply(i,o.config.classNames?.blocks?.["inline-code"],o.config.styles?.blocks?.["inline-code"]);break;case"marker":Tt.apply(i,o.config.classNames?.blocks?.marker,o.config.styles?.blocks?.marker);break;case"status":zt.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs);break;case"link":Bt.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs);break;case"tooltip":Ft.apply(i,{classNames:o.config.classNames?.tooltips,styles:o.config.styles?.tooltips},{classNames:o.config.classNames?.blocks?.tooltip,styles:o.config.styles?.blocks?.tooltip})}s.classList.add("active")}}catch(e){console.warn("Error applying inline tool:",e)}})),r.appendChild(s),e.createTooltip(r,s,n.label)}static createTooltip(t,n,a){const o=q("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=q("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=q("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.querySelectorAll(".clepit-toolbar-button").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-tooltip").forEach(e=>e.remove())}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden"),o.classList.add("clepit-toolbar--visible"),o.classList.contains("clepit-toolbar--visible")){const e=parseFloat(o.style.left)||0,t=parseFloat(o.style.top)||0;(Math.abs(e-n)>1||Math.abs(t-a)>1)&&o.classList.add("clepit-toolbar--position-animation")}else o.classList.add("clepit-toolbar--show-animation");o.style.left=`${n}px`,o.style.top=`${a}px`,requestAnimationFrame(()=>{o.classList.add("clepit-toolbar--visible")})}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${Gt}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=Kt().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${Gt}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},Xt={},Yt={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of Xt[e]??[])n.removeEventListener(a,o,t);Xt[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){Yt.dismiss(e);const o=window.getSelection(),r=o?.rangeCount?o.getRangeAt(0):null;if(!r)return;r.deleteContents();const s=document.createTextNode(n);r.insertNode(s),r.setStartAfter(s),r.collapse(!0),o?.removeAllRanges(),o?.addRange(r);const l=document.getElementById(e);if(!l)return;const c=i.getState().getInstance(e)?.config,d=qe[a.provider]??a.provider,p=document.createElement("div");p.className="clepit-embed-offer",p.setAttribute("data-testid","embed-offer"),p.setAttribute("data-embed-offer-for",e);const u=document.createElement("span");u.textContent=je(c?.embedLabels,"offerShowLive",{tool:d}).replace(" · Show live",""),p.appendChild(u);const m=document.createElement("button");m.type="button",m.setAttribute("data-testid","embed-offer-accept"),m.textContent=je(c?.embedLabels,"offerShowLive",{tool:d}).split(" · ").pop()??"Show live",p.appendChild(m);const h=r.getBoundingClientRect(),g=l.getBoundingClientRect();p.style.left=`${Math.max(0,h.left-g.left)}px`,p.style.top=h.bottom-g.top+6+"px",l.appendChild(p);const b=()=>{const a=t.getAttribute("data-id"),o=Gr.getBlockIndex(e,a);Yt.dismiss(e),-1!==o&&y(e,o,!0,n)},f=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void b();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&Yt.dismiss(e)},v=t=>{p.contains(t.target)||Yt.dismiss(e)};m.addEventListener("click",b),document.addEventListener("keydown",f,!0),document.addEventListener("mousedown",v),Xt[e]=[{element:m,event:"click",handler:b},{capture:!0,element:document,event:"keydown",handler:f},{element:document,event:"mousedown",handler:v}]}},Zt={},Qt={dismiss(e){for(const{element:t,event:n,handler:a}of Zt[e]??[])t.removeEventListener(n,a);Zt[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){Qt.dismiss(e),C.injectStyles(ue,me);const n=document.getElementById(e);if(!n)return;const a=i.getState().getInstance(e)?.config,o=Ne.read(t),r=ye(o.tool),s=document.createElement("div");s.className="clepit-issue-menu",s.setAttribute("data-testid","issue-menu"),s.setAttribute("data-issue-menu-for",e);const l=Ee(o,a?.issueLabels);if(l){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=l,s.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=fe(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{Qt.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),s.appendChild(t)}}const c=document.createElement("a");c.href=o.url,c.target="_blank",c.rel="noopener noreferrer",c.setAttribute("data-testid","issue-open"),c.textContent=fe(a?.issueLabels,"openInTool",{tool:r}),c.addEventListener("click",()=>Qt.dismiss(e)),s.appendChild(c);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=fe(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{Qt.dismiss(e),Qt.showAsCard(e,t)}),s.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();s.style.left=`${Math.max(0,p.left-u.left)}px`,s.style.top=p.bottom-u.top+6+"px",n.appendChild(s);const m=t=>{"Escape"===t.key&&Qt.dismiss(e)},h=n=>{s.contains(n.target)||t.contains(n.target)||Qt.dismiss(e)};document.addEventListener("keydown",m),document.addEventListener("mousedown",h),Zt[e]=[{element:document,event:"keydown",handler:m},{element:document,event:"mousedown",handler:h}]},showAsCard(e,t){const n=Ne.read(t),a=t.closest(`.${C.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=Gr.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};Gr.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?Gr.replaceBlock(e,i,s):(r&&Gr.saveBlockData(r),Gr.insertBlock(s,e,i+1))}},en=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick))}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${C.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const r=i.getState().getInstance(o);return r?{instance:r,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${ve}`);if(a){if("edit"!==i.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void Qt.show(t.id,a)}const o=n.closest(`.${C.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=i.getState().getInstance(t.id);return void(n&&Bt.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs))}const r=n.closest(`.${C.classNames.block.tooltip}`);if(r){const e=document.createRange();e.selectNodeContents(r);const n=i.getState().getInstance(t.id);return void(n&&Ft.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip}))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView){try{Jt.hide(a.instance.config.containerId)}catch{}return}if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();if(o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed)try{Jt.repaint(a.instance.config.containerId,n)}catch{}else try{Jt.hide(a.instance.config.containerId)}catch{}}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${C.classNames.block.container}`);if(!a)return;const o=a.closest(`.${C.classNames.editor.container}`);if(!o)return;const r=i.getState().getInstance(o.id)?.config,s=st(r,t);if(!s)return;const l=a.getAttribute("data-id"),c=Gr.getBlockIndex(o.id,l);if(-1===c)return;const d=Gr.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==s.kind)if("embed"!==s.kind)if("image"===s.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:s.url},type:"image"};p?Gr.replaceBlock(o.id,c,e):Gr.insertBlock(e,o.id,c+1)}else{let e=s.url;s.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(s.url)||s.url:s.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(s.url)||s.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?Gr.replaceBlock(o.id,c,t):Gr.insertBlock(t,o.id,c+1)}else"offer"===(r?.pasteEmbeds??"live")?Yt.show(o.id,a,t,s.embed):y(o.id,c,p,t);else et(o.id,0,c,p,t,s.issue)}},tn="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",nn=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:O(t.innerHTML),variant:n}}static render(t,n,a){C.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=C.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",e.placeholder),i.html?r.innerHTML=i.html:r.innerHTML="",e.addEventListener(t,r,"keydown",Gr.handleKeydown),e.addEventListener(t,r,"input",Gr.handleInput),r}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const r=t.innerHTML||"",s={html:r.trim()&&"<br>"!==r.trim()?r:"",variant:n},l={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},c=Gr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,s,l);t.replaceWith(d),i.getState().updateBlockData(a,c,s)}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},an=class e{static render(t,n,a,o){if(C.injectStyles("clepit-alert-output-styles",tn),!e.validate(t))return P();if(nn.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.variant,s=C.createStyledElement("div",`clepit-output-alert clepit-output-alert--${r}`,{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=L){if(!e.validate(t)||nn.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},on={icon:"!",get input(){return nn},label:"Alert",get output(){return an},shortcut:yt("A"),testId:"block-type-alert",type:"alert"},rn=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${C.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${C.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${C.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${C.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,sn="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",ln=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${C.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${C.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:O(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){C.injectStyles("clepit-audio-input-styles",rn);const i=a||{alt:"",caption:"",url:""},r=C.createStyledElement("div",C.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=C.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const l=C.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});l.classList.add("clepit-audio-caption-container");const c=C.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",e.placeholder),c.innerHTML=n.caption||"",e.addEventListener(o,c,"keydown",Gr.handleKeydown),e.addEventListener(o,c,"input",Gr.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="♪";const l=C.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const c=C.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=C.createStyledElement("button",`${C.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),r.appendChild(d);const p=a?i.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;le(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Gr.removeBlock(a,Gr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(r)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Gr.getBlockIndex(o,l),Gr.getBlockData(l).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(s){console.error("Audio upload error:",s),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=Gr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Gr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${C.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},cn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-audio-output-styles",sn),!e.validate(t))return P();if(ln.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=C.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":c.classList.add("clepit-output-audio-wrapper--left");break;case"center":c.classList.add("clepit-output-audio-wrapper--center");break;case"right":c.classList.add("clepit-output-audio-wrapper--right")}const d=q("audio","clepit-output-audio");if(d.src=i,d.controls=!0,d.preload="metadata",t.alt&&d.setAttribute("alt",t.alt),c.appendChild(d),l.appendChild(c),r){const e=C.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=L){if(!e.validate(t)||ln.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},dn={icon:"♪",get input(){return ln},label:"Audio",get output(){return cn},shortcut:yt("O"),testId:"block-type-audio",type:"audio"},pn=`\n/* Checklist input block styles */\n.${C.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${C.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${C.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${C.classNames.block.checklist.text}::before,\n.${C.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${C.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${C.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${C.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${C.classNames.block.checklist.checkbox}::before,\n.${C.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${C.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${C.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${C.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${C.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,un='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',mn=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${C.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${C.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:O(a.innerHTML)})}),{items:t}}static render(t,n,a){C.injectStyles("clepit-checklist-input-styles",pn);const o={items:[]},i=n?{...o,...n}:o,r=C.createStyledElement("div",C.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=C.createStyledElement("div",C.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=C.createStyledElement("input",C.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=C.createStyledElement("div",C.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",e.placeholder),s.innerHTML=t.text?.trim()||"",e.addEventListener(a,r,"change",()=>Gr.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,l=n.closest(`.${C.classNames.block.container}`);if(!l)return;const c=Gr.getBlockIndex(a,l.getAttribute("data-id")),d=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&Gr.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Gr.getBlocks(a);e&&c<e.length-1&&Gr.moveBlock(a,c,c+1)}else if(d)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Gr.removeBlock(a,c)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),z(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;const o=Gr.getBlockIndex(a,t.getAttribute("data-id"));Gr.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(z(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${C.classNames.block.container}`);if(!e)return;const t=Gr.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Gr.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{Gr.ensureActiveBlock(a);const e=Gr.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(c>0){const t=e[c-1];t&&Gr.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${C.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(c<e.length-1){const t=e[c+1];t&&Gr.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${C.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",Gr.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${C.classNames.block.checklist.item}`)),n=t.filter(e=>z(e.querySelector(`.${C.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${C.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>z(e.querySelector(`.${C.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>z(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},hn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-checklist-output-styles",un),!e.validate(t))return P();if(mn.isEmptyData(t))return document.createElement("div");const i=t.items,r=C.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=C.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=C.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=C.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});e.text&&e.text.trim()&&(s.innerHTML=e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=L){if(!e.validate(t)||mn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},gn={icon:"☑",get input(){return mn},label:"Checklist",get output(){return hn},shortcut:yt("K"),testId:"block-type-checklist",type:"checklist"},bn={icon:"𝕔",get input(){return Q},label:"Code",get output(){return pe},shortcut:yt("C"),testId:"block-type-code",type:"code"},fn="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",yn=`${fn}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,vn=fn,xn=new WeakMap;var kn=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=xn.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:O(n?.innerHTML),open:a}}static render(t,n,a){C.injectStyles("collapsible-input",yn);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=C.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,xn.set(r,[...i.children??[]]);const s=document.createElement("summary"),l=document.createElement("span");l.className="clepit-collapsible__title",l.setAttribute("contenteditable","true"),l.setAttribute("data-placeholder",e.placeholder),i.html&&(l.innerHTML=O(i.html)),s.appendChild(l),r.appendChild(s);const c=document.createElement("div");return c.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{c.appendChild(e.renderChild(t,n))}),r.appendChild(c),e.addEventListener(t,l,"keydown",Gr.handleKeydown),e.addEventListener(t,l,"input",Gr.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=Gr.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return z(n?.innerHTML)&&!a}static isEmptyData(e){return z(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},wn="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Cn=wn,En=wn,Sn=class e{static render(t,n,a,o){if(C.injectStyles("collection-output",En),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},An="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",Nn=`${An}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,Ln=An,Bn=class e{static render(t,n,a,o){if(C.injectStyles("columns-output",Ln),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=C.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=Pi(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},In="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",$n=`${In}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,Tn=In,Mn=/^(\d{4})-(\d{2})-(\d{2})$/;function _n(e){const t=Mn.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var Dn=class e{static render(t,n,a,o){C.injectStyles("date-output",Tn);const i=e.validate(t)?_n(t.date):null;if(!i)return P();const r=C.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=L){const a=e.validate(t)?_n(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},qn='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',jn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){C.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=C.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=C.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=C.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${C.classNames.block.container}`);if(!a)return;const o=Gr.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&Gr.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=Gr.getBlocks(t);n&&o<n.length-1&&Gr.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Gr.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),Gr.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),Gr.removeBlock(t,o);else{Gr.ensureActiveBlock(t);const a=Gr.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&Gr.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&Gr.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const r={variant:n},s={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},l=Gr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-delimiter-output-styles",qn),!e.validate(t))return P();if(jn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=C.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=L){if(!e.validate(t)||jn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},On="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",Hn=On,Pn=On,Rn=class e{static render(t,n,a,o){if(C.injectStyles("doc-card-output",Pn),!e.validate(t))return P();const i=C.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),l=document.createElement("span");if(l.className="clepit-doc-card__title",l.textContent=t.title||"Untitled",s.appendChild(l),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},Fn="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",Un=`${Fn}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,Vn=Fn;function Wn(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Kn=class e{static render(t,n,a,o){if(C.injectStyles("file-output",Vn),!e.validate(t))return P();const i=C.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=Wn(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=Wn(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},Gn='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',Jn="At a glance",Xn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-glance-output-styles",Gn),!e.validate(t))return P();if(0===t.rows.length)return document.createElement("div");const i=C.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=q("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:Jn,i.appendChild(r);const s=q("dl","clepit-glance-rows");for(const e of t.rows){const t=q("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=q("dd","clepit-glance-value");n.innerHTML=O(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=L){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:Jn),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},Yn="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",Zn=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:O(t?.innerHTML),level:n}}static render(t,n,a){C.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=C.createStyledElement(r,C.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",e.placeholder),i.html?s.innerHTML=i.html:s.innerHTML="",e.addEventListener(t,s,"keydown",Gr.handleKeydown),e.addEventListener(t,s,"input",Gr.handleInput),s}static changeLevel(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const r={html:t.innerHTML,level:n},s={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},l=Gr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Qn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-header-output-styles",Yn),!e.validate(t))return P();if(Zn.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.level||"h1",s=C.createStyledElement(r,"clepit-output-header",{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=L){if(!e.validate(t)||Zn.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ea=`\n/* Image block styles */\n.${C.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${C.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${C.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${C.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${C.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Image delete button */\n.${C.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${C.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${C.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,ta="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",na=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${C.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:O(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){C.injectStyles("clepit-image-input-styles",ea);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=C.createStyledElement("div",C.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=C.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const l=C.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});l.classList.add("clepit-image-caption-container");const c=C.createStyledElement("div",C.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",e.placeholder),c.innerHTML=n?.caption||"",e.addEventListener(o,c,"keydown",Gr.handleKeydown),e.addEventListener(o,c,"input",Gr.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="📷";const l=C.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop an image here</strong><br>or <span class="clepit-image-click-text">click to select</span>';const c=C.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports JPEG, PNG, GIF, WebP, SVG, and other image formats";const d=C.createStyledElement("button",`${C.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),r.appendChild(d);const p=i.getState().getInstance(a),u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;le(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Gr.removeBlock(a,Gr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(r)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showError(n,"Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showError(t,"Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Gr.getBlockIndex(o,l),Gr.getBlockData(l).data)}else e.showError(n,"Failed to upload image. Please try again.")}catch(s){console.error("Image upload error:",s),e.showError(n,"Failed to upload image. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-image-loading",void 0);t.textContent="Uploading image...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-image-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=Gr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Gr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.image.wrapper} img`),n=e.querySelector(`.${C.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},aa=class e{static render(t,n,a,o){if(C.injectStyles("clepit-image-output-styles",ta),!e.validate(t))return P();if(na.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",l=C.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":c.classList.add("clepit-output-image-wrapper--left");break;case"center":c.classList.add("clepit-output-image-wrapper--center");break;case"right":c.classList.add("clepit-output-image-wrapper--right")}const d=q("img","clepit-output-image");if(d.src=i,d.alt=s,c.appendChild(d),l.appendChild(c),r){const e=C.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}return l}static draw(t,n=L){if(!e.validate(t)||na.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},oa=me,ia=me,ra=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)ra(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))ra(e,t)}}else e.includes("clepit-issue")&&t.push(...$e(e))},sa=class e{static collect(e,t){const n=[];ra(e??[],n);const a=new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){C.injectStyles("issues-output",ia);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=C.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=fe(n?.issueLabels,"linkedIssuesEmpty"),e}const r=D(e.table(i,L,n?.issueLabels));return C.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=L,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText(fe(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText(Se(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||fe(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},la="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",ca=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(O(e.innerHTML))),{items:a,type:n}}static render(t,n,a){C.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=C.createStyledElement(r,C.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const l=a?.classNames?.[i.type]?.item,c=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,l,c)):e.createAndAppendListItem("",s,t,l,c),s}static createAndAppendListItem(t,n,a,o,i){const r=C.createStyledElement("li",C.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=t,r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",e.placeholder),e.addEventListener(a,r,"keydown",t=>{const s=t,l=n.closest(`.${C.classNames.block.container}`);if(!l)return;const c=Gr.getBlockIndex(a,l.getAttribute("data-id")),d=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&Gr.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Gr.getBlocks(a);e&&c<e.length-1&&Gr.moveBlock(a,c,c+1)}else if(d)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Gr.removeBlock(a,c)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),z(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;const o=Gr.getBlockIndex(a,t.getAttribute("data-id"));Gr.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(z(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${C.classNames.block.container}`);if(!e)return;const t=Gr.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Gr.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{Gr.ensureActiveBlock(a);const e=Gr.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${C.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(c>0){const t=e[c-1];t&&Gr.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${C.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(c<e.length-1){const t=e[c+1];t&&Gr.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",Gr.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const r={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},s={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},l=Gr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>z(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${C.classNames.block.list.item}`);return!t||Array.from(t).every(e=>z(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>z(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},da=class e{static render(t,n,a,o){if(C.injectStyles("clepit-list-output-styles",la),!e.validate(t))return P();if(ca.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=C.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=e,i=C.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n&&n.trim()&&(i.innerHTML=n),s.appendChild(i)}),s}static draw(t,n=L){if(!e.validate(t)||ca.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},pa="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav — approved 2026-08-06\n * (direction 2B, \"Eyebrow\"). */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen — approved 2026-08-06 (direction 1B, \"Panel\"). */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip — approved 2026-08-06\n * (direction 1B, \"Tabbed\"). */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",ua=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ma=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!ua(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=ma(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>ma(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=ma(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!ua(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=ma(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},ha=(e,t)=>ma(e,{schemas:t,stack:new Set}),ga=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ba=e=>{if(!ga(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},fa=e=>{if(!ga(e)||!ga(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=ba(a);return t},ya=e=>e.security[0],va=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},xa={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${va(e,t)}"`],a=ya(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=fa(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=fa(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${va(e,t)}'),`],i=[],r=ya(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=fa(e.request),a=e.method.toLowerCase(),o=[` "${va(e,t)}",`],i=ya(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=fa(e.request),a=[],o=ya(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${va(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},ka=["bash","typescript","dart","python"],wa=["get","post","put","patch","delete"],Ca=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ea=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Sa=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),Aa=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(Ca).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),Na=e=>Ca(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=Ca(t)?t:{},a=Ca(n.content)?n.content:void 0,o=a&&Ca(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],La=e=>{if(!Ca(e.requestBody))return;const t=Ca(e.requestBody.content)?e.requestBody.content:void 0;return(t&&Ca(t["application/json"])?t["application/json"]:void 0)?.schema},Ba=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(Ca);return t?Object.keys(t):[]},Ia=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(Ca);return"string"==typeof t?.url?t.url:void 0},$a=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",Ta=(e,t)=>{const n=Ca(e)?e:{},a=Ca(n.info)?n.info:{},o=Ca(n.components)?n.components:{},i={groups:[],schemas:Ca(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(Ca).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=Ca(n.paths)?n.paths:{},s=new Map;for(const[l,c]of Object.entries(r))if(Ca(c))for(const e of wa){const n=c[e];if(!Ca(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(Sa(t.exclude,a,l))continue;if(t.include&&!i&&!Sa(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:Ea(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:Aa(n),path:l,...void 0===La(n)?{}:{request:La(n)},responses:Na(n),security:Ba(n),...void 0===Ia(n)?{}:{server:Ia(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=$a(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:Ea(d),operations:[r],title:d})}return i.groups=[...s.values()],i},Ma=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},_a=(e,t)=>{const n=Ma(e,"div","clepit-openapi-table-scroll");return n.append(t),n},Da=(e,t,n,a)=>{const o=Ma(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},qa=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},ja=(e,t=0)=>t>6?qa(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,ja(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,ja(e,t+1)])):qa(e),za=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},Oa=(e,t,n,a)=>{const o=Ma(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=Ma(e,"div","clepit-openapi-operation-head"),s=Ma(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=Ma(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=Ma(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=Ma(e,"div","clepit-openapi-operation-body"),d=Ma(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(Ma(e,"p","clepit-openapi-description",t.description));const p=Ma(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(Ma(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(Ma(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=Ma(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(Ma(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=Ma(e,"td","clepit-openapi-name",i.name);i.required&&o.append(Ma(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(Ma(e,"td","clepit-openapi-cell",i.in)),t.append(Ma(e,"td","clepit-openapi-type",qa(ha(i.schema,n.schemas)))),t.append(Ma(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(Da(e,"Parameters","parameters",t.id)),c.append(_a(e,u))),void 0!==t.request){const a=ha(t.request,n.schemas);if(a.children.length>0){c.append(Da(e,"Body","body",t.id));const n=Ma(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=pe.draw({code:JSON.stringify(ja(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(Da(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=Ma(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=Ma(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=Ma(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=Ma(e,"p","clepit-openapi-response-description");if(r){const t=Ma(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",za(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=ha(a.schema,n.schemas);if(t.children.length>0){const n=pe.draw({code:JSON.stringify(ja(t),null,2),language:"json",showCopy:!0},e);n&&l.append(n)}}i.push(l);const d=Ma(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",za(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const m=((e,t,n)=>n.flatMap(n=>{const a=xa[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??ka);if(m.length>0){c.append(Da(e,"Try it","try-it",t.id));const n=pe.draw({code:m[0].code,language:m[0].language,showCopy:!0,syncKey:"api-reference",variants:m},e);n&&c.append(n)}return o.append(c),o},Ha=class e{static draw(t,n=L){if(!e.validate(t))return null;const a=Ta(t.spec,t),o=Ma(n,"div","clepit-openapi");if(a.servers.length>0){const e=Ma(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(Ma(n,"th","clepit-openapi-th","Host")),t.append(Ma(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(Ma(n,"td","clepit-openapi-name",o.url)),t.append(Ma(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(_a(n,e))}for(const e of a.groups){const i=Ma(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=Ma(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(Oa(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(C.injectStyles("clepit-openapi-output-styles",pa),!e.validate(t))return P();const i=D(e.draw(t,L));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])pe.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(pe.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const a of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...a.querySelectorAll(".clepit-openapi-response-tab")],t=[...a.querySelectorAll(".clepit-openapi-response")],o=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n})};e.forEach((t,a)=>{n(t,"click",()=>o(a)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(a+i+e.length)%e.length;-1!==r&&(t.preventDefault(),o(r),e[r]?.focus())})})}return()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},Pa="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",Ra=class e{static{this.placeholder="Enter text..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:O(e.querySelector(`.${C.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){C.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=C.createStyledElement("div",C.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",e.placeholder),o.innerHTML=n?.html||"",e.addEventListener(t,o,"keydown",Gr.handleKeydown),e.addEventListener(t,o,"input",Gr.handleInput),o}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Fa=class e{static render(t,n,a,o){if(C.injectStyles("clepit-paragraph-output-styles",Pa),!e.validate(t))return P();const i=C.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});if(Ra.isEmptyData(t))return i.appendChild(document.createElement("br")),i;const r=t.html;return r&&(i.innerHTML=r),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),Ra.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Ua=`\n/* Quote block styles */\n.${C.classNames.block.quote.container} {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${C.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${C.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${C.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${C.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${C.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${C.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${C.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${C.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,Va="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",Wa=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.quote.text}`),n=e.querySelector(`.${C.classNames.block.quote.author}`);return{author:O(n?.innerHTML),html:O(t?.innerHTML)}}static render(t,n,a){C.injectStyles("clepit-quote-input-styles",Ua);const o=n||{author:"",html:""},i=C.createStyledElement("div",C.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=C.createStyledElement("div",C.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=C.createStyledElement("div",C.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=o.html||"",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",e.placeholder),s.innerHTML=o.author||"",s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",e.authorPlaceholder),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",Gr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",Gr.handleInput),i.appendChild(r),o.author){const e=C.createStyledElement("div",C.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${C.classNames.block.container}`),o=Gr.getEditorId(a);if(!o)return;const i=Gr.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${C.classNames.block.quote.text}`),s=a.querySelector(`.${C.classNames.block.quote.author}`),l=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Gr.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Gr.getBlocks(o);t&&i<t.length-1&&Gr.moveBlock(o,i,i+1)}else if(l)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Gr.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),Gr.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!z(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?Gr.removeBlock(o,i):n===s&&(z(r.innerHTML)?Gr.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&Gr.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&Gr.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${C.classNames.block.container}`),o=Gr.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${C.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=Gr.getBlockIndex(o,a.getAttribute("data-id"));Gr.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.quote.text}`),n=e.querySelector(`.${C.classNames.block.quote.author}`);let a=!1,o=!1;return t?z(t.innerHTML)&&(a=!0):a=!0,n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return z(e.html)&&z(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ka=class e{static render(t,n,a,o){if(C.injectStyles("clepit-quote-output-styles",Va),!e.validate(t))return P();if(Wa.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.author||"",s=C.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),l=C.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=q("div","clepit-output-quote-content");if(i&&i.trim()&&(c.innerHTML=i),l.appendChild(c),s.appendChild(l),r){const e=C.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});s.appendChild(e);const t=C.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${r}`,s.appendChild(t)}return s.querySelectorAll(`span.${C.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(le(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),s}static draw(t,n=L){if(!e.validate(t)||Wa.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Ga="\n.clepit-sketch {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",Ja=Ga,Xa=Ga,Ya="http://www.w3.org/2000/svg";function Za(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function Qa(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var eo=class e{static render(t,n,a,o){if(C.injectStyles("sketch-output",Xa),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(Ya,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=Qa(s.points??[]);if(!t)continue;const n=document.createElementNS(Ya,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",Za(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(Ya,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=Qa(i.points??[]);if(!t)continue;const a=n.createNS(Ya,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",Za(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},to=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: 8px;\n border: 1px solid var(--clepit-border);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${C.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${C.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${C.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${C.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${C.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${C.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${C.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${C.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${C.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Row handle cell */\n.clepit-table-row-handle {\n position: absolute;\n left: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-handle {\n position: absolute;\n top: -22px;\n left: 50%;\n transform: translateX(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-row-delete {\n position: absolute;\n right: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-delete {\n right: -22px;\n top: calc(50% + 18px);\n transform: translateY(-50%);\n}\n\n/* Show handles on hover/active */\n.clepit-table-row:hover .clepit-row-handle,\n.${C.classNames.block.table.headerCell}:hover .clepit-col-handle,\n.clepit-table-row:hover .clepit-row-delete,\n.${C.classNames.block.table.headerCell}:hover .clepit-col-delete {\n display: flex;\n}\n\n/* Hover/active states like toolbar buttons */\n.clepit-row-handle:hover, .clepit-col-handle:hover,\n.clepit-row-delete:hover, .clepit-col-delete:hover {\n color: var(--clepit-primary);\n}\n\n/* Table menu buttons */\n.clepit-table-row-menu-btn,\n.clepit-table-col-menu-btn {\n position: absolute;\n background: var(--clepit-bg);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 4px 8px;\n font-size: 12px;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 1002;\n}\n\n.clepit-table-row-menu-btn:hover,\n.clepit-table-col-menu-btn:hover {\n color: var(--clepit-primary);\n background: var(--clepit-bg);\n border-color: var(--clepit-border);\n}\n\n.clepit-table-row-menu-btn--visible,\n.clepit-table-col-menu-btn--visible {\n display: flex;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,no="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n overflow: hidden;\n background: var(--clepit-bg);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border-radius: 4px;\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-top: none;\n border-radius: 0 0 8px 8px;\n}\n",ao=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${C.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-col-handle, .clepit-col-delete").forEach(e=>e.remove()),r.push(O(t.innerHTML))}i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),n=[];for(const e of t){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-row-handle, .clepit-row-delete").forEach(e=>e.remove()),n.push(O(t.innerHTML))}i.push(n)}const l=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:O(t.querySelector(`.${C.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:l}}static render(t,n,a){C.injectStyles("clepit-table-input-styles",to);const o=n?{...e.defaultData,...n}:e.defaultData,r=C.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),s=C.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),l=C.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),c=e.createRow(t,o.data[0],!0);l.appendChild(c),s.appendChild(l);const d=C.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let i=1;i<o.data.length;i++){const n=e.createRow(t,o.data[i]);d.appendChild(n)}s.appendChild(d);const p=C.createStyledElement("div","clepit-table-scroll-container");p.appendChild(s),r.appendChild(p);const u=C.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",r.appendChild(u);const m=C.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});m.style.position="absolute",m.style.display="none",m.style.zIndex="1000",m.textContent="⋯",r.appendChild(m);let h=null,g=-1,b=null;e.addEventListener(t,r,"mouseleave",()=>(u.style.display="none",m.style.display="none",void(b&&(b.remove(),b=null))));const f=e=>{h=e;const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(g=Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)).indexOf(e),g<0)return;const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;m.style.left=`${a}px`,m.style.top=`${Math.max(4,o)}px`,m.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&f(t)}),e.addEventListener(t,l,"mouseover",e=>{const t=e.target.closest(`.${C.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${C.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)[a];e&&y(e)}f(n)});const v=()=>{h&&"none"!==u.style.display&&f(h);const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)[g];e&&"none"!==m.style.display&&y(e)};e.addEventListener(t,window,"scroll",v,{passive:!0}),e.addEventListener(t,p,"scroll",v,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!h)return;const o=Array.from(d.querySelectorAll("tr")),i=o.indexOf(h),s=u.getBoundingClientRect(),l=r.getBoundingClientRect();e.createMenu(t,r,u,m,[{label:"Move up",onClick:()=>{i>0&&(d.insertBefore(h,o[i-1]),Gr.saveBlockData(h))},shortcut:ut("up")},{label:"Move down",onClick:()=>{i>=0&&i<o.length-1&&(d.insertBefore(o[i+1],h),Gr.saveBlockData(h))},shortcut:ut("down")},{label:"Insert above",onClick:()=>{const n=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,h),Gr.saveBlockData(h)},shortcut:vt("up")},{label:"Insert below",onClick:()=>{const n=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));h.nextSibling?d.insertBefore(a,h.nextSibling):d.appendChild(a),Gr.saveBlockData(h)},shortcut:vt("down")},{label:"Delete",onClick:()=>{o.length>1&&(h.remove(),Gr.saveBlockData(h))},shortcut:ht()}],s.left-l.left,s.bottom-l.top+4,a,b)}),e.addEventListener(t,m,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),g<0)return;const o=Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)),i=m.getBoundingClientRect(),s=r.getBoundingClientRect();e.createMenu(t,r,u,m,[{label:"Move left",onClick:()=>{if(g<=0)return;const e=g,t=o[e-1],n=o[e];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),g=e-1,Gr.saveBlockData(c)},shortcut:ut("left")},{label:"Move right",onClick:()=>{const e=g;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),g=e+1,Gr.saveBlockData(c)},shortcut:ut("right")},{label:"Insert left",onClick:()=>{const n=g,a=e.createHeaderCell(t,"");c.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${C.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Gr.saveBlockData(c)},shortcut:vt("left")},{label:"Insert right",onClick:()=>{const n=g+1,a=o[g]?.nextSibling||null,i=e.createHeaderCell(t,"");c.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${C.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Gr.saveBlockData(c)},shortcut:vt("right")},{label:"Delete",onClick:()=>{const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`);if(g<0||e.length<=1)return;const t=e[g];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${C.classNames.block.table.cell}`);t[g]&&t[g].parentElement?.removeChild(t[g])}),Gr.saveBlockData(c)},shortcut:gt()}],i.left-s.left,i.bottom-s.top+4,a,b)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>f(n))})(n)),Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const x=C.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});x.style.display="flex",x.style.alignItems="center",x.style.gap="8px",x.style.marginTop="8px";const k=C.createStyledElement("div",`${C.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});k.contentEditable="true",k.setAttribute("tabindex","0"),k.setAttribute("data-placeholder",e.captionPlaceholder),k.style.flex="1",k.style.minWidth="0",k.innerHTML=O(o.caption),e.addEventListener(t,k,"input",Gr.handleInput),e.addEventListener(t,k,"keydown",e.handleKeydown),e.addEventListener(t,k,"click",e.handleClick),x.appendChild(k);const w=C.createStyledElement("div",`${C.classNames.block.table.downloadSwitch}`);w.style.flexShrink="0";const E=Z.create({checked:o.showDownload||!1,label:"Allow download",onToggle:e=>{const n=r.closest(`.${C.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&i.getState().partialUpdateBlockData(t,Gr.getBlockIndex(t,a),{showDownload:e})}}});w.appendChild(E),x.appendChild(w),r.appendChild(x);return e.addEventListener(t,r,"focusin",()=>{const e=document.activeElement;if(e&&r.contains(e))if(e.classList.contains(C.classNames.block.table.cell)){const t=e.closest("tr");t&&(h=t,f(t))}else e.classList.contains(C.classNames.block.table.headerCell)&&y(e)}),r}static createRow(t,n,a){const o=i.getState().getInstance(t),r=o?.config.classNames?.blocks?.table?.row,s=o?.config.styles?.blocks?.table?.row,l=C.createStyledElement("tr",a?`${C.classNames.block.table.headerRow}`:`${C.classNames.block.table.row}`,{classNames:r,styles:s});for(let i=0;i<n.length;i++)l.appendChild(a?e.createHeaderCell(t,n[i]):e.createCell(t,n[i]));return l.querySelector(`.${C.classNames.block.table.cell}`)?.focus(),l}static createCell(t,n){const a=i.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,r=a?.config.styles?.blocks?.table?.cell,s=C.createStyledElement("td",`${C.classNames.block.table.cell}`,{classNames:o,styles:r});return s.contentEditable="true",s.setAttribute("tabindex","0"),s.setAttribute("data-placeholder",e.cellPlaceholder),s.innerHTML=O(n),e.addEventListener(t,s,"input",Gr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"click",e.handleClick),s}static createHeaderCell(t,n){const a=i.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,r=a?.config.styles?.blocks?.table?.header,s=C.createStyledElement("th",`${C.classNames.block.table.headerCell}`,{classNames:o,styles:r});return s.contentEditable="true",s.setAttribute("tabindex","0"),s.setAttribute("data-placeholder",e.headerPlaceholder),s.innerHTML=O(n),e.addEventListener(t,s,"input",Gr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"click",e.handleClick),s}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=Gr.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=Gr.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,l,c){c&&(c.remove(),c=null);const d=C.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:l?.classNames?.menu,styles:l?.styles?.menu});d.classList.add("clepit-block-operations-menu--visible"),d.style.position="absolute",d.style.zIndex="20",d.style.left=`${r}px`,d.style.top=`${s}px`,d.style.minWidth="180px",i.forEach(n=>{const a="delete"===n.label.toLowerCase(),o=C.createStyledElement("div","clepit-menu-item"+(a?" clepit-menu-item--danger":""),{classNames:l?.classNames?.menuItem,styles:l?.styles?.menuItem});o.style.fontSize="14px";const i=C.createStyledElement("span","clepit-menu-icon"),r=n.label.toLowerCase();r.includes("move up")?i.textContent="↑":r.includes("move down")?i.textContent="↓":r.includes("move left")?i.textContent="←":r.includes("move right")?i.textContent="→":r.includes("insert")?i.textContent="+":r.includes("delete")?i.textContent="×":i.textContent="•";const s=C.createStyledElement("span","clepit-menu-text");if(s.textContent=n.label,o.appendChild(i),o.appendChild(s),n.shortcut){const e=C.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,o.appendChild(e)}e.addEventListener(t,o,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),c&&(c.remove(),c=null)}),d.appendChild(o)}),n.appendChild(d),c=d;const p=e=>{d.contains(e.target)||e.target===a||e.target===o||(d.remove(),c=null,document.removeEventListener("click",p))};return setTimeout(()=>document.addEventListener("click",p),0),d}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${C.classNames.block.container}`);t&&Gr.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=Gr.getEditorId(n);if(!a)return;const o=n.closest(`.${C.classNames.block.container}`);if(!o)return;const i=Gr.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Gr.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Gr.getBlocks(a);t&&i<t.length-1&&Gr.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),Gr.saveBlockData(t);const i=t.querySelectorAll(`.${C.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),Gr.saveBlockData(t);const i=t.querySelectorAll(`.${C.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const l=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))t=l.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=l[a-1],r=l[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${C.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}Gr.saveBlockData(s)}break;case"ArrowRight":let c=-1;const d=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))c=d.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");c=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(c<d.length-1){e.preventDefault(),e.stopPropagation();const t=c,a=d[t],i=d[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${C.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}Gr.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),Gr.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),Gr.removeBlock(a,i);break;case"Delete":let p=-1;const u=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))p=u.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");p=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(p>=0&&u.length>1){e.preventDefault(),e.stopPropagation();const t=u[p];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${C.classNames.block.table.cell}`);t[p]&&t[p].parentElement?.removeChild(t[p])}),Gr.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),Gr.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),Gr.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell},.${C.classNames.block.table.headerCell}`)).every(e=>z(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),Gr.removeBlock(a,i))}else{Gr.ensureActiveBlock(a);const o=Gr.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(C.classNames.block.table.caption)){const e=n.closest(`.${C.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&Gr.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(C.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&Gr.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const l=n.closest("tr"),c=Array.from(l?.cells||[]).indexOf(n);if("THEAD"===l?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[c])return void e.cells[c].focus()}if(l?.nextElementSibling){const e=l.nextElementSibling.cells[c];e&&e.focus()}else{if("TBODY"===l?.parentElement?.tagName&&l===l.parentElement.lastElementChild){const e=s.closest(`.${C.classNames.block.container}`)?.querySelector(`.${C.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&Gr.focusBlock(e)}}return;case"ArrowLeft":if(!H(n,"left"))return;e.preventDefault(),e.stopPropagation();const d=n.closest("table");if(!d)return;const p=n.closest("tr"),u=Array.from(p?.cells||[]).indexOf(n);if(u>0){const e=p?.cells[u-1];e&&e.focus()}else{if("TBODY"===p?.parentElement?.tagName&&p===p.parentElement.firstElementChild){const e=d.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(p?.previousElementSibling){const e=p.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!H(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const h=n.closest("tr"),g=Array.from(h?.cells||[]).indexOf(n);if(g<(h?.cells.length||0)-1){const e=h?.cells[g+1];e&&e.focus()}else{if("THEAD"===h?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(h?.nextElementSibling){const e=h.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.table.caption}`),n=e.querySelectorAll(`.${C.classNames.block.table.cell},.${C.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?z(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>z(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return z(e.caption)&&e.data.every(e=>e.every(e=>z(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},oo="http://www.w3.org/2000/svg",io=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],ro=/^[=+@\t\r-]/,so=class e{static{this.eventListenersMap=new WeakMap}static render(t,n,a,o,i){if(C.injectStyles("clepit-table-output-styles",no),!e.validate(t))return P();if(ao.isEmptyData(t))return document.createElement("div");const r=e.draw(t,L);if(!r)return document.createElement("div");const s=D(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const l=s.querySelector(".clepit-output-table-caption");l&&o?.caption&&l.classList.add(o.caption),l&&a?.caption&&Object.assign(l.style,a.caption);const c=s.querySelector(".clepit-output-table-footer-container");return c&&o?.footerContainer&&c.classList.add(o.footerContainer),c&&a?.footerContainer&&Object.assign(c.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||ao.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,r){const s=t.querySelector(".clepit-output-table-download-btn");if(!s)return()=>{};o?.downloadButton&&s.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(s.style,a.downloadButton);const l=()=>e.downloadTableAsCSV(n);s.addEventListener("click",l);const c=r?document.getElementById(r):null;if(c){const t=e.eventListenersMap.get(c)??[];t.push({element:s,event:"click",handler:l}),e.eventListenersMap.set(c,t)}const d=r?i.getState().getInstance(r):null,p=le(s,"Download CSV","above",d?.config.classNames?.tooltips,d?.config.styles?.tooltips);return()=>{s.removeEventListener("click",l),p()}}static draw(t,n=L){if(!e.validate(t)||ao.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(oo,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of io){const a=e.createNS(oo,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>ro.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},lo="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",co=lo,po=lo,uo={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},mo=class{static render(e,t,n,a){C.injectStyles("toc-output",po);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=C.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents — headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=C.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=uo[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=O(o.html),i.appendChild(r)}),i}static draw(e,t=L,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*uo[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},ho="\n.clepit-typeset {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",go=ho,bo=ho,fo=.55,yo=.52,vo=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function xo(e,t=18){switch(e.kind){case"atom":return ko(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=xo(r,t);n.push(...vo(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=xo(e.base,t),a=wo(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=xo(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...vo(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=xo(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...vo(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=xo(e.numerator,t),a=xo(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...vo(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...vo(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=xo(e.radicand,t),a=.6*t,o=null===e.index?null:xo(e.index,wo(wo(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...vo(n,i+.12*t,0)];null!==o&&s.push(...vo(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=ko(e.symbol,"upright",n),o=wo(t),i=null===e.upper?null:xo(e.upper,o),r=null===e.lower?null:xo(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...vo(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...vo(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...vo(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=xo(e.base,t),a=ko(e.over,"upright",wo(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...vo(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=xo(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:ko(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:ko(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...vo(i,0,s(i)),...vo(n,i.width,0),...vo(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>xo(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let v=0;v<a;v+=1)o.push(Math.max(...n.map(e=>e[v]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[v,x]of n.entries()){u+=i[v]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...vo(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[v]??0)+l}const[m,h]=Co[e.style],g=Math.max(t,.62*d),b=""===m?{depth:0,draw:[],height:0,width:0}:ko(m,"upright",g),f=""===h?{depth:0,draw:[],height:0,width:0}:ko(h,"upright",g),y=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...vo(b,0,y(b)),...p.map(e=>({...e,x:e.x+b.width})),...vo(f,b.width+c,y(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function ko(e,t,n){const a="italic"===t?fo:yo;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function wo(e){return Math.max(9,.7*e)}var Co={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var Eo={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},So={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},Ao={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},No=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],Lo={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},Bo={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},Io={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},$o=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],To={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},Mo=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,_o=/[A-Za-z]/,Do=/[0-9]/,qo={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},jo=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!_o.test(this.peek()))return this.take();let e="";for(;_o.test(this.peek());)e+=this.take();return e}},zo=class extends Error{};function Oo(e){const t=new jo(e);try{const e=Ho(t,null);if(Ro(t))throw new zo("a \\right appears without a matching \\left");if(!t.done)throw new zo(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof zo)return{ok:!1,reason:n.message};throw n}}function Ho(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!Po(e)&&!Fo(e))&&!Ro(e);){const t=Uo(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function Po(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function Ro(e){return!!e.source.startsWith("\\right",e.at)&&!_o.test(e.peek(6))}function Fo(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function Uo(e){const t=Vo(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=Vo(e);if(null===o)throw new zo(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new zo("a term carries two superscripts");a=o}else{if(null!==n)throw new zo("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function Vo(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=Ho(e,"}");if("}"!==e.peek())throw new zo("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if($o.includes(t))throw new zo(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new zo("a row break appears outside a matrix");if("begin"===t)return function(e){const t=Ko(e),n=To[t];if(void 0===n)throw new zo(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(Ho(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!Po(e)){if(Fo(e)){e.at+=4;const i=Ko(e);if(i!==t)throw new zo(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new zo(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new zo(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new zo("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=Wo(e);return{denominator:Wo(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=Ho(e,"]"),"]"!==e.peek())throw new zo("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:Wo(e)}}(e);if("left"===t)return function(e){const t=Go(e,"left"),n=Ho(e,null);if(!Ro(e))throw new zo("a \\left has no matching \\right");return e.at+=6,{body:n,close:Go(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new zo("a \\right appears without a matching \\left");const n=qo[t];if(void 0!==n)return{kind:"atom",style:n,text:Ko(e)};const a=Lo[t];if(void 0!==a)return{base:Wo(e),kind:"accent",over:a};if("overline"===t)return{base:Wo(e),kind:"accent",over:"‾"};if("underline"===t)return{base:Wo(e),kind:"accent",over:"_"};const o=Ao[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=Eo[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=So[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(No.includes(t))return{kind:"atom",style:"upright",text:t};const s=Bo[t];if(void 0!==s)return{kind:"space",width:s};const l=Io[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new zo(`"\\${t}" is not supported yet`)}(e);if(Mo.test(t))return e.take(),{kind:"atom",style:Do.test(t)?"upright":"italic",text:t};throw new zo(`"${t}" is not a character this engine understands`)}function Wo(e){if(e.skipSpace(),"{"!==e.peek()){const t=Vo(e);if(null===t)throw new zo("a command is missing its argument");return t}e.take();const t=Ho(e,"}");if("}"!==e.peek())throw new zo("a { group is never closed");return e.take(),t}function Ko(e){if(e.skipSpace(),"{"!==e.peek())throw new zo("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new zo("a text command’s { group is never closed")}function Go(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=Io[`\\${t}`];if(void 0===n)throw new zo(`"\\${t}" is not a delimiter this engine understands`);return n}const a=Io[n];if(void 0===a)throw new zo(`\\${t} is missing a delimiter`);return e.take(),a}var Jo={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function Xo(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function Yo(e,t=L){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=Xo("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=Jo[r.style],n=Xo("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(Zo(r,o,t)):i.append(Xo("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function Zo(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return Xo("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var Qo=72,ei=40,ti=28,ni=16;function ai(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=new Map,a=new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=new Map;for(const b of e.nodes)o.set(b.id,oi(b.label,Qo));const i=new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*ei+(e.length-1)*ti:e.reduce((e,t)=>e+(o.get(t)??Qo),0)+(e.length-1)*ti,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=ni+b*((t?Qo:ei)+64);let c=ni+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??Qo;i.set(a,{height:ei,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?ei:s)+ti}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,m=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),h=m.some(e=>e.points.length>2),g=t?d:Math.max(d,h?u:0);return{edges:m,height:(t?Math.max(p,h?u:0):p)+ni,kind:"flowchart",nodes:c,width:g+ni}}(e):function(e){const t=[];let n=ni;for(const m of e.participants){const e=oi(m.label,96);t.push({actor:m.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:m.id,label:m.label}),n+=e+ti}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const m of e.steps){if("activation"===m.kind){m.active?s.set(m.participant,l):c(m.participant,l);continue}if("note"===m.kind){const e=m.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=oi(m.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===m.placement?n-t-ti:"right"===m.placement?o+ti:(n+o)/2-t/2;i.push({height:34,text:m.text,width:t,x:r,y:l}),l+=62;continue}const e=a(m.from),t=a(m.to);null!==e&&null!==t&&(m.activate&&s.set(m.to,l),o.push({end:m.end,fromX:e,line:m.line,selfCall:m.from===m.to,text:m.text,toX:t,y:l}),l+=48,m.deactivate&&c(m.to,l))}const d=l;for(const m of[...s.keys()])c(m,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-ti+ni,p+ni);return{activations:r,height:d+ni,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function oi(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var ii=["BT","LR","RL","TB","TD"],ri=["subgraph","end","click","style","classDef","class","linkStyle","direction"],si=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],li=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],ci=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],di=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],pi=e=>({ok:!1,reason:e});function ui(e){return e.split(/[\s(]/,1)[0]??""}function mi(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return pi("the block is empty");const[n,...a]=t,o=ui(n??"");return"sequenceDiagram"===o?function(e){const t=new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=ui(o);if(si.includes(e))return pi(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=vi(o,e);if(null===n)return pi(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!yi(t))return pi(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=xi(o);if(null===e)return pi(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=ki(o);if(null===i)return pi(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(ui(e).length).trim();if(0===n.length)return pi('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=ii.find(e=>e===n);if(void 0===a)return pi(`"${n}" is not a supported direction — use TD, TB, BT, LR or RL`);const o=new Map,i=[];for(const r of t){const e=ui(r);if(ri.includes(e))return pi(`"${e}" is not supported yet`);if(r.includes("&"))return pi('"&" fan-out is not supported yet');const t=hi(r,o,i);if(null!==t)return pi(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):pi(`"${o}" diagrams are not supported yet — only flowchart and sequenceDiagram are`)}function hi(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=gi(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=fi(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function gi(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=li.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of li){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=bi(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function bi(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function fi(e){const t=e.trim();if(0===t.length)return null;for(const n of di){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(yi(a))return{id:a,label:o.trim(),shape:n.shape}}return yi(t)?{id:t,label:t,shape:"rect"}:null}function yi(e){return/^[A-Za-z_][\w-]*$/.test(e)}function vi(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!yi(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function xi(e){const t=e.slice(ui(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(yi)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return yi(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function ki(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of ci){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(yi(t)&&yi(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var wi={dotted:"5 4",solid:"",thick:""},Ci={dotted:1.5,solid:1.5,thick:3};function Ei(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function Si(e,t,n,a,o){const i=Ei("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function Ai(e,t=L){const n=Ei("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=Ei("defs",{},e),n=Ei("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(Ei("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)Li(e,a,n);for(const a of t.nodes)Ni(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(Ei("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(Ei("rect",o,n)),e.append(Si(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(Ei("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)Bi(e,a,n);for(const a of t.notes)e.append(Ei("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(Si(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function Ni(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return Ei("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return Ei("polygon",{...s,points:e},t)}if("stadium"===a)return Ei("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return Ei("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=Ei("g",{},t);return e.append(Ei("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(Ei("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(Ei("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return Ei("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(Si(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function Li(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?Ei("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":wi[t.line],"stroke-width":Ci[t.line]},n):Ei("line",{class:"clepit-typeset__edge","stroke-dasharray":wi[t.line],"stroke-width":Ci[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=Si(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function Bi(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":wi[t.line],"stroke-width":Ci[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=Ei("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(Si(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=Ei("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(Ei("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(Ei("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(Si(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var Ii=class e{static render(t,n,a,o,i){if(C.injectStyles("typeset-output",bo),!e.validate(n))return P();const r=C.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=mi(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(D(Ai(ai(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=Oo(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(D(Yo(xo(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=L){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=mi(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(Ai(ai(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=Oo(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(Yo(xo(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},$i=class{static render(e,t,n,a){return Ii.render("LaTeX",e,t,n,a)}static draw(e,t=L){return Ii.draw("LaTeX",e,t)}},Ti=class{static render(e,t,n,a){return Ii.render("Mermaid",e,t,n,a)}static draw(e,t=L){return Ii.draw("Mermaid",e,t)}},Mi="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",_i=Mi,Di=Mi,qi=class{static render(e,t,n,a){C.injectStyles("updates-output",Di);const o=C.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=L){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},ji=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${C.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${C.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${C.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,zi="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Oi=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${C.classNames.block.video.captionEditable}`),o=e.querySelector(`.${C.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:O(a?.innerHTML),url:r}}static render(t,n,a,o){C.injectStyles("clepit-video-input-styles",ji);const i=a||{alt:"",caption:"",url:""},r=C.createStyledElement("div",C.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=at(n?.url||""),l=ot(n?.url||"");if(s||l){const e=C.createStyledElement("iframe",C.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=C.createStyledElement("video",C.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const c=C.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-video-caption-container");const d=C.createStyledElement("div",C.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",e.placeholder),d.innerHTML=n?.caption||"",e.addEventListener(o,d,"input",Gr.handleInput),e.addEventListener(o,d,"keydown",Gr.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="🎥";const l=C.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const c=C.createStyledElement("button",`${C.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});c.type="button",c.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),e.addEventListener(a,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Gr.removeBlock(a,Gr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?i.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;le(c,"Delete block","below",p,u),t.appendChild(r)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Gr.getBlockIndex(o,l),Gr.getBlockData(l).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(s){console.error("Video upload error:",s),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=Gr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Gr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.video.wrapper} video`),n=e.querySelector(`.${C.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${C.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?z(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Hi=class e{static render(t,n,a,o){if(C.injectStyles("clepit-video-output-styles",zi),!e.validate(t))return P();if(Oi.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=C.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":c.classList.add("clepit-output-video-wrapper--left");break;case"center":c.classList.add("clepit-output-video-wrapper--center");break;case"right":c.classList.add("clepit-output-video-wrapper--right")}const d=at(i),p=ot(i);if(d||p){const e=q("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",c.appendChild(e),l.appendChild(c)}else{const e=q("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",c.appendChild(e),l.appendChild(c)}if(r){const e=C.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=L){if(!e.validate(t)||Oi.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Pi=(e,t,n)=>{const a=Ri(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},Ri=(e,t,n)=>{switch(e.type){case"alert":return an.draw(e.data,t);case"audio":return cn.draw(e.data,t);case"checklist":return hn.draw(e.data,t);case"code":return pe.draw(e.data,t,n);case"collapsible":return Ui.draw(e.data,t,n);case"collection":return Sn.draw(e.data,t);case"columns":return Bn.draw(e.data,t,n);case"date":return Dn.draw(e.data,t);case"delimiter":return zn.draw(e.data,t);case"doc_card":return Rn.draw(e.data,t,n);case"embed":return Ve.draw(e.data,t,n);case"file":return Kn.draw(e.data,t);case"glance":return Xn.draw(e.data,t);case"header":return Qn.draw(e.data,t);case"image":return aa.draw(e.data,t);case"issues":return sa.draw(e.data,t,n);case"latex":return $i.draw(e.data,t);case"list":return da.draw(e.data,t);case"mermaid":return Ti.draw(e.data,t);case"openapi":return Ha.draw(e.data,t);case"paragraph":return Fa.draw(e.data,t);case"quote":return Ka.draw(e.data,t);case"sketch":return eo.draw(e.data,t);case"table":return so.draw(e.data,t);case"toc":return mo.draw(e.data,t,n);case"updates":return qi.draw(e.data,t);case"video":return Hi.draw(e.data,t);default:return Fi(e)}},Fi=e=>(console.warn("drawBlock: no drawer for block",e),null),Ui=class e{static render(t,n,a,o){if(C.injectStyles("collapsible-output",vn),!e.validate(t))return P();const i=C.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=O(t.html),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="clepit-collapsible__children";for(const c of t.children??[])l.appendChild(e.renderChild(c,n));return i.appendChild(l),i}static renderChild(e,t){const n=zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=Pi(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},Vi={icon:"▸",get input(){return kn},label:"Collapsible section",get output(){return Ui},shortcut:yt("E"),testId:"block-type-collapsible",type:"collapsible"},Wi=new WeakMap,Ki=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=Wi.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){C.injectStyles("collection-input",Cn);const a=t??{collectionId:""},o=Sn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),Wi.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Gi={icon:"▦",get input(){return Ki},label:"Collection",get output(){return Sn},shortcut:yt("G"),testId:"block-type-collection",type:"collection"},Ji=new WeakMap;var Xi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=Ji.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){C.injectStyles("columns-input",Nn);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=C.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return Ji.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=C.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=Gr.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Yi={icon:"▥",get input(){return Xi},label:"Columns",get output(){return Bn},shortcut:yt("L"),testId:"block-type-columns",type:"columns"},Zi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){C.injectStyles("date-input",$n);const o=C.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&_n(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Qi={icon:"▤",get input(){return Zi},label:"Date",get output(){return Dn},shortcut:yt("D"),testId:"block-type-date",type:"date"},er={icon:"—",get input(){return jn},label:"Delimiter",get output(){return zn},shortcut:yt("D"),testId:"block-type-delimiter",type:"delimiter"},tr=new WeakMap,nr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=tr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){C.injectStyles("doc-card-input",Hn);const a=t??{pageId:"",title:""},o=Rn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),tr.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ar={icon:"🗎",get input(){return nr},label:"Doc card",get output(){return Rn},shortcut:yt("K"),testId:"block-type-doc-card",type:"doc_card"},or={icon:"🔗",get input(){return Ze},label:"Embed",get output(){return Ve},shortcut:yt("M"),testId:"block-type-embed",type:"embed"},ir=new WeakMap,rr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=ir.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){C.injectStyles("file-input",Un);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&ir.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=ir.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=Kn.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);ir.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},sr={icon:"📎",get input(){return rr},label:"File",get output(){return Kn},shortcut:yt("F"),testId:"block-type-file",type:"file"},lr={html:"",label:""},cr=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:O(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){C.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[lr]},o=Xn.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder","Label");for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder","Value");return o}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const r=Gr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),s={...e.save(t),variant:n},l={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},c=e.render(a,s,l);t.replaceWith(c),i.getState().updateBlockData(a,r,s)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===O(e.html).trim())}static destroy(e){}},dr={icon:"≡",get input(){return cr},label:"At a glance",get output(){return Xn},shortcut:yt("N"),testId:"block-type-glance",type:"glance"},pr={icon:"H",get input(){return Zn},label:"Header",get output(){return Qn},shortcut:yt("H"),testId:"block-type-header",type:"header"},ur={icon:"𝑖",get input(){return na},label:"Image",get output(){return aa},shortcut:yt("I"),testId:"block-type-image",type:"image"},mr={},hr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){C.injectStyles("issues-input",oa);const a=i.getState().getInstance(e)?.config,o=i.getState().getData(e)?.blocks??[],r=sa.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:mr[e]},n?.styles,n?.classNames);return r.classList.add("clepit-issues--input"),r.setAttribute("contenteditable","false"),r}static refresh(t,n){mr[t]={...mr[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${C.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${C.classNames.block.content}`);if(!n)continue;const a=i.getState().getInstance(t),r={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},r))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete mr[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},gr={icon:"☑",get input(){return hr},label:"Linked issues",get output(){return sa},shortcut:yt("J"),testId:"block-type-issues",type:"issues"},br={icon:"•",get input(){return ca},label:"List",get output(){return da},shortcut:yt("L"),testId:"block-type-list",type:"list"},fr="clepit-openapi__source",yr=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},vr=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=new WeakMap}static render(t,n,a){C.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=q("div","clepit-openapi-input"),i=q("div",fr);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",e.placeholder),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=q("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(Ha.render(n)),i.addEventListener("input",()=>{const t=yr(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(Ha.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains(fr)?e:e.querySelector(`.${fr}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return yr(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},xr={icon:"⇄",get input(){return vr},label:"API reference",get output(){return Ha},shortcut:yt("A"),testId:"block-type-openapi",type:"openapi"},kr={icon:"¶",get input(){return Ra},label:"Paragraph",get output(){return Fa},shortcut:yt("P"),testId:"block-type-paragraph",type:"paragraph"},wr={icon:"“",get input(){return Wa},label:"Quote",get output(){return Ka},shortcut:yt("Q"),testId:"block-type-quote",type:"quote"},Cr=new WeakMap,Er=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?Cr.get(t):void 0)??{strokes:[]}}static render(t,n,a){C.injectStyles("sketch-input",Ja);const o=n??{strokes:[]},i=eo.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),Cr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=Cr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=eo.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=Cr.get(n)??{strokes:[]};Cr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Sr={icon:"✏️",get input(){return Er},label:"Sketch",get output(){return eo},shortcut:yt("W"),testId:"block-type-sketch",type:"sketch"},Ar={icon:"⊞",get input(){return ao},label:"Table",get output(){return so},shortcut:yt("T"),testId:"block-type-table",type:"table"},Nr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){C.injectStyles("toc-input",co);const a=i.getState().getData(e)?.blocks??[],o=mo.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Lr={icon:"≡",get input(){return Nr},label:"Table of contents",get output(){return mo},shortcut:yt("T"),testId:"block-type-toc",type:"toc"},Br={latex:"LaTeX",mermaid:"Mermaid"};function Ir(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function $r(e,t,n){C.injectStyles("typeset-input",go);const a=t??{source:""},o=C.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:n?.classNames?.wrapper,styles:n?.styles?.wrapper});o.setAttribute("data-language",e),o.setAttribute("data-rendered","source");const i=q("span","clepit-typeset__kind");i.textContent=Br[e],o.appendChild(i);const r=q("span","clepit-typeset__title");r.setAttribute("data-testid","typeset-title"),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder","mermaid"===e?"What does this diagram show?":"What does this formula show?"),r.textContent=a.title??"",o.appendChild(r);const s=q("pre","clepit-typeset__source");return s.setAttribute("contenteditable","true"),s.textContent=a.source,o.appendChild(s),o}var Tr=class{static{this.placeholder=""}static save(e){return Ir(e)}static render(e,t,n){return $r("latex",t,n)}static isEmpty(e){return""===Ir(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Mr=class{static{this.placeholder=""}static save(e){return Ir(e)}static render(e,t,n){return $r("mermaid",t,n)}static isEmpty(e){return""===Ir(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},_r={icon:"∑",get input(){return Tr},label:"LaTeX",get output(){return $i},shortcut:yt("X"),testId:"block-type-latex",type:"latex"},Dr={icon:"◈",get input(){return Mr},label:"Mermaid",get output(){return Ti},shortcut:yt("Y"),testId:"block-type-mermaid",type:"mermaid"},qr=new WeakMap,jr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=qr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){C.injectStyles("updates-input",_i);const a=t??{},o=qi.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),qr.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zr=[on,dn,gn,bn,Vi,Gi,{icon:"🕘",get input(){return jr},label:"Updates",get output(){return qi},shortcut:yt("U"),testId:"block-type-updates",type:"updates"},Yi,Qi,er,ar,or,sr,dr,pr,ur,gr,br,xr,kr,wr,Sr,_r,Dr,Ar,Lr,{icon:"▶",get input(){return Oi},label:"Video",get output(){return Hi},shortcut:yt("V"),testId:"block-type-video",type:"video"}],Or="clepit-block-type-selector",Hr="clepit-code-language-submenu",Pr="clepit-code-theme-submenu",Rr="clepit-convert-submenu",Fr="clepit-block-operations-menu";function Ur(e){return Vt.includes(e)}function Vr(e,t,n){return e?.[t]??n}var Wr,Kr=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=i.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const r=void 0!==a.config.audioUploader,s=void 0!==a.config.imageUploader,l=void 0!==a.config.videoUploader,c=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,p=a.config.classNames?.convertSubmenu,u=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,h=a.config.styles?.blockTypeMenu,g=a.config.styles?.convertSubmenu,b=a.config.styles?.operationsMenu;e.remove(n),C.injectStyles("clepit-block-toolbar-styles",'\n/* Block Toolbar */\n.clepit-block-toolbar {\n position: absolute;\n left: 4px;\n top: 4px;\n z-index: 1000;\n display: none;\n gap: 4px;\n flex-shrink: 0;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n transform: translateY(0) !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-block-toolbar-add:active,\n.clepit-block-toolbar-ops:active {\n transform: scale(0.95);\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n z-index: 998;\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const f=q("div",e.defaultClassName);f.id=`${t}-block-toolbar`,f.innerHTML="",C.applyStyling(f,{classNames:c?.container,styles:m?.container});const y=q("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML="+",C.applyStyling(y,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:r,block:n,classNames:d,containerId:t,imageIsEnabled:s,menuLabels:a.config.blockToolbarLabels,styles:h,toolLabels:a.config.blockToolLabels,videoIsEnabled:l}));const v=q("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});v.innerHTML="⋯",C.applyStyling(v,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,v,"click",()=>e.showOperationsMenu({audioIsEnabled:r,block:n,classNames:u,containerId:t,convertSubmenuClassNames:p,convertSubmenuStyles:g,imageIsEnabled:s,operationLabels:a.config.blockToolbarLabels,styles:b,toolLabels:a.config.blockToolLabels,videoIsEnabled:l})),f.appendChild(y),f.appendChild(v),e.addEventListener(o,f,"click",e=>e.stopPropagation()),n.appendChild(f)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:r,classNames:s,styles:l,menuLabels:c,toolLabels:d}){e.closeAllMenus();const p=document.querySelector(`.${Or}`);if(p)return p.classList.remove(`${Or}--visible`),p.classList.add(`${Or}--hidden`),void setTimeout(()=>p.remove(),200);const u=q("div",Or);C.applyStyling(u,{classNames:s?.container,styles:l?.container});const m=q("input","",{placeholder:Vr(c,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),C.applyStyling(m,{classNames:s?.input,styles:l?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=q("div",`${Or}-items`),b=i=>{g.innerHTML="",i.forEach(i=>{if("image"===i.type&&!a)return;if("video"===i.type&&!o)return;if("audio"===i.type&&!r)return;const c=q("div","clepit-menu-item clepit-block-type-item");c.setAttribute("data-testid",`block-type-${i.type}`),C.applyStyling(c,{classNames:s?.item?.container,styles:l?.item?.container});const p=q("span","clepit-menu-icon "+("image"===i.type?"clepit-menu-icon--italic":""));p.textContent=i.icon,C.applyStyling(p,{classNames:s?.item?.icon,styles:l?.item?.icon}),c.appendChild(p);const m=q("span","clepit-menu-label");if(m.textContent=(Ur(i.type)?d?.[i.type]:void 0)??i.label,C.applyStyling(m,{classNames:s?.item?.text,styles:l?.item?.text}),c.appendChild(m),i.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=i.shortcut,C.applyStyling(e,{classNames:s?.item?.shortcut,styles:l?.item?.shortcut}),c.appendChild(e)}e.addEventListener(h,c,"click",e=>{if(e.stopPropagation(),n){const e=Gr.getBlockIndex(t,n.getAttribute("data-id")||"");Gr.insertBlock({data:{html:""},type:i.type},t,e+1)}u.hidePopover()}),g.appendChild(c)})},f=((e,t)=>t.filter(t=>rt(e,t.type)))(i.getState().getInstance(t)?.config,zr);if(b(f),e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",()=>{const e=m.value.toLowerCase(),t=f.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e));if(b(t),0===t.length&&""!==e.trim()){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Vr(c,"noBlockTypesFound","No block types found"),g.appendChild(e)}}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.hidePopover()}),u.appendChild(g),u.classList.add(Or),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}document.body.appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Or}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||u.remove()})):u.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:c,operationLabels:d,toolLabels:p}){e.closeAllMenus();const u=q("div",Fr);o?.container&&C.applyStyling(u,{classNames:a?.container,styles:o.container}),a?.container&&u.classList.add(a.container);const m=q("input","",{placeholder:Vr(d,"searchOperations","Search operations..."),type:"text"});m.setAttribute("data-testid","operations-search"),C.applyStyling(m,{classNames:a?.input,styles:o?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=q("div",`${Fr}-items`),b=n.getAttribute("data-tool");if(!b)return;const f=(e,t)=>Vr(d,e,t),y=[{hasSubmenu:!0,icon:"↻",label:f("convert","Convert To"),testId:"operation-convert",value:"convert"},{icon:"↑",label:f("moveUp","Move Up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"},{icon:"↓",label:f("moveDown","Move Down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"},{icon:"×",label:f("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"}],v=[{icon:"←",label:f("alignLeft","Align Left"),testId:"image-align-left",value:"imageAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"image-align-center",value:"imageAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"image-align-right",value:"imageAlignRight"}],x=[{icon:"←",label:f("alignLeft","Align Left"),testId:"video-align-left",value:"videoAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"video-align-center",value:"videoAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"video-align-right",value:"videoAlignRight"}],k=[{icon:"←",label:f("alignLeft","Align Left"),testId:"audio-align-left",value:"audioAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"audio-align-center",value:"audioAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"audio-align-right",value:"audioAlignRight"}],w=[{hasSubmenu:!0,icon:"⌘",label:f("codeLanguage","Language"),testId:"code-language",value:"codeLanguage"},{hasSubmenu:!0,icon:"◆",label:f("codeTheme","Theme"),testId:"code-theme",value:"codeTheme"}],E="embed"===b&&Ze.save(n).issue?[{icon:"▭",label:f("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:"▣",label:f("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:"▭",label:f("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];y.forEach(m=>{const b=q("div","clepit-menu-item clepit-block-operation-item");b.setAttribute("data-testid",`operation-${m.value}`),C.applyStyling(b,{classNames:a?.item?.container,styles:o?.item?.container}),b.setAttribute("data-testid",m.testId);const f=q("span","clepit-menu-icon");f.textContent=m.icon,C.applyStyling(f,{classNames:a?.item?.icon,styles:o?.item?.icon}),b.appendChild(f);const y=q("span","clepit-menu-label");if(y.textContent=m.label,C.applyStyling(y,{classNames:a?.item?.text,styles:o?.item?.text}),b.appendChild(y),m.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=m.shortcut,C.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),b.appendChild(e)}if(m.hasSubmenu){const e=q("span","clepit-menu-arrow");e.textContent="›",b.appendChild(e)}"delete"===m.value&&(b.classList.add("clepit-block-toolbar--delete-enabled"),1===h.querySelectorAll(".clepit-block").length&&(b.classList.add("clepit-block-toolbar--delete-disabled"),b.title="Cannot delete the last block")),e.addEventListener(h,b,"click",a=>{a.stopPropagation(),m.hasSubmenu?(document.querySelector(`.${Hr}`)?.remove(),document.querySelector(`.${Pr}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:c,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:d,parentItem:b,parentMenu:u,styles:r,toolLabels:p,videoIsEnabled:l})):(e.handleOperationSelect(m.value,n,t),u.remove())}),g.appendChild(b)});const S=()=>{const e=q("div","clepit-menu-divider");C.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),g.appendChild(e)};if("image"===b&&(S(),v.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("imageAlign")){const e=n.querySelector(".clepit-image-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("imageAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"video"===b&&(S(),x.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("videoAlign")){const e=n.querySelector(".clepit-video-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("videoAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"audio"===b&&(S(),k.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("audioAlign")){const e=n.querySelector(".clepit-audio-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("audioAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"code"===b&&(S(),w.forEach(s=>{const l=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(l,{classNames:a?.item?.container,styles:o?.item?.container}),l.setAttribute("data-testid",s.testId);const c=q("span","clepit-menu-icon");c.textContent=s.icon,C.applyStyling(c,{classNames:a?.item?.icon,styles:o?.item?.icon}),l.appendChild(c);const p=q("span","clepit-menu-label");if(p.textContent=s.label,C.applyStyling(p,{classNames:a?.item?.text,styles:o?.item?.text}),l.appendChild(p),s.hasSubmenu){const e=q("span","clepit-menu-arrow");e.textContent="›",l.appendChild(e)}e.addEventListener(h,l,"click",a=>{a.stopPropagation(),s.hasSubmenu?"codeLanguage"===s.value?e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):"codeTheme"===s.value&&e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):(e.handleOperationSelect(s.value,n,t),u.remove())}),g.appendChild(l)})),"embed"===b&&(S(),E.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"header"===b){S();const i=e.getCurrentHeadingLevel(n);[{icon:"H1",label:f("headingH1","Heading 1"),value:"heading-h1"},{icon:"H2",label:f("headingH2","Heading 2"),value:"heading-h2"},{icon:"H3",label:f("headingH3","Heading 3"),value:"heading-h3"},{icon:"H4",label:f("headingH4","Heading 4"),value:"heading-h4"},{icon:"H5",label:f("headingH5","Heading 5"),value:"heading-h5"},{icon:"H6",label:f("headingH6","Heading 6"),value:"heading-h6"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===`heading-${i}`&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(r.value,n,t),u.remove()}),g.appendChild(s)})}if("list"===b){S();const i=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";[{icon:"•",label:f("listUnordered","Unordered"),value:"unordered"},{icon:"1.",label:f("listOrdered","Ordered"),value:"ordered"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`listType${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("alert"===b){S();const i=n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info";[{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"},{icon:"—",label:f("variantPlain","Plain"),value:"plain"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`alertVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("glance"===b){S();const i=n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain";[{icon:"—",label:f("variantPlain","Plain"),value:"plain"},{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`glanceVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("delimiter"===b){S();const i=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";[{icon:"—",label:f("delimiterLine","Line"),value:"line"},{icon:"***",label:f("delimiterStars","Stars"),value:"stars"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`delimiterVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}const A=g.querySelectorAll(".clepit-block-operation-item"),N=g.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",e=>{(e=>{let t=0;A.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=g.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=f("noOperationsFound","No operations found"),g.appendChild(e)}}else n&&n.remove();N.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.remove()}),u.appendChild(g),u.classList.add(Fr),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}document.body.appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Fr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||u.remove()})):u.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:r,styles:s,imageIsEnabled:l,videoIsEnabled:c,audioIsEnabled:d,menuLabels:p,toolLabels:u}){const m=document.querySelector(`.${Rr}`);m&&m.remove();const h=n.getAttribute("data-tool");if(!h)return;const g=q("div",Rr);g.classList.add(Rr),g.classList.add(`${Rr}--hidden`),s?.container&&C.applyStyles(g,s.container),r?.container&&g.classList.add(r.container);const b=q("input","",{placeholder:Vr(p,"searchConvertOptions","Search convert options..."),type:"text"});b.setAttribute("data-testid","convert-search"),C.applyStyling(b,{classNames:r?.input,styles:s?.input}),g.appendChild(b),setTimeout(()=>b.focus(),10);const f=document.querySelector(`#${t}`),y=q("div",`${Rr}-items`),v=e=>(Ur(e.type)?u?.[e.type]:void 0)??e.label,x=i.getState().getInstance(t)?.config;zr.filter(e=>e.type!==h&&(!!rt(x,e.type)&&(!("image"===e.type&&!l||"video"===e.type&&!c||"audio"===e.type&&!d)||void 0))).sort((e,t)=>v(e).localeCompare(v(t))).forEach(a=>{const i=q("div","clepit-menu-item clepit-convert-option-item");i.setAttribute("data-testid",a.testId),C.applyStyling(i,{classNames:r?.item?.container,styles:s?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=a.icon,C.applyStyling(l,{classNames:r?.item?.icon,styles:s?.item?.icon}),i.appendChild(l);const c=q("span","clepit-menu-label");if(c.textContent=v(a),C.applyStyling(c,{classNames:r?.item?.text,styles:s?.item?.text}),i.appendChild(c),a.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=a.shortcut,C.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),i.appendChild(e)}e.addEventListener(f,i,"click",e=>{e.stopPropagation();const i=n?.getAttribute("data-tool");if(!i)return;let r;if(n){const e=n.querySelector(".clepit-block-content");"paragraph"===i?r=e.querySelector(".clepit-paragraph")?.innerText||"":"quote"===i?r=e.querySelector(".clepit-quote-text")?.innerText||"":"list"===i?r=Array.from(e.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===i?r=e.querySelector(".clepit-alert")?.innerText||"":"header"===i&&(r=e.querySelector(".clepit-header")?.innerText||"")}const s=n?.getAttribute("data-id");s&&Gr.convertBlock(s,a.type,t),setTimeout(()=>{if(!n)return;const e=n.getAttribute("data-tool");if(r&&r.trim()){const t=n.querySelector(".clepit-block-content");if("paragraph"===e){const e=t.querySelector(".clepit-paragraph");e&&(e.innerText=r)}else if("quote"===e){const e=t.querySelector(".clepit-quote-text");e&&(e.innerText=r)}else if("list"===e){const e=t.querySelector(".clepit-list");e&&(e.innerHTML="",r.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===e){const e=t.querySelector(".clepit-alert");e&&(e.innerText=r)}else if("header"===e){const e=t.querySelector(".clepit-header");e&&(e.innerText=r)}}},0),o.remove()}),y.appendChild(i)});const k=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(f,b,"click",e=>e.stopPropagation()),e.addEventListener(f,b,"focus",e=>e.stopPropagation()),e.addEventListener(f,b,"input",e=>{(e=>{let t=0;k.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Vr(p,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(f,b,"keydown",t=>{"Escape"===t.key&&e.closeMenu(Rr)}),g.appendChild(y);const w="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",w),g.style.setProperty("position-anchor",w),g.classList.remove(`${Rr}--hidden`),g.setAttribute("popover","auto"),document.body.appendChild(g),g.addEventListener("toggle",e=>{"closed"===e.newState&&g.remove()}),"function"!=typeof g.showPopover?(o.appendChild(g),g.classList.add(`${Rr}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;g.contains(t)||a.contains(t)||o.contains(t)||g.remove()})):g.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&Gr.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&Zn.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&ca.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&nn.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&cr.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return jn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${C.classNames.block.content}`);if(!a)return;return ao.handleAction(n,a)}if(e.startsWith("embed"))return Ze.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return na.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Oi.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return ln.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;return Q.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===Gr.getBlockIndex(a.id,t.getAttribute("data-id")))return;return Q.updateTheme(t,n)}const o=Gr.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":Gr.removeBlock(a.id,o);break;case"moveUp":o>0&&Gr.moveBlock(a.id,o,o-1);break;case"moveDown":o<Gr.getBlocks(a.id).length-1&&Gr.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Hr}`);l&&l.remove();const c=document.querySelector(`.${Pr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${C.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",u=C.createStyledElement("div",Hr,{classNames:i?.container,styles:s?.container});u.classList.add(Rr,"clepit-block-toolbar--submenu-positioned");const m=q("input","",{placeholder:Vr(r,"searchLanguages","Search languages..."),type:"text"});m.setAttribute("data-testid","language-search"),u.appendChild(m);const h=Q.supportedLanguages;Object.entries(h).forEach(([t,r])=>{const l=C.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-language-${t}`);const c=C.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-language-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Hr}--hidden`),u.classList.add(`${Hr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Hr}--visible`),u.classList.add(`${Hr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Pr}`);l&&l.remove();const c=document.querySelector(`.${Hr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${C.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",u=C.createStyledElement("div",Pr,{classNames:i?.container,styles:s?.container});u.classList.add(Rr,"clepit-block-toolbar--submenu-positioned");const m=q("input","",{placeholder:Vr(r,"searchThemes","Search themes..."),type:"text"});m.setAttribute("data-testid","theme-search"),u.appendChild(m);const h=Q.supportedThemes;Object.entries(h).forEach(([t,r])=>{const l=C.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-theme-${t}`);const c=C.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-theme-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Pr}--hidden`),u.classList.add(`${Pr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Pr}--visible`),u.classList.add(`${Pr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${Or}, .${Fr}, .${Rr}`)||e.hideAllToolbars(t)}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(Or),e.closeMenu(Fr),e.closeMenu(Rr)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},Gr=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=i.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=q("div",C.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const r={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let s,l;if(r.margins&&(s=r.margins.top,l=r.margins.bottom),void 0===s&&r.styles){const e=r.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}if(void 0===l&&r.styles){const e=r.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?l=parseInt(t.replace("px",""),10):"number"==typeof t&&(l=t)}}void 0===s&&void 0!==a.config.margins?.top&&(s=a.config.margins.top),void 0===l&&void 0!==a.config.margins?.bottom&&(l=a.config.margins.bottom),void 0!==s&&(o.style.marginTop=`${s}px`),void 0!==l&&(o.style.marginBottom=`${l}px`),Kr.create({block:o,containerId:n});const c=q("div",C.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(c.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(c),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const r=e.getBlockData(o.getAttribute("data-id"));return i.getState().addBlock(n,r,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),i.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const r=i.getState().getData(t);if(!r)return;const s=i.getState().getContentElement(t);if(!s)return;const l=o[n];o.splice(n,1),o.splice(a,0,l),0===a?s.insertBefore(l,s.firstChild):a>=o.length-1?s.appendChild(l):s.insertBefore(l,o[a+1]);const c=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),d={...r,blocks:c};i.getState().setData(t,d),e.focusBlock(l)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${C.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${C.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return zr.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${C.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=i.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return nn.render(n,t,o);case"audio":return a.config.audioUploader?ln.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return Q.render(n,t,o);case"collapsible":return kn.render(n,t,o);case"columns":return Xi.render(n,t,o);case"date":return Zi.render(n,t,o);case"delimiter":return jn.render(n,t,o);case"collection":return Ki.render(n,t,o);case"doc_card":return nr.render(n,t,o);case"embed":return Ze.render(n,t,o);case"openapi":return vr.render(n,t,o);case"sketch":return Er.render(n,t,o);case"latex":return Tr.render(n,t,o);case"mermaid":return Mr.render(n,t,o);case"file":return a.config.fileUploader?rr.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"header":return Zn.render(n,t,o);case"image":return a.config.imageUploader?na.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return ca.render(n,t,o);case"checklist":return mn.render(n,t,o);case"paragraph":return Ra.render(n,t,o);case"quote":return Wa.render(n,t,o);case"table":return ao.render(n,t,o);case"toc":return Nr.render(n,t,o);case"issues":return hr.render(n,t,o);case"video":return a.config.videoUploader?Oi.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(C.classNames.block.active);t.classList.add(C.classNames.block.active),Kr.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${C.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);const r=e.getBlockData(t),s=e.getTool(n);if(!s)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const l=e.getBlockIndex(a,t);let c=r.data;if("list"===n){const e=r.data,t=e.html||e.text||"";c={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=r.data;c={html:e.html||e.text||"",level:"h1"}}const d={data:c,id:t,type:s.type},p=e.createBlockElement(d,a);if(!p)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(p);const u=e.getBlockData(p.getAttribute("data-id"));i.getState().updateBlock(a,l,u),e.focusBlock(p)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=en.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${C.classNames.block.container}`);if(!a)return;const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));i.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),r=i.getState().getContentElement(n);if(!r)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];r.insertBefore(t,e),o.splice(a,0,t)}else r.appendChild(t),o.push(t);else r.appendChild(t),o.push(t);e.focusBlock(t);const s=i.getState().getInstance(n);s&&Ft.initializeElements(t,{classNames:s.config.classNames?.blocks?.tooltip,styles:s.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),i.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();i.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${C.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${C.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!z(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${C.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${C.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;const o=n.getAttribute("data-id");i.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){const o=e.getBlock(t);if(o){const t=o.querySelector(`.${C.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i)}i.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),zr.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},Jr=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=i.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);C.injectStyles("clepit-action-bar-styles","\n/* View Toggle */\n.clepit-action-bar {\n position: relative;\n z-index: 1000;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: -14px; /* Position buttons so exactly half is inside and half outside */\n pointer-events: none;\n padding: 0 100px;\n}\n\n.clepit-action-bar-group {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-action-bar-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-action-bar-button:active {\n transform: scale(0.95);\n}\n\n.clepit-action-bar-button.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n/* Action Buttons */\n.clepit-view-actions {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-view-action-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-view-action-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-view-action-button:active {\n transform: scale(0.95);\n}\n\n/* Copy button feedback animation */\n.clepit-view-action-button--copy-feedback {\n transform: scale(0.95) !important;\n background-color: var(--clepit-success) !important;\n color: var(--clepit-bg) !important;\n}\n");const a=document.getElementById(t);if(!a)return;const o=n.config.styles?.controls?.group,r=n.config.classNames?.controls?.group,s=n.config.styles?.controls?.button,l=n.config.classNames?.controls?.button,c=n.config.styles?.tooltips,d=n.config.classNames?.tooltips,p=q("div",C.classNames.actionBar.container);e.createButtonGroup(a,p,{buttonClassNames:l,buttonStyles:s,currentView:n.currentView,groupClassNames:r,groupStyles:o,tooltipClassNames:d,tooltipStyles:c}),a.insertBefore(p,a.firstChild)}static createButtonGroup(t,n,a){const o=q("div",C.classNames.actionBar.group);C.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const i=q("button",C.classNames.actionBar.button,{"data-testid":"action-bar-edit-button","data-view":"edit",id:j(t.id,C.idSuffixes.actionBar.editButton),type:"button"});i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',C.applyStyling(i,{classNames:a.buttonClassNames,styles:a.buttonStyles});const r=q("button",C.classNames.actionBar.button,{"data-testid":"action-bar-preview-button","data-view":"preview",id:j(t.id,C.idSuffixes.actionBar.previewButton),type:"button"});r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',C.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles});const s=q("button",C.classNames.actionBar.button,{"data-testid":"action-bar-json-button","data-view":"json",id:j(t.id,C.idSuffixes.actionBar.jsonButton),type:"button"});s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14,2 14,8 20,8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10,9 9,9 8,9"/></svg>',C.applyStyling(s,{classNames:a.buttonClassNames,styles:a.buttonStyles}),"edit"===a.currentView?i.classList.add("active"):"preview"===a.currentView?r.classList.add("active"):"json"===a.currentView&&s.classList.add("active"),e.addEventListener(t.id,i,"click",e.handleViewChange),e.addEventListener(t.id,r,"click",e.handleViewChange),e.addEventListener(t.id,s,"click",e.handleViewChange),o.appendChild(i),o.appendChild(r),o.appendChild(s),n.appendChild(o),le(i,"Edit Mode","above",a.tooltipClassNames,a.tooltipStyles),le(r,"Preview Mode","above",a.tooltipClassNames,a.tooltipStyles),le(s,"JSON Output","above",a.tooltipClassNames,a.tooltipStyles);const l=q("div",C.classNames.actionBar.action);C.applyStyling(l,{classNames:a.groupClassNames,styles:a.groupStyles});const c=q("button",C.classNames.actionBar.actionButton,{"data-testid":"view-copy-button",id:j(t.id,C.idSuffixes.actionBar.copyButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',C.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=q("button",C.classNames.actionBar.actionButton,{"data-testid":"view-download-button",id:j(t.id,C.idSuffixes.actionBar.downloadButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',C.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles});const p=q("button",C.classNames.actionBar.actionButton,{"data-testid":"view-clear-button",id:j(t.id,C.idSuffixes.actionBar.clearButton),type:"button"});p.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',C.applyStyling(p,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,c,"click",e.handleCopyJson),e.addEventListener(t.id,d,"click",e.handleDownloadJson),e.addEventListener(t.id,p,"click",e.handleClearEditor),l.appendChild(c),l.appendChild(d),l.appendChild(p),n.appendChild(l),le(c,"Copy JSON to Clipboard","above",a.tooltipClassNames,a.tooltipStyles),le(d,"Download JSON File","above",a.tooltipClassNames,a.tooltipStyles),le(p,"Clear Editor","above",a.tooltipClassNames,a.tooltipStyles)}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${C.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${C.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${j(e,C.idSuffixes.actionBar.editButton)}, #${j(e,C.idSuffixes.actionBar.previewButton)}, #${j(e,C.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{e.getAttribute("data-view")===t?e.classList.add("active"):e.classList.remove("active")})}static handleViewChange(t){const n=t.currentTarget,a=Gr.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(i.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=Gr.getEditorId(t);if(!n)return;const a=i.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(C.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(C.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=Gr.getEditorId(t);n&&Gr.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=Gr.getEditorId(t);if(!n)return;const a=Gr.getBlocks(n).map(e=>Gr.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${C.classNames.actionBar.container}`);n&&n.remove()}},Xr=`\n/* Editor Container */\n.${C.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${C.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${C.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${C.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${C.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${C.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${C.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${C.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${C.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${C.classNames.editor.container} {\n padding: 8px;\n }\n\n .${C.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,Yr=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(i.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=new Set;for(const a of Ne.collect(t))n.add(Ne.read(a).url);for(const a of Gr.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=Ze.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await Qe(t,n),o=document.getElementById(t),r=i.getState().getInstance(t)?.config;if(o&&r&&0!==Object.keys(a).length){Ne.refreshAll(o,a,r.issueLabels);for(const e of Gr.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=Ze.save(e),o=n.issue?a[n.url]:void 0;o&&Ze.refreshIssue(e,t,o)}hr.refresh(t,a)}}},Zr=class{static render(e){const t=i.getState().getInstance(e);t&&(Jt.create(e),C.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block:hover {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block--active {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Default menu item styles - package doesn\'t care about theme */\n.clepit-menu-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n width: 16px;\n height: 16px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n}\n\n.clepit-menu-item:hover {\n background-color: var(--clepit-selection-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n.clepit-menu-item--danger {\n color: var(--clepit-error);\n}\n\n/* Block type menu items - match font size with operations menu */\n.clepit-block-type-item {\n font-size: 14px;\n}\n\n/* Default menu divider styles */\n.clepit-menu-divider {\n height: 1px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 8px 0;\n}\n\n/* Default menu arrow styles */\n.clepit-menu-arrow {\n margin-left: auto;\n font-size: 12px;\n color: var(--clepit-text-muted);\n}\n\n/* Input styles for block type selector */\n.clepit-block-type-selector input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-type-selector input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-type-selector-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-menu-icon {\n font-size: 14px;\n min-width: 20px;\n text-align: center;\n font-weight: bold;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n font-size: 9px;\n color: var(--clepit-text-muted);\n opacity: 0.7;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n margin: 0;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n background: var(--clepit-bg);\n padding: 8px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: bottom span-inline-end;\n margin-block-start: 5px;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),Gr.renderBlocks(t.data.blocks,e))}},Qr=class e{static render(t){const n=i.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=C.createStyledElement("pre",C.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(C.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=C.createStyledElement("div",C.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=Gr.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=i.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${C.classNames.editor.jsonOutput}`);n&&(n.classList.remove(C.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;i.getState().setData(a,e),"json"===o&&i.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=i.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${C.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(e){const t=e.target,n=t.textContent||"",a=Gr.getEditorId(t);if(!a)return;const o=i.getState().getInstance(a);if(o)try{const e=JSON.parse(n);if("object"!=typeof e||null===e)throw new Error("Invalid JSON structure");{e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);try{Jt.hide(a),Kr.hide(a)}catch{}const t=o.currentView;i.getState().setData(a,e),"json"===t&&i.getState().setCurrentView(a,"json");const n=document.querySelector(`#${o.contentId} .${C.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),o.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),o.config.onChange&&o.config.onChange(e)}}catch{const e=document.querySelector(`#${o.contentId} .${C.classNames.editor.jsonOutput}`);e&&(e.classList.add("clepit-json-error"),e.classList.remove("clepit-json-editable"))}}static destroy(t){const n=i.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${C.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},es=new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),ts=(e,t)=>es.has(`${e}.${t}`),ns=new Set(["checklist.items","list.items","table.data"]),as=(e,t)=>ns.has(`${e}.${t}`),os=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=rs(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},is=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(as(e,r)){const t=os(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!ts(e,r)){i[r]=s;continue}const t=rs(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},rs=(e,t,n)=>{if(void 0===e)return null;if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},ss="clepit-theme-styles",ls=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",cs=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${Wr=x,Object.keys(k).map(e=>`@property ${k[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${Wr[e]};\n}`).join("\n\n")}\n\n@layer clepit.tokens {\n${w(x,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"rgba(240, 246, 252, 0.62)",codeSelectionBg:"rgba(124, 124, 255, 0.18)",codeString:"#7ee787",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",marker:"rgba(255, 224, 71, 0.28)",primary:"#7c7cff",primaryBg:"rgba(124, 124, 255, 0.14)",primaryHover:"#9494ff",selectionBg:"rgba(124, 124, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},ls)}\n\n${ls} {\n color-scheme: light;\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,ds=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Error(`Container element with ID '${t.containerId}' not found`);return C.injectStyles(ss,cs),C.injectStyles(Mt,_t),C.injectStyles(ue,me),n.classList.add(C.classNames.renderer.content),C.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Ne.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Ne.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=is(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=q("div",C.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,l,c=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(c={...c,tooltipClassNames:n.editorClassNames.tooltips}),c?.margins&&(r=c.margins.top,s=c.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":l=an.render(e.data,c,o,i);break;case"audio":l=cn.render(e.data,c,o,i);break;case"code":l=pe.render(e.data,c,o,i);break;case"collapsible":l=Ui.render(e.data,c,o,i);break;case"columns":l=Bn.render(e.data,c,o,i);break;case"date":l=Dn.render(e.data,c,o,i);break;case"delimiter":l=zn.render(e.data,c,o,i);break;case"collection":l=Sn.render(e.data,c,o,i);break;case"updates":l=qi.render(e.data,c,o,i);break;case"glance":l=Xn.render(e.data,c,o,i);break;case"embed":l=Ve.render(e.data,{...c,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":l=eo.render(e.data,c,o,i);break;case"latex":l=$i.render(e.data,c,o,i);break;case"mermaid":l=Ti.render(e.data,c,o,i);break;case"openapi":l=Ha.render(e.data,c,o,i);break;case"doc_card":l=Rn.render(e.data,c,o,i);break;case"file":l=Kn.render(e.data,c,o,i);break;case"header":l=Qn.render(e.data,c,o,i);break;case"image":l=aa.render(e.data,c,o,i);break;case"list":l=da.render(e.data,c,o,i);break;case"checklist":l=hn.render(e.data,c,o,i);break;case"paragraph":l=Fa.render(e.data,c,o,i);break;case"quote":l=Ka.render(e.data,c,o,i);break;case"table":l=so.render(e.data,c,o,i);break;case"toc":l=mo.render(e.data,{...c,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":l=sa.render(e.data,{...c,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":l=Hi.render(e.data,c,o,i);break;default:l=null}return l?(a.appendChild(l),Ft.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},ps=class{static render(e){const t=i.getState().getInstance(e);t&&ds.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},us=e=>e.replace(/["\\]/g,"\\$&"),ms=e=>e.flatMap(e=>"collapsible"===e.type?[e,...ms(e.data.children??[])]:"columns"===e.type?[e,...ms(e.data.columns?.flat()??[])]:[e]),hs=new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),gs=new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),bs=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),fs=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g,ys=e=>{const t=new Map;fs.lastIndex=0;let n=fs.exec(e);for(;null!==n;)t.set(n[1].toLowerCase(),n[2]??n[3]??n[4]??""),n=fs.exec(e);return t},vs=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},xs=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[],n=/<\/?([a-zA-Z][a-zA-Z0-9-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;let a=0,o=n.exec(e);for(;null!==o;){o.index>a&&t.push({type:"text",value:e.slice(a,o.index)});const i=o[1].toLowerCase();o[0].startsWith("</")?t.push({tag:i,type:"close"}):t.push({attributes:ys(o[2]??""),selfClosing:(o[2]??"").trimEnd().endsWith("/"),tag:i,type:"open"}),a=o.index+o[0].length,o=n.exec(e)}return a<e.length&&t.push({type:"text",value:e.slice(a)}),t})(e)){if("text"===a.type){t.push(a.value);continue}if("close"===a.type){if(!hs.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!hs.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)gs.has(t)&&("href"!==t||vs(n))&&e.push(`${t}="${$(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||bs.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},ks=()=>[cs,tn,sn,un,K,ne(),vn,En,Ln,Tn,qn,Pn,A,Vn,Gn,Yn,ta,me,la,pa,Pa,Va,Xa,no,po,bo,Di,zi].join("\n"),ws=(e,t)=>{const n=M(xs),a={...t,documentBlocks:t?.documentBlocks??e},o=e.map(e=>Pi(e,n,a)).filter(e=>null!==e).map(e=>_(e)).join("\n");return Te(o,t?.issues,t?.issueChip,t?.issueLabels,xs)};exports.BLOCK_TOOLS=Vt,exports.EMBED_ENGLISH=De,exports.EMBED_LABELS=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],exports.EMBED_TOOL_NAMES=qe,exports.EMBED_WIRE_KEYS=u,exports.Editor=class e{static create(t){return e.teardown(t.containerId),e.initialize(t),Jr.create(t.containerId),e.render(t.containerId),en.addListeners(t.containerId),Yr.start(t.containerId),i.getState().setIsReady(t.containerId,!0),i.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>Gr.convertBlock(e,n,t.containerId),count:()=>Gr.getBlocks(t.containerId).length,get:e=>Gr.getBlock(e)?Gr.getBlockData(e):null,getAll:()=>Gr.getBlocks(t.containerId).map(e=>Gr.getBlockData(e.getAttribute("data-id"))),insert:(e,n,a,o)=>Gr.insertBlock({data:n,id:o??Math.random().toString(36).substring(2,11),type:e},t.containerId,a),move:(e,n)=>Gr.moveBlock(t.containerId,e,n),remove:e=>Gr.removeBlock(t.containerId,e),update:(e,n)=>Gr.updateBlockData(e,n,t.containerId)},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{i.getState().clearData(t.containerId),Gr.destroy(t.containerId)},clearContent:()=>Gr.destroy(t.containerId),clearStorage:()=>i.getState().clearData(t.containerId),extract:()=>Gr.extractData(t.containerId),set:e=>Gr.setBlocks(e.blocks,t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=Gr.getBlocks(t.containerId)[0];e&&Gr.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>Kr.hide(t.containerId),hideToolbar:()=>Jt.hide(t.containerId),showBlockMenu:e=>Kr.show(t.containerId,e),showToolbar:(e,n)=>Jt.show(t.containerId,e,n)},view:{getCurrentView:e=>i.getState().getCurrentView(e),switchView:(e,t)=>i.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;C.injectStyles(ss,cs),C.injectStyles("clepit-editor-container-styles",Xr),C.injectStyles(Et,St),C.injectStyles(Ht,Pt),C.injectStyles(It,$t),C.injectStyles(ue,me);const a={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t};n.className=C.classNames.editor.container,n.setAttribute("contenteditable","false"),Ne.applyParts(n,a.issueChip),C.registerEditor(t.containerId,a.theme??"auto",a.themeOverrides),a.minHeight&&n.style.setProperty("--clepit-min-height",`${a.minHeight}px`),a.maxHeight&&n.style.setProperty("--clepit-max-height",`${a.maxHeight}px`),C.applyStyles(n,a.styles?.container),C.applyClassNames(n,a.classNames?.container),a.margins&&(void 0!==a.margins.top&&n.style.setProperty("--block-margin-top",`${a.margins.top}px`),void 0!==a.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${a.margins.bottom}px`));const o=`${a.containerId}-${C.idSuffixes.editorContent}`,r=q("div",C.classNames.editor.content);r.id=o,r.setAttribute("data-testid","editor-content-container"),r.setAttribute("data-container-id",t.containerId),C.applyStyles(r,a.styles?.editorContent),C.applyClassNames(r,a.classNames?.editorContent),n.appendChild(r),i.getState().addInstance(t.containerId,{config:a,contentId:o,currentView:a.initialView||"edit",data:e.localizeData(a.initialData,a),isReady:!1})}static localizeData(e,t){const n=e||{blocks:[],time:Date.now(),version:"1.0.0"},a=t.locale;if(!a)return n;const o=t.defaultLocale??a;return{...n,blocks:n.blocks.map(e=>{const n=e.data;for(const r of(e=>Array.from(es).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(e.type)){const i=rs(n[r],a,o);i?.isFallback&&t.onLocaleFallback?.({blockId:e.id??"",field:r,requested:a,showing:i.locale})}const i=is(e.type,n,a,o);return i===n?e:{...e,data:i}})}}static render(e){const t=i.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(Qr.destroy(e),n.innerHTML=""),"edit"===t.currentView?Zr.render(e):"preview"===t.currentView?ps.render(e):"json"===t.currentView&&Qr.render(e),t.config.onReady&&t.config.onReady()}static teardown(e){Yr.stop(e),Qt.dismiss(e),en.removeListeners(e),Jr.destroy(e),Kr.destroy(e),Jt.destroy(e),Gr.destroy(e),C.unregisterEditor(e);const t=document.getElementById(e);t&&(t.innerHTML="")}static destroy(t){e.teardown(t),i.getState().removeInstance(t)}},exports.INLINE_REWRITE_ACTIONS=Wt,exports.INLINE_TOOLS=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],exports.ISSUE_ENGLISH=he,exports.ISSUE_LABELS=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],exports.ISSUE_TOOLS=["asana","github_issues","jira","linear"],exports.ISSUE_TOOL_NAMES=ge,exports.IssueChip=Ne,exports.Renderer=ds,exports.StyleManager=C,exports.activateBlocks=(e,t)=>{const n=[];for(const a of ms(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${us(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?pe.activate(t,a.data):"openapi"===a.type?Ha.activate(t):so.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},exports.chipsInHtml=$e,exports.classifyIssueUrl=Xe,exports.domBacking=L,exports.drawBlock=Pi,exports.embedLabel=je,exports.isEmbedProviderDisabled=m,exports.issueLabel=fe,exports.issueToolName=ye,exports.pageStylesheet=ks,exports.parseOpenApi=Ta,exports.readChipMarkup=Ie,exports.refreshChipsInHtml=Te,exports.renderBlocks=ws,exports.renderPage=(e,t)=>{const n=I(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<title>${n}</title>`,e.description?`<meta name="description" content="${$(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${$(e.canonicalUrl)}">`:"",`<meta property="og:title" content="${$(e.title)}">`,e.description?`<meta property="og:description" content="${$(e.description)}">`:"",`<style>${ks()}</style>`].filter(Boolean);return["<!doctype html>",`<html lang="${$(e.locale??"en")}">`,`<head>${a.join("")}</head>`,"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,ws(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")},exports.renderToString=_,exports.resolveEmbed=f,exports.sanitizeHtmlWithoutDom=xs,exports.stringBacking=M,exports.toDomElement=D,exports.tokensToLightDarkBlock=w;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./highlight-eQD0I7eW.js");var t=e=>{let t;const n=new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var n,a,o,i=(o?t(o):t)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((n=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},seedBlocks:(n,a)=>{const o=t().instances[n];o&&e(e=>({instances:{...e.instances,[n]:{...o,data:{...o.data,blocks:a}}}}))},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),a={name:"clepit-store",version:0},(e,t,o)=>{const i=a.version??0,r=a.storage??("undefined"==typeof localStorage?void 0:localStorage),s=a.merge??((e,t)=>Object.assign({},t,e)),l=n(e,t,o);if(r){try{const e=r.getItem(a.name);if(e){const t=JSON.parse(e),n=t.version===i?t.state:a.migrate?a.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(l,s(n,l))}}catch{}o.subscribe(e=>{try{r.setItem(a.name,JSON.stringify({state:a.partialize?a.partialize(e):e,version:i}))}catch{}})}return l})))),r=["http:","https:"],s=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],l=["file","design","board","proto","slides","deck"],c=["document","spreadsheets","presentation"],d=/^[0-9a-f]{32}$/,p=/^[A-Za-z0-9]+$/,u={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function m(e,t){const n=u[e];return void 0!==n&&(t??[]).includes(n)}var h=(e,t="link")=>({embedUrl:null,provider:t,url:e});function g(e,t){return e===t||e.endsWith(`.${t}`)}function b(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(s.includes(n)){const t=function(e){if(g(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:h(a,"youtube")}if(g(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&l.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:h(a,"figma")}if(g(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:h(a,"miro")}if(g(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&p.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:h(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:h(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&c.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:h(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&d.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:h(a,"githubGist")}if(g(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:h(a,"airtable")}if(g(n,"diagrams.net")||g(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(g(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:h(a,"googleMaps")}return h(a)}function f(e,t){const n=function(e){try{const t=new URL(e);return r.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=b(n,t);return m(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function y(e,t,n,a){const o=i.getState().getInstance(e)?.config,r=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?Jr.replaceBlock(e,t,r):Jr.insertBlock(r,e,t+1);const s=Jr.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return s&&o?.resolveLink&&await v(e,s,o.resolveLink),s}async function v(e,t,n){if(!n)return;const a=Jr.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;Jr.updateBlockData(t,{...r,...o,url:a.url},e)}catch{Jr.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var x={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(91, 91, 255, 0.14)",codeString:"#0a7c3e",codeText:"#0a0a0a",codeType:"#953800",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",marker:"#ffe047",primary:"#5b5bff",primaryBg:"rgba(91, 91, 255, 0.08)",primaryHover:"#4747e6",selectionBg:"rgba(91, 91, 255, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},k={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",error:"--clepit-error",errorBg:"--clepit-error-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",marker:"--clepit-marker",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},w=(e,t,n)=>{const a=[];for(const o of Object.keys(k)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const r=k[o];void 0!==n&&void 0!==i?a.push(` ${r}: light-dark(${n}, ${i});`):a.push(` ${r}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},C=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(e,t){if(document.getElementById(e))return!1;const n=document.createElement("style");return n.id=e,n.textContent=t,document.head.appendChild(n),!0}static{this.themeRegistry=new Map}static{this.themeSubscribers=new Set}static registerEditor(t,n,a){const o=document.getElementById(t);o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute();const i=document.getElementById(`clepit-overrides-${t}`);if(i&&i.remove(),a){const n=w(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){const n=document.getElementById(`clepit-overrides-${t}`);n&&n.remove();const a=document.getElementById(t);a&&(a.removeAttribute("data-clepit-theme"),a.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},S="\n.clepit-embed {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",E=S,A=S,N=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=e}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},L={create:e=>new N(document.createElement(e)),createNS:(e,t)=>new N(document.createElementNS(e,t))},B=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),I=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),$=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;"),T=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(I(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(I(e))}toString(){const e=[...this.classes.length>0?[`class="${$(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${$(t)}"`)],t=[this.tag,...e].join(" ");return B.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},M=e=>({create:t=>new T(t,e),createNS:(t,n)=>new T(n,e)}),_=e=>String(e),D=e=>{if(!(e instanceof N))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function q(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function j(e,t){return`${e}-${t}`}function z(e){return!e||!e.trim()||"<br>"===e}function O(e){if(!e||z(e))return"";const t=document.createElement("div");t.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return e.cloneNode(!0);if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes)a.includes(e.name.toLowerCase())&&r.setAttribute(e.name,e.value);"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function H(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}function P(){C.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=q("div","clepit-invalid-data"),t=q("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var R={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function F(e){return R[e]||"Unknown"}var U=Object.fromEntries(Object.keys(e.GRAMMARS).map(e=>[e,{name:F(e)}])),V=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${C.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: 6px;\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${C.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${C.classNames.block.code.editor} .clepit-code-highlight,\n.${C.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre;\n overflow: auto;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${C.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${C.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${C.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${C.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${C.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,W="clepit-code-output-styles",K="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n overflow-x: auto;\n white-space: pre;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",G=(e,t,n)=>i.getState().getInstance(e)?.config.blockToolbarLabels?.[t]||n,J={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function X(e){return J[e]||"Unknown"}var Y=Object.fromEntries(Object.keys(J).map(e=>[e,{name:X(e),theme:null}])),Z=`\n/* Custom Switch Container */\n.${C.classNames.switch.container} {\n --switch-blue: #0D7EFF;\n --switch-red: #FF0D0D;\n --switch-text: var(--clepit-bg);\n --switch-white: var(--clepit-bg);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.${C.classNames.switch.container} .tgl {\n display: none;\n}\n\n.${C.classNames.switch.container} .tgl,\n.${C.classNames.switch.container} .tgl:after,\n.${C.classNames.switch.container} .tgl:before,\n.${C.classNames.switch.container} .tgl *,\n.${C.classNames.switch.container} .tgl *:after,\n.${C.classNames.switch.container} .tgl *:before,\n.${C.classNames.switch.container} .tgl + .tgl-btn {\n box-sizing: border-box;\n}\n\n.${C.classNames.switch.container} .tgl::selection,\n.${C.classNames.switch.container} .tgl:after::selection,\n.${C.classNames.switch.container} .tgl:before::selection,\n.${C.classNames.switch.container} .tgl *::selection,\n.${C.classNames.switch.container} .tgl *:after::selection,\n.${C.classNames.switch.container} .tgl *:before::selection,\n.${C.classNames.switch.container} .tgl + .tgl-btn::selection {\n background: none;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn {\n outline: 0;\n display: block;\n width: 57px;\n height: 27px;\n position: relative;\n cursor: pointer;\n user-select: none;\n font-size: 12px;\n font-weight: 400;\n color: var(--switch-white);\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:after,\n.${C.classNames.switch.container} .tgl + .tgl-btn:before {\n position: relative;\n display: block;\n content: "";\n width: 44%;\n height: 100%;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:after {\n left: 0;\n}\n\n.${C.classNames.switch.container} .tgl + .tgl-btn:before {\n display: inline;\n position: absolute;\n top: 3px;\n}\n\n.${C.classNames.switch.container} .tgl:checked + .tgl-btn:after {\n left: 56.5%;\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn {\n background: var(--switch-red);\n border-radius: 20rem;\n padding: 2px;\n transition: all 0.4s ease;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:after {\n border-radius: 2em;\n background: var(--switch-white);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:before {\n content: "No";\n left: 30px;\n color: var(--switch-text);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios + .tgl-btn:active:after {\n padding-right: 0.4em;\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn {\n background: var(--switch-blue);\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active:after {\n margin-left: -0.4em;\n}\n\n.${C.classNames.switch.container} .tgl-ios:checked + .tgl-btn:before {\n content: "Yes";\n left: 6px;\n color: var(--switch-white);\n}\n\n.clepit-switch-label-text {\n font-size: 13px;\n display: flex;\n align-items: center;\n}\n`,Q=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,id:r=`switch-${Math.random().toString(36).substring(2,11)}`}=e;C.injectStyles("clepit-custom-switch-styles",Z);const s=C.createStyledElement("div",C.classNames.switch.container,{classNames:a?.container,styles:o?.container}),l=C.createStyledElement("input","tgl tgl-ios",{classNames:a?.input,styles:o?.input});l.type="checkbox",l.id=r,l.checked=t;const c=C.createStyledElement("label","tgl-btn",{classNames:a?.label,styles:o?.label});if(c.setAttribute("for",r),n&&l.addEventListener("change",e=>{const t=e.target;n(t.checked)}),s.appendChild(l),s.appendChild(c),i){const e=C.createStyledElement("span","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.textContent=i,s.appendChild(e)}return s}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t)}},ee=class t{static{this.placeholder="Enter code..."}static{this.supportedLanguages=U}static{this.supportedThemes=Y}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=new WeakMap}static{this.dataMap=new WeakMap}static save(e){const n=e.querySelector(`.${C.classNames.block.code.container}`),a=n.querySelector(`.${C.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||t.defaultLanguage,i=n?.getAttribute("data-theme")||t.defaultTheme,r=!!a&&Q.getState(a),s=t.inputMap.get(n);if(s){const e=s.value,a=t.dataMap.get(n),l={code:e.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),t.dataMap.set(n,l),l}return{...t.dataMap.get(n)||{code:"",language:t.defaultLanguage,theme:t.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(e,n,a,o){C.injectStyles("clepit-code-input-styles",V);const r={code:"",language:o?.language||t.defaultLanguage,showCopy:!0,theme:o?.theme||t.defaultTheme},s=n?{...r,...n}:r,l=C.createStyledElement("div",C.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});l.setAttribute("data-language",s.language||t.defaultLanguage),l.setAttribute("data-theme",s.theme||t.defaultTheme);const c=C.createStyledElement("div",C.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=C.createStyledElement("div",C.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=U[s.language]?.name||F(t.defaultLanguage),u=Y[s.theme]?.name||X(t.defaultTheme);d.textContent=t.getHeaderText(p,u);const m=C.createStyledElement("div",C.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});m.setAttribute("data-placeholder",G(e,"codeHint",t.placeholder));const h=e?i.getState().getInstance(e):null,g=h?.config.classNames?.switch,b=h?.config.styles?.switch,f=Q.create({checked:s.showCopy||!1,classNames:g,label:"Allow copy",onToggle:e=>{const n=t.dataMap.get(l)||{code:"",language:t.defaultLanguage,theme:t.defaultTheme};t.dataMap.set(l,{...n,showCopy:e}),Jr.saveBlockData(l)},styles:b});return c.appendChild(d),c.appendChild(f),l.appendChild(c),l.appendChild(m),t.mountEditor(l,m,s),l}static mountEditor(e,n,a){const o=a.language??t.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${F(o)} code`),s.placeholder=n.getAttribute("data-placeholder")||t.placeholder,n.replaceChildren(i,s),t.inputMap.set(e,s),t.dataMap.set(e,a),t.paint(e,r,s.value),s.addEventListener("input",()=>{t.paint(e,r,s.value);const n=t.dataMap.get(e)??{code:"",language:e.getAttribute("data-language")||t.defaultLanguage,theme:e.getAttribute("data-theme")||t.defaultTheme};t.dataMap.set(e,{...n,code:s.value}),Jr.saveBlockData(e)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>t.handleKeydown(e,s,n))}static paint(n,a,o){const i=n.getAttribute("data-language")||t.defaultLanguage;a.replaceChildren(...e.tokenizeCode(o.endsWith("\n")?`${o} `:o,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(e,n){const a=e.querySelector(`.${C.classNames.block.code.container}`);if(!a)return;const o=e.querySelector(`.${C.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${C.classNames.block.code.header}`),r=a.getAttribute("data-theme")||t.defaultTheme,s=X(r),l=F(n);i&&(i.textContent=t.getHeaderText(l,s));const c=t.inputMap.get(a);c&&t.mountEditor(a,o,{code:c.value,language:n,theme:r}),Jr.saveBlockData(a)}static updateTheme(e,n){const a=e.querySelector(`.${C.classNames.block.code.container}`);if(!a)return;const o=e.querySelector(`.${C.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${C.classNames.block.code.header}`),r=a.getAttribute("data-language")||t.defaultLanguage,s=F(r),l=X(n);i&&(i.textContent=t.getHeaderText(s,l));const c=t.inputMap.get(a);c&&t.mountEditor(a,o,{code:c.value,language:r,theme:n}),Jr.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${C.classNames.block.container}`);if(!a)return;const o=Jr.getEditorId(a);if(!o)return;const i=Jr.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void Jr.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?Jr.moveBlock(o,i,i-1):Jr.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?Jr.moveBlock(o,i,i+1):Jr.focusBlock(a.nextElementSibling))):void Jr.removeBlock(o,i):(n.preventDefault(),void Jr.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(e){const n=e.querySelector(`.${C.classNames.block.code.container}`);if(!n)return!0;const a=t.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return z(e.code)}static destroy(e){const n=document.getElementById(e);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",e);n.querySelectorAll(`.${C.classNames.block.code.container}`).forEach(e=>{t.inputMap.delete(e),t.dataMap.delete(e)})}},te=".clepit-output-code-container",ne=(t,n)=>[`${t} { background: ${n.background}; color: ${n.text}; }`,...e.CODE_TOKEN_GROUPS.map(e=>`${t} .clepit-code-${e} { color: ${n[e]};${(e=>"comment"===e?" font-style: italic;":"")(e)} }`)].join("\n"),ae=()=>[ne(te,e.resolveAutoTokens()),...Object.entries(e.CODE_THEME_TOKENS).map(([e,t])=>ne(`${te}[data-theme='${e}']`,t))].join("\n"),oe="clepit:code-variant-sync",ie=e=>`clepit.code-variant.${e}`,re=(e,t)=>e.label?e.label:e.language?R[e.language]??e.language:`Tab ${t+1}`,se=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>re(e,n)===t);return-1===n?0:n},le=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(ie(e))}catch{return null}};function ce(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;C.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,C.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,C.applyStyling(s,{styles:o?.content});const c=document.createElement("div");c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,C.applyStyling(c,{styles:o?.arrow}),s.appendChild(c),i.appendChild(s),document.body.appendChild(i);const d=e.getBoundingClientRect(),p=s.offsetWidth,u=s.offsetHeight;let m,h=d.left+d.width/2-p/2;h=Math.max(8,Math.min(h,window.innerWidth-p-8));let g=n;"below"===n?(m=d.bottom+6+2,m+u>window.innerHeight-8&&(m=d.top-u-6-2,g="above")):(m=d.top-u-6-2,m<8&&(m=d.bottom+6+2,g="below")),c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${g} ${a?.arrow||""}`,i.style.left=`${h}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-u-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(l(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},l=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",l),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",l),l()}}var de="http://www.w3.org/2000/svg",pe=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],ue=class t{static{this.eventListenersMap=new WeakMap}static draw(n,a=L,o){if(!t.validate(n)||ee.isEmptyData(n))return null;const i=pe(n),r=i.length>1,s=Math.min(Math.max(o?.activeVariant??0,0),i.length-1),l=a.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",n.theme??ee.defaultTheme),n.syncKey&&l.setAttribute("data-sync-key",n.syncKey);const c=a.create("div");if(c.addClass("clepit-output-code-header"),r){const e=a.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,n)=>{const o=a.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",n===s?"true":"false"),o.setAttribute("tabindex",n===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${n}`),o.setText(re(t,n)),e.append(o)}),c.append(e)}else{const e=a.create("span");e.setText(R[n.language??"typescript"]??"TypeScript"),c.append(e)}if(n.showCopy){const e=a.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(de,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(de,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(a)),c.append(e)}l.append(c);const d=a.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((t,o)=>{const i=a.create("pre");i.addClass("clepit-output-code-pane"),i.setAttribute("data-variant-index",String(o)),o!==s&&i.setAttribute("hidden","");const r=a.create("code");for(const s of e.tokenizeCode(t.code??n.code,t.language??n.language??"plaintext")){const e=a.create("span");s.classes&&e.addClass(...s.classes.split(" ")),e.setText(s.text),r.append(e)}i.append(r),d.append(i)}),l.append(d),l}static render(e,n,a,o,i){if(C.injectStyles(W,K),C.injectStyles(`${W}-theme`,ae()),!t.validate(e))return P();if(ee.isEmptyData(e))return document.createElement("div");const r=pe(e),s=r.length>1?se(r,le(e.syncKey)):0,l=D(t.draw(e,L,{activeVariant:s}));o?.container&&l.classList.add(o.container),a?.container&&Object.assign(l.style,a.container);const c=l.querySelector(".clepit-output-code-header");return c&&o?.header?.text&&c.classList.add(o.header.text),c&&a?.header?.text&&Object.assign(c.style,a.header.text),t.attach(l,e,s,i),l}static activate(e,n){if(!t.validate(n)||ee.isEmptyData(n))return()=>{};const a=pe(n),o=a.length>1?se(a,le(n.syncKey)):0;return t.attach(e,n,o,void 0,!0)}static activateFromMarkup(e){const n=[...e.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...e.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=e.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==e.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?se(o,le(i)):0;return t.attach(e,r,s,void 0,!0)}static attach(e,n,a,o,r=!1){const s=pe(n),l=o?document.getElementById(o):null,c=[...e.querySelectorAll(".clepit-output-code-tab")],d=[...e.querySelectorAll(".clepit-output-code-pane")];let p=a;const u=[];let m;const h=(e,n,a)=>{if(e.addEventListener(n,a),u.push({event:n,handler:a,target:e}),l){const o=t.eventListenersMap.get(l)??[];o.push({element:e,event:n,handler:a}),t.eventListenersMap.set(l,o)}},g=(e,t)=>{if(e<0||e>=s.length)return;if(p=e,c.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),d.forEach((t,n)=>{t.hidden=n!==e}),!t||!n.syncKey)return;const a=re(s[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(ie(e),t)}catch{return}})(n.syncKey,a),window.dispatchEvent(new CustomEvent(oe,{detail:{label:a,syncKey:n.syncKey}}))};if(c.forEach((e,t)=>{h(e,"click",()=>g(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?s.length-1:0===a?-1:(t+a+s.length)%s.length;-1!==o&&(e.preventDefault(),g(o,!0),c[o]?.focus())})}),c.length>1&&n.syncKey){const e=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=s.findIndex((e,n)=>re(e,n)===t.label);-1!==a&&a!==p&&g(a,!1)};if(window.addEventListener(oe,e),u.push({event:oe,handler:e,target:window}),l){const n=t.eventListenersMap.get(l)??[];n.push({element:window,event:oe,handler:e}),t.eventListenersMap.set(l,n)}}const b=()=>{for(const{event:e,handler:t,target:n}of u)n.removeEventListener(e,t);m?.()};r&&g(a,!1);const f=e.querySelector(".clepit-output-code-copy-btn");if(!f)return b;h(f,"click",()=>{t.copyCodeToClipboard(s[p]?.code??n.code),t.animateCopyButton(f)});const y=o?i.getState().getInstance(o):null;return m=ce(f,"Copy code","above",y?.config.classNames?.tooltips,y?.config.styles?.tooltips),b}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(e){const n=document.getElementById(e);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",e);const a=t.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),t.eventListenersMap.delete(n))}},me="inline-issue",he='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5b5bff);\n background: var(--clepit-primary-bg, rgba(91, 91, 255, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',ge={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},be={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},fe={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function ye(e,t,n={}){let a=e?.[t]??ge[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var ve=e=>be[e]??e,xe="clepit-issue",ke=["todo","started","done","cancelled"],we=["connect_tool","no_access","provider_unreachable"],Ce={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},Se=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),Ee=(e,t)=>e.reason?ye(t,Ce[e.reason],{tool:ve(e.tool)}):null,Ae=(e,t)=>e.stateName||ye(t,fe[e.category]),Ne=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),Le=class e{static build(t,n,a=L){const o=a.create("a");o.addClass(xe),t.reason&&o.addClass(`${xe}--reason`),o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${xe}__key`),i.setText(t.key||(t.title?"":ve(t.tool))),!t.key&&t.title||o.append(i);const r=Ee(t,n);if(r){const e=a.create("span");return e.addClass(`${xe}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${xe}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${xe}__state`),e.setAttribute("data-issue-category",t.category),e.setText(Ae(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${xe}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(Se(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return _(e.build(t,n,M(a)))}static create(t,n){return C.injectStyles(me,he),D(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:ke.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:we.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||e.getAttribute("href")||""}}static collect(e){return Array.from(e.querySelectorAll(`a.${xe}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Be=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,Ie=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/&quot;/g,'"').replace(/&amp;/g,"&"),$e=e=>{const t=t=>Ie(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:ke.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:we.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||Ie(e,"href")}},Te=e=>Array.from(e.matchAll(Be),e=>$e(e[0])),Me=(e,t,n,a,o)=>t||n?e.replace(Be,e=>{const i=$e(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Le.markup(r,a,o)}):e,_e=class e{static render(t,n){return C.injectStyles(me,he),D(e.draw(t,L,n,!0))}static draw(t,n,a,o){const i=Ee(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText(Ae(t,a)),s.append(c),r.append(s);const d=n.create("span");d.addClass("clepit-issue-card__meta");const p=n.create("span");if(p.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(Se(t.assigneeName)),p.append(e),p.appendText(t.assigneeName)}else p.setText(ye(a,"unassigned"));if(d.append(p),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText(ye(a,"updatedRelative",{when:(u=t.updatedAt,u.length>=10?u.slice(0,10):u)})),d.append(e)}var u;return r.append(d),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||ve(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText(ye(a,"connectAction")),l.append(t)}return i.append(l),i}},De="allow-scripts allow-same-origin allow-presentation allow-forms",qe={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},je={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function ze(e,t,n={}){let a=e?.[t]??qe[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Oe=new Set(Object.keys(R)),He={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function Pe(e){if(!e)return;const t=e.toLowerCase(),n=He[t];return n||(Oe.has(t)?t:void 0)}var Re={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},Fe={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function Ue(e,t){const n=je[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var Ve=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,We=class e{static render(t,n,a,o){if(C.injectStyles("embed-output",A),!e.validate(t))return P();if(t.issue)return _e.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=f(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return P();if(!Ve(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=Ue(t,i);if(!s)return r;const l=C.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),l.appendChild(r);const c=document.createElement("span");c.className="clepit-embed-card__reason",c.setAttribute("data-testid","embed-reason");const d=document.createElement("span");if(d.textContent=ze(n?.embedLabels,Re[s.reason],{tool:s.tool}),c.appendChild(d),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=ze(n?.embedLabels,Fe[s.action]),c.appendChild(e)}return l.appendChild(c),l}static draw(t,n=L,a){if(!e.validate(t))return null;if(t.issue)return _e.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=f(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!Ve(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=Ue(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(ze(a?.embedLabels,Re[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(ze(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(ze(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=ue.draw({code:i.content,language:Pe(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",De),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=C.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=C.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",De),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=C.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},Ke=/^[A-Z][A-Z0-9_]*-\d+$/,Ge=/^\d+$/,Je=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),Xe=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function Ye(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&Ke.test(t)?Xe("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&Ge.test(a)?Xe("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&Ge.test(t[0])&&Ge.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&Ge.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&Ge.test(t[2]))?Xe("asana",""):null}if(Je(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&Ke.test(o[1]))return Xe("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&Ke.test(t)?Xe("jira",t,e):null}return null}var Ze=new WeakMap,Qe=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?Ze.get(t):void 0)??{url:""}}static render(t,n,a){C.injectStyles("embed-input",E);const o=n??{url:""},r=i.getState().getInstance(t)?.config,s=We.render(o,{disabledEmbedProviders:r?.disabledEmbedProviders,embedLabels:r?.embedLabels},a?.styles,a?.classNames);return s.classList.add("clepit-embed--input"),s.setAttribute("contenteditable","false"),Ze.set(s,o),e.listenForActions(t,s),s}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),r=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=r;return Jr.updateBlockData(o,t,a)}case"embedShowCard":return Jr.updateBlockData(o,{...r,display:"card"},a);case"embedShowLink":{const e=Jr.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=r.url,t.textContent=r.url,Jr.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(r.url);case"embedShowChip":{const e=Jr.getBlockIndex(a,o);if(-1===e)return;const t=i.getState().getInstance(a)?.config,n=Ye(r.url,t?.jiraSites),s=r.issue??Ne(r.url,n?.tool??"",n?.key??""),l=Le.create({...s,url:r.url},t?.issueLabels);return Jr.replaceBlock(a,e,{data:{html:`${l.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const r=t.querySelector(`.${C.classNames.block.content}`);if(!r)return;const s=i.getState().getInstance(n),l={classNames:s?.config.classNames?.blocks?.embed,styles:s?.config.styles?.blocks?.embed};r.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},l))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void i.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const r=o.getAttribute("data-embed-action"),s=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");if(!s)return;const l=i.getState().getInstance(t)?.config;"retry"===r?v(t,s,l?.resolveLink):l?.onEmbedAction?.(r,s)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function et(e,t){const n=i.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=Ye(a,n.jiraSites);e[a]={...Ne(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function tt(e,t,n,a,o,r){const s=i.getState().getInstance(e)?.config,l=Ne(o,r.tool,r.key);if(a&&"on"===s?.issueCards){const t={data:{issue:l,url:o},type:"embed"};Jr.replaceBlock(e,n,t);const a=Jr.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await et(e,[n]))[n];if(!a)return;const o=Jr.getBlock(t);if(!o)return;const i=Qe.save(o);Jr.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const c=Le.insertAtCaret(l,s?.issueLabels);if(!c)return;const d=c.closest('[contenteditable="true"]');d&&Jr.saveBlockData(d),await async function(e,t,n){const a=(await et(e,[n]))[n];if(!a||!t.isConnected)return;const o=i.getState().getInstance(e)?.config;Le.refresh(t,a,o?.issueLabels);const r=t.closest('[contenteditable="true"]');r&&Jr.saveBlockData(r)}(e,c,o)}function nt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function at(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function ot(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function it(e){return e.toLowerCase().includes("vimeo.com")}function rt(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=ot(t),a=it(t);return{isImage:nt(t),isUrl:!0,isVideo:at(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var st=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),lt=(e,t)=>{const n=rt(t);if(!n.isUrl)return null;if(n.isImage)return st(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return st(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,Ye(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!st(e,"embed"))return null;const r=function(e,t){const n=f(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null};function ct(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function dt(){return"mac"===ct()?"⌘":"Ctrl"}function pt(e){return"mac"===ct()?e.join(""):e.join(" + ")}var ut=e=>pt([dt(),e]),mt=e=>pt([dt(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),ht=()=>pt([dt(),"B"]),gt=()=>pt([dt(),"⌫"]),bt=()=>pt([dt(),"⌦"]),ft=()=>pt([dt(),"I"]),yt=()=>pt([dt(),"K"]),vt=e=>pt([dt(),"⇧",e]),xt=e=>pt([dt(),"⇧",{down:"↓",left:"←",right:"→",up:"↑"}[e]]),kt=()=>pt([dt(),"U"]),wt=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=ht()}static apply(e){C.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),Jr.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},Ct=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=ut("`")}static apply(e,t,n){C.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&C.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),Jr.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&C.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},St=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=ft()}static apply(e){C.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),Jr.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Et="clepit-link-styles",At=`\n/* Link styles - simple and clean */\n.${C.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${C.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n`,Nt="clepit-dialogs-styles",Lt="\n/* Dialog Overlay */\n/* A native <dialog>. showModal() puts it in the top layer and paints a real\n * ::backdrop, so the full-screen scrim, the z-index and the manual centring are\n * the browser's job now. The non-modal branch below keeps the old flex overlay\n * for a DOM without showModal, where the element is an ordinary block. */\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(2px);\n}\n\n/* Fallback: no showModal, so the element is not in the top layer and paints no\n * backdrop of its own. */\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n backdrop-filter: blur(2px);\n}\n\n/* Dialog Container */\n.clepit-dialog {\n background: var(--clepit-bg);\n border-radius: 8px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);\n padding: 24px;\n min-width: 400px;\n max-width: 500px;\n max-height: 80vh;\n overflow-y: auto;\n position: relative;\n transform: scale(0.95);\n opacity: 0;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.95);\n opacity: 0;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n/* Dialog Title */\n.clepit-dialog-title {\n margin: 0 0 20px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--clepit-text);\n text-align: center;\n}\n\n/* Dialog Group */\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n/* Dialog Label */\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 14px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n/* Dialog Input */\n.clepit-dialog-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n font-size: 14px;\n color: var(--clepit-text);\n background: var(--clepit-bg);\n transition: border-color 0.2s ease, box-shadow 0.2s ease;\n box-sizing: border-box;\n}\n\n.clepit-dialog-input:focus {\n outline: none;\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Dialog Buttons */\n.clepit-dialog-buttons {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n/* Dialog Button */\n.clepit-dialog-button {\n padding: 10px 20px;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease;\n min-width: 80px;\n}\n\n.clepit-dialog-button--cancel {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-border);\n border-color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: white;\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n/* Responsive */\n@media (max-width: 640px) {\n .clepit-dialog {\n min-width: 320px;\n max-width: 90vw;\n margin: 20px;\n }\n\n .clepit-dialog-buttons {\n flex-direction: column;\n }\n\n .clepit-dialog-button {\n width: 100%;\n }\n}\n",Bt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.textInput?.value.trim()||"",t=this.urlInput?.value.trim()||"";e&&t&&(this.options.onConfirm(e,t),this.hide())}},this.options=e}show(){this.overlay||e.isOpen||(C.injectStyles(Nt,Lt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=q("h3","clepit-dialog-title");e.textContent="Insert Link",this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup("Text",this.options.text,"text");this.textInput=t.querySelector("input");const n=this.createInputGroup("URL",this.options.url,"url");this.urlInput=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none")}createInputGroup(e,t,n){const a=q("div","clepit-dialog-group");this.applyStyles(a,this.options.styles?.group),this.applyClassNames(a,this.options.classNames?.group);const o=q("label","clepit-dialog-label");o.textContent=e,this.applyStyles(o,this.options.styles?.label),this.applyClassNames(o,this.options.classNames?.label);const i=q("input","clepit-dialog-input");return i.type="url"===n?"url":"text",i.value=t,i.placeholder="url"===n?"https://example.com":"Link text",this.applyStyles(i,this.options.styles?.input),this.applyClassNames(i,this.options.classNames?.input),a.appendChild(o),a.appendChild(i),a}createButtonGroup(){const e=q("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=q("button","clepit-dialog-button clepit-dialog-button--cancel");t.textContent="Cancel",t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=q("button","clepit-dialog-button clepit-dialog-button--save");return n.textContent="Apply",n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.textInput?.value.trim()||"",this.urlInput?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.textInput&&this.textInput.addEventListener("keydown",this.handleInputKeyDown),this.urlInput&&this.urlInput.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.urlInput&&(this.urlInput.focus(),this.urlInput.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{void 0!==n&&e.style.setProperty(t,String(n))})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){document.removeEventListener("keydown",this.handleKeyDown),this.hide(),e.isOpen=!1}},It=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=yt()}static apply(t,n,a){C.injectStyles(Et,At);const o=t.toString().trim(),i=e.findLinkElement(t.commonAncestorContainer);let r=o,s="";i&&(r=i.textContent||o,s=i.href||"");const l=t.cloneRange();new Bt({classNames:n,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(l))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(a){if(a.removeAllRanges(),a.addRange(l),!n.trim())return void e.remove(l);if(t!==o){l.deleteContents();const e=document.createTextNode(t);l.insertNode(e),l.selectNode(e)}const i=C.createStyledElement("a",C.classNames.block.link);i.href=n,i.target="_blank",i.rel="noopener noreferrer";try{l.surroundContents(i)}catch{const e=l.extractContents();i.appendChild(e),l.insertNode(i)}const r=document.createRange();r.selectNodeContents(i),a.removeAllRanges(),a.addRange(r);const s=i.closest('[contenteditable="true"]');if(s){const e=new Event("input",{bubbles:!0});s.dispatchEvent(e)}}}catch(a){console.error("Failed to apply link:",a)}},styles:a,text:r||"Link text",url:s}).show(),Jr.updateStateFromRange(t)}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},$t="clepit-marker-styles",Tt="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",Mt=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static{this.shortcut=vt("M")}static apply(t,n,a){C.injectStyles($t,Tt);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),Jr.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}Jr.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(C.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(C.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&C.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${C.classNames.editor.content}, .${C.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${C.classNames.block.content}`);if(!s)return;const l=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(l&&"initial"!==l&&"inherit"!==l){const t=e.createStrokeSVG(l);return void(n.style.background=t)}const c=window.getComputedStyle(s).backgroundColor;if(c&&"rgba(0, 0, 0, 0)"!==c&&"transparent"!==c){const t=e.createStrokeSVG(c);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},_t="clepit-inline-status-styles",Dt='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',qt=["info","success","warning","error","plain"],jt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(C.injectStyles(Nt,Lt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const e=q("h3","clepit-dialog-title");e.textContent="Inline status",this.applyStyles(e,this.options.styles?.title),this.dialog.appendChild(e);const t=q("label","clepit-dialog-label");t.textContent="Label",this.applyStyles(t,this.options.styles?.label),this.dialog.appendChild(t),this.textInput=q("input","clepit-dialog-input"),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.placeholder="Status label",this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const n=q("label","clepit-dialog-label");n.textContent="Variant",this.applyStyles(n,this.options.styles?.label),this.dialog.appendChild(n);const a=q("div","clepit-status-dialog-variants");for(const c of qt){const e=q("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${c}`);e.type="button",e.dataset.variant=c,e.textContent=c,e.dataset.selected=String(c===this.variant),e.addEventListener("click",()=>{this.variant=c;for(const e of Array.from(a.children))e.dataset.selected=String(e.dataset.variant===c)}),a.appendChild(e)}this.dialog.appendChild(a);const o=q("div","clepit-dialog-buttons");this.applyStyles(o,this.options.styles?.buttons);const i=q("button","clepit-dialog-button clepit-dialog-button--cancel");i.type="button",i.textContent="Cancel",i.addEventListener("click",()=>this.handleCancel()),this.applyStyles(i,this.options.styles?.cancelButton),o.appendChild(i);const r=q("button","clepit-dialog-button clepit-dialog-button--save");r.type="button",r.textContent="Apply",r.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(r,this.options.styles?.saveButton),o.appendChild(r),this.dialog.appendChild(o),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const s=this.overlay;"function"==typeof s.showModal?s.showModal():s.style.display="flex";const l=document.querySelector(".clepit-toolbar");l&&(l.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},zt="clepit-status",Ot=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a){C.injectStyles(_t,Dt);const o=t.toString().trim(),i=e.findStatusElement(t.commonAncestorContainer),r=i?i.textContent??o:o,s=i?e.readVariant(i):"info",l=t.cloneRange();new jt({classNames:n,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(l))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(l),!t.trim())return void e.remove(l);if(e.unwrap(l),t!==o){l.deleteContents();const e=document.createTextNode(t);l.insertNode(e),l.selectNode(e)}const i=document.createElement("span");i.className=(e=>`${zt} ${zt}--${e}`)(n),i.dataset.statusVariant=n;try{l.surroundContents(i)}catch{const e=l.extractContents();i.appendChild(e),l.insertNode(i)}const r=document.createRange();r.selectNodeContents(i),a.removeAllRanges(),a.addRange(r);const s=i.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:r||"status",variant:s}).show(),Jr.updateStateFromRange(t)}static remove(t){e.unwrap(t),Jr.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${zt}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${zt}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(zt))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${zt}--${n}`))return n;return"info"}},Ht=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static{this.shortcut=vt("X")}static apply(e){C.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),Jr.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},Pt="clepit-tooltip-styles",Rt=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${C.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${C.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,Ft=class{constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(C.injectStyles(Nt,Lt),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}createDialog(){this.overlay=q("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=q("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=q("h3","clepit-dialog-title");e.textContent="Insert Tooltip",this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup("Text",this.options.text,"text");this.inputText=t.querySelector("input");const n=this.createInputGroup("Tooltip",this.options.tooltip,"text");this.inputTooltip=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n){const a=q("div","clepit-dialog-group");this.applyStyles(a,this.options.styles?.group),this.applyClassNames(a,this.options.classNames?.group);const o=q("label","clepit-dialog-label");o.textContent=e,this.applyStyles(o,this.options.styles?.label),this.applyClassNames(o,this.options.classNames?.label);const i=q("input","clepit-dialog-input");return i.type="url"===n?"url":"text",i.value=t,i.placeholder="Tooltip"===e?"Tooltip text":"Text",this.applyStyles(i,this.options.styles?.input),this.applyClassNames(i,this.options.classNames?.input),a.appendChild(o),a.appendChild(i),a}createButtonGroup(){const e=q("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=q("button","clepit-dialog-button clepit-dialog-button--cancel");t.textContent="Cancel",t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=q("button","clepit-dialog-button clepit-dialog-button--save");return n.textContent="Apply",n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},Ut=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static{this.shortcut=vt("T")}static apply(t,n,a){C.injectStyles(Pt,Rt);const o=t.toString(),i=t.cloneRange();let r="",s=o;const l=e.findTooltipSpan(t.commonAncestorContainer);l&&(r=l.getAttribute("data-tooltip")||"",s=l.textContent||""),new Ft({classNames:n.classNames,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(i))},onConfirm:(t,o)=>{const r=window.getSelection();if(!r)return;if(r.removeAllRanges(),r.addRange(i),!o.trim())return e.remove(i),void(t!==s&&(i.deleteContents(),i.insertNode(document.createTextNode(t))));if(l){const e=l.parentElement;if(e){const t=document.createTextNode(l.textContent||"");e.insertBefore(t,l),e.removeChild(l),i.selectNode(t)}}if(t!==s){i.deleteContents();const e=document.createTextNode(t);i.insertNode(e),i.selectNode(e)}const c=C.createStyledElement("span",C.classNames.block.tooltip);c.setAttribute("data-tooltip",o),a.classNames&&C.applyClassNames(c,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);c.style.setProperty(n,String(t))}});try{i.surroundContents(c)}catch{const e=i.extractContents();c.appendChild(e),i.insertNode(c)}t!==s&&c.textContent!==t&&(c.textContent=t),ce(c,o,"above",n.classNames,n.styles);const d=c.closest('[contenteditable="true"]');d&&d.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:s,tooltip:r}).show(),Jr.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${C.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${C.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&C.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(ce(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(C.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},Vt=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=kt()}static apply(e){C.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),Jr.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Jr.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},Wt=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Kt=["improve","shorten","lengthen","simplify","fix_grammar"],Gt=()=>[wt,St,Vt,Ht,Ct,Mt,Ot,It,Ut],Jt="inline-toolbar",Xt=class e{static{this.eventListenersMap=new WeakMap}static{this.hideTimeoutMap=new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=i.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),C.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 8px;\n padding: 8px;\n box-shadow: var(--clepit-toolbar-shadow, 0 2px 8px rgba(0, 0, 0, 0.1));\n backdrop-filter: blur(8px);\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 0px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 14px;\n height: 14px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n transform: scale(1.05);\n}\n\n.clepit-toolbar-button:active {\n transform: scale(0.95);\n transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar-button.active {\n background: var(--clepit-toolbar-active-bg, var(--clepit-primary-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n font-weight: bold;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-bg);\n background-color: var(--clepit-text);\n padding: 6px 10px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-text);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), top 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=q("div","clepit-toolbar");o.id=`${t}-${Jt}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),C.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=i.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);if(!e.getElementFromContainerId(t))return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t);const o=((n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${C.classNames.block.container}`))?.getAttribute("data-tool"),r=e.getFilteredTools(o,a.config);r.forEach(a=>e.addButton(t,a,n)),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const s=n.getBoundingClientRect(),l=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!l)return;const c=((e=!1,t=Gt().length)=>({height:40,width:24*(t+(e?1:0))+16}))(Boolean(a.config.onInlineRewrite),r.length),d=s.left-l.left+s.width/2-c.width/2;let p=s.top-l.top-c.height-8;p<0&&(p=s.bottom-l.top+8),e.show(a.config.containerId,d,p)}static addRewriteButton(t,n){const a=i.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const r=e.getElementFromContainerId(t),s=document.getElementById(t);if(!r||!s)return;const l=q("button","clepit-toolbar-button",{type:"button"});l.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',l.setAttribute("data-tool","rewrite"),C.applyStyling(l,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const c=q("div","clepit-toolbar-rewrite-menu");c.style.display="none",c.setAttribute("data-rewrite-menu","true");for(const i of Kt){const t=q("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[i]??i,t.setAttribute("data-rewrite-action",i),e.addEventListener(s,t,"mousedown",e=>e.preventDefault()),e.addEventListener(s,t,"click",()=>{c.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,r=a.toString();r.trim()&&(l.classList.add("busy"),o(r,i).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),s.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(()=>{}).finally(()=>l.classList.remove("busy")))}),c.appendChild(t)}e.addEventListener(s,l,"mousedown",e=>e.preventDefault()),e.addEventListener(s,l,"click",()=>{c.style.display="none"===c.style.display?"flex":"none"}),r.appendChild(l),e.createTooltip(r,l,a.config.inlineRewriteTooltip??"rewrite"),r.appendChild(c)}static addButton(t,n,a){const o=i.getState().getInstance(t);if(!o)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const r=e.getElementFromContainerId(t);if(!r)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const s=q("button","clepit-toolbar-button",{type:"button"});s.innerHTML=n.icon,C.applyStyling(s,{classNames:o.config.classNames?.inlineToolbar?.button,styles:o.config.styles?.inlineToolbar?.button}),n.isActive(a)&&s.classList.add("active"),s.setAttribute("data-tool",n.label.toLowerCase());const l=document.getElementById(t);l&&(e.addEventListener(l,s,"mousedown",e=>e.preventDefault()),e.addEventListener(l,s,"click",()=>{try{const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,i=t&&!t.collapsed?t:a;if(i&&n.isActive(i))n.remove(i),s.classList.remove("active");else if(i){switch(n.label){case"italic":St.apply(i);break;case"bold":wt.apply(i);break;case"underline":Vt.apply(i);break;case"strikethrough":Ht.apply(i);break;case"inlineCode":Ct.apply(i,o.config.classNames?.blocks?.["inline-code"],o.config.styles?.blocks?.["inline-code"]);break;case"marker":Mt.apply(i,o.config.classNames?.blocks?.marker,o.config.styles?.blocks?.marker);break;case"status":Ot.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs);break;case"link":It.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs);break;case"tooltip":Ut.apply(i,{classNames:o.config.classNames?.tooltips,styles:o.config.styles?.tooltips},{classNames:o.config.classNames?.blocks?.tooltip,styles:o.config.styles?.blocks?.tooltip})}s.classList.add("active")}}catch(e){console.warn("Error applying inline tool:",e)}})),r.appendChild(s),e.createTooltip(r,s,n.label)}static createTooltip(t,n,a){const o=q("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=q("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=q("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.querySelectorAll(".clepit-toolbar-button").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-tooltip").forEach(e=>e.remove())}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden"),o.classList.add("clepit-toolbar--visible"),o.classList.contains("clepit-toolbar--visible")){const e=parseFloat(o.style.left)||0,t=parseFloat(o.style.top)||0;(Math.abs(e-n)>1||Math.abs(t-a)>1)&&o.classList.add("clepit-toolbar--position-animation")}else o.classList.add("clepit-toolbar--show-animation");o.style.left=`${n}px`,o.style.top=`${a}px`,requestAnimationFrame(()=>{o.classList.add("clepit-toolbar--visible")})}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${Jt}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=Gt().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${Jt}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},Yt={},Zt={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of Yt[e]??[])n.removeEventListener(a,o,t);Yt[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){Zt.dismiss(e);const o=window.getSelection(),r=o?.rangeCount?o.getRangeAt(0):null;if(!r)return;r.deleteContents();const s=document.createTextNode(n);r.insertNode(s),r.setStartAfter(s),r.collapse(!0),o?.removeAllRanges(),o?.addRange(r);const l=document.getElementById(e);if(!l)return;const c=i.getState().getInstance(e)?.config,d=je[a.provider]??a.provider,p=document.createElement("div");p.className="clepit-embed-offer",p.setAttribute("data-testid","embed-offer"),p.setAttribute("data-embed-offer-for",e);const u=document.createElement("span");u.textContent=ze(c?.embedLabels,"offerShowLive",{tool:d}).replace(" · Show live",""),p.appendChild(u);const m=document.createElement("button");m.type="button",m.setAttribute("data-testid","embed-offer-accept"),m.textContent=ze(c?.embedLabels,"offerShowLive",{tool:d}).split(" · ").pop()??"Show live",p.appendChild(m);const h=r.getBoundingClientRect(),g=l.getBoundingClientRect();p.style.left=`${Math.max(0,h.left-g.left)}px`,p.style.top=h.bottom-g.top+6+"px",l.appendChild(p);const b=()=>{const a=t.getAttribute("data-id"),o=Jr.getBlockIndex(e,a);Zt.dismiss(e),-1!==o&&y(e,o,!0,n)},f=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void b();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&Zt.dismiss(e)},v=t=>{p.contains(t.target)||Zt.dismiss(e)};m.addEventListener("click",b),document.addEventListener("keydown",f,!0),document.addEventListener("mousedown",v),Yt[e]=[{element:m,event:"click",handler:b},{capture:!0,element:document,event:"keydown",handler:f},{element:document,event:"mousedown",handler:v}]}},Qt={},en={dismiss(e){for(const{element:t,event:n,handler:a}of Qt[e]??[])t.removeEventListener(n,a);Qt[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){en.dismiss(e),C.injectStyles(me,he);const n=document.getElementById(e);if(!n)return;const a=i.getState().getInstance(e)?.config,o=Le.read(t),r=ve(o.tool),s=document.createElement("div");s.className="clepit-issue-menu",s.setAttribute("data-testid","issue-menu"),s.setAttribute("data-issue-menu-for",e);const l=Ee(o,a?.issueLabels);if(l){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=l,s.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=ye(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{en.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),s.appendChild(t)}}const c=document.createElement("a");c.href=o.url,c.target="_blank",c.rel="noopener noreferrer",c.setAttribute("data-testid","issue-open"),c.textContent=ye(a?.issueLabels,"openInTool",{tool:r}),c.addEventListener("click",()=>en.dismiss(e)),s.appendChild(c);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=ye(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{en.dismiss(e),en.showAsCard(e,t)}),s.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();s.style.left=`${Math.max(0,p.left-u.left)}px`,s.style.top=p.bottom-u.top+6+"px",n.appendChild(s);const m=t=>{"Escape"===t.key&&en.dismiss(e)},h=n=>{s.contains(n.target)||t.contains(n.target)||en.dismiss(e)};document.addEventListener("keydown",m),document.addEventListener("mousedown",h),Qt[e]=[{element:document,event:"keydown",handler:m},{element:document,event:"mousedown",handler:h}]},showAsCard(e,t){const n=Le.read(t),a=t.closest(`.${C.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=Jr.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};Jr.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?Jr.replaceBlock(e,i,s):(r&&Jr.saveBlockData(r),Jr.insertBlock(s,e,i+1))}},tn=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick))}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${C.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const r=i.getState().getInstance(o);return r?{instance:r,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${xe}`);if(a){if("edit"!==i.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void en.show(t.id,a)}const o=n.closest(`.${C.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=i.getState().getInstance(t.id);return void(n&&It.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs))}const r=n.closest(`.${C.classNames.block.tooltip}`);if(r){const e=document.createRange();e.selectNodeContents(r);const n=i.getState().getInstance(t.id);return void(n&&Ut.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip}))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView){try{Xt.hide(a.instance.config.containerId)}catch{}return}if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();if(o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed)try{Xt.repaint(a.instance.config.containerId,n)}catch{}else try{Xt.hide(a.instance.config.containerId)}catch{}}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${C.classNames.block.container}`);if(!a)return;const o=a.closest(`.${C.classNames.editor.container}`);if(!o)return;const r=i.getState().getInstance(o.id)?.config,s=lt(r,t);if(!s)return;const l=a.getAttribute("data-id"),c=Jr.getBlockIndex(o.id,l);if(-1===c)return;const d=Jr.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==s.kind)if("embed"!==s.kind)if("image"===s.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:s.url},type:"image"};p?Jr.replaceBlock(o.id,c,e):Jr.insertBlock(e,o.id,c+1)}else{let e=s.url;s.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(s.url)||s.url:s.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(s.url)||s.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?Jr.replaceBlock(o.id,c,t):Jr.insertBlock(t,o.id,c+1)}else"offer"===(r?.pasteEmbeds??"live")?Zt.show(o.id,a,t,s.embed):y(o.id,c,p,t);else tt(o.id,0,c,p,t,s.issue)}},nn="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",an=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:O(t.innerHTML),variant:n}}static render(t,n,a){C.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=C.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",G(t,"alertTextHint",e.placeholder)),i.html?r.innerHTML=i.html:r.innerHTML="",e.addEventListener(t,r,"keydown",Jr.handleKeydown),e.addEventListener(t,r,"input",Jr.handleInput),r}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const r=t.innerHTML||"",s={html:r.trim()&&"<br>"!==r.trim()?r:"",variant:n},l={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},c=Jr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,s,l);t.replaceWith(d),i.getState().updateBlockData(a,c,s)}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},on=class e{static render(t,n,a,o){if(C.injectStyles("clepit-alert-output-styles",nn),!e.validate(t))return P();if(an.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.variant,s=C.createStyledElement("div",`clepit-output-alert clepit-output-alert--${r}`,{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=L){if(!e.validate(t)||an.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},rn={icon:"!",get input(){return an},label:"Alert",get output(){return on},shortcut:vt("A"),testId:"block-type-alert",type:"alert"},sn=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${C.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${C.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${C.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${C.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,ln="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",cn=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${C.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${C.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:O(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){C.injectStyles("clepit-audio-input-styles",sn);const i=a||{alt:"",caption:"",url:""},r=C.createStyledElement("div",C.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=C.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const l=C.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});l.classList.add("clepit-audio-caption-container");const c=C.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",G(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n.caption||"",e.addEventListener(o,c,"keydown",Jr.handleKeydown),e.addEventListener(o,c,"input",Jr.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="♪";const l=C.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const c=C.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=C.createStyledElement("button",`${C.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),r.appendChild(d);const p=a?i.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;ce(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Jr.removeBlock(a,Jr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(r)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Jr.getBlockIndex(o,l),Jr.getBlockData(l).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(s){console.error("Audio upload error:",s),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=Jr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Jr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${C.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},dn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-audio-output-styles",ln),!e.validate(t))return P();if(cn.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=C.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":c.classList.add("clepit-output-audio-wrapper--left");break;case"center":c.classList.add("clepit-output-audio-wrapper--center");break;case"right":c.classList.add("clepit-output-audio-wrapper--right")}const d=q("audio","clepit-output-audio");if(d.src=i,d.controls=!0,d.preload="metadata",t.alt&&d.setAttribute("alt",t.alt),c.appendChild(d),l.appendChild(c),r){const e=C.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=L){if(!e.validate(t)||cn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},pn={icon:"♪",get input(){return cn},label:"Audio",get output(){return dn},shortcut:vt("O"),testId:"block-type-audio",type:"audio"},un=`\n/* Checklist input block styles */\n.${C.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${C.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${C.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${C.classNames.block.checklist.text}::before,\n.${C.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${C.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${C.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${C.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${C.classNames.block.checklist.checkbox}::before,\n.${C.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${C.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${C.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${C.classNames.block.checklist.checkbox}:checked + .${C.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${C.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${C.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,mn='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',hn=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${C.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${C.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:O(a.innerHTML)})}),{items:t}}static render(t,n,a){C.injectStyles("clepit-checklist-input-styles",un);const o={items:[]},i=n?{...o,...n}:o,r=C.createStyledElement("div",C.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=C.createStyledElement("div",C.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=C.createStyledElement("input",C.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=C.createStyledElement("div",C.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",G(a,"checklistItemHint",e.placeholder)),s.innerHTML=t.text?.trim()||"",e.addEventListener(a,r,"change",()=>Jr.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,l=n.closest(`.${C.classNames.block.container}`);if(!l)return;const c=Jr.getBlockIndex(a,l.getAttribute("data-id")),d=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&Jr.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Jr.getBlocks(a);e&&c<e.length-1&&Jr.moveBlock(a,c,c+1)}else if(d)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Jr.removeBlock(a,c)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),z(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;const o=Jr.getBlockIndex(a,t.getAttribute("data-id"));Jr.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(z(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${C.classNames.block.container}`);if(!e)return;const t=Jr.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Jr.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{Jr.ensureActiveBlock(a);const e=Jr.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(c>0){const t=e[c-1];t&&Jr.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${C.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${C.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(c<e.length-1){const t=e[c+1];t&&Jr.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${C.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",Jr.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${C.classNames.block.checklist.item}`)),n=t.filter(e=>z(e.querySelector(`.${C.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${C.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>z(e.querySelector(`.${C.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>z(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},gn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-checklist-output-styles",mn),!e.validate(t))return P();if(hn.isEmptyData(t))return document.createElement("div");const i=t.items,r=C.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=C.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=C.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=C.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});e.text&&e.text.trim()&&(s.innerHTML=e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=L){if(!e.validate(t)||hn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},bn={icon:"☑",get input(){return hn},label:"Checklist",get output(){return gn},shortcut:vt("K"),testId:"block-type-checklist",type:"checklist"},fn={icon:"𝕔",get input(){return ee},label:"Code",get output(){return ue},shortcut:vt("C"),testId:"block-type-code",type:"code"},yn="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",vn=`${yn}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,xn=yn,kn=new WeakMap;var wn=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=kn.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Or.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:O(n?.innerHTML),open:a}}static render(t,n,a){C.injectStyles("collapsible-input",vn);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=C.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,kn.set(r,[...i.children??[]]);const s=document.createElement("summary"),l=document.createElement("span");l.className="clepit-collapsible__title",l.setAttribute("contenteditable","true"),l.setAttribute("data-placeholder",G(t,"collapsibleTitleHint",e.placeholder)),i.html&&(l.innerHTML=O(i.html)),s.appendChild(l),r.appendChild(s);const c=document.createElement("div");return c.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{c.appendChild(e.renderChild(t,n))}),r.appendChild(c),e.addEventListener(t,l,"keydown",Jr.handleKeydown),e.addEventListener(t,l,"input",Jr.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=Jr.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return z(n?.innerHTML)&&!a}static isEmptyData(e){return z(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Cn="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Sn=Cn,En=Cn,An=class e{static render(t,n,a,o){if(C.injectStyles("collection-output",En),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},Nn="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",Ln=`${Nn}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,Bn=Nn,In=class e{static render(t,n,a,o){if(C.injectStyles("columns-output",Bn),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=C.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=Or.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=Ri(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},$n="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",Tn=`${$n}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,Mn=$n,_n=/^(\d{4})-(\d{2})-(\d{2})$/;function Dn(e){const t=_n.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var qn=class e{static render(t,n,a,o){C.injectStyles("date-output",Mn);const i=e.validate(t)?Dn(t.date):null;if(!i)return P();const r=C.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=L){const a=e.validate(t)?Dn(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},jn='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',zn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){C.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=C.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=C.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=C.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${C.classNames.block.container}`);if(!a)return;const o=Jr.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&Jr.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=Jr.getBlocks(t);n&&o<n.length-1&&Jr.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Jr.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),Jr.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),Jr.removeBlock(t,o);else{Jr.ensureActiveBlock(t);const a=Jr.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&Jr.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&Jr.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const r={variant:n},s={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},l=Jr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},On=class e{static render(t,n,a,o){if(C.injectStyles("clepit-delimiter-output-styles",jn),!e.validate(t))return P();if(zn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=C.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=L){if(!e.validate(t)||zn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},Hn="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",Pn=Hn,Rn=Hn,Fn=class e{static render(t,n,a,o){if(C.injectStyles("doc-card-output",Rn),!e.validate(t))return P();const i=C.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),l=document.createElement("span");if(l.className="clepit-doc-card__title",l.textContent=t.title||"Untitled",s.appendChild(l),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},Un="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",Vn=`${Un}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,Wn=Un;function Kn(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Gn=class e{static render(t,n,a,o){if(C.injectStyles("file-output",Wn),!e.validate(t))return P();const i=C.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=Kn(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=Kn(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},Jn='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',Xn="At a glance",Yn=class e{static render(t,n,a,o){if(C.injectStyles("clepit-glance-output-styles",Jn),!e.validate(t))return P();if(0===t.rows.length)return document.createElement("div");const i=C.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=q("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:Xn,i.appendChild(r);const s=q("dl","clepit-glance-rows");for(const e of t.rows){const t=q("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=q("dd","clepit-glance-value");n.innerHTML=O(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=L){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:Xn),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},Zn="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",Qn=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:O(t?.innerHTML),level:n}}static render(t,n,a){C.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=C.createStyledElement(r,C.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",G(t,"headerHint",e.placeholder)),i.html?s.innerHTML=i.html:s.innerHTML="",e.addEventListener(t,s,"keydown",Jr.handleKeydown),e.addEventListener(t,s,"input",Jr.handleInput),s}static changeLevel(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const r={html:t.innerHTML,level:n},s={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},l=Jr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ea=class e{static render(t,n,a,o){if(C.injectStyles("clepit-header-output-styles",Zn),!e.validate(t))return P();if(Qn.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.level||"h1",s=C.createStyledElement(r,"clepit-output-header",{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=L){if(!e.validate(t)||Qn.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ta=`\n/* Image block styles */\n.${C.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${C.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${C.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${C.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${C.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${C.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Image delete button */\n.${C.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${C.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${C.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,na="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",aa=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${C.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:O(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){C.injectStyles("clepit-image-input-styles",ta);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=C.createStyledElement("div",C.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=C.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const l=C.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});l.classList.add("clepit-image-caption-container");const c=C.createStyledElement("div",C.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",G(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n?.caption||"",e.addEventListener(o,c,"keydown",Jr.handleKeydown),e.addEventListener(o,c,"input",Jr.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="📷";const l=C.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop an image here</strong><br>or <span class="clepit-image-click-text">click to select</span>';const c=C.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports JPEG, PNG, GIF, WebP, SVG, and other image formats";const d=C.createStyledElement("button",`${C.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),r.appendChild(d);const p=i.getState().getInstance(a),u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;ce(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Jr.removeBlock(a,Jr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(r)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showError(n,"Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showError(t,"Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Jr.getBlockIndex(o,l),Jr.getBlockData(l).data)}else e.showError(n,"Failed to upload image. Please try again.")}catch(s){console.error("Image upload error:",s),e.showError(n,"Failed to upload image. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-image-loading",void 0);t.textContent="Uploading image...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-image-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=Jr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Jr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.image.wrapper} img`),n=e.querySelector(`.${C.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},oa=class e{static render(t,n,a,o){if(C.injectStyles("clepit-image-output-styles",na),!e.validate(t))return P();if(aa.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",l=C.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":c.classList.add("clepit-output-image-wrapper--left");break;case"center":c.classList.add("clepit-output-image-wrapper--center");break;case"right":c.classList.add("clepit-output-image-wrapper--right")}const d=q("img","clepit-output-image");if(d.src=i,d.alt=s,c.appendChild(d),l.appendChild(c),r){const e=C.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}return l}static draw(t,n=L){if(!e.validate(t)||aa.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},ia=he,ra=he,sa=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)sa(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))sa(e,t)}}else e.includes("clepit-issue")&&t.push(...Te(e))},la=class e{static collect(e,t){const n=[];sa(e??[],n);const a=new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){C.injectStyles("issues-output",ra);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=C.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=ye(n?.issueLabels,"linkedIssuesEmpty"),e}const r=D(e.table(i,L,n?.issueLabels));return C.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=L,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText(ye(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText(Ae(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||ye(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},ca="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",da=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(O(e.innerHTML))),{items:a,type:n}}static render(t,n,a){C.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=C.createStyledElement(r,C.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const l=a?.classNames?.[i.type]?.item,c=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,l,c)):e.createAndAppendListItem("",s,t,l,c),s}static createAndAppendListItem(t,n,a,o,i){const r=C.createStyledElement("li",C.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=t,r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",G(a,"listItemHint",e.placeholder)),e.addEventListener(a,r,"keydown",t=>{const s=t,l=n.closest(`.${C.classNames.block.container}`);if(!l)return;const c=Jr.getBlockIndex(a,l.getAttribute("data-id")),d=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&Jr.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Jr.getBlocks(a);e&&c<e.length-1&&Jr.moveBlock(a,c,c+1)}else if(d)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Jr.removeBlock(a,c)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),z(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;const o=Jr.getBlockIndex(a,t.getAttribute("data-id"));Jr.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(z(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${C.classNames.block.container}`);if(!e)return;const t=Jr.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Jr.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{Jr.ensureActiveBlock(a);const e=Jr.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${C.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(c>0){const t=e[c-1];t&&Jr.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${C.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(c<e.length-1){const t=e[c+1];t&&Jr.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",Jr.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const r={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},s={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},l=Jr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,r,s);t.replaceWith(c),i.getState().updateBlockData(a,l,r)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>z(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${C.classNames.block.list.item}`);return!t||Array.from(t).every(e=>z(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>z(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},pa=class e{static render(t,n,a,o){if(C.injectStyles("clepit-list-output-styles",ca),!e.validate(t))return P();if(da.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=C.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=e,i=C.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n&&n.trim()&&(i.innerHTML=n),s.appendChild(i)}),s}static draw(t,n=L){if(!e.validate(t)||da.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},ua="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav — approved 2026-08-06\n * (direction 2B, \"Eyebrow\"). */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen — approved 2026-08-06 (direction 1B, \"Panel\"). */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip — approved 2026-08-06\n * (direction 1B, \"Tabbed\"). */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",ma=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ha=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!ma(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=ha(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>ha(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=ha(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!ma(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=ha(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},ga=(e,t)=>ha(e,{schemas:t,stack:new Set}),ba=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),fa=e=>{if(!ba(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},ya=e=>{if(!ba(e)||!ba(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=fa(a);return t},va=e=>e.security[0],xa=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},ka={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${xa(e,t)}"`],a=va(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=ya(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=ya(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${xa(e,t)}'),`],i=[],r=va(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=ya(e.request),a=e.method.toLowerCase(),o=[` "${xa(e,t)}",`],i=va(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=ya(e.request),a=[],o=va(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${xa(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},wa=["bash","typescript","dart","python"],Ca=["get","post","put","patch","delete"],Sa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ea=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Aa=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),Na=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(Sa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),La=e=>Sa(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=Sa(t)?t:{},a=Sa(n.content)?n.content:void 0,o=a&&Sa(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],Ba=e=>{if(!Sa(e.requestBody))return;const t=Sa(e.requestBody.content)?e.requestBody.content:void 0;return(t&&Sa(t["application/json"])?t["application/json"]:void 0)?.schema},Ia=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(Sa);return t?Object.keys(t):[]},$a=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(Sa);return"string"==typeof t?.url?t.url:void 0},Ta=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",Ma=(e,t)=>{const n=Sa(e)?e:{},a=Sa(n.info)?n.info:{},o=Sa(n.components)?n.components:{},i={groups:[],schemas:Sa(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(Sa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=Sa(n.paths)?n.paths:{},s=new Map;for(const[l,c]of Object.entries(r))if(Sa(c))for(const e of Ca){const n=c[e];if(!Sa(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(Aa(t.exclude,a,l))continue;if(t.include&&!i&&!Aa(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:Ea(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:Na(n),path:l,...void 0===Ba(n)?{}:{request:Ba(n)},responses:La(n),security:Ia(n),...void 0===$a(n)?{}:{server:$a(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=Ta(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:Ea(d),operations:[r],title:d})}return i.groups=[...s.values()],i},_a=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},Da=(e,t)=>{const n=_a(e,"div","clepit-openapi-table-scroll");return n.append(t),n},qa=(e,t,n,a)=>{const o=_a(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},ja=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},za=(e,t=0)=>t>6?ja(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,za(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,za(e,t+1)])):ja(e),Oa=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},Ha=(e,t,n,a)=>{const o=_a(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=_a(e,"div","clepit-openapi-operation-head"),s=_a(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=_a(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=_a(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=_a(e,"div","clepit-openapi-operation-body"),d=_a(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(_a(e,"p","clepit-openapi-description",t.description));const p=_a(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(_a(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(_a(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=_a(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(_a(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=_a(e,"td","clepit-openapi-name",i.name);i.required&&o.append(_a(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(_a(e,"td","clepit-openapi-cell",i.in)),t.append(_a(e,"td","clepit-openapi-type",ja(ga(i.schema,n.schemas)))),t.append(_a(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(qa(e,"Parameters","parameters",t.id)),c.append(Da(e,u))),void 0!==t.request){const a=ga(t.request,n.schemas);if(a.children.length>0){c.append(qa(e,"Body","body",t.id));const n=_a(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=ue.draw({code:JSON.stringify(za(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(qa(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=_a(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=_a(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=_a(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=_a(e,"p","clepit-openapi-response-description");if(r){const t=_a(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",Oa(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=ga(a.schema,n.schemas);if(t.children.length>0){const n=ue.draw({code:JSON.stringify(za(t),null,2),language:"json",showCopy:!0},e);n&&l.append(n)}}i.push(l);const d=_a(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",Oa(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const m=((e,t,n)=>n.flatMap(n=>{const a=ka[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??wa);if(m.length>0){c.append(qa(e,"Try it","try-it",t.id));const n=ue.draw({code:m[0].code,language:m[0].language,showCopy:!0,syncKey:"api-reference",variants:m},e);n&&c.append(n)}return o.append(c),o},Pa=class e{static draw(t,n=L){if(!e.validate(t))return null;const a=Ma(t.spec,t),o=_a(n,"div","clepit-openapi");if(a.servers.length>0){const e=_a(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(_a(n,"th","clepit-openapi-th","Host")),t.append(_a(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(_a(n,"td","clepit-openapi-name",o.url)),t.append(_a(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(Da(n,e))}for(const e of a.groups){const i=_a(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=_a(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(Ha(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(C.injectStyles("clepit-openapi-output-styles",ua),!e.validate(t))return P();const i=D(e.draw(t,L));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])ue.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(ue.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const a of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...a.querySelectorAll(".clepit-openapi-response-tab")],t=[...a.querySelectorAll(".clepit-openapi-response")],o=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n})};e.forEach((t,a)=>{n(t,"click",()=>o(a)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(a+i+e.length)%e.length;-1!==r&&(t.preventDefault(),o(r),e[r]?.focus())})})}return()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},Ra="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",Fa=class e{static{this.placeholder="Start writing..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:O(e.querySelector(`.${C.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){C.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=C.createStyledElement("div",C.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",i.getState().getInstance(t)?.config.placeholder||e.placeholder),o.innerHTML=n?.html||"",e.addEventListener(t,o,"keydown",Jr.handleKeydown),e.addEventListener(t,o,"input",Jr.handleInput),o}static isEmpty(e){return z(e.querySelector(`.${C.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return z(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ua=class e{static render(t,n,a,o){if(C.injectStyles("clepit-paragraph-output-styles",Ra),!e.validate(t))return P();const i=C.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});if(Fa.isEmptyData(t))return i.appendChild(document.createElement("br")),i;const r=t.html;return r&&(i.innerHTML=r),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),Fa.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Va=`\n/* Quote block styles */\n.${C.classNames.block.quote.container} {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${C.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${C.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${C.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${C.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${C.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${C.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${C.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${C.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,Wa="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",Ka=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${C.classNames.block.quote.text}`),n=e.querySelector(`.${C.classNames.block.quote.author}`);return{author:O(n?.innerHTML),html:O(t?.innerHTML)}}static render(t,n,a){C.injectStyles("clepit-quote-input-styles",Va);const o=n||{author:"",html:""},i=C.createStyledElement("div",C.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=C.createStyledElement("div",C.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=C.createStyledElement("div",C.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=o.html||"",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",G(t,"quoteBodyHint",e.placeholder)),s.innerHTML=o.author||"",s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",G(t,"quoteAuthorHint",e.authorPlaceholder)),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",Jr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",Jr.handleInput),i.appendChild(r),o.author){const e=C.createStyledElement("div",C.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${C.classNames.block.container}`),o=Jr.getEditorId(a);if(!o)return;const i=Jr.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${C.classNames.block.quote.text}`),s=a.querySelector(`.${C.classNames.block.quote.author}`),l=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Jr.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Jr.getBlocks(o);t&&i<t.length-1&&Jr.moveBlock(o,i,i+1)}else if(l)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Jr.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),Jr.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!z(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?Jr.removeBlock(o,i):n===s&&(z(r.innerHTML)?Jr.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&Jr.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&Jr.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${C.classNames.block.container}`),o=Jr.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${C.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=Jr.getBlockIndex(o,a.getAttribute("data-id"));Jr.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.quote.text}`),n=e.querySelector(`.${C.classNames.block.quote.author}`);let a=!1,o=!1;return t?z(t.innerHTML)&&(a=!0):a=!0,n?z(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return z(e.html)&&z(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ga=class e{static render(t,n,a,o){if(C.injectStyles("clepit-quote-output-styles",Wa),!e.validate(t))return P();if(Ka.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.author||"",s=C.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),l=C.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=q("div","clepit-output-quote-content");if(i&&i.trim()&&(c.innerHTML=i),l.appendChild(c),s.appendChild(l),r){const e=C.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});s.appendChild(e);const t=C.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${r}`,s.appendChild(t)}return s.querySelectorAll(`span.${C.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(ce(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),s}static draw(t,n=L){if(!e.validate(t)||Ka.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Ja="\n.clepit-sketch {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",Xa=Ja,Ya=Ja,Za="http://www.w3.org/2000/svg";function Qa(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function eo(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var to=class e{static render(t,n,a,o){if(C.injectStyles("sketch-output",Ya),!e.validate(t))return P();const i=C.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(Za,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=eo(s.points??[]);if(!t)continue;const n=document.createElementNS(Za,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",Qa(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=L){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(Za,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=eo(i.points??[]);if(!t)continue;const a=n.createNS(Za,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",Qa(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},no=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: 8px;\n border: 1px solid var(--clepit-border);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${C.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${C.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${C.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${C.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${C.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${C.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${C.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${C.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${C.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Row handle cell */\n.clepit-table-row-handle {\n position: absolute;\n left: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-handle {\n position: absolute;\n top: -22px;\n left: 50%;\n transform: translateX(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-row-delete {\n position: absolute;\n right: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-delete {\n right: -22px;\n top: calc(50% + 18px);\n transform: translateY(-50%);\n}\n\n/* Show handles on hover/active */\n.clepit-table-row:hover .clepit-row-handle,\n.${C.classNames.block.table.headerCell}:hover .clepit-col-handle,\n.clepit-table-row:hover .clepit-row-delete,\n.${C.classNames.block.table.headerCell}:hover .clepit-col-delete {\n display: flex;\n}\n\n/* Hover/active states like toolbar buttons */\n.clepit-row-handle:hover, .clepit-col-handle:hover,\n.clepit-row-delete:hover, .clepit-col-delete:hover {\n color: var(--clepit-primary);\n}\n\n/* Table menu buttons */\n.clepit-table-row-menu-btn,\n.clepit-table-col-menu-btn {\n position: absolute;\n background: var(--clepit-bg);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 4px 8px;\n font-size: 12px;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 1002;\n}\n\n.clepit-table-row-menu-btn:hover,\n.clepit-table-col-menu-btn:hover {\n color: var(--clepit-primary);\n background: var(--clepit-bg);\n border-color: var(--clepit-border);\n}\n\n.clepit-table-row-menu-btn--visible,\n.clepit-table-col-menu-btn--visible {\n display: flex;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,ao="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n overflow: hidden;\n background: var(--clepit-bg);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border-radius: 4px;\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-top: none;\n border-radius: 0 0 8px 8px;\n}\n",oo=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${C.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-col-handle, .clepit-col-delete").forEach(e=>e.remove()),r.push(O(t.innerHTML))}i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),n=[];for(const e of t){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-row-handle, .clepit-row-delete").forEach(e=>e.remove()),n.push(O(t.innerHTML))}i.push(n)}const l=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:O(t.querySelector(`.${C.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:l}}static render(t,n,a){C.injectStyles("clepit-table-input-styles",no);const o=n?{...e.defaultData,...n}:e.defaultData,r=C.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),s=C.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),l=C.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),c=e.createRow(t,o.data[0],!0);l.appendChild(c),s.appendChild(l);const d=C.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let i=1;i<o.data.length;i++){const n=e.createRow(t,o.data[i]);d.appendChild(n)}s.appendChild(d);const p=C.createStyledElement("div","clepit-table-scroll-container");p.appendChild(s),r.appendChild(p);const u=C.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",r.appendChild(u);const m=C.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});m.style.position="absolute",m.style.display="none",m.style.zIndex="1000",m.textContent="⋯",r.appendChild(m);let h=null,g=-1,b=null;e.addEventListener(t,r,"mouseleave",()=>(u.style.display="none",m.style.display="none",void(b&&(b.remove(),b=null))));const f=e=>{h=e;const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(g=Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)).indexOf(e),g<0)return;const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;m.style.left=`${a}px`,m.style.top=`${Math.max(4,o)}px`,m.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&f(t)}),e.addEventListener(t,l,"mouseover",e=>{const t=e.target.closest(`.${C.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${C.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)[a];e&&y(e)}f(n)});const v=()=>{h&&"none"!==u.style.display&&f(h);const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)[g];e&&"none"!==m.style.display&&y(e)};e.addEventListener(t,window,"scroll",v,{passive:!0}),e.addEventListener(t,p,"scroll",v,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!h)return;const o=Array.from(d.querySelectorAll("tr")),i=o.indexOf(h),s=u.getBoundingClientRect(),l=r.getBoundingClientRect();e.createMenu(t,r,u,m,[{label:"Move up",onClick:()=>{i>0&&(d.insertBefore(h,o[i-1]),Jr.saveBlockData(h))},shortcut:mt("up")},{label:"Move down",onClick:()=>{i>=0&&i<o.length-1&&(d.insertBefore(o[i+1],h),Jr.saveBlockData(h))},shortcut:mt("down")},{label:"Insert above",onClick:()=>{const n=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,h),Jr.saveBlockData(h)},shortcut:xt("up")},{label:"Insert below",onClick:()=>{const n=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));h.nextSibling?d.insertBefore(a,h.nextSibling):d.appendChild(a),Jr.saveBlockData(h)},shortcut:xt("down")},{label:"Delete",onClick:()=>{o.length>1&&(h.remove(),Jr.saveBlockData(h))},shortcut:gt()}],s.left-l.left,s.bottom-l.top+4,a,b)}),e.addEventListener(t,m,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),g<0)return;const o=Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)),i=m.getBoundingClientRect(),s=r.getBoundingClientRect();e.createMenu(t,r,u,m,[{label:"Move left",onClick:()=>{if(g<=0)return;const e=g,t=o[e-1],n=o[e];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),g=e-1,Jr.saveBlockData(c)},shortcut:mt("left")},{label:"Move right",onClick:()=>{const e=g;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),g=e+1,Jr.saveBlockData(c)},shortcut:mt("right")},{label:"Insert left",onClick:()=>{const n=g,a=e.createHeaderCell(t,"");c.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${C.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Jr.saveBlockData(c)},shortcut:xt("left")},{label:"Insert right",onClick:()=>{const n=g+1,a=o[g]?.nextSibling||null,i=e.createHeaderCell(t,"");c.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${C.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Jr.saveBlockData(c)},shortcut:xt("right")},{label:"Delete",onClick:()=>{const e=c.querySelectorAll(`.${C.classNames.block.table.headerCell}`);if(g<0||e.length<=1)return;const t=e[g];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${C.classNames.block.table.cell}`);t[g]&&t[g].parentElement?.removeChild(t[g])}),Jr.saveBlockData(c)},shortcut:bt()}],i.left-s.left,i.bottom-s.top+4,a,b)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>f(n))})(n)),Array.from(c.querySelectorAll(`.${C.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const x=C.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});x.style.display="flex",x.style.alignItems="center",x.style.gap="8px",x.style.marginTop="8px";const k=C.createStyledElement("div",`${C.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});k.contentEditable="true",k.setAttribute("tabindex","0"),k.setAttribute("data-placeholder",G(t,"tableCaptionHint",e.captionPlaceholder)),k.style.flex="1",k.style.minWidth="0",k.innerHTML=O(o.caption),e.addEventListener(t,k,"input",Jr.handleInput),e.addEventListener(t,k,"keydown",e.handleKeydown),e.addEventListener(t,k,"click",e.handleClick),x.appendChild(k);const w=C.createStyledElement("div",`${C.classNames.block.table.downloadSwitch}`);w.style.flexShrink="0";const S=Q.create({checked:o.showDownload||!1,label:"Allow download",onToggle:e=>{const n=r.closest(`.${C.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&i.getState().partialUpdateBlockData(t,Jr.getBlockIndex(t,a),{showDownload:e})}}});w.appendChild(S),x.appendChild(w),r.appendChild(x);return e.addEventListener(t,r,"focusin",()=>{const e=document.activeElement;if(e&&r.contains(e))if(e.classList.contains(C.classNames.block.table.cell)){const t=e.closest("tr");t&&(h=t,f(t))}else e.classList.contains(C.classNames.block.table.headerCell)&&y(e)}),r}static createRow(t,n,a){const o=i.getState().getInstance(t),r=o?.config.classNames?.blocks?.table?.row,s=o?.config.styles?.blocks?.table?.row,l=C.createStyledElement("tr",a?`${C.classNames.block.table.headerRow}`:`${C.classNames.block.table.row}`,{classNames:r,styles:s});for(let i=0;i<n.length;i++)l.appendChild(a?e.createHeaderCell(t,n[i]):e.createCell(t,n[i]));return l.querySelector(`.${C.classNames.block.table.cell}`)?.focus(),l}static createCell(t,n){const a=i.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,r=a?.config.styles?.blocks?.table?.cell,s=C.createStyledElement("td",`${C.classNames.block.table.cell}`,{classNames:o,styles:r});return s.contentEditable="true",s.setAttribute("tabindex","0"),s.setAttribute("data-placeholder",G(t,"tableCellHint",e.cellPlaceholder)),s.innerHTML=O(n),e.addEventListener(t,s,"input",Jr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"click",e.handleClick),s}static createHeaderCell(t,n){const a=i.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,r=a?.config.styles?.blocks?.table?.header,s=C.createStyledElement("th",`${C.classNames.block.table.headerCell}`,{classNames:o,styles:r});return s.contentEditable="true",s.setAttribute("tabindex","0"),s.setAttribute("data-placeholder",G(t,"tableHeaderHint",e.headerPlaceholder)),s.innerHTML=O(n),e.addEventListener(t,s,"input",Jr.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"click",e.handleClick),s}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=Jr.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=Jr.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,l,c){c&&(c.remove(),c=null);const d=C.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:l?.classNames?.menu,styles:l?.styles?.menu});d.classList.add("clepit-block-operations-menu--visible"),d.style.position="absolute",d.style.zIndex="20",d.style.left=`${r}px`,d.style.top=`${s}px`,d.style.minWidth="180px",i.forEach(n=>{const a="delete"===n.label.toLowerCase(),o=C.createStyledElement("div","clepit-menu-item"+(a?" clepit-menu-item--danger":""),{classNames:l?.classNames?.menuItem,styles:l?.styles?.menuItem});o.style.fontSize="14px";const i=C.createStyledElement("span","clepit-menu-icon"),r=n.label.toLowerCase();r.includes("move up")?i.textContent="↑":r.includes("move down")?i.textContent="↓":r.includes("move left")?i.textContent="←":r.includes("move right")?i.textContent="→":r.includes("insert")?i.textContent="+":r.includes("delete")?i.textContent="×":i.textContent="•";const s=C.createStyledElement("span","clepit-menu-text");if(s.textContent=n.label,o.appendChild(i),o.appendChild(s),n.shortcut){const e=C.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,o.appendChild(e)}e.addEventListener(t,o,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),c&&(c.remove(),c=null)}),d.appendChild(o)}),n.appendChild(d),c=d;const p=e=>{d.contains(e.target)||e.target===a||e.target===o||(d.remove(),c=null,document.removeEventListener("click",p))};return setTimeout(()=>document.addEventListener("click",p),0),d}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${C.classNames.block.container}`);t&&Jr.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=Jr.getEditorId(n);if(!a)return;const o=n.closest(`.${C.classNames.block.container}`);if(!o)return;const i=Jr.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Jr.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Jr.getBlocks(a);t&&i<t.length-1&&Jr.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),Jr.saveBlockData(t);const i=t.querySelectorAll(`.${C.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),Jr.saveBlockData(t);const i=t.querySelectorAll(`.${C.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const l=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))t=l.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=l[a-1],r=l[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${C.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}Jr.saveBlockData(s)}break;case"ArrowRight":let c=-1;const d=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))c=d.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");c=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(c<d.length-1){e.preventDefault(),e.stopPropagation();const t=c,a=d[t],i=d[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${C.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}Jr.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(C.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),Jr.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),Jr.removeBlock(a,i);break;case"Delete":let p=-1;const u=Array.from(s.querySelectorAll(`.${C.classNames.block.table.headerCell}`));if(n.classList.contains(C.classNames.block.table.headerCell))p=u.indexOf(n);else if(n.classList.contains(C.classNames.block.table.cell)){const e=n.closest("tr");p=Array.from(e.querySelectorAll(`.${C.classNames.block.table.cell}`)).indexOf(n)}if(p>=0&&u.length>1){e.preventDefault(),e.stopPropagation();const t=u[p];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${C.classNames.block.table.cell}`);t[p]&&t[p].parentElement?.removeChild(t[p])}),Jr.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),Jr.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),Jr.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${C.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${C.classNames.block.table.cell},.${C.classNames.block.table.headerCell}`)).every(e=>z(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),Jr.removeBlock(a,i))}else{Jr.ensureActiveBlock(a);const o=Jr.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(C.classNames.block.table.caption)){const e=n.closest(`.${C.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&Jr.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(C.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&Jr.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const l=n.closest("tr"),c=Array.from(l?.cells||[]).indexOf(n);if("THEAD"===l?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[c])return void e.cells[c].focus()}if(l?.nextElementSibling){const e=l.nextElementSibling.cells[c];e&&e.focus()}else{if("TBODY"===l?.parentElement?.tagName&&l===l.parentElement.lastElementChild){const e=s.closest(`.${C.classNames.block.container}`)?.querySelector(`.${C.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&Jr.focusBlock(e)}}return;case"ArrowLeft":if(!H(n,"left"))return;e.preventDefault(),e.stopPropagation();const d=n.closest("table");if(!d)return;const p=n.closest("tr"),u=Array.from(p?.cells||[]).indexOf(n);if(u>0){const e=p?.cells[u-1];e&&e.focus()}else{if("TBODY"===p?.parentElement?.tagName&&p===p.parentElement.firstElementChild){const e=d.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(p?.previousElementSibling){const e=p.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!H(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const h=n.closest("tr"),g=Array.from(h?.cells||[]).indexOf(n);if(g<(h?.cells.length||0)-1){const e=h?.cells[g+1];e&&e.focus()}else{if("THEAD"===h?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(h?.nextElementSibling){const e=h.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.table.caption}`),n=e.querySelectorAll(`.${C.classNames.block.table.cell},.${C.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?z(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>z(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return z(e.caption)&&e.data.every(e=>e.every(e=>z(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},io="http://www.w3.org/2000/svg",ro=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],so=/^[=+@\t\r-]/,lo=class e{static{this.eventListenersMap=new WeakMap}static render(t,n,a,o,i){if(C.injectStyles("clepit-table-output-styles",ao),!e.validate(t))return P();if(oo.isEmptyData(t))return document.createElement("div");const r=e.draw(t,L);if(!r)return document.createElement("div");const s=D(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const l=s.querySelector(".clepit-output-table-caption");l&&o?.caption&&l.classList.add(o.caption),l&&a?.caption&&Object.assign(l.style,a.caption);const c=s.querySelector(".clepit-output-table-footer-container");return c&&o?.footerContainer&&c.classList.add(o.footerContainer),c&&a?.footerContainer&&Object.assign(c.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||oo.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,r){const s=t.querySelector(".clepit-output-table-download-btn");if(!s)return()=>{};o?.downloadButton&&s.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(s.style,a.downloadButton);const l=()=>e.downloadTableAsCSV(n);s.addEventListener("click",l);const c=r?document.getElementById(r):null;if(c){const t=e.eventListenersMap.get(c)??[];t.push({element:s,event:"click",handler:l}),e.eventListenersMap.set(c,t)}const d=r?i.getState().getInstance(r):null,p=ce(s,"Download CSV","above",d?.config.classNames?.tooltips,d?.config.styles?.tooltips);return()=>{s.removeEventListener("click",l),p()}}static draw(t,n=L){if(!e.validate(t)||oo.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(io,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of ro){const a=e.createNS(io,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>so.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},co="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",po=co,uo=co,mo={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},ho=class{static render(e,t,n,a){C.injectStyles("toc-output",uo);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=C.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents — headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=C.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=mo[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=O(o.html),i.appendChild(r)}),i}static draw(e,t=L,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*mo[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},go="\n.clepit-typeset {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",bo=go,fo=go,yo=.55,vo=.52,xo=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function ko(e,t=18){switch(e.kind){case"atom":return wo(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=ko(r,t);n.push(...xo(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=ko(e.base,t),a=Co(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=ko(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...xo(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=ko(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...xo(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=ko(e.numerator,t),a=ko(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...xo(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...xo(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=ko(e.radicand,t),a=.6*t,o=null===e.index?null:ko(e.index,Co(Co(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...xo(n,i+.12*t,0)];null!==o&&s.push(...xo(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=wo(e.symbol,"upright",n),o=Co(t),i=null===e.upper?null:ko(e.upper,o),r=null===e.lower?null:ko(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...xo(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...xo(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...xo(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=ko(e.base,t),a=wo(e.over,"upright",Co(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...xo(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=ko(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:wo(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:wo(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...xo(i,0,s(i)),...xo(n,i.width,0),...xo(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>ko(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let v=0;v<a;v+=1)o.push(Math.max(...n.map(e=>e[v]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[v,x]of n.entries()){u+=i[v]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...xo(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[v]??0)+l}const[m,h]=So[e.style],g=Math.max(t,.62*d),b=""===m?{depth:0,draw:[],height:0,width:0}:wo(m,"upright",g),f=""===h?{depth:0,draw:[],height:0,width:0}:wo(h,"upright",g),y=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...xo(b,0,y(b)),...p.map(e=>({...e,x:e.x+b.width})),...xo(f,b.width+c,y(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function wo(e,t,n){const a="italic"===t?yo:vo;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function Co(e){return Math.max(9,.7*e)}var So={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var Eo={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},Ao={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},No={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},Lo=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],Bo={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},Io={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},$o={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},To=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],Mo={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},_o=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,Do=/[A-Za-z]/,qo=/[0-9]/,jo={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},zo=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!Do.test(this.peek()))return this.take();let e="";for(;Do.test(this.peek());)e+=this.take();return e}},Oo=class extends Error{};function Ho(e){const t=new zo(e);try{const e=Po(t,null);if(Fo(t))throw new Oo("a \\right appears without a matching \\left");if(!t.done)throw new Oo(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof Oo)return{ok:!1,reason:n.message};throw n}}function Po(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!Ro(e)&&!Uo(e))&&!Fo(e);){const t=Vo(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function Ro(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function Fo(e){return!!e.source.startsWith("\\right",e.at)&&!Do.test(e.peek(6))}function Uo(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function Vo(e){const t=Wo(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=Wo(e);if(null===o)throw new Oo(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new Oo("a term carries two superscripts");a=o}else{if(null!==n)throw new Oo("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function Wo(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=Po(e,"}");if("}"!==e.peek())throw new Oo("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if(To.includes(t))throw new Oo(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new Oo("a row break appears outside a matrix");if("begin"===t)return function(e){const t=Go(e),n=Mo[t];if(void 0===n)throw new Oo(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(Po(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!Ro(e)){if(Uo(e)){e.at+=4;const i=Go(e);if(i!==t)throw new Oo(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new Oo(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new Oo(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new Oo("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=Ko(e);return{denominator:Ko(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=Po(e,"]"),"]"!==e.peek())throw new Oo("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:Ko(e)}}(e);if("left"===t)return function(e){const t=Jo(e,"left"),n=Po(e,null);if(!Fo(e))throw new Oo("a \\left has no matching \\right");return e.at+=6,{body:n,close:Jo(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new Oo("a \\right appears without a matching \\left");const n=jo[t];if(void 0!==n)return{kind:"atom",style:n,text:Go(e)};const a=Bo[t];if(void 0!==a)return{base:Ko(e),kind:"accent",over:a};if("overline"===t)return{base:Ko(e),kind:"accent",over:"‾"};if("underline"===t)return{base:Ko(e),kind:"accent",over:"_"};const o=No[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=Eo[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=Ao[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(Lo.includes(t))return{kind:"atom",style:"upright",text:t};const s=Io[t];if(void 0!==s)return{kind:"space",width:s};const l=$o[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new Oo(`"\\${t}" is not supported yet`)}(e);if(_o.test(t))return e.take(),{kind:"atom",style:qo.test(t)?"upright":"italic",text:t};throw new Oo(`"${t}" is not a character this engine understands`)}function Ko(e){if(e.skipSpace(),"{"!==e.peek()){const t=Wo(e);if(null===t)throw new Oo("a command is missing its argument");return t}e.take();const t=Po(e,"}");if("}"!==e.peek())throw new Oo("a { group is never closed");return e.take(),t}function Go(e){if(e.skipSpace(),"{"!==e.peek())throw new Oo("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new Oo("a text command’s { group is never closed")}function Jo(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=$o[`\\${t}`];if(void 0===n)throw new Oo(`"\\${t}" is not a delimiter this engine understands`);return n}const a=$o[n];if(void 0===a)throw new Oo(`\\${t} is missing a delimiter`);return e.take(),a}var Xo={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function Yo(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function Zo(e,t=L){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=Yo("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=Xo[r.style],n=Yo("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(Qo(r,o,t)):i.append(Yo("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function Qo(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return Yo("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var ei=72,ti=40,ni=28,ai=16;function oi(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=new Map,a=new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=new Map;for(const b of e.nodes)o.set(b.id,ii(b.label,ei));const i=new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*ti+(e.length-1)*ni:e.reduce((e,t)=>e+(o.get(t)??ei),0)+(e.length-1)*ni,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=ai+b*((t?ei:ti)+64);let c=ai+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??ei;i.set(a,{height:ti,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?ti:s)+ni}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,m=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),h=m.some(e=>e.points.length>2),g=t?d:Math.max(d,h?u:0);return{edges:m,height:(t?Math.max(p,h?u:0):p)+ai,kind:"flowchart",nodes:c,width:g+ai}}(e):function(e){const t=[];let n=ai;for(const m of e.participants){const e=ii(m.label,96);t.push({actor:m.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:m.id,label:m.label}),n+=e+ni}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const m of e.steps){if("activation"===m.kind){m.active?s.set(m.participant,l):c(m.participant,l);continue}if("note"===m.kind){const e=m.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=ii(m.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===m.placement?n-t-ni:"right"===m.placement?o+ni:(n+o)/2-t/2;i.push({height:34,text:m.text,width:t,x:r,y:l}),l+=62;continue}const e=a(m.from),t=a(m.to);null!==e&&null!==t&&(m.activate&&s.set(m.to,l),o.push({end:m.end,fromX:e,line:m.line,selfCall:m.from===m.to,text:m.text,toX:t,y:l}),l+=48,m.deactivate&&c(m.to,l))}const d=l;for(const m of[...s.keys()])c(m,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-ni+ai,p+ai);return{activations:r,height:d+ai,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function ii(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var ri=["BT","LR","RL","TB","TD"],si=["subgraph","end","click","style","classDef","class","linkStyle","direction"],li=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],ci=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],di=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],pi=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],ui=e=>({ok:!1,reason:e});function mi(e){return e.split(/[\s(]/,1)[0]??""}function hi(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return ui("the block is empty");const[n,...a]=t,o=mi(n??"");return"sequenceDiagram"===o?function(e){const t=new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=mi(o);if(li.includes(e))return ui(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=xi(o,e);if(null===n)return ui(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!vi(t))return ui(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=ki(o);if(null===e)return ui(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=wi(o);if(null===i)return ui(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(mi(e).length).trim();if(0===n.length)return ui('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=ri.find(e=>e===n);if(void 0===a)return ui(`"${n}" is not a supported direction — use TD, TB, BT, LR or RL`);const o=new Map,i=[];for(const r of t){const e=mi(r);if(si.includes(e))return ui(`"${e}" is not supported yet`);if(r.includes("&"))return ui('"&" fan-out is not supported yet');const t=gi(r,o,i);if(null!==t)return ui(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):ui(`"${o}" diagrams are not supported yet — only flowchart and sequenceDiagram are`)}function gi(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=bi(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=yi(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function bi(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=ci.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of ci){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=fi(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function fi(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function yi(e){const t=e.trim();if(0===t.length)return null;for(const n of pi){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(vi(a))return{id:a,label:o.trim(),shape:n.shape}}return vi(t)?{id:t,label:t,shape:"rect"}:null}function vi(e){return/^[A-Za-z_][\w-]*$/.test(e)}function xi(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!vi(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function ki(e){const t=e.slice(mi(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(vi)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return vi(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function wi(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of di){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(vi(t)&&vi(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var Ci={dotted:"5 4",solid:"",thick:""},Si={dotted:1.5,solid:1.5,thick:3};function Ei(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function Ai(e,t,n,a,o){const i=Ei("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function Ni(e,t=L){const n=Ei("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=Ei("defs",{},e),n=Ei("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(Ei("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)Bi(e,a,n);for(const a of t.nodes)Li(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(Ei("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(Ei("rect",o,n)),e.append(Ai(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(Ei("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)Ii(e,a,n);for(const a of t.notes)e.append(Ei("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(Ai(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function Li(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return Ei("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return Ei("polygon",{...s,points:e},t)}if("stadium"===a)return Ei("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return Ei("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=Ei("g",{},t);return e.append(Ei("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(Ei("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(Ei("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return Ei("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(Ai(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function Bi(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?Ei("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":Ci[t.line],"stroke-width":Si[t.line]},n):Ei("line",{class:"clepit-typeset__edge","stroke-dasharray":Ci[t.line],"stroke-width":Si[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=Ai(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function Ii(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":Ci[t.line],"stroke-width":Si[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=Ei("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(Ai(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=Ei("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(Ei("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(Ei("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(Ai(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var $i=class e{static render(t,n,a,o,i){if(C.injectStyles("typeset-output",fo),!e.validate(n))return P();const r=C.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=hi(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(D(Ni(oi(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=Ho(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(D(Zo(ko(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=L){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=hi(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(Ni(oi(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=Ho(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(Zo(ko(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},Ti=class{static render(e,t,n,a){return $i.render("LaTeX",e,t,n,a)}static draw(e,t=L){return $i.draw("LaTeX",e,t)}},Mi=class{static render(e,t,n,a){return $i.render("Mermaid",e,t,n,a)}static draw(e,t=L){return $i.draw("Mermaid",e,t)}},_i="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",Di=_i,qi=_i,ji=class{static render(e,t,n,a){C.injectStyles("updates-output",qi);const o=C.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=L){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},zi=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${C.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${C.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${C.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${C.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Oi="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Hi=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${C.classNames.block.video.captionEditable}`),o=e.querySelector(`.${C.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:O(a?.innerHTML),url:r}}static render(t,n,a,o){C.injectStyles("clepit-video-input-styles",zi);const i=a||{alt:"",caption:"",url:""},r=C.createStyledElement("div",C.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=ot(n?.url||""),l=it(n?.url||"");if(s||l){const e=C.createStyledElement("iframe",C.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=C.createStyledElement("video",C.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const c=C.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-video-caption-container");const d=C.createStyledElement("div",C.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",G(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=n?.caption||"",e.addEventListener(o,d,"input",Jr.handleInput),e.addEventListener(o,d,"keydown",Jr.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const r=C.createStyledElement("div",C.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});r.setAttribute("tabindex","0"),r.classList.add("clepit-drop-area");const s=C.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});s.textContent="🎥";const l=C.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});l.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const c=C.createStyledElement("button",`${C.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});c.type="button",c.textContent="✕",r.appendChild(s),r.appendChild(l),r.appendChild(c),e.addEventListener(a,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");t&&Jr.removeBlock(a,Jr.getBlockIndex(a,t))}),e.addEventListener(a,r,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,r,"dragleave",()=>{r.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,r,"dragover",e=>{e.preventDefault(),e.stopPropagation(),r.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,r,"drop",i=>{i.preventDefault(),i.stopPropagation(),r.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(i,t,n,a,o)}),e.addEventListener(a,r,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,r,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?i.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;ce(c,"Delete block","below",p,u),t.appendChild(r)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,r){e.showLoading(n);try{let s=await a(t);if(s){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:s},a,o,r);const l=n.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id");l&&i.getState().updateBlockData(o,Jr.getBlockIndex(o,l),Jr.getBlockData(l).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(s){console.error("Video upload error:",s),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=C.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=C.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=Jr.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&i.getState().partialUpdateBlockData(a,Jr.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${C.classNames.block.video.wrapper} video`),n=e.querySelector(`.${C.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${C.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?z(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&z(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Pi=class e{static render(t,n,a,o){if(C.injectStyles("clepit-video-output-styles",Oi),!e.validate(t))return P();if(Hi.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=C.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),c=C.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":c.classList.add("clepit-output-video-wrapper--left");break;case"center":c.classList.add("clepit-output-video-wrapper--center");break;case"right":c.classList.add("clepit-output-video-wrapper--right")}const d=ot(i),p=it(i);if(d||p){const e=q("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",c.appendChild(e),l.appendChild(c)}else{const e=q("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",c.appendChild(e),l.appendChild(c)}if(r){const e=C.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=L){if(!e.validate(t)||Hi.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Ri=(e,t,n)=>{const a=Fi(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},Fi=(e,t,n)=>{switch(e.type){case"alert":return on.draw(e.data,t);case"audio":return dn.draw(e.data,t);case"checklist":return gn.draw(e.data,t);case"code":return ue.draw(e.data,t,n);case"collapsible":return Vi.draw(e.data,t,n);case"collection":return An.draw(e.data,t);case"columns":return In.draw(e.data,t,n);case"date":return qn.draw(e.data,t);case"delimiter":return On.draw(e.data,t);case"doc_card":return Fn.draw(e.data,t,n);case"embed":return We.draw(e.data,t,n);case"file":return Gn.draw(e.data,t);case"glance":return Yn.draw(e.data,t);case"header":return ea.draw(e.data,t);case"image":return oa.draw(e.data,t);case"issues":return la.draw(e.data,t,n);case"latex":return Ti.draw(e.data,t);case"list":return pa.draw(e.data,t);case"mermaid":return Mi.draw(e.data,t);case"openapi":return Pa.draw(e.data,t);case"paragraph":return Ua.draw(e.data,t);case"quote":return Ga.draw(e.data,t);case"sketch":return to.draw(e.data,t);case"table":return lo.draw(e.data,t);case"toc":return ho.draw(e.data,t,n);case"updates":return ji.draw(e.data,t);case"video":return Pi.draw(e.data,t);default:return Ui(e)}},Ui=e=>(console.warn("drawBlock: no drawer for block",e),null),Vi=class e{static render(t,n,a,o){if(C.injectStyles("collapsible-output",xn),!e.validate(t))return P();const i=C.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=O(t.html),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="clepit-collapsible__children";for(const c of t.children??[])l.appendChild(e.renderChild(c,n));return i.appendChild(l),i}static renderChild(e,t){const n=Or.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=L,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=Ri(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},Wi={icon:"▸",get input(){return wn},label:"Collapsible section",get output(){return Vi},shortcut:vt("E"),testId:"block-type-collapsible",type:"collapsible"},Ki=new WeakMap,Gi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=Ki.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){C.injectStyles("collection-input",Sn);const a=t??{collectionId:""},o=An.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),Ki.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ji={icon:"▦",get input(){return Gi},label:"Collection",get output(){return An},shortcut:vt("G"),testId:"block-type-collection",type:"collection"},Xi=new WeakMap;var Yi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=Xi.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Or.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){C.injectStyles("columns-input",Ln);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=C.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return Xi.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=C.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=Jr.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Zi={icon:"▥",get input(){return Yi},label:"Columns",get output(){return In},shortcut:vt("L"),testId:"block-type-columns",type:"columns"},Qi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){C.injectStyles("date-input",Tn);const o=C.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&Dn(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},er={icon:"▤",get input(){return Qi},label:"Date",get output(){return qn},shortcut:vt("D"),testId:"block-type-date",type:"date"},tr={icon:"—",get input(){return zn},label:"Delimiter",get output(){return On},shortcut:vt("D"),testId:"block-type-delimiter",type:"delimiter"},nr=new WeakMap,ar=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=nr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){C.injectStyles("doc-card-input",Pn);const a=t??{pageId:"",title:""},o=Fn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),nr.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},or={icon:"🗎",get input(){return ar},label:"Doc card",get output(){return Fn},shortcut:vt("K"),testId:"block-type-doc-card",type:"doc_card"},ir={icon:"🔗",get input(){return Qe},label:"Embed",get output(){return We},shortcut:vt("M"),testId:"block-type-embed",type:"embed"},rr=new WeakMap,sr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=rr.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){C.injectStyles("file-input",Vn);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&rr.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=rr.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=Gn.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);rr.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},lr={icon:"📎",get input(){return sr},label:"File",get output(){return Gn},shortcut:vt("F"),testId:"block-type-file",type:"file"},cr={html:"",label:""},dr=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:O(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){C.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[cr]},o=Yn.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",G(e,"glanceLabelHint","Label"));for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",G(e,"glanceValueHint","Value"));return o}static changeVariant(t,n,a){const o=i.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const r=Jr.getBlockIndex(a,t.closest(`.${C.classNames.block.container}`)?.getAttribute("data-id")),s={...e.save(t),variant:n},l={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},c=e.render(a,s,l);t.replaceWith(c),i.getState().updateBlockData(a,r,s)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===O(e.html).trim())}static destroy(e){}},pr={icon:"≡",get input(){return dr},label:"At a glance",get output(){return Yn},shortcut:vt("N"),testId:"block-type-glance",type:"glance"},ur={icon:"H",get input(){return Qn},label:"Header",get output(){return ea},shortcut:vt("H"),testId:"block-type-header",type:"header"},mr={icon:"𝑖",get input(){return aa},label:"Image",get output(){return oa},shortcut:vt("I"),testId:"block-type-image",type:"image"},hr={},gr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){C.injectStyles("issues-input",ia);const a=i.getState().getInstance(e)?.config,o=i.getState().getData(e)?.blocks??[],r=la.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:hr[e]},n?.styles,n?.classNames);return r.classList.add("clepit-issues--input"),r.setAttribute("contenteditable","false"),r}static refresh(t,n){hr[t]={...hr[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${C.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${C.classNames.block.content}`);if(!n)continue;const a=i.getState().getInstance(t),r={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},r))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete hr[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},br={icon:"☑",get input(){return gr},label:"Linked issues",get output(){return la},shortcut:vt("J"),testId:"block-type-issues",type:"issues"},fr={icon:"•",get input(){return da},label:"List",get output(){return pa},shortcut:vt("L"),testId:"block-type-list",type:"list"},yr="clepit-openapi__source",vr=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},xr=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=new WeakMap}static render(t,n,a){C.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=q("div","clepit-openapi-input"),i=q("div",yr);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",G(t,"openApiSourceHint",e.placeholder)),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=q("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(Pa.render(n)),i.addEventListener("input",()=>{const t=vr(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(Pa.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains(yr)?e:e.querySelector(`.${yr}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return vr(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},kr={icon:"⇄",get input(){return xr},label:"API reference",get output(){return Pa},shortcut:vt("A"),testId:"block-type-openapi",type:"openapi"},wr={icon:"¶",get input(){return Fa},label:"Paragraph",get output(){return Ua},shortcut:vt("P"),testId:"block-type-paragraph",type:"paragraph"},Cr={icon:"“",get input(){return Ka},label:"Quote",get output(){return Ga},shortcut:vt("Q"),testId:"block-type-quote",type:"quote"},Sr=new WeakMap,Er=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?Sr.get(t):void 0)??{strokes:[]}}static render(t,n,a){C.injectStyles("sketch-input",Xa);const o=n??{strokes:[]},i=to.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),Sr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=Sr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=to.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=Sr.get(n)??{strokes:[]};Sr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ar={icon:"✏️",get input(){return Er},label:"Sketch",get output(){return to},shortcut:vt("W"),testId:"block-type-sketch",type:"sketch"},Nr={icon:"⊞",get input(){return oo},label:"Table",get output(){return lo},shortcut:vt("T"),testId:"block-type-table",type:"table"},Lr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){C.injectStyles("toc-input",po);const a=i.getState().getData(e)?.blocks??[],o=ho.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Br={icon:"≡",get input(){return Lr},label:"Table of contents",get output(){return ho},shortcut:vt("T"),testId:"block-type-toc",type:"toc"},Ir={latex:"LaTeX",mermaid:"Mermaid"};function $r(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function Tr(e,t,n,a){C.injectStyles("typeset-input",bo);const o=n??{source:""},i=C.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:a?.classNames?.wrapper,styles:a?.styles?.wrapper});i.setAttribute("data-language",e),i.setAttribute("data-rendered","source");const r=q("span","clepit-typeset__kind");r.textContent=Ir[e],i.appendChild(r);const s=q("span","clepit-typeset__title");s.setAttribute("data-testid","typeset-title"),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",t),s.textContent=o.title??"",i.appendChild(s);const l=q("pre","clepit-typeset__source");return l.setAttribute("contenteditable","true"),l.textContent=o.source,i.appendChild(l),i}var Mr=class{static{this.placeholder=""}static save(e){return $r(e)}static render(e,t,n){return Tr("latex",G(e,"formulaTitleHint","What does this formula show?"),t,n)}static isEmpty(e){return""===$r(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},_r=class{static{this.placeholder=""}static save(e){return $r(e)}static render(e,t,n){return Tr("mermaid",G(e,"diagramTitleHint","What does this diagram show?"),t,n)}static isEmpty(e){return""===$r(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Dr={icon:"∑",get input(){return Mr},label:"LaTeX",get output(){return Ti},shortcut:vt("X"),testId:"block-type-latex",type:"latex"},qr={icon:"◈",get input(){return _r},label:"Mermaid",get output(){return Mi},shortcut:vt("Y"),testId:"block-type-mermaid",type:"mermaid"},jr=new WeakMap,zr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=jr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){C.injectStyles("updates-input",Di);const a=t??{},o=ji.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),jr.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Or=[rn,pn,bn,fn,Wi,Ji,{icon:"🕘",get input(){return zr},label:"Updates",get output(){return ji},shortcut:vt("U"),testId:"block-type-updates",type:"updates"},Zi,er,tr,or,ir,lr,pr,ur,mr,br,fr,kr,wr,Cr,Ar,Dr,qr,Nr,Br,{icon:"▶",get input(){return Hi},label:"Video",get output(){return Pi},shortcut:vt("V"),testId:"block-type-video",type:"video"}],Hr="clepit-block-type-selector",Pr="clepit-code-language-submenu",Rr="clepit-code-theme-submenu",Fr="clepit-convert-submenu",Ur="clepit-block-operations-menu";function Vr(e){return Wt.includes(e)}function Wr(e,t,n){return e?.[t]??n}var Kr,Gr=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=i.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const r=void 0!==a.config.audioUploader,s=void 0!==a.config.imageUploader,l=void 0!==a.config.videoUploader,c=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,p=a.config.classNames?.convertSubmenu,u=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,h=a.config.styles?.blockTypeMenu,g=a.config.styles?.convertSubmenu,b=a.config.styles?.operationsMenu;e.remove(n),C.injectStyles("clepit-block-toolbar-styles",'\n/* Block Toolbar */\n.clepit-block-toolbar {\n position: absolute;\n left: 4px;\n top: 4px;\n z-index: 1000;\n display: none;\n gap: 4px;\n flex-shrink: 0;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n transform: translateY(0) !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-block-toolbar-add:active,\n.clepit-block-toolbar-ops:active {\n transform: scale(0.95);\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n z-index: 998;\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const f=q("div",e.defaultClassName);f.id=`${t}-block-toolbar`,f.innerHTML="",C.applyStyling(f,{classNames:c?.container,styles:m?.container});const y=q("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML="+",C.applyStyling(y,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:r,block:n,classNames:d,containerId:t,imageIsEnabled:s,menuLabels:a.config.blockToolbarLabels,styles:h,toolLabels:a.config.blockToolLabels,videoIsEnabled:l}));const v=q("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});v.innerHTML="⋯",C.applyStyling(v,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,v,"click",()=>e.showOperationsMenu({audioIsEnabled:r,block:n,classNames:u,containerId:t,convertSubmenuClassNames:p,convertSubmenuStyles:g,imageIsEnabled:s,operationLabels:a.config.blockToolbarLabels,styles:b,toolLabels:a.config.blockToolLabels,videoIsEnabled:l})),f.appendChild(y),f.appendChild(v),e.addEventListener(o,f,"click",e=>e.stopPropagation()),n.appendChild(f)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:r,classNames:s,styles:l,menuLabels:c,toolLabels:d}){e.closeAllMenus();const p=document.querySelector(`.${Hr}`);if(p)return p.classList.remove(`${Hr}--visible`),p.classList.add(`${Hr}--hidden`),void setTimeout(()=>p.remove(),200);const u=q("div",Hr);C.applyStyling(u,{classNames:s?.container,styles:l?.container});const m=q("input","",{placeholder:Wr(c,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),C.applyStyling(m,{classNames:s?.input,styles:l?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=q("div",`${Hr}-items`),b=i=>{g.innerHTML="",i.forEach(i=>{if("image"===i.type&&!a)return;if("video"===i.type&&!o)return;if("audio"===i.type&&!r)return;const c=q("div","clepit-menu-item clepit-block-type-item");c.setAttribute("data-testid",`block-type-${i.type}`),C.applyStyling(c,{classNames:s?.item?.container,styles:l?.item?.container});const p=q("span","clepit-menu-icon "+("image"===i.type?"clepit-menu-icon--italic":""));p.textContent=i.icon,C.applyStyling(p,{classNames:s?.item?.icon,styles:l?.item?.icon}),c.appendChild(p);const m=q("span","clepit-menu-label");if(m.textContent=(Vr(i.type)?d?.[i.type]:void 0)??i.label,C.applyStyling(m,{classNames:s?.item?.text,styles:l?.item?.text}),c.appendChild(m),i.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=i.shortcut,C.applyStyling(e,{classNames:s?.item?.shortcut,styles:l?.item?.shortcut}),c.appendChild(e)}e.addEventListener(h,c,"click",e=>{if(e.stopPropagation(),n){const e=Jr.getBlockIndex(t,n.getAttribute("data-id")||"");Jr.insertBlock({data:{html:""},type:i.type},t,e+1)}u.hidePopover()}),g.appendChild(c)})},f=((e,t)=>t.filter(t=>st(e,t.type)))(i.getState().getInstance(t)?.config,Or);if(b(f),e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",()=>{const e=m.value.toLowerCase(),t=f.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e));if(b(t),0===t.length&&""!==e.trim()){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Wr(c,"noBlockTypesFound","No block types found"),g.appendChild(e)}}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.hidePopover()}),u.appendChild(g),u.classList.add(Hr),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Hr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||u.remove()})):u.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:c,operationLabels:d,toolLabels:p}){e.closeAllMenus();const u=q("div",Ur);o?.container&&C.applyStyling(u,{classNames:a?.container,styles:o.container}),a?.container&&u.classList.add(a.container);const m=q("input","",{placeholder:Wr(d,"searchOperations","Search operations..."),type:"text"});m.setAttribute("data-testid","operations-search"),C.applyStyling(m,{classNames:a?.input,styles:o?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=q("div",`${Ur}-items`),b=n.getAttribute("data-tool");if(!b)return;const f=(e,t)=>Wr(d,e,t),y=[{hasSubmenu:!0,icon:"↻",label:f("convert","Convert To"),testId:"operation-convert",value:"convert"},{icon:"↑",label:f("moveUp","Move Up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"},{icon:"↓",label:f("moveDown","Move Down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"},{icon:"×",label:f("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"}],v=[{icon:"←",label:f("alignLeft","Align Left"),testId:"image-align-left",value:"imageAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"image-align-center",value:"imageAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"image-align-right",value:"imageAlignRight"}],x=[{icon:"←",label:f("alignLeft","Align Left"),testId:"video-align-left",value:"videoAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"video-align-center",value:"videoAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"video-align-right",value:"videoAlignRight"}],k=[{icon:"←",label:f("alignLeft","Align Left"),testId:"audio-align-left",value:"audioAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"audio-align-center",value:"audioAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"audio-align-right",value:"audioAlignRight"}],w=[{hasSubmenu:!0,icon:"⌘",label:f("codeLanguage","Language"),testId:"code-language",value:"codeLanguage"},{hasSubmenu:!0,icon:"◆",label:f("codeTheme","Theme"),testId:"code-theme",value:"codeTheme"}],S="embed"===b&&Qe.save(n).issue?[{icon:"▭",label:f("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:"▣",label:f("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:"▭",label:f("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];y.forEach(m=>{const b=q("div","clepit-menu-item clepit-block-operation-item");b.setAttribute("data-testid",`operation-${m.value}`),C.applyStyling(b,{classNames:a?.item?.container,styles:o?.item?.container}),b.setAttribute("data-testid",m.testId);const f=q("span","clepit-menu-icon");f.textContent=m.icon,C.applyStyling(f,{classNames:a?.item?.icon,styles:o?.item?.icon}),b.appendChild(f);const y=q("span","clepit-menu-label");if(y.textContent=m.label,C.applyStyling(y,{classNames:a?.item?.text,styles:o?.item?.text}),b.appendChild(y),m.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=m.shortcut,C.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),b.appendChild(e)}if(m.hasSubmenu){const e=q("span","clepit-menu-arrow");e.textContent="›",b.appendChild(e)}"delete"===m.value&&(b.classList.add("clepit-block-toolbar--delete-enabled"),1===h.querySelectorAll(".clepit-block").length&&(b.classList.add("clepit-block-toolbar--delete-disabled"),b.title="Cannot delete the last block")),e.addEventListener(h,b,"click",a=>{a.stopPropagation(),m.hasSubmenu?(document.querySelector(`.${Pr}`)?.remove(),document.querySelector(`.${Rr}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:c,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:d,parentItem:b,parentMenu:u,styles:r,toolLabels:p,videoIsEnabled:l})):(e.handleOperationSelect(m.value,n,t),u.remove())}),g.appendChild(b)});const E=()=>{const e=q("div","clepit-menu-divider");C.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),g.appendChild(e)};if("image"===b&&(E(),v.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("imageAlign")){const e=n.querySelector(".clepit-image-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("imageAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"video"===b&&(E(),x.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("videoAlign")){const e=n.querySelector(".clepit-video-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("videoAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"audio"===b&&(E(),k.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");if(l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("audioAlign")){const e=n.querySelector(".clepit-audio-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("audioAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"code"===b&&(E(),w.forEach(s=>{const l=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(l,{classNames:a?.item?.container,styles:o?.item?.container}),l.setAttribute("data-testid",s.testId);const c=q("span","clepit-menu-icon");c.textContent=s.icon,C.applyStyling(c,{classNames:a?.item?.icon,styles:o?.item?.icon}),l.appendChild(c);const p=q("span","clepit-menu-label");if(p.textContent=s.label,C.applyStyling(p,{classNames:a?.item?.text,styles:o?.item?.text}),l.appendChild(p),s.hasSubmenu){const e=q("span","clepit-menu-arrow");e.textContent="›",l.appendChild(e)}e.addEventListener(h,l,"click",a=>{a.stopPropagation(),s.hasSubmenu?"codeLanguage"===s.value?e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):"codeTheme"===s.value&&e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):(e.handleOperationSelect(s.value,n,t),u.remove())}),g.appendChild(l)})),"embed"===b&&(E(),S.forEach(i=>{const r=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=q("span","clepit-menu-icon");s.textContent=i.icon,C.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=q("span","clepit-menu-label");l.textContent=i.label,C.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"header"===b){E();const i=e.getCurrentHeadingLevel(n);[{icon:"H1",label:f("headingH1","Heading 1"),value:"heading-h1"},{icon:"H2",label:f("headingH2","Heading 2"),value:"heading-h2"},{icon:"H3",label:f("headingH3","Heading 3"),value:"heading-h3"},{icon:"H4",label:f("headingH4","Heading 4"),value:"heading-h4"},{icon:"H5",label:f("headingH5","Heading 5"),value:"heading-h5"},{icon:"H6",label:f("headingH6","Heading 6"),value:"heading-h6"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===`heading-${i}`&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(r.value,n,t),u.remove()}),g.appendChild(s)})}if("list"===b){E();const i=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";[{icon:"•",label:f("listUnordered","Unordered"),value:"unordered"},{icon:"1.",label:f("listOrdered","Ordered"),value:"ordered"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`listType${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("alert"===b){E();const i=n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info";[{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"},{icon:"—",label:f("variantPlain","Plain"),value:"plain"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`alertVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("glance"===b){E();const i=n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain";[{icon:"—",label:f("variantPlain","Plain"),value:"plain"},{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`glanceVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("delimiter"===b){E();const i=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";[{icon:"—",label:f("delimiterLine","Line"),value:"line"},{icon:"***",label:f("delimiterStars","Stars"),value:"stars"}].forEach(r=>{const s=q("div","clepit-menu-item clepit-block-operation-item");C.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=r.icon,C.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=q("span","clepit-menu-label");c.textContent=r.label,C.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`delimiterVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}const A=g.querySelectorAll(".clepit-block-operation-item"),N=g.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",e=>{(e=>{let t=0;A.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=g.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=f("noOperationsFound","No operations found"),g.appendChild(e)}}else n&&n.remove();N.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.remove()}),u.appendChild(g),u.classList.add(Ur),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Ur}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||u.remove()})):u.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:r,styles:s,imageIsEnabled:l,videoIsEnabled:c,audioIsEnabled:d,menuLabels:p,toolLabels:u}){const m=document.querySelector(`.${Fr}`);m&&m.remove();const h=n.getAttribute("data-tool");if(!h)return;const g=q("div",Fr);g.classList.add(Fr),g.classList.add(`${Fr}--hidden`),s?.container&&C.applyStyles(g,s.container),r?.container&&g.classList.add(r.container);const b=q("input","",{placeholder:Wr(p,"searchConvertOptions","Search convert options..."),type:"text"});b.setAttribute("data-testid","convert-search"),C.applyStyling(b,{classNames:r?.input,styles:s?.input}),g.appendChild(b),setTimeout(()=>b.focus(),10);const f=document.querySelector(`#${t}`),y=q("div",`${Fr}-items`),v=e=>(Vr(e.type)?u?.[e.type]:void 0)??e.label,x=i.getState().getInstance(t)?.config;Or.filter(e=>e.type!==h&&(!!st(x,e.type)&&(!("image"===e.type&&!l||"video"===e.type&&!c||"audio"===e.type&&!d)||void 0))).sort((e,t)=>v(e).localeCompare(v(t))).forEach(a=>{const i=q("div","clepit-menu-item clepit-convert-option-item");i.setAttribute("data-testid",a.testId),C.applyStyling(i,{classNames:r?.item?.container,styles:s?.item?.container});const l=q("span","clepit-menu-icon");l.textContent=a.icon,C.applyStyling(l,{classNames:r?.item?.icon,styles:s?.item?.icon}),i.appendChild(l);const c=q("span","clepit-menu-label");if(c.textContent=v(a),C.applyStyling(c,{classNames:r?.item?.text,styles:s?.item?.text}),i.appendChild(c),a.shortcut){const e=q("span","clepit-menu-shortcut");e.textContent=a.shortcut,C.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),i.appendChild(e)}e.addEventListener(f,i,"click",e=>{e.stopPropagation();const i=n?.getAttribute("data-tool");if(!i)return;let r;if(n){const e=n.querySelector(".clepit-block-content");"paragraph"===i?r=e.querySelector(".clepit-paragraph")?.innerText||"":"quote"===i?r=e.querySelector(".clepit-quote-text")?.innerText||"":"list"===i?r=Array.from(e.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===i?r=e.querySelector(".clepit-alert")?.innerText||"":"header"===i&&(r=e.querySelector(".clepit-header")?.innerText||"")}const s=n?.getAttribute("data-id");s&&Jr.convertBlock(s,a.type,t),setTimeout(()=>{if(!n)return;const e=n.getAttribute("data-tool");if(r&&r.trim()){const t=n.querySelector(".clepit-block-content");if("paragraph"===e){const e=t.querySelector(".clepit-paragraph");e&&(e.innerText=r)}else if("quote"===e){const e=t.querySelector(".clepit-quote-text");e&&(e.innerText=r)}else if("list"===e){const e=t.querySelector(".clepit-list");e&&(e.innerHTML="",r.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===e){const e=t.querySelector(".clepit-alert");e&&(e.innerText=r)}else if("header"===e){const e=t.querySelector(".clepit-header");e&&(e.innerText=r)}}},0),o.remove()}),y.appendChild(i)});const k=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(f,b,"click",e=>e.stopPropagation()),e.addEventListener(f,b,"focus",e=>e.stopPropagation()),e.addEventListener(f,b,"input",e=>{(e=>{let t=0;k.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=q("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Wr(p,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(f,b,"keydown",t=>{"Escape"===t.key&&e.closeMenu(Fr)}),g.appendChild(y);const w="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",w),g.style.setProperty("position-anchor",w),g.classList.remove(`${Fr}--hidden`),g.setAttribute("popover","auto"),e.menuHost(t).appendChild(g),g.addEventListener("toggle",e=>{"closed"===e.newState&&g.remove()}),"function"!=typeof g.showPopover?(o.appendChild(g),g.classList.add(`${Fr}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;g.contains(t)||a.contains(t)||o.contains(t)||g.remove()})):g.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&Jr.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&Qn.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&da.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&an.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&dr.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return zn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${C.classNames.block.content}`);if(!a)return;return oo.handleAction(n,a)}if(e.startsWith("embed"))return Qe.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return aa.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Hi.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return cn.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;return ee.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===Jr.getBlockIndex(a.id,t.getAttribute("data-id")))return;return ee.updateTheme(t,n)}const o=Jr.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":Jr.removeBlock(a.id,o);break;case"moveUp":o>0&&Jr.moveBlock(a.id,o,o-1);break;case"moveDown":o<Jr.getBlocks(a.id).length-1&&Jr.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Pr}`);l&&l.remove();const c=document.querySelector(`.${Rr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${C.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",u=C.createStyledElement("div",Pr,{classNames:i?.container,styles:s?.container});u.classList.add(Fr,"clepit-block-toolbar--submenu-positioned");const m=q("input","",{placeholder:Wr(r,"searchLanguages","Search languages..."),type:"text"});m.setAttribute("data-testid","language-search"),u.appendChild(m);const h=ee.supportedLanguages;Object.entries(h).forEach(([t,r])=>{const l=C.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-language-${t}`);const c=C.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-language-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Pr}--hidden`),u.classList.add(`${Pr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Pr}--visible`),u.classList.add(`${Pr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Rr}`);l&&l.remove();const c=document.querySelector(`.${Pr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${C.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",u=C.createStyledElement("div",Rr,{classNames:i?.container,styles:s?.container});u.classList.add(Fr,"clepit-block-toolbar--submenu-positioned");const m=q("input","",{placeholder:Wr(r,"searchThemes","Search themes..."),type:"text"});m.setAttribute("data-testid","theme-search"),u.appendChild(m);const h=ee.supportedThemes;Object.entries(h).forEach(([t,r])=>{const l=C.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-theme-${t}`);const c=C.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-theme-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Rr}--hidden`),u.classList.add(`${Rr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Rr}--visible`),u.classList.add(`${Rr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${Hr}, .${Ur}, .${Fr}`)||e.hideAllToolbars(t)}static menuHost(e){return document.getElementById(e)?.closest("dialog")??document.body}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(Hr),e.closeMenu(Ur),e.closeMenu(Fr)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},Jr=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=i.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=q("div",C.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const r={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let s,l;if(r.margins&&(s=r.margins.top,l=r.margins.bottom),void 0===s&&r.styles){const e=r.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}if(void 0===l&&r.styles){const e=r.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?l=parseInt(t.replace("px",""),10):"number"==typeof t&&(l=t)}}void 0===s&&void 0!==a.config.margins?.top&&(s=a.config.margins.top),void 0===l&&void 0!==a.config.margins?.bottom&&(l=a.config.margins.bottom),void 0!==s&&(o.style.marginTop=`${s}px`),void 0!==l&&(o.style.marginBottom=`${l}px`),Gr.create({block:o,containerId:n});const c=q("div",C.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(c.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(c),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){e.adoptStartingBlock(n);const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const r=e.getBlockData(o.getAttribute("data-id"));return i.getState().addBlock(n,r,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),i.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const r=i.getState().getData(t);if(!r)return;const s=i.getState().getContentElement(t);if(!s)return;const l=o[n];o.splice(n,1),o.splice(a,0,l),0===a?s.insertBefore(l,s.firstChild):a>=o.length-1?s.appendChild(l):s.insertBefore(l,o[a+1]);const c=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),d={...r,blocks:c};i.getState().setData(t,d),e.focusBlock(l)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${C.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${C.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return Or.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${C.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=i.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return an.render(n,t,o);case"audio":return a.config.audioUploader?cn.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return ee.render(n,t,o);case"collapsible":return wn.render(n,t,o);case"columns":return Yi.render(n,t,o);case"date":return Qi.render(n,t,o);case"delimiter":return zn.render(n,t,o);case"collection":return Gi.render(n,t,o);case"doc_card":return ar.render(n,t,o);case"embed":return Qe.render(n,t,o);case"openapi":return xr.render(n,t,o);case"sketch":return Er.render(n,t,o);case"latex":return Mr.render(n,t,o);case"mermaid":return _r.render(n,t,o);case"file":return a.config.fileUploader?sr.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"header":return Qn.render(n,t,o);case"image":return a.config.imageUploader?aa.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return da.render(n,t,o);case"checklist":return hn.render(n,t,o);case"paragraph":return Fa.render(n,t,o);case"quote":return Ka.render(n,t,o);case"table":return oo.render(n,t,o);case"toc":return Lr.render(n,t,o);case"issues":return gr.render(n,t,o);case"video":return a.config.videoUploader?Hi.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(C.classNames.block.active);t.classList.add(C.classNames.block.active),Gr.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${C.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);e.adoptStartingBlock(a);const r=e.getBlockData(t),s=e.getTool(n);if(!s)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const l=e.getBlockIndex(a,t);let c=r.data;if("list"===n){const e=r.data,t=e.html||e.text||"";c={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=r.data;c={html:e.html||e.text||"",level:"h1"}}const d={data:c,id:t,type:s.type},p=e.createBlockElement(d,a);if(!p)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(p);const u=e.getBlockData(p.getAttribute("data-id"));i.getState().updateBlock(a,l,u),e.focusBlock(p)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=tn.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${C.classNames.block.container}`);if(!a)return;e.adoptStartingBlock(n.instance.config.containerId);const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));i.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),r=i.getState().getContentElement(n);if(!r)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];r.insertBefore(t,e),o.splice(a,0,t)}else r.appendChild(t),o.push(t);else r.appendChild(t),o.push(t);e.focusBlock(t);const s=i.getState().getInstance(n);s&&Ut.initializeElements(t,{classNames:s.config.classNames?.blocks?.tooltip,styles:s.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),i.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static adoptStartingBlock(t){const n=i.getState().getInstance(t)?.data.blocks,a=e.getBlocks(t);!n||n.length>0||1!==a.length||i.getState().seedBlocks(t,[e.getBlockData(a[0].getAttribute("data-id"))])}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();i.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${C.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${C.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!z(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${C.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${C.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;e.adoptStartingBlock(a);const o=n.getAttribute("data-id");i.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){e.adoptStartingBlock(a);const o=e.getBlock(t);if(o){const t=o.querySelector(`.${C.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i)}i.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),Or.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},Xr=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=i.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);C.injectStyles("clepit-action-bar-styles","\n/* View Toggle */\n.clepit-action-bar {\n position: relative;\n z-index: 1000;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: -14px; /* Position buttons so exactly half is inside and half outside */\n pointer-events: none;\n padding: 0 100px;\n}\n\n.clepit-action-bar-group {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-action-bar-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-action-bar-button:active {\n transform: scale(0.95);\n}\n\n.clepit-action-bar-button.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n/* Action Buttons */\n.clepit-view-actions {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-view-action-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-view-action-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-view-action-button:active {\n transform: scale(0.95);\n}\n\n/* Copy button feedback animation */\n.clepit-view-action-button--copy-feedback {\n transform: scale(0.95) !important;\n background-color: var(--clepit-success) !important;\n color: var(--clepit-bg) !important;\n}\n");const a=document.getElementById(t);if(!a)return;const o=!1!==n.config.hasViewSwitcher,r=!1!==n.config.hasDocumentActions;if(!o&&!r)return;const s=n.config.styles?.controls?.group,l=n.config.classNames?.controls?.group,c=n.config.styles?.controls?.button,d=n.config.classNames?.controls?.button,p=n.config.styles?.tooltips,u=n.config.classNames?.tooltips,m=q("div",C.classNames.actionBar.container);e.createButtonGroup(a,m,{buttonClassNames:d,buttonStyles:c,currentView:n.currentView,groupClassNames:l,groupStyles:s,hasDocumentActions:r,hasViewSwitcher:o,labels:n.config.controlLabels,tooltipClassNames:u,tooltipStyles:p}),a.insertBefore(m,a.firstChild)}static createButtonGroup(t,n,a){const o=(e,t)=>a.labels?.[e]||t,i=o("editView","Edit Mode"),r=o("previewView","Preview Mode"),s=o("jsonView","JSON Output"),l=o("copyJson","Copy JSON to Clipboard"),c=o("downloadJson","Download JSON File"),d=o("clearEditor","Clear Editor");if(a.hasViewSwitcher){const o=q("div",C.classNames.actionBar.group);C.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const l=q("button",C.classNames.actionBar.button,{"aria-label":i,"data-testid":"action-bar-edit-button","data-view":"edit",id:j(t.id,C.idSuffixes.actionBar.editButton),type:"button"});l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',C.applyStyling(l,{classNames:a.buttonClassNames,styles:a.buttonStyles});const c=q("button",C.classNames.actionBar.button,{"aria-label":r,"data-testid":"action-bar-preview-button","data-view":"preview",id:j(t.id,C.idSuffixes.actionBar.previewButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',C.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=q("button",C.classNames.actionBar.button,{"aria-label":s,"data-testid":"action-bar-json-button","data-view":"json",id:j(t.id,C.idSuffixes.actionBar.jsonButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14,2 14,8 20,8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10,9 9,9 8,9"/></svg>',C.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles}),"edit"===a.currentView?l.classList.add("active"):"preview"===a.currentView?c.classList.add("active"):"json"===a.currentView&&d.classList.add("active"),e.addEventListener(t.id,l,"click",e.handleViewChange),e.addEventListener(t.id,c,"click",e.handleViewChange),e.addEventListener(t.id,d,"click",e.handleViewChange),o.appendChild(l),o.appendChild(c),o.appendChild(d),n.appendChild(o),ce(l,i,"above",a.tooltipClassNames,a.tooltipStyles),ce(c,r,"above",a.tooltipClassNames,a.tooltipStyles),ce(d,s,"above",a.tooltipClassNames,a.tooltipStyles)}if(a.hasDocumentActions){const o=q("div",C.classNames.actionBar.action);C.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const i=q("button",C.classNames.actionBar.actionButton,{"aria-label":l,"data-testid":"view-copy-button",id:j(t.id,C.idSuffixes.actionBar.copyButton),type:"button"});i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',C.applyStyling(i,{classNames:a.buttonClassNames,styles:a.buttonStyles});const r=q("button",C.classNames.actionBar.actionButton,{"aria-label":c,"data-testid":"view-download-button",id:j(t.id,C.idSuffixes.actionBar.downloadButton),type:"button"});r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',C.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles});const s=q("button",C.classNames.actionBar.actionButton,{"aria-label":d,"data-testid":"view-clear-button",id:j(t.id,C.idSuffixes.actionBar.clearButton),type:"button"});s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',C.applyStyling(s,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,i,"click",e.handleCopyJson),e.addEventListener(t.id,r,"click",e.handleDownloadJson),e.addEventListener(t.id,s,"click",e.handleClearEditor),o.appendChild(i),o.appendChild(r),o.appendChild(s),n.appendChild(o),ce(i,l,"above",a.tooltipClassNames,a.tooltipStyles),ce(r,c,"above",a.tooltipClassNames,a.tooltipStyles),ce(s,d,"above",a.tooltipClassNames,a.tooltipStyles)}}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${C.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${C.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${j(e,C.idSuffixes.actionBar.editButton)}, #${j(e,C.idSuffixes.actionBar.previewButton)}, #${j(e,C.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{e.getAttribute("data-view")===t?e.classList.add("active"):e.classList.remove("active")})}static handleViewChange(t){const n=t.currentTarget,a=Jr.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(i.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=Jr.getEditorId(t);if(!n)return;const a=i.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(C.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(C.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=Jr.getEditorId(t);n&&Jr.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=Jr.getEditorId(t);if(!n)return;const a=Jr.getBlocks(n).map(e=>Jr.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${C.classNames.actionBar.container}`);n&&n.remove()}},Yr=`\n/* Editor Container */\n.${C.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${C.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${C.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${C.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${C.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${C.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${C.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${C.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${C.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${C.classNames.editor.container} {\n padding: 8px;\n }\n\n .${C.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,Zr=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(i.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=new Set;for(const a of Le.collect(t))n.add(Le.read(a).url);for(const a of Jr.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=Qe.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await et(t,n),o=document.getElementById(t),r=i.getState().getInstance(t)?.config;if(o&&r&&0!==Object.keys(a).length){Le.refreshAll(o,a,r.issueLabels);for(const e of Jr.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=Qe.save(e),o=n.issue?a[n.url]:void 0;o&&Qe.refreshIssue(e,t,o)}gr.refresh(t,a)}}},Qr=class{static render(e){const t=i.getState().getInstance(e);t&&(Xt.create(e),C.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block:hover {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block--active {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Default menu item styles - package doesn\'t care about theme */\n.clepit-menu-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n width: 16px;\n height: 16px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n}\n\n.clepit-menu-item:hover {\n background-color: var(--clepit-selection-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n.clepit-menu-item--danger {\n color: var(--clepit-error);\n}\n\n/* Block type menu items - match font size with operations menu */\n.clepit-block-type-item {\n font-size: 14px;\n}\n\n/* Default menu divider styles */\n.clepit-menu-divider {\n height: 1px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 8px 0;\n}\n\n/* Default menu arrow styles */\n.clepit-menu-arrow {\n margin-left: auto;\n font-size: 12px;\n color: var(--clepit-text-muted);\n}\n\n/* Input styles for block type selector */\n.clepit-block-type-selector input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-type-selector input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-type-selector-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-menu-icon {\n font-size: 14px;\n min-width: 20px;\n text-align: center;\n font-weight: bold;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n font-size: 9px;\n color: var(--clepit-text-muted);\n opacity: 0.7;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n margin: 0;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n background: var(--clepit-bg);\n padding: 8px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: block-end span-inline-end;\n margin-block-start: 5px;\n inset: auto;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),Jr.renderBlocks(t.data.blocks,e))}},es=class e{static render(t){const n=i.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=C.createStyledElement("pre",C.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(C.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=C.createStyledElement("div",C.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=Jr.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=i.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${C.classNames.editor.jsonOutput}`);n&&(n.classList.remove(C.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;i.getState().setData(a,e),"json"===o&&i.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=i.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${C.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(e){const t=e.target,n=t.textContent||"",a=Jr.getEditorId(t);if(!a)return;const o=i.getState().getInstance(a);if(o)try{const e=JSON.parse(n);if("object"!=typeof e||null===e)throw new Error("Invalid JSON structure");{e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);try{Xt.hide(a),Gr.hide(a)}catch{}const t=o.currentView;i.getState().setData(a,e),"json"===t&&i.getState().setCurrentView(a,"json");const n=document.querySelector(`#${o.contentId} .${C.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),o.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),o.config.onChange&&o.config.onChange(e)}}catch{const e=document.querySelector(`#${o.contentId} .${C.classNames.editor.jsonOutput}`);e&&(e.classList.add("clepit-json-error"),e.classList.remove("clepit-json-editable"))}}static destroy(t){const n=i.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${C.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},ts=new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),ns=(e,t)=>ts.has(`${e}.${t}`),as=new Set(["checklist.items","list.items","table.data"]),os=(e,t)=>as.has(`${e}.${t}`),is=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=ss(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},rs=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(os(e,r)){const t=is(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!ns(e,r)){i[r]=s;continue}const t=ss(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},ss=(e,t,n)=>{if(void 0===e)return null;if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},ls="clepit-theme-styles",cs=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",ds=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${Kr=x,Object.keys(k).map(e=>`@property ${k[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${Kr[e]};\n}`).join("\n\n")}\n\n@layer clepit.tokens {\n${w(x,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"rgba(240, 246, 252, 0.62)",codeSelectionBg:"rgba(124, 124, 255, 0.18)",codeString:"#7ee787",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",marker:"rgba(255, 224, 71, 0.28)",primary:"#7c7cff",primaryBg:"rgba(124, 124, 255, 0.14)",primaryHover:"#9494ff",selectionBg:"rgba(124, 124, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},cs)}\n\n${cs} {\n color-scheme: light;\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,ps=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Error(`Container element with ID '${t.containerId}' not found`);return C.injectStyles(ls,ds),C.injectStyles(_t,Dt),C.injectStyles(me,he),n.classList.add(C.classNames.renderer.content),C.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Le.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Le.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=rs(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=q("div",C.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,l,c=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(c={...c,tooltipClassNames:n.editorClassNames.tooltips}),c?.margins&&(r=c.margins.top,s=c.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":l=on.render(e.data,c,o,i);break;case"audio":l=dn.render(e.data,c,o,i);break;case"code":l=ue.render(e.data,c,o,i);break;case"collapsible":l=Vi.render(e.data,c,o,i);break;case"columns":l=In.render(e.data,c,o,i);break;case"date":l=qn.render(e.data,c,o,i);break;case"delimiter":l=On.render(e.data,c,o,i);break;case"collection":l=An.render(e.data,c,o,i);break;case"updates":l=ji.render(e.data,c,o,i);break;case"glance":l=Yn.render(e.data,c,o,i);break;case"embed":l=We.render(e.data,{...c,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":l=to.render(e.data,c,o,i);break;case"latex":l=Ti.render(e.data,c,o,i);break;case"mermaid":l=Mi.render(e.data,c,o,i);break;case"openapi":l=Pa.render(e.data,c,o,i);break;case"doc_card":l=Fn.render(e.data,c,o,i);break;case"file":l=Gn.render(e.data,c,o,i);break;case"header":l=ea.render(e.data,c,o,i);break;case"image":l=oa.render(e.data,c,o,i);break;case"list":l=pa.render(e.data,c,o,i);break;case"checklist":l=gn.render(e.data,c,o,i);break;case"paragraph":l=Ua.render(e.data,c,o,i);break;case"quote":l=Ga.render(e.data,c,o,i);break;case"table":l=lo.render(e.data,c,o,i);break;case"toc":l=ho.render(e.data,{...c,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":l=la.render(e.data,{...c,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":l=Pi.render(e.data,c,o,i);break;default:l=null}return l?(a.appendChild(l),Ut.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},us=class{static render(e){const t=i.getState().getInstance(e);t&&ps.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},ms=e=>e.replace(/["\\]/g,"\\$&"),hs=e=>e.flatMap(e=>"collapsible"===e.type?[e,...hs(e.data.children??[])]:"columns"===e.type?[e,...hs(e.data.columns?.flat()??[])]:[e]),gs=new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),bs=new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),fs=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ys=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g,vs=e=>{const t=new Map;ys.lastIndex=0;let n=ys.exec(e);for(;null!==n;)t.set(n[1].toLowerCase(),n[2]??n[3]??n[4]??""),n=ys.exec(e);return t},xs=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},ks=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[],n=/<\/?([a-zA-Z][a-zA-Z0-9-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;let a=0,o=n.exec(e);for(;null!==o;){o.index>a&&t.push({type:"text",value:e.slice(a,o.index)});const i=o[1].toLowerCase();o[0].startsWith("</")?t.push({tag:i,type:"close"}):t.push({attributes:vs(o[2]??""),selfClosing:(o[2]??"").trimEnd().endsWith("/"),tag:i,type:"open"}),a=o.index+o[0].length,o=n.exec(e)}return a<e.length&&t.push({type:"text",value:e.slice(a)}),t})(e)){if("text"===a.type){t.push(a.value);continue}if("close"===a.type){if(!gs.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!gs.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)bs.has(t)&&("href"!==t||xs(n))&&e.push(`${t}="${$(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||fs.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},ws=()=>[ds,nn,ln,mn,K,ae(),xn,En,Bn,Mn,jn,Rn,A,Wn,Jn,Zn,na,he,ca,ua,Ra,Wa,Ya,ao,uo,fo,qi,Oi].join("\n"),Cs=(e,t)=>{const n=M(ks),a={...t,documentBlocks:t?.documentBlocks??e},o=e.map(e=>Ri(e,n,a)).filter(e=>null!==e).map(e=>_(e)).join("\n");return Me(o,t?.issues,t?.issueChip,t?.issueLabels,ks)};exports.BLOCK_TOOLS=Wt,exports.CONTROL_LABELS=["editView","previewView","jsonView","copyJson","downloadJson","clearEditor"],exports.EMBED_ENGLISH=qe,exports.EMBED_LABELS=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],exports.EMBED_TOOL_NAMES=je,exports.EMBED_WIRE_KEYS=u,exports.Editor=class e{static create(t){return e.teardown(t.containerId),e.initialize(t),Xr.create(t.containerId),e.render(t.containerId),tn.addListeners(t.containerId),Zr.start(t.containerId),i.getState().setIsReady(t.containerId,!0),i.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>Jr.convertBlock(e,n,t.containerId),count:()=>Jr.getBlocks(t.containerId).length,get:e=>Jr.getBlock(e)?Jr.getBlockData(e):null,getAll:()=>Jr.getBlocks(t.containerId).map(e=>Jr.getBlockData(e.getAttribute("data-id"))),insert:(e,n,a,o)=>Jr.insertBlock({data:n,id:o??Math.random().toString(36).substring(2,11),type:e},t.containerId,a),move:(e,n)=>Jr.moveBlock(t.containerId,e,n),remove:e=>Jr.removeBlock(t.containerId,e),update:(e,n)=>Jr.updateBlockData(e,n,t.containerId)},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{i.getState().clearData(t.containerId),Jr.destroy(t.containerId)},clearContent:()=>Jr.destroy(t.containerId),clearStorage:()=>i.getState().clearData(t.containerId),extract:()=>Jr.extractData(t.containerId),set:e=>Jr.setBlocks(e.blocks,t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=Jr.getBlocks(t.containerId)[0];e&&Jr.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>Gr.hide(t.containerId),hideToolbar:()=>Xt.hide(t.containerId),showBlockMenu:e=>Gr.show(t.containerId,e),showToolbar:(e,n)=>Xt.show(t.containerId,e,n)},view:{getCurrentView:e=>i.getState().getCurrentView(e),switchView:(e,t)=>i.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;C.injectStyles(ls,ds),C.injectStyles("clepit-editor-container-styles",Yr),C.injectStyles(Et,At),C.injectStyles(Pt,Rt),C.injectStyles($t,Tt),C.injectStyles(me,he);const a={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t};n.className=C.classNames.editor.container,n.setAttribute("contenteditable","false"),Le.applyParts(n,a.issueChip),C.registerEditor(t.containerId,a.theme??"auto",a.themeOverrides),a.minHeight&&n.style.setProperty("--clepit-min-height",`${a.minHeight}px`),a.maxHeight&&n.style.setProperty("--clepit-max-height",`${a.maxHeight}px`),C.applyStyles(n,a.styles?.container),C.applyClassNames(n,a.classNames?.container),a.margins&&(void 0!==a.margins.top&&n.style.setProperty("--block-margin-top",`${a.margins.top}px`),void 0!==a.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${a.margins.bottom}px`));const o=`${a.containerId}-${C.idSuffixes.editorContent}`,r=q("div",C.classNames.editor.content);r.id=o,r.setAttribute("data-testid","editor-content-container"),r.setAttribute("data-container-id",t.containerId),C.applyStyles(r,a.styles?.editorContent),C.applyClassNames(r,a.classNames?.editorContent),n.appendChild(r),i.getState().addInstance(t.containerId,{config:a,contentId:o,currentView:a.initialView||"edit",data:e.localizeData(a.initialData,a),isReady:!1})}static localizeData(e,t){const n=e||{blocks:[],time:Date.now(),version:"1.0.0"},a=t.locale;if(!a)return n;const o=t.defaultLocale??a;return{...n,blocks:n.blocks.map(e=>{const n=e.data;for(const r of(e=>Array.from(ts).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(e.type)){const i=ss(n[r],a,o);i?.isFallback&&t.onLocaleFallback?.({blockId:e.id??"",field:r,requested:a,showing:i.locale})}const i=rs(e.type,n,a,o);return i===n?e:{...e,data:i}})}}static render(e){const t=i.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(es.destroy(e),n.innerHTML=""),"edit"===t.currentView?Qr.render(e):"preview"===t.currentView?us.render(e):"json"===t.currentView&&es.render(e),t.config.onReady&&t.config.onReady()}static teardown(e){Zr.stop(e),en.dismiss(e),tn.removeListeners(e),Xr.destroy(e),Gr.destroy(e),Xt.destroy(e),Jr.destroy(e),C.unregisterEditor(e);const t=document.getElementById(e);t&&(t.innerHTML="")}static destroy(t){e.teardown(t),i.getState().removeInstance(t)}},exports.INLINE_REWRITE_ACTIONS=Kt,exports.INLINE_TOOLS=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],exports.ISSUE_ENGLISH=ge,exports.ISSUE_LABELS=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],exports.ISSUE_TOOLS=["asana","github_issues","jira","linear"],exports.ISSUE_TOOL_NAMES=be,exports.IssueChip=Le,exports.Renderer=ps,exports.StyleManager=C,exports.activateBlocks=(e,t)=>{const n=[];for(const a of hs(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${ms(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?ue.activate(t,a.data):"openapi"===a.type?Pa.activate(t):lo.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},exports.chipsInHtml=Te,exports.classifyIssueUrl=Ye,exports.domBacking=L,exports.drawBlock=Ri,exports.embedLabel=ze,exports.isEmbedProviderDisabled=m,exports.issueLabel=ye,exports.issueToolName=ve,exports.pageStylesheet=ws,exports.parseOpenApi=Ma,exports.readChipMarkup=$e,exports.refreshChipsInHtml=Me,exports.renderBlocks=Cs,exports.renderPage=(e,t)=>{const n=I(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<title>${n}</title>`,e.description?`<meta name="description" content="${$(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${$(e.canonicalUrl)}">`:"",`<meta property="og:title" content="${$(e.title)}">`,e.description?`<meta property="og:description" content="${$(e.description)}">`:"",`<style>${ws()}</style>`].filter(Boolean);return["<!doctype html>",`<html lang="${$(e.locale??"en")}">`,`<head>${a.join("")}</head>`,"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,Cs(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")},exports.renderToString=_,exports.resolveEmbed=f,exports.sanitizeHtmlWithoutDom=ks,exports.stringBacking=M,exports.toDomElement=D,exports.tokensToLightDarkBlock=w;
2
2
  //# sourceMappingURL=index.js.map