noteloom 0.1.4 → 0.1.6

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/noteloom.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var po=Object.defineProperty;var fo=(e,n,t)=>n in e?po(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var tt=(e,n,t)=>fo(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),f=require("react"),Le=require("react-dom"),U={INSERT_BLOCK:"insertBlock",REMOVE_BLOCK:"removeBlock",MOVE_BLOCK:"moveBlock",UPDATE_BLOCK_PROPS:"updateBlockProps",UPDATE_RUN:"updateRun",SET_BLOCK_CONTENT_IDS:"setBlockContentIds",REPLACE_RUN_SPAN:"replaceRunSpan",SET_BLOCK_RUNS:"setBlockRuns",ADD_FIELD_TYPE:"addFieldType",UPDATE_FIELD_TYPE:"updateFieldType",REMOVE_FIELD_TYPE:"removeFieldType"};function G(e,n,t,r){return{type:U.INSERT_BLOCK,block:e,parentId:n,index:t,subtree:r}}function _(e){return{type:U.REMOVE_BLOCK,id:e}}function ke(e,n,t){return{type:U.MOVE_BLOCK,id:e,toParentId:n,toIndex:t}}function z(e,n){return{type:U.UPDATE_BLOCK_PROPS,id:e,patch:n}}function J(e,n){return{type:U.UPDATE_RUN,id:e,patch:n}}function je(e,n){return{type:U.SET_BLOCK_CONTENT_IDS,blockId:e,contentIds:n}}function qe(e,n,t){return{type:U.REPLACE_RUN_SPAN,blockId:e,oldRunIds:n,newRuns:t}}function se(e,n){return{type:U.SET_BLOCK_RUNS,blockId:e,runs:n}}function Sn(e){return{type:U.ADD_FIELD_TYPE,fieldType:e}}function En(e,n){return{type:U.UPDATE_FIELD_TYPE,id:e,patch:n}}function On(e){return{type:U.REMOVE_FIELD_TYPE,id:e}}const bo=Object.freeze(Object.defineProperty({__proto__:null,OP:U,addFieldType:Sn,insertBlock:G,moveBlock:ke,removeBlock:_,removeFieldType:On,replaceRunSpan:qe,setBlockContentIds:je,setBlockRuns:se,updateBlockProps:z,updateFieldType:En,updateRun:J},Symbol.toStringTag,{value:"Module"})),kn="$fieldTypes";class Ln{constructor(n){this.blocks=new Map(((n==null?void 0:n.blocks)??[]).map(t=>[t.id,t])),this.runs=new Map(((n==null?void 0:n.runs)??[]).map(t=>[t.id,t])),this.rootId=(n==null?void 0:n.rootId)??null,this.fieldTypes=new Map(((n==null?void 0:n.fieldTypes)??[]).map(t=>[t.id,t])),this._fieldTypesSnapshot=null,this._listeners=new Map}getBlock(n){return this.blocks.get(n)}getRun(n){return this.runs.get(n)}getFieldTypes(){return this._fieldTypesSnapshot||(this._fieldTypesSnapshot=[...this.fieldTypes.values()]),this._fieldTypesSnapshot}getFieldType(n){return this.fieldTypes.get(n)}getRootId(){return this.rootId}subscribe(n,t){let r=this._listeners.get(n);return r||(r=new Set,this._listeners.set(n,r)),r.add(t),()=>{r.delete(t),r.size===0&&this._listeners.delete(n)}}_notify(n){for(const t of n){const r=this._listeners.get(t);if(r)for(const o of[...r])o()}}_captureSubtree(n){const t=[],r=[],o=l=>{var c;if(this.runs.has(l)){r.push(this.runs.get(l));return}const s=this.blocks.get(l);if(s){t.push(s);for(const i of s.contentIds)o(i);for(const i of((c=s.props)==null?void 0:c.titleRunIds)??[])o(i)}};return o(n),{blocks:t,runs:r}}_deleteSubtree(n){const t=r=>{var l;if(this.runs.has(r)){this.runs.delete(r);return}const o=this.blocks.get(r);if(o){for(const s of o.contentIds)t(s);for(const s of((l=o.props)==null?void 0:l.titleRunIds)??[])t(s);this.blocks.delete(r)}};t(n)}applyOperation(n){var t;switch(n.type){case U.UPDATE_RUN:{const r=this.runs.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r[l];return this.runs.set(n.id,{...r,...n.patch}),this._notify([n.id]),J(n.id,o)}case U.UPDATE_BLOCK_PROPS:{const r=this.blocks.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r.props[l];return this.blocks.set(n.id,{...r,props:{...r.props,...n.patch}}),this._notify([n.id]),z(n.id,o)}case U.INSERT_BLOCK:{if(n.subtree){for(const s of n.subtree.blocks)this.blocks.set(s.id,s);for(const s of n.subtree.runs)this.runs.set(s.id,s)}else this.blocks.set(n.block.id,n.block);const r=this.blocks.get(n.parentId),o=[...r.contentIds],l=n.index??o.length;return o.splice(l,0,n.block.id),this.blocks.set(n.parentId,{...r,contentIds:o}),this._notify([n.block.id,n.parentId]),_(n.block.id)}case U.REMOVE_BLOCK:{const r=this.blocks.get(n.id),o=r.parentId,l=this.blocks.get(o),s=l.contentIds.indexOf(n.id),c=this._captureSubtree(n.id);this._deleteSubtree(n.id);const i=l.contentIds.filter(u=>u!==n.id);return this.blocks.set(o,{...l,contentIds:i}),this._notify([o]),{type:U.INSERT_BLOCK,block:r,parentId:o,index:s,subtree:c}}case U.MOVE_BLOCK:{const o=this.blocks.get(n.id).parentId,l=this.blocks.get(o),s=l.contentIds.indexOf(n.id),c=l.contentIds.filter(d=>d!==n.id);this.blocks.set(o,{...l,contentIds:c});const i=n.toParentId===o?this.blocks.get(o):this.blocks.get(n.toParentId),u=[...i.contentIds];u.splice(n.toIndex??u.length,0,n.id),this.blocks.set(n.toParentId,{...i,contentIds:u}),this.blocks.set(n.id,{...this.blocks.get(n.id),parentId:n.toParentId});const p=new Set([n.id,o,n.toParentId]);return this._notify(p),ke(n.id,o,s)}case U.SET_BLOCK_CONTENT_IDS:{const r=this.blocks.get(n.blockId),o=r.contentIds;return this.blocks.set(n.blockId,{...r,contentIds:n.contentIds}),this._notify([n.blockId]),je(n.blockId,o)}case U.REPLACE_RUN_SPAN:{const r=this.blocks.get(n.blockId),o=r.contentIds.indexOf(n.oldRunIds[0])!==-1,l=o?r.contentIds:((t=r.props)==null?void 0:t.titleRunIds)??[],s=l.indexOf(n.oldRunIds[0]),c=n.oldRunIds.map(u=>this.runs.get(u));for(const u of n.oldRunIds)this.runs.delete(u);for(const u of n.newRuns)this.runs.set(u.id,u);const i=[...l];return i.splice(s,n.oldRunIds.length,...n.newRuns.map(u=>u.id)),o?this.blocks.set(n.blockId,{...r,contentIds:i}):this.blocks.set(n.blockId,{...r,props:{...r.props,titleRunIds:i}}),this._notify([n.blockId,...n.oldRunIds,...n.newRuns.map(u=>u.id)]),qe(n.blockId,n.newRuns.map(u=>u.id),c)}case U.SET_BLOCK_RUNS:{const r=this.blocks.get(n.blockId),o=r.props&&"titleRunIds"in r.props,l=o?r.props.titleRunIds:r.contentIds,s=l.map(i=>this.runs.get(i)).filter(Boolean);for(const i of l)this.runs.delete(i);for(const i of n.runs)this.runs.set(i.id,i);const c=n.runs.map(i=>i.id);return o?this.blocks.set(n.blockId,{...r,props:{...r.props,titleRunIds:c}}):this.blocks.set(n.blockId,{...r,contentIds:c}),this._notify([n.blockId,...l,...c]),se(n.blockId,s)}case U.ADD_FIELD_TYPE:return this.fieldTypes.set(n.fieldType.id,n.fieldType),this._fieldTypesSnapshot=null,this._notify([kn]),On(n.fieldType.id);case U.UPDATE_FIELD_TYPE:{const r=this.fieldTypes.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r[l];return this.fieldTypes.set(n.id,{...r,...n.patch}),this._fieldTypesSnapshot=null,this._notify([kn]),En(n.id,o)}case U.REMOVE_FIELD_TYPE:{const r=this.fieldTypes.get(n.id);return this.fieldTypes.delete(n.id),this._fieldTypesSnapshot=null,this._notify([kn]),Sn(r)}default:throw new Error(`Unknown operation type: ${n.type}`)}}applyOperations(n){return n.map(t=>this.applyOperation(t))}toJSON(){return{blocks:[...this.blocks.values()],runs:[...this.runs.values()],rootId:this.rootId,fieldTypes:[...this.fieldTypes.values()]}}static fromJSON(n){return new Ln(n)}}const mo=500;class ho{constructor(n,{idleMs:t=mo}={}){this.store=n,this.idleMs=t,this.undoStack=[],this.redoStack=[],this.currentBatch=null,this.idleTimer=null,this.historyLog=[],this._listeners=new Set,this._undoRedoSnapshot={canUndo:!1,canRedo:!1}}getUndoRedoSnapshot(){const n=this.canUndo(),t=this.canRedo();return(this._undoRedoSnapshot.canUndo!==n||this._undoRedoSnapshot.canRedo!==t)&&(this._undoRedoSnapshot={canUndo:n,canRedo:t}),this._undoRedoSnapshot}getBlock(n){return this.store.getBlock(n)}getRun(n){return this.store.getRun(n)}getRootId(){return this.store.getRootId()}getFieldTypes(){return this.store.getFieldTypes()}getFieldType(n){return this.store.getFieldType(n)}subscribe(n,t){return this.store.subscribe(n,t)}toJSON(){return this.store.toJSON()}applyOperation(n,t={}){return this.perform(n,t)}applyOperations(n,t={}){return n.map(r=>this.perform(r,t))}performBatch(n,t={}){var s;const r=t.actorId??null,o=t.timestamp??Date.now();this._commitCurrentBatch();const l=[];for(const c of n)l.unshift(this.store.applyOperation(c)),this.historyLog.push({opType:c.type,id:c.id??c.blockId??((s=c.block)==null?void 0:s.id),actorId:r,timestamp:o});this.redoStack=[],this.undoStack.push({ops:[...n],inverses:l,batchKey:null,actorId:r,timestamp:o,lastTimestamp:o,boundaryHit:!0}),this._notify()}perform(n,t={}){const r=t.actorId??null,o=t.timestamp??Date.now(),l=this.store.applyOperation(n);return this._record(n,l,{actorId:r,timestamp:o}),l}_batchKeyFor(n){return n.type==="updateRun"?`run:${n.id}`:null}_isWordBoundary(n){var r;if(n.type!=="updateRun")return!1;const t=(r=n.patch)==null?void 0:r.value;return typeof t!="string"||t.length===0?!1:/\s/.test(t[t.length-1])}_record(n,t,r){var c;this.redoStack=[];const o=this._batchKeyFor(n),l=this.currentBatch&&r.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&o!==null&&this.currentBatch.batchKey===o&&l&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(n),this.currentBatch.inverses.unshift(t),this.currentBatch.lastTimestamp=r.timestamp,this._isWordBoundary(n)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[n],inverses:[t],batchKey:o,actorId:r.actorId,timestamp:r.timestamp,lastTimestamp:r.timestamp,boundaryHit:this._isWordBoundary(n)}),this._resetIdleTimer(),this.historyLog.push({opType:n.type,id:n.id??((c=n.block)==null?void 0:c.id),actorId:r.actorId,timestamp:r.timestamp}),this._notify()}_resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this._commitCurrentBatch(),this._notify()},this.idleMs)}_commitCurrentBatch(){this.currentBatch&&(this.undoStack.push(this.currentBatch),this.currentBatch=null,this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null))}flush(){this._commitCurrentBatch(),this._notify()}undo(){this._commitCurrentBatch();const n=this.undoStack.pop();if(!n)return!1;for(const t of n.inverses)this.store.applyOperation(t);return this.redoStack.push(n),this._notify(),!0}redo(){const n=this.redoStack.pop();if(!n)return!1;for(const t of n.ops)this.store.applyOperation(t);return this.undoStack.push(n),this._notify(),!0}canUndo(){return this.undoStack.length>0||this.currentBatch!==null}canRedo(){return this.redoStack.length>0}getHistoryLog(){return[...this.historyLog]}subscribeToHistory(n){return this._listeners.add(n),()=>this._listeners.delete(n)}_notify(){for(const n of this._listeners)n()}}class yt{constructor(){this._types=new Map}register(n,t){this._types.set(n,t)}get(n){return this._types.get(n)}isLeaf(n){var t;return!!((t=this._types.get(n))!=null&&t.isLeaf)}listSlashCommands(){const n=[];for(const t of this._types.values())t.slashCommand&&n.push(t.slashCommand),t.slashCommands&&n.push(...t.slashCommands);return n}listHtmlMatchers(){return[...this._types.values()].filter(n=>n.fromHTML)}}function go(){return new yt}class vt{constructor(){this._types=new Map}register(n,t){this._types.set(n,t)}unregister(n){this._types.delete(n)}get(n){return this._types.get(n)}listHtmlMatchers(){return[...this._types.values()].filter(n=>n.fromHTML)}listSlashCommands(){const n=[];for(const t of this._types.values())t.slashCommand&&n.push(t.slashCommand),t.slashCommands&&n.push(...t.slashCommands);return n}listAtCommands(){const n=[];for(const t of this._types.values())t.atCommand&&n.push(t.atCommand),t.atCommands&&n.push(...t.atCommands);return n}}function xo(){return new vt}const ko=`/*\r
1
+ "use strict";var hl=Object.defineProperty;var gl=(e,n,t)=>n in e?hl(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var Mt=(e,n,t)=>gl(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),p=require("react"),ge=require("react-dom"),V={INSERT_BLOCK:"insertBlock",REMOVE_BLOCK:"removeBlock",MOVE_BLOCK:"moveBlock",UPDATE_BLOCK_PROPS:"updateBlockProps",UPDATE_RUN:"updateRun",SET_BLOCK_CONTENT_IDS:"setBlockContentIds",REPLACE_RUN_SPAN:"replaceRunSpan",SET_BLOCK_RUNS:"setBlockRuns",ADD_FIELD_TYPE:"addFieldType",UPDATE_FIELD_TYPE:"updateFieldType",REMOVE_FIELD_TYPE:"removeFieldType"};function Q(e,n,t,r){return{type:V.INSERT_BLOCK,block:e,parentId:n,index:t,subtree:r}}function $(e){return{type:V.REMOVE_BLOCK,id:e}}function ke(e,n,t){return{type:V.MOVE_BLOCK,id:e,toParentId:n,toIndex:t}}function F(e,n){return{type:V.UPDATE_BLOCK_PROPS,id:e,patch:n}}function G(e,n){return{type:V.UPDATE_RUN,id:e,patch:n}}function $e(e,n){return{type:V.SET_BLOCK_CONTENT_IDS,blockId:e,contentIds:n}}function tn(e,n,t){return{type:V.REPLACE_RUN_SPAN,blockId:e,oldRunIds:n,newRuns:t}}function ue(e,n){return{type:V.SET_BLOCK_RUNS,blockId:e,runs:n}}function qn(e){return{type:V.ADD_FIELD_TYPE,fieldType:e}}function Wn(e,n){return{type:V.UPDATE_FIELD_TYPE,id:e,patch:n}}function Yn(e){return{type:V.REMOVE_FIELD_TYPE,id:e}}const kl=Object.freeze(Object.defineProperty({__proto__:null,OP:V,addFieldType:qn,insertBlock:Q,moveBlock:ke,removeBlock:$,removeFieldType:Yn,replaceRunSpan:tn,setBlockContentIds:$e,setBlockRuns:ue,updateBlockProps:F,updateFieldType:Wn,updateRun:G},Symbol.toStringTag,{value:"Module"})),Mn="$fieldTypes";class Gn{constructor(n){this.blocks=new Map(((n==null?void 0:n.blocks)??[]).map(t=>[t.id,t])),this.runs=new Map(((n==null?void 0:n.runs)??[]).map(t=>[t.id,t])),this.rootId=(n==null?void 0:n.rootId)??null,this.fieldTypes=new Map(((n==null?void 0:n.fieldTypes)??[]).map(t=>[t.id,t])),this._fieldTypesSnapshot=null,this._listeners=new Map}getBlock(n){return this.blocks.get(n)}getRun(n){return this.runs.get(n)}getFieldTypes(){return this._fieldTypesSnapshot||(this._fieldTypesSnapshot=[...this.fieldTypes.values()]),this._fieldTypesSnapshot}getFieldType(n){return this.fieldTypes.get(n)}getRootId(){return this.rootId}subscribe(n,t){let r=this._listeners.get(n);return r||(r=new Set,this._listeners.set(n,r)),r.add(t),()=>{r.delete(t),r.size===0&&this._listeners.delete(n)}}_notify(n){for(const t of n){const r=this._listeners.get(t);if(r)for(const o of[...r])o()}}_captureSubtree(n){const t=[],r=[],o=l=>{var i;if(this.runs.has(l)){r.push(this.runs.get(l));return}const s=this.blocks.get(l);if(s){t.push(s);for(const c of s.contentIds)o(c);for(const c of((i=s.props)==null?void 0:i.titleRunIds)??[])o(c)}};return o(n),{blocks:t,runs:r}}_deleteSubtree(n){const t=r=>{var l;if(this.runs.has(r)){this.runs.delete(r);return}const o=this.blocks.get(r);if(o){for(const s of o.contentIds)t(s);for(const s of((l=o.props)==null?void 0:l.titleRunIds)??[])t(s);this.blocks.delete(r)}};t(n)}applyOperation(n){var t;switch(n.type){case V.UPDATE_RUN:{const r=this.runs.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r[l];return this.runs.set(n.id,{...r,...n.patch}),this._notify([n.id]),G(n.id,o)}case V.UPDATE_BLOCK_PROPS:{const r=this.blocks.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r.props[l];return this.blocks.set(n.id,{...r,props:{...r.props,...n.patch}}),this._notify([n.id]),F(n.id,o)}case V.INSERT_BLOCK:{if(n.subtree){for(const s of n.subtree.blocks)this.blocks.set(s.id,s);for(const s of n.subtree.runs)this.runs.set(s.id,s)}else this.blocks.set(n.block.id,n.block);const r=this.blocks.get(n.parentId),o=[...r.contentIds],l=n.index??o.length;return o.splice(l,0,n.block.id),this.blocks.set(n.parentId,{...r,contentIds:o}),this._notify([n.block.id,n.parentId]),$(n.block.id)}case V.REMOVE_BLOCK:{const r=this.blocks.get(n.id),o=r.parentId,l=this.blocks.get(o),s=l.contentIds.indexOf(n.id),i=this._captureSubtree(n.id);this._deleteSubtree(n.id);const c=l.contentIds.filter(u=>u!==n.id);return this.blocks.set(o,{...l,contentIds:c}),this._notify([o]),{type:V.INSERT_BLOCK,block:r,parentId:o,index:s,subtree:i}}case V.MOVE_BLOCK:{const o=this.blocks.get(n.id).parentId,l=this.blocks.get(o),s=l.contentIds.indexOf(n.id),i=l.contentIds.filter(d=>d!==n.id);this.blocks.set(o,{...l,contentIds:i});const c=n.toParentId===o?this.blocks.get(o):this.blocks.get(n.toParentId),u=[...c.contentIds];u.splice(n.toIndex??u.length,0,n.id),this.blocks.set(n.toParentId,{...c,contentIds:u}),this.blocks.set(n.id,{...this.blocks.get(n.id),parentId:n.toParentId});const f=new Set([n.id,o,n.toParentId]);return this._notify(f),ke(n.id,o,s)}case V.SET_BLOCK_CONTENT_IDS:{const r=this.blocks.get(n.blockId),o=r.contentIds;return this.blocks.set(n.blockId,{...r,contentIds:n.contentIds}),this._notify([n.blockId]),$e(n.blockId,o)}case V.REPLACE_RUN_SPAN:{const r=this.blocks.get(n.blockId),o=r.contentIds.indexOf(n.oldRunIds[0])!==-1,l=o?r.contentIds:((t=r.props)==null?void 0:t.titleRunIds)??[],s=l.indexOf(n.oldRunIds[0]),i=n.oldRunIds.map(u=>this.runs.get(u));for(const u of n.oldRunIds)this.runs.delete(u);for(const u of n.newRuns)this.runs.set(u.id,u);const c=[...l];return c.splice(s,n.oldRunIds.length,...n.newRuns.map(u=>u.id)),o?this.blocks.set(n.blockId,{...r,contentIds:c}):this.blocks.set(n.blockId,{...r,props:{...r.props,titleRunIds:c}}),this._notify([n.blockId,...n.oldRunIds,...n.newRuns.map(u=>u.id)]),tn(n.blockId,n.newRuns.map(u=>u.id),i)}case V.SET_BLOCK_RUNS:{const r=this.blocks.get(n.blockId),o=r.props&&"titleRunIds"in r.props,l=o?r.props.titleRunIds:r.contentIds,s=l.map(c=>this.runs.get(c)).filter(Boolean);for(const c of l)this.runs.delete(c);for(const c of n.runs)this.runs.set(c.id,c);const i=n.runs.map(c=>c.id);return o?this.blocks.set(n.blockId,{...r,props:{...r.props,titleRunIds:i}}):this.blocks.set(n.blockId,{...r,contentIds:i}),this._notify([n.blockId,...l,...i]),ue(n.blockId,s)}case V.ADD_FIELD_TYPE:return this.fieldTypes.set(n.fieldType.id,n.fieldType),this._fieldTypesSnapshot=null,this._notify([Mn]),Yn(n.fieldType.id);case V.UPDATE_FIELD_TYPE:{const r=this.fieldTypes.get(n.id),o={};for(const l of Object.keys(n.patch))o[l]=r[l];return this.fieldTypes.set(n.id,{...r,...n.patch}),this._fieldTypesSnapshot=null,this._notify([Mn]),Wn(n.id,o)}case V.REMOVE_FIELD_TYPE:{const r=this.fieldTypes.get(n.id);return this.fieldTypes.delete(n.id),this._fieldTypesSnapshot=null,this._notify([Mn]),qn(r)}default:throw new Error(`Unknown operation type: ${n.type}`)}}applyOperations(n){return n.map(t=>this.applyOperation(t))}toJSON(){return{blocks:[...this.blocks.values()],runs:[...this.runs.values()],rootId:this.rootId,fieldTypes:[...this.fieldTypes.values()]}}static fromJSON(n){return new Gn(n)}}const xl=500;function yl(e,n){const t=e??"",r=n??"";let o=0;const l=Math.min(t.length,r.length);for(;o<l&&t[o]===r[o];)o+=1;let s=t.length,i=r.length;for(;s>o&&i>o&&t[s-1]===r[i-1];)s-=1,i-=1;return{beforeOffset:s,afterOffset:i}}function At(e){var s,i;if(!e.ops.length||!e.inverses.length)return null;const n=e.ops[0],t=e.ops[e.ops.length-1];if(n.type!=="updateRun"||t.type!=="updateRun"||n.id!==t.id||typeof((s=t.patch)==null?void 0:s.value)!="string")return null;const r=e.inverses[e.inverses.length-1];if((r==null?void 0:r.type)!=="updateRun"||typeof((i=r.patch)==null?void 0:i.value)!="string")return null;const{beforeOffset:o,afterOffset:l}=yl(r.patch.value,t.patch.value);return{runId:n.id,beforeOffset:o,afterOffset:l}}function Dt(e){const n=[],t=r=>{var o;r&&((o=r.block)!=null&&o.id&&n.push(r.block.id),r.blockId&&n.push(r.blockId),r.id&&n.push(r.id),r.parentId&&n.push(r.parentId),r.toParentId&&n.push(r.toParentId))};for(const r of e.ops)t(r);for(const r of e.inverses)t(r);return[...new Set(n)]}class vl{constructor(n,{idleMs:t=xl,trackChanges:r=!1,maxChangeLogSize:o=500}={}){this.store=n,this.idleMs=t,this.undoStack=[],this.redoStack=[],this.currentBatch=null,this.idleTimer=null,this.historyLog=[],this._listeners=new Set,this._undoRedoSnapshot={canUndo:!1,canRedo:!1},this._pendingSelection=null,this._pendingAffectedBlockIds=[],this.trackChanges=r,this.maxChangeLogSize=o,this.changeLog=[]}_recordChange(n,t,r){var l;if(!this.trackChanges)return;const o=n.patch!==void 0&&(t==null?void 0:t.patch)!==void 0;this.changeLog.push({opType:n.type,id:n.id??n.blockId??((l=n.block)==null?void 0:l.id),before:o?t.patch:void 0,after:o?n.patch:void 0,actorId:r.actorId??null,timestamp:r.timestamp??Date.now()}),this.changeLog.length>this.maxChangeLogSize&&this.changeLog.shift()}getChangeLog(){return[...this.changeLog]}getPendingSelection(){return this._pendingSelection}getPendingAffectedBlockIds(){return this._pendingAffectedBlockIds}getUndoRedoSnapshot(){const n=this.canUndo(),t=this.canRedo();return(this._undoRedoSnapshot.canUndo!==n||this._undoRedoSnapshot.canRedo!==t)&&(this._undoRedoSnapshot={canUndo:n,canRedo:t}),this._undoRedoSnapshot}getBlock(n){return this.store.getBlock(n)}getRun(n){return this.store.getRun(n)}getRootId(){return this.store.getRootId()}getFieldTypes(){return this.store.getFieldTypes()}getFieldType(n){return this.store.getFieldType(n)}subscribe(n,t){return this.store.subscribe(n,t)}toJSON(){return this.store.toJSON()}applyOperation(n,t={}){return this.perform(n,t)}applyOperations(n,t={}){return n.map(r=>this.perform(r,t))}performBatch(n,t={}){var s;const r=t.actorId??null,o=t.timestamp??Date.now();this._commitCurrentBatch();const l=[];for(const i of n){const c=this.store.applyOperation(i);l.unshift(c),this.historyLog.push({opType:i.type,id:i.id??i.blockId??((s=i.block)==null?void 0:s.id),actorId:r,timestamp:o}),this._recordChange(i,c,{actorId:r,timestamp:o})}this.redoStack=[],this.undoStack.push({ops:[...n],inverses:l,batchKey:null,actorId:r,timestamp:o,lastTimestamp:o,boundaryHit:!0}),this._notify()}perform(n,t={}){const r=t.actorId??null,o=t.timestamp??Date.now(),l=this.store.applyOperation(n);return this._record(n,l,{actorId:r,timestamp:o}),l}_batchKeyFor(n){return n.type==="updateRun"?`run:${n.id}`:null}_isWordBoundary(n){var r;if(n.type!=="updateRun")return!1;const t=(r=n.patch)==null?void 0:r.value;return typeof t!="string"||t.length===0?!1:/\s/.test(t[t.length-1])}_record(n,t,r){var i;this.redoStack=[];const o=this._batchKeyFor(n),l=this.currentBatch&&r.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&o!==null&&this.currentBatch.batchKey===o&&l&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(n),this.currentBatch.inverses.unshift(t),this.currentBatch.lastTimestamp=r.timestamp,this._isWordBoundary(n)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[n],inverses:[t],batchKey:o,actorId:r.actorId,timestamp:r.timestamp,lastTimestamp:r.timestamp,boundaryHit:this._isWordBoundary(n)}),this._resetIdleTimer(),this.historyLog.push({opType:n.type,id:n.id??((i=n.block)==null?void 0:i.id),actorId:r.actorId,timestamp:r.timestamp}),this._recordChange(n,t,r),this._notify()}_resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this._commitCurrentBatch(),this._notify()},this.idleMs)}_commitCurrentBatch(){this.currentBatch&&(this.undoStack.push(this.currentBatch),this.currentBatch=null,this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null))}flush(){this._commitCurrentBatch(),this._notify()}undo(){this._commitCurrentBatch();const n=this.undoStack.pop();if(!n)return!1;for(const r of n.inverses)this.store.applyOperation(r);this.redoStack.push(n);const t=At(n);return this._pendingSelection=t?{runId:t.runId,offset:t.beforeOffset}:null,this._pendingAffectedBlockIds=Dt(n),this._notify(),!0}redo(){const n=this.redoStack.pop();if(!n)return!1;for(const r of n.ops)this.store.applyOperation(r);this.undoStack.push(n);const t=At(n);return this._pendingSelection=t?{runId:t.runId,offset:t.afterOffset}:null,this._pendingAffectedBlockIds=Dt(n),this._notify(),!0}canUndo(){return this.undoStack.length>0||this.currentBatch!==null}canRedo(){return this.redoStack.length>0}getHistoryLog(){return[...this.historyLog]}subscribeToHistory(n){return this._listeners.add(n),()=>this._listeners.delete(n)}_notify(){for(const n of this._listeners)n()}}class or{constructor(){this._types=new Map}register(n,t){this._types.set(n,t)}get(n){return this._types.get(n)}isLeaf(n){var t;return!!((t=this._types.get(n))!=null&&t.isLeaf)}listSlashCommands(){const n=[];for(const t of this._types.values())t.slashCommand&&n.push(t.slashCommand),t.slashCommands&&n.push(...t.slashCommands);return n}listHtmlMatchers(){return[...this._types.values()].filter(n=>n.fromHTML)}}function wl(){return new or}class lr{constructor(){this._types=new Map}register(n,t){this._types.set(n,t)}unregister(n){this._types.delete(n)}get(n){return this._types.get(n)}listHtmlMatchers(){return[...this._types.values()].filter(n=>n.fromHTML)}listSlashCommands(){const n=[];for(const t of this._types.values())t.slashCommand&&n.push(t.slashCommand),t.slashCommands&&n.push(...t.slashCommands);return n}listAtCommands(){const n=[];for(const t of this._types.values())t.atCommand&&n.push(t.atCommand),t.atCommands&&n.push(...t.atCommands);return n}}function Il(){return new lr}const Cl=`/*\r
2
2
  * noteloom's default theme — minimal, clean, Notion/Linear-adjacent.\r
3
3
  *\r
4
4
  * Ships as plain CSS custom properties on :root (not scoped to a wrapper\r
@@ -155,6 +155,13 @@
155
155
  outline: none;\r
156
156
  }\r
157
157
  \r
158
+ .be-blockquote[dir='rtl'] {\r
159
+ padding-left: 0;\r
160
+ padding-right: 0.9em;\r
161
+ border-left: none;\r
162
+ border-right: 3px solid var(--noteloom-border);\r
163
+ }\r
164
+ \r
158
165
  /* --- callout --- */\r
159
166
  \r
160
167
  .be-callout {\r
@@ -640,6 +647,12 @@
640
647
  color: #fff;\r
641
648
  }\r
642
649
  \r
650
+ .be-embed-alt-text-btn {\r
651
+ width: auto;\r
652
+ padding: 0 8px;\r
653
+ font-size: 0.75rem;\r
654
+ }\r
655
+ \r
643
656
  .be-embed-remove {\r
644
657
  border: none;\r
645
658
  background: transparent;\r
@@ -1098,6 +1111,15 @@ tr.be-table-row:hover .be-table-delete-row {\r
1098
1111
  user-select: none; /* it's a drag handle (see useBlockRangeDrag) — never let its own space become selectable text */\r
1099
1112
  }\r
1100
1113
  \r
1114
+ /* \`left\`/\`right\` are physical, not logical, properties — unlike the list\r
1115
+ marker's flexbox position (which flips for free via dir inheritance),\r
1116
+ this absolute offset needs an explicit RTL override to sit on the\r
1117
+ correct side of the block. */\r
1118
+ [dir='rtl'] .be-block-gutter {\r
1119
+ left: auto;\r
1120
+ right: -56px;\r
1121
+ }\r
1122
+ \r
1101
1123
  .be-block-row:hover .be-block-gutter,\r
1102
1124
  .be-block-gutter-active {\r
1103
1125
  opacity: 1;\r
@@ -1117,6 +1139,20 @@ tr.be-table-row:hover .be-table-delete-row {\r
1117
1139
  transition: background-color 0.12s ease, color 0.12s ease;\r
1118
1140
  }\r
1119
1141
  \r
1142
+ /* Touch: no hover state exists to reveal the gutter at all, and its\r
1143
+ desktop position (left: -56px, sitting in the page's own side margin)\r
1144
+ would be off-screen on a narrow phone/tablet viewport regardless — so\r
1145
+ rather than force it into the row itself, its two actions (Add block,\r
1146
+ block options menu) live inside MobileActionBar instead (see\r
1147
+ MobileActionBar.jsx), pinned above the keyboard where they're always\r
1148
+ reachable. \`.be-touch-input\` is set by useCoarsePointer.js, based on\r
1149
+ real pointerdown activity, not just a static device-capability guess —\r
1150
+ see that file for why a plain \`pointer: coarse\` media query alone isn't\r
1151
+ enough (touchscreen laptops, etc.). */\r
1152
+ .be-touch-input .be-block-gutter {\r
1153
+ display: none;\r
1154
+ }\r
1155
+ \r
1120
1156
  .be-block-gutter-btn:hover,\r
1121
1157
  .be-block-gutter-btn[aria-expanded='true'] {\r
1122
1158
  background: var(--noteloom-bg-hover);\r
@@ -1294,6 +1330,132 @@ tr.be-table-row:hover .be-table-delete-row {\r
1294
1330
  max-width: 640px;\r
1295
1331
  }\r
1296
1332
  \r
1333
+ /* Bottom sheet variant (mobile block picker) — anchored to the bottom edge\r
1334
+ instead of centered, rounded only on top, full page width. */\r
1335
+ .be-modal-overlay-sheet {\r
1336
+ align-items: flex-end;\r
1337
+ padding: 0;\r
1338
+ }\r
1339
+ \r
1340
+ .be-modal-sheet {\r
1341
+ max-width: 100%;\r
1342
+ width: 100%;\r
1343
+ max-height: 70vh;\r
1344
+ border-radius: var(--noteloom-radius-xl) var(--noteloom-radius-xl) 0 0;\r
1345
+ border-bottom: none;\r
1346
+ padding-bottom: max(1.4em, env(safe-area-inset-bottom));\r
1347
+ }\r
1348
+ \r
1349
+ .be-mobile-picker-list {\r
1350
+ display: flex;\r
1351
+ flex-direction: column;\r
1352
+ gap: 2px;\r
1353
+ }\r
1354
+ \r
1355
+ .be-mobile-picker-item {\r
1356
+ display: flex;\r
1357
+ align-items: center;\r
1358
+ gap: 10px;\r
1359
+ width: 100%;\r
1360
+ border: none;\r
1361
+ background: transparent;\r
1362
+ border-radius: var(--noteloom-radius-md);\r
1363
+ padding: 12px 10px;\r
1364
+ font: inherit;\r
1365
+ font-size: 0.95rem;\r
1366
+ color: var(--noteloom-text);\r
1367
+ text-align: left;\r
1368
+ cursor: pointer;\r
1369
+ }\r
1370
+ \r
1371
+ .be-mobile-picker-item:hover,\r
1372
+ .be-mobile-picker-item:active {\r
1373
+ background: var(--noteloom-bg-hover);\r
1374
+ }\r
1375
+ \r
1376
+ .be-mobile-picker-item-danger {\r
1377
+ color: var(--noteloom-danger);\r
1378
+ }\r
1379
+ \r
1380
+ .be-mobile-picker-item-danger:hover,\r
1381
+ .be-mobile-picker-item-danger:active {\r
1382
+ background: var(--noteloom-danger-soft);\r
1383
+ }\r
1384
+ \r
1385
+ .be-mobile-picker-item-danger .be-mobile-picker-item-icon {\r
1386
+ color: var(--noteloom-danger);\r
1387
+ }\r
1388
+ \r
1389
+ /* --- mobile action bar (pinned above the on-screen keyboard) --- */\r
1390
+ \r
1391
+ .be-mobile-action-bar {\r
1392
+ position: fixed;\r
1393
+ left: 0;\r
1394
+ right: 0;\r
1395
+ z-index: 1500;\r
1396
+ display: flex;\r
1397
+ align-items: center;\r
1398
+ gap: 2px;\r
1399
+ padding: 6px calc(6px + env(safe-area-inset-right)) 6px calc(6px + env(safe-area-inset-left));\r
1400
+ background: var(--noteloom-bg);\r
1401
+ border-top: 1px solid var(--noteloom-border);\r
1402
+ overflow-x: auto;\r
1403
+ }\r
1404
+ \r
1405
+ .be-mobile-bar-btn {\r
1406
+ flex: none;\r
1407
+ display: flex;\r
1408
+ align-items: center;\r
1409
+ justify-content: center;\r
1410
+ gap: 4px;\r
1411
+ min-width: 40px;\r
1412
+ height: 40px;\r
1413
+ padding: 0 10px;\r
1414
+ border: none;\r
1415
+ background: transparent;\r
1416
+ border-radius: var(--noteloom-radius-sm);\r
1417
+ color: var(--noteloom-text);\r
1418
+ font-size: 0.85rem;\r
1419
+ font-weight: 500;\r
1420
+ cursor: pointer;\r
1421
+ }\r
1422
+ \r
1423
+ .be-mobile-bar-btn:disabled {\r
1424
+ opacity: 0.4;\r
1425
+ }\r
1426
+ \r
1427
+ .be-mobile-bar-btn-active {\r
1428
+ background: var(--noteloom-accent-soft);\r
1429
+ color: var(--noteloom-accent);\r
1430
+ }\r
1431
+ \r
1432
+ .be-mobile-bar-spacer {\r
1433
+ flex: 1;\r
1434
+ }\r
1435
+ \r
1436
+ .be-mobile-bar-select {\r
1437
+ flex: none;\r
1438
+ }\r
1439
+ \r
1440
+ .be-mobile-bar-swatches {\r
1441
+ display: flex;\r
1442
+ align-items: center;\r
1443
+ gap: 6px;\r
1444
+ padding: 0 6px;\r
1445
+ }\r
1446
+ \r
1447
+ .be-mobile-picker-item-icon {\r
1448
+ flex: none;\r
1449
+ display: flex;\r
1450
+ align-items: center;\r
1451
+ justify-content: center;\r
1452
+ width: 32px;\r
1453
+ height: 32px;\r
1454
+ border-radius: var(--noteloom-radius-sm);\r
1455
+ background: var(--noteloom-bg-subtle);\r
1456
+ color: var(--noteloom-text-muted);\r
1457
+ }\r
1458
+ \r
1297
1459
  .be-modal-title {\r
1298
1460
  font-weight: 600;\r
1299
1461
  font-size: 1.05rem;\r
@@ -1895,12 +2057,158 @@ tr.be-table-row:hover .be-table-delete-row {\r
1895
2057
  background: var(--noteloom-bg-hover);\r
1896
2058
  color: var(--noteloom-text);\r
1897
2059
  }\r
1898
- `,rt="noteloom-default-styles";function It(){if(typeof document>"u"||document.getElementById(rt))return;const e=document.createElement("style");e.id=rt,e.textContent=ko,document.head.appendChild(e)}const wt=f.createContext(null);function yo({store:e,registry:n,inlineRegistry:t=null,history:r=null,className:o,style:l,theme:s="default",getBlockClassName:c,children:i}){f.useEffect(()=>{s!=="none"&&It()},[s]);const[u,p]=f.useState(!1),[d,b]=f.useState([]),[h,m]=f.useState(!1),[g,x]=f.useState(null),k=f.useCallback(()=>x("new"),[]),I=f.useCallback(v=>x(v),[]),y=f.useCallback(()=>x(null),[]),E=f.useRef(null),R=f.useCallback(()=>E.current,[]),S=f.useCallback(v=>{var B,O;const j=E.current;j!==v&&(j&&((B=document.querySelector(`[data-block-id="${j}"]`))==null||B.classList.remove("be-block-selected")),E.current=v,v&&((O=document.querySelector(`[data-block-id="${v}"]`))==null||O.classList.add("be-block-selected")))},[]),C=f.useMemo(()=>({store:e,registry:n,inlineRegistry:t,history:r,isWholeDocumentSelected:u,setIsWholeDocumentSelected:p,selectedBlockRange:d,setSelectedBlockRange:b,getSelectedBlockId:R,setSelectedBlockId:S,isPreviewMode:h,setIsPreviewMode:m,fieldTypeEditorTarget:g,openCreateFieldType:k,openEditFieldType:I,closeFieldTypeEditor:y,getBlockClassName:c}),[e,n,t,r,u,d,R,S,h,g,k,I,y,c]),w=o||l?a.jsx("div",{className:o?`be-root ${o}`:"be-root",style:l,children:i}):i;return a.jsx(wt.Provider,{value:C,children:w})}function pe(){const e=f.useContext(wt);if(!e)throw new Error("Editor hooks must be used within an <EditorProvider>");return e}function D(){return pe().store}function Ne(){return pe().registry}function he(){return pe().inlineRegistry}function Nn(){const{isWholeDocumentSelected:e,setIsWholeDocumentSelected:n}=pe();return[e,n]}function We(){const{selectedBlockRange:e,setSelectedBlockRange:n}=pe();return[e,n]}function ge(){const{getSelectedBlockId:e,setSelectedBlockId:n}=pe();return{getSelectedBlockId:e,setSelectedBlockId:n}}function Mn(){const{isPreviewMode:e,setIsPreviewMode:n}=pe();return[e,n]}function ee(e,n){const{getBlockClassName:t}=pe(),r=n&&t?t(n):void 0;return r?`${e} ${r}`:e}function An(){const{fieldTypeEditorTarget:e,openCreateFieldType:n,openEditFieldType:t,closeFieldTypeEditor:r}=pe();return{target:e,openCreate:n,openEdit:t,close:r}}function Q(e){const n=D(),t=f.useCallback(o=>n.subscribe(e,o),[n,e]),r=f.useCallback(()=>n.getBlock(e),[n,e]);return f.useSyncExternalStore(t,r)}function ye(e){const n=D(),t=f.useCallback(o=>n.subscribe(e,o),[n,e]),r=f.useCallback(()=>n.getRun(e),[n,e]);return f.useSyncExternalStore(t,r)}function T(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const Ct="​",vo=/​/g;function me(e){return(e??"").replace(vo,"")}function ot(e){return me(e.textContent)}function Io(e,n){var c;const t=new Map(n.map(i=>[i.id,i])),r=new Set,o=[];let l=!0;for(const i of e.childNodes){const u=i.nodeType===1?(c=i.dataset)==null?void 0:c.runId:void 0;if(u&&t.has(u)){r.add(u);const d=t.get(u);if(d.type!=="text"){o.push(d);continue}const b=ot(i);o.push(b===d.value?d:{...d,value:b});continue}l=!1;const p=ot(i);p&&o.push({id:T(),type:"text",value:p,marks:{}})}if(n.some(i=>!r.has(i.id))&&(l=!1),o.length!==n.length&&(l=!1),l){for(let i=0;i<o.length;i+=1)if(o[i].id!==n[i].id){l=!1;break}}const s=!l||o.some((i,u)=>i!==n[u]);return{runs:o,changed:s,onlyValueChanges:l}}function Bt(e){return e?e.type!=="text"?!1:(e.value??"")==="":!0}function ae(e,n){return!n||n.length===0?!0:n.every(t=>Bt(e.getRun(t)))}function Ve(e,n){var o,l;if(!n)return!1;const t=n.contentIds.length>0,r=(((l=(o=n.props)==null?void 0:o.titleRunIds)==null?void 0:l.length)??0)>0;return!t&&!r}function Rt(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const r=document.createRange();r.selectNodeContents(t),r.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)})}function X(e){Rt(e,!1)}function Dn(e){Rt(e,!0)}function be(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const r=t.firstChild,o=document.createRange();if(r&&r.nodeType===3){const s=Math.max(0,Math.min(n,r.length));o.setStart(r,s),o.setEnd(r,s)}else o.selectNodeContents(t),o.collapse(n<=0);const l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(o)})}function Ye({isOpen:e,onClose:n,title:t,size:r="default",children:o}){return f.useEffect(()=>{if(!e)return;const l=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,n]),e?a.jsx("div",{className:"be-modal-overlay",onMouseDown:l=>{l.target===l.currentTarget&&n()},children:a.jsxs("div",{className:`be-modal${r==="large"?" be-modal-large":""}`,role:"dialog","aria-modal":"true","aria-label":t,children:[t&&a.jsx("div",{className:"be-modal-title",children:t}),o]})}):null}function Tt({isOpen:e,initialHref:n,initialTarget:t,hasExistingLink:r,onSave:o,onRemove:l,onClose:s}){const[c,i]=f.useState(""),[u,p]=f.useState("_self");f.useEffect(()=>{e&&(i(n),p(t))},[e]);const d=c.trim(),b=f.useCallback(h=>{h.preventDefault(),d&&o(d,u)},[d,u,o]);return a.jsx(Ye,{isOpen:e,onClose:s,title:r?"Edit link":"Add link",children:a.jsxs("form",{onSubmit:b,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"URL"}),a.jsx("input",{type:"text",value:c,onChange:h=>i(h.target.value),placeholder:"https://example.com",autoFocus:!0})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Open in"}),a.jsxs("select",{value:u,onChange:h=>p(h.target.value),children:[a.jsx("option",{value:"_self",children:"Same tab"}),a.jsx("option",{value:"_blank",children:"New tab"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[r&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:l,children:"Remove link"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:s,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",disabled:!d,children:"Save"})]})]})})}function A({children:e,size:n=16,strokeWidth:t=2,...r}){return a.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:e})}function pn(e){return a.jsx(A,{...e,children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function _n(e){return a.jsx(A,{...e,children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Ge(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function jt(e){return a.jsx(A,{...e,children:a.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function St(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function wo(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),a.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}function Co(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),a.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}function Bo(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M6 3v7a6 6 0 0 0 12 0V3"}),a.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}function Ro(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M12 20h9"}),a.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function To(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function jo(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),a.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function So(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"17",y1:"18",x2:"3",y2:"18"})]})}function Eo(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"18",y1:"18",x2:"6",y2:"18"})]})}function Oo(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"21",y1:"18",x2:"7",y2:"18"})]})}function Lo(e){return a.jsx(A,{...e,children:[5,12,19].flatMap(n=>[9,15].map(t=>a.jsx("circle",{cx:t,cy:n,r:"1.3",fill:"currentColor",stroke:"none"},`${t}-${n}`)))})}function $n(e){return a.jsxs(A,{...e,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),a.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function Et(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Ot(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Lt(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function No(e){return a.jsxs(A,{...e,children:[a.jsx("circle",{cx:"6",cy:"6",r:"3"}),a.jsx("circle",{cx:"6",cy:"18",r:"3"}),a.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),a.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),a.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}function Mo(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"17",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"21",y1:"12",x2:"3",y2:"12"}),a.jsx("line",{x1:"15",y1:"18",x2:"3",y2:"18"})]})}function Pn({level:e=1,size:n=16,...t}){return a.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",...t,children:a.jsxs("text",{x:"2",y:"18",fontSize:"14",fontWeight:"700",fill:"currentColor",fontFamily:"inherit",children:["H",e]})})}function Ao(e){return a.jsx(Pn,{level:1,...e})}function Do(e){return a.jsx(Pn,{level:2,...e})}function _o(e){return a.jsx(Pn,{level:3,...e})}function $o(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M7 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H6a3 3 0 0 1 3-3z"}),a.jsx("path",{d:"M17 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2a3 3 0 0 1 3-3z"})]})}function Nt(e){return a.jsxs(A,{...e,children:[a.jsx("polyline",{points:"9 8 4 12 9 16"}),a.jsx("polyline",{points:"15 8 20 12 15 16"})]})}function Po(e){return a.jsx(A,{...e,children:a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function Ho(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M4 5h16a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H9l-4 4v-4H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z"}),a.jsx("line",{x1:"7",y1:"9",x2:"17",y2:"9"}),a.jsx("line",{x1:"7",y1:"12.5",x2:"13",y2:"12.5"})]})}function zo(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"8",width:"18",height:"8",rx:"3"}),a.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function Uo(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),a.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),a.jsx("line",{x1:"3",y1:"16",x2:"21",y2:"16"}),a.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function Fo(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),a.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function Ko(e){return a.jsxs(A,{...e,children:[a.jsx("circle",{cx:"4.5",cy:"6",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"4.5",cy:"12",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"4.5",cy:"18",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("line",{x1:"9",y1:"6",x2:"21",y2:"6"}),a.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),a.jsx("line",{x1:"9",y1:"18",x2:"21",y2:"18"})]})}function qo(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),a.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),a.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),a.jsx("text",{x:"2",y:"8.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"1"}),a.jsx("text",{x:"2",y:"14.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"2"}),a.jsx("text",{x:"2",y:"20.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"3"})]})}function Mt(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3"}),a.jsx("polyline",{points:"8 12 11 15 16 9"})]})}function Wo(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2"}),a.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),a.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"7"}),a.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"7"})]})}function Vo(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M12 3h7a2 2 0 0 1 2 2v7a2 2 0 0 1-.59 1.41l-8 8a2 2 0 0 1-2.82 0l-7-7a2 2 0 0 1 0-2.82l8-8A2 2 0 0 1 12 3z"}),a.jsx("circle",{cx:"15.5",cy:"8.5",r:"1.2",fill:"currentColor",stroke:"none"})]})}function Yo(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),a.jsx("circle",{cx:"9",cy:"10",r:"1.5",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4 17l5-5 4 4 4-5 4 6"})]})}function Go(e){return a.jsxs(A,{...e,children:[a.jsx("rect",{x:"3",y:"5",width:"14",height:"14",rx:"2"}),a.jsx("path",{d:"M17 10l4-2.5v9L17 14"})]})}function At(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Dt(e){return a.jsxs(A,{...e,children:[a.jsx("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 19c-6.5 0-10-7-10-7a18.5 18.5 0 0 1 5.06-5.94M9.9 4.24A10.94 10.94 0 0 1 12 4c6.5 0 10 7 10 7a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Xo(e){return a.jsxs(A,{...e,children:[a.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"14"}),a.jsx("line",{x1:"8",y1:"7",x2:"8",y2:"17"}),a.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"}),a.jsx("line",{x1:"16",y1:"7",x2:"16",y2:"17"}),a.jsx("line",{x1:"20",y1:"10",x2:"20",y2:"14"})]})}function Jo({containerRef:e,store:n}){var x;const[t,r]=f.useState(null),[o,l]=f.useState(!1),s=f.useRef(null),c=f.useRef(null),i=f.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),u=f.useCallback(()=>{i(),s.current=setTimeout(()=>{r(k=>o?k:null)},250)},[i,o]);f.useEffect(()=>{const k=e.current;if(!k)return;const I=E=>{var w,v,j;const R=(v=(w=E.target).closest)==null?void 0:v.call(w,"[data-run-id]");if(!R||!k.contains(R))return;const S=R.dataset.runId,C=n.getRun(S);(j=C==null?void 0:C.marks)!=null&&j.link&&(i(),r(B=>(B==null?void 0:B.runId)===S?B:{runId:S,rect:R.getBoundingClientRect()}))},y=()=>u();return k.addEventListener("mouseover",I),k.addEventListener("mouseout",y),()=>{k.removeEventListener("mouseover",I),k.removeEventListener("mouseout",y)}},[e,n,i,u]),f.useEffect(()=>()=>i(),[i]);const p=f.useCallback(()=>l(!0),[]),d=f.useCallback(()=>{l(!1),r(null)},[]),b=f.useCallback((k,I)=>{if(!t)return;const y=n.getRun(t.runId);y&&(n.applyOperation(J(t.runId,{marks:{...y.marks,link:{href:k,target:I}}})),d())},[t,n,d]),h=f.useCallback(()=>{if(!t)return;const k=n.getRun(t.runId);if(!k)return;const I={...k.marks};delete I.link,n.applyOperation(J(t.runId,{marks:I})),d()},[t,n,d]),m=t&&n.getRun(t.runId),g=(x=m==null?void 0:m.marks)==null?void 0:x.link;return a.jsxs(a.Fragment,{children:[t&&g&&!o?Le.createPortal(a.jsxs("div",{ref:c,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:t.rect.bottom+6,left:t.rect.left},onMouseEnter:i,onMouseLeave:u,children:[a.jsx("a",{className:"be-link-hover-card-url",href:g.href,target:g.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:g.href}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:p,"aria-label":"Edit link",title:"Edit link",children:a.jsx(Ro,{size:13})}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:h,"aria-label":"Remove link",title:"Remove link",children:a.jsx(Ge,{size:13})})]}),document.body):null,a.jsx(Tt,{isOpen:o,initialHref:(g==null?void 0:g.href)??"",initialTarget:(g==null?void 0:g.target)??"_self",hasExistingLink:!!g,onSave:b,onRemove:h,onClose:d})]})}function lt(e,n){const t=e==null?void 0:e.parentElement;if(!t||!t.hasAttribute("data-placeholder"))return;n.length===0||n.every(Bt)?t.setAttribute("data-empty",""):t.removeAttribute("data-empty")}function Qo(e={}){return{fontWeight:e.bold?"bold":void 0,fontStyle:e.italic?"italic":void 0,textDecoration:[(e.underline||e.link)&&"underline",e.strike&&"line-through"].filter(Boolean).join(" ")||void 0,verticalAlign:e.subscript?"sub":e.superscript?"super":void 0,fontSize:e.subscript||e.superscript?"smaller":void 0,color:e.color||(e.link?"var(--noteloom-accent)":void 0),backgroundColor:e.highlight||void 0,cursor:e.link?"pointer":void 0}}function Zo({id:e,host:n,onValueSynced:t}){const r=ye(e);return f.useLayoutEffect(()=>{var u;if(!n||!r)return;const o=r.value??"";(me(n.textContent)!==o||o===""&&n.textContent==="")&&(n.textContent=o===""?Ct:o);const c=Qo(r.marks);n.style.fontWeight=c.fontWeight??"",n.style.fontStyle=c.fontStyle??"",n.style.textDecoration=c.textDecoration??"",n.style.verticalAlign=c.verticalAlign??"",n.style.fontSize=c.fontSize??"",n.style.color=c.color??"",n.style.backgroundColor=c.backgroundColor??"",n.style.cursor=c.cursor??"";const i=(u=r.marks)==null?void 0:u.link;n.title=i!=null&&i.href?`${i.href} — Ctrl+Click to open`:"",n.onclick=i!=null&&i.href?p=>{!p.ctrlKey&&!p.metaKey||(p.preventDefault(),window.open(i.href,i.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,t==null||t()},[n,r,t]),null}function st(e,n,t,r){var d,b,h;const o=(d=window.getSelection)==null?void 0:d.call(window);if(!o||!o.isCollapsed||o.rangeCount===0)return null;const{anchorNode:l,anchorOffset:s}=o;if(!l||!e.contains(l))return null;const c=m=>{const g=n.indexOf(m);if(g===-1)return null;const x=r?n[g-1]:n[g+1];if(!x)return null;const k=t(x);return k&&k.type!=="text"?x:null};if(l===e){const m=r?s-1:s,g=e.childNodes[m],x=(g==null?void 0:g.nodeType)===1?(b=g.dataset)==null?void 0:b.runId:void 0;if(!x||n.indexOf(x)===-1)return null;const k=t(x);return k&&k.type!=="text"?x:null}const i=l.nodeType===1?l:l.parentElement,u=(h=i==null?void 0:i.closest)==null?void 0:h.call(i,"[data-run-id]");return!u||!e.contains(u)||!(r?s===0:s===(l.textContent??"").length)?null:c(u.getAttribute("data-run-id"))}function at(e,n,t){var i,u;const r=(i=window.getSelection)==null?void 0:i.call(window);if(!r||r.isCollapsed||r.rangeCount===0)return null;const o=r.getRangeAt(0);if(o.startContainer!==o.endContainer||!e.contains(o.startContainer)||o.endOffset!==o.startOffset+1)return null;const l=o.startContainer.childNodes[o.startOffset],s=(l==null?void 0:l.nodeType)===1?(u=l.dataset)==null?void 0:u.runId:void 0;if(!s||n.indexOf(s)===-1)return null;const c=t(s);return c&&c.type!=="text"?s:null}function ct(e,n,t){var c;if(n===e)return{childIndex:t,charOffset:null};const r=n.nodeType===1?n:n.parentElement,o=(c=r==null?void 0:r.closest)==null?void 0:c.call(r,"[data-run-id]");if(!o||!e.contains(o))return null;const l=Array.prototype.indexOf.call(e.childNodes,o),s=n===o?t===0?0:(o.textContent??"").length:t;return{childIndex:l,charOffset:s}}function el(e,n,t,r){const o=ct(e,r.startContainer,r.startOffset),l=ct(e,r.endContainer,r.endOffset);if(!o||!l)return null;const s=Array.from(e.childNodes).filter(p=>{var d;return p.nodeType===1&&((d=p.dataset)==null?void 0:d.runId)&&n.indexOf(p.dataset.runId)!==-1});let c=!1;const i=[];let u=null;return s.forEach((p,d)=>{const b=p.dataset.runId,h=t(b);if(!h)return;const m=d<o.childIndex,g=l.charOffset===null?d>=l.childIndex:d>l.childIndex;if(m||g){i.push(h);return}const x=o.charOffset!==null&&d===o.childIndex,k=l.charOffset!==null&&d===l.childIndex;if(h.type!=="text"){c=!0,u===null&&(u=i.length);return}const I=h.value??"";if(x&&k){const y=I.slice(0,o.charOffset)+I.slice(l.charOffset);y&&i.push({...h,value:y}),u=i.length}else if(x){const y=I.slice(0,o.charOffset);y&&i.push({...h,value:y}),u===null&&(u=i.length)}else if(k){const y=I.slice(l.charOffset);y&&i.push({id:T(),type:"text",value:y,marks:h.marks})}}),c?{nextRuns:i,insertionIndex:u??i.length}:null}function nl(e){var l;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||!n.isCollapsed)return!1;const t=e.firstChild;if(!t)return!0;if(n.anchorNode===e)return n.anchorOffset===0;let r=t;for(;r&&r.firstChild;)r=r.firstChild;if(n.anchorNode!==r&&n.anchorNode!==t)return!1;const o=r.nodeType===3&&r.textContent===Ct?1:0;return n.anchorOffset<=o}function tl(e){var l;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||!n.isCollapsed)return!1;const t=e.lastChild;if(!t)return!0;if(n.anchorNode===e)return n.anchorOffset>=e.childNodes.length;let r=t;for(;r&&r.lastChild;)r=r.lastChild;if(n.anchorNode!==r&&n.anchorNode!==t)return!1;const o=r.nodeType===3?(r.textContent??"").length:0;return n.anchorOffset>=o}function it(e,n,t){const r=e.getBlock(n),o=e.getBlock(r==null?void 0:r.parentId);if(!o)return null;const l=o.contentIds.indexOf(n),s=t==="backward"?l-1:l+1;if(s<0||s>=o.contentIds.length)return null;const c=o.contentIds[s];return Ve(e,e.getBlock(c))?c:null}function rl({id:e,blockId:n,host:t,inlineRegistry:r,onValueSynced:o}){const l=ye(e);if(!l)return null;if(l.type==="text")return a.jsx(Zo,{id:e,host:t,onValueSynced:o});const s=r==null?void 0:r.get(l.type);if(!s)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No inline type registered for "${l.type}" (run: ${e})`),null;const c=s.component;return a.jsx(c,{id:e,blockId:n})}function ol(e,n,t){let r=e.get(t);if(!r){r=document.createElement("span"),r.dataset.runId=t;const o=n.getRun(t);o&&o.type!=="text"&&r.setAttribute("contenteditable","false"),e.set(t,r)}return r}function xe({blockId:e,runIds:n,onEnter:t,onBackspaceAtStart:r,onDeleteAtEnd:o,onArrowUp:l,onArrowDown:s,onTab:c,onShiftTab:i,onAutoformat:u}){const p=D(),d=he(),{getSelectedBlockId:b,setSelectedBlockId:h}=ge(),m=f.useRef(null),g=f.useRef(!1),x=f.useRef(new Map);f.useLayoutEffect(()=>{const v=m.current;if(!v)return;const j=new Set(n);for(const[O,N]of x.current)j.has(O)||(N.remove(),x.current.delete(O));let B=null;for(const O of n){const N=x.current.get(O);if(!N)continue;const M=B?B.nextSibling:v.firstChild;M!==N&&v.insertBefore(N,M),B=N}},[n]);const k=f.useCallback(()=>{if(g.current)return;const v=m.current;if(!v)return;const j=n.map(M=>p.getRun(M)).filter(Boolean),{runs:B,changed:O,onlyValueChanges:N}=Io(v,j);if(O){if(N){if(B.forEach((M,q)=>{M!==j[q]&&p.applyOperation(J(M.id,{value:M.value}))}),u!=null&&u(B))return}else p.applyOperation(se(e,B.length?B:[{id:T(),type:"text",value:"",marks:{}}]));lt(v,B)}},[p,e,n,u]),I=f.useCallback(()=>{lt(m.current,n.map(v=>p.getRun(v)).filter(Boolean))},[p,n]),y=f.useCallback(()=>{g.current=!0},[]),E=f.useCallback(()=>{g.current=!1,k()},[k]),R=f.useCallback(v=>{const B=n.map(O=>p.getRun(O)).filter(Boolean).filter(O=>O.id!==v);p.applyOperation(se(e,B.length?B:[{id:T(),type:"text",value:"",marks:{}}]))},[p,e,n]),S=f.useCallback(v=>{b()===v?(p.applyOperation(_(v)),h(null)):h(v)},[p,b,h]),C=f.useCallback(v=>{var le,fe,Y;if(g.current)return;const j=v.inputType??"",B=j.startsWith("delete"),O=j==="insertText"||j==="insertReplacementText";if(!B&&!O)return;const N=m.current;if(!N)return;const M=(le=v.getTargetRanges)==null?void 0:le.call(v),q=(fe=window.getSelection)==null?void 0:fe.call(window),V=(M==null?void 0:M[0])??(q!=null&&q.rangeCount?q.getRangeAt(0):null);if(!V||!N.contains(V.startContainer)||!N.contains(V.endContainer))return;const H=el(N,n,L=>p.getRun(L),V);if(!H)return;v.preventDefault();let{nextRuns:P,insertionIndex:W}=H,K=null,oe=!1;if(O&&v.data){const L={id:T(),type:"text",value:v.data,marks:{}};P=[...P.slice(0,W),L,...P.slice(W)],K=L.id,oe=!1}else W>0?(K=(Y=P[W-1])==null?void 0:Y.id,oe=!1):P.length>0&&(K=P[0].id,oe=!0);const Re=P.length?P:[{id:T(),type:"text",value:"",marks:{}}];p.applyOperation(se(e,Re));const Z=K??Re[0].id;oe?Dn(Z):X(Z)},[p,e,n]);f.useEffect(()=>{const v=m.current;if(v)return v.addEventListener("beforeinput",C),()=>v.removeEventListener("beforeinput",C)},[C]);const w=f.useCallback(v=>{if(!g.current){if(v.key==="Enter"&&t){v.preventDefault(),t(v);return}if(v.key==="Backspace"){const j=m.current,B=j&&at(j,n,p.getRun.bind(p));if(B){v.preventDefault(),R(B);return}const O=j&&st(j,n,p.getRun.bind(p),!0);if(O){v.preventDefault(),R(O);return}if(j&&nl(j)){if(!ae(p,n)){const M=it(p,e,"backward");if(M){v.preventDefault(),S(M);return}}v.preventDefault(),r&&r(v)}return}if(v.key==="Delete"){const j=m.current,B=j&&at(j,n,p.getRun.bind(p));if(B){v.preventDefault(),R(B);return}const O=j&&st(j,n,p.getRun.bind(p),!1);if(O){v.preventDefault(),R(O);return}if(j&&tl(j)){const N=it(p,e,"forward");if(N){v.preventDefault(),S(N);return}o&&o(v)}return}if(v.key==="ArrowUp"&&l){v.preventDefault(),l(v);return}if(v.key==="ArrowDown"&&s){v.preventDefault(),s(v);return}v.key==="Tab"&&(v.shiftKey&&i?(v.preventDefault(),i(v)):!v.shiftKey&&c&&(v.preventDefault(),c(v)))}},[t,r,o,l,s,c,i,R,S,n,e,p]);return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:m,className:"be-editable",contentEditable:!0,suppressContentEditableWarning:!0,onInput:k,onCompositionStart:y,onCompositionEnd:E,onKeyDown:w,children:n.map(v=>{const j=ol(x.current,p,v);return Le.createPortal(a.jsx(rl,{id:v,blockId:e,host:j,inlineRegistry:d,onValueSynced:I},v),j)})}),a.jsx(Jo,{containerRef:m,store:p})]})}function ll(e,n,t){const r=e.getBlock(n),o=r&&e.getBlock(r.parentId);if(!o)return null;const l=o.contentIds.indexOf(n),s=t==="up"?l-1:l+1;return s<0||s>=o.contentIds.length?null:o.contentIds[s]}function _t(e,n,t){let r=n;for(;;){const o=ll(e,r,t);if(!o)return null;const l=t==="up"?fn(e,o):Hn(e,o);if(l)return l;r=o}}function te(e,n,t){const r=_t(e,n,t);r&&X(r)}function Hn(e,n){var l;const t=e.getBlock(n);if(!t)return null;const r=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!r||r.length===0)return null;const o=r[0];return e.getRun(o)?o:Hn(e,o)}function re(e,n){const t=Hn(e,n);t&&X(t)}function fn(e,n){var l;const t=e.getBlock(n);if(!t)return null;const r=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!r||r.length===0)return null;const o=r[r.length-1];return e.getRun(o)?o:fn(e,o)}function ut(e,n){const t=fn(e,n);t&&X(t)}function sl(){var c,i;const e=(c=window.getSelection)==null?void 0:c.call(window);if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(n.collapsed||n.startContainer!==n.endContainer)return null;const t=n.startContainer,r=t.nodeType===1?t:t.parentElement,o=(i=r==null?void 0:r.closest)==null?void 0:i.call(r,"[data-run-id]");if(!o)return null;const l=o.closest("[data-block-id]");if(!l)return null;const s=t.textContent??"";return{runId:o.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),startOffset:me(s.slice(0,n.startOffset)).length,endOffset:me(s.slice(0,n.endOffset)).length}}function al(e,n){var c,i;if((e==null?void 0:e.nodeType)!==1||((c=e.getAttribute)==null?void 0:c.call(e,"contenteditable"))!=="true")return null;const t=e.childNodes;if(t.length===0)return null;const r=n>=t.length,o=t[r?t.length-1:Math.max(0,n)],l=(o==null?void 0:o.nodeType)===1?(i=o.dataset)==null?void 0:i.runId:void 0;if(!l)return null;const s=o.closest("[data-block-id]");return s?{runId:l,blockId:s.getAttribute("data-block-id"),offset:r?me(o.textContent??"").length:0}:null}function Ue(e,n){var c;const t=al(e,n);if(t)return t;let r=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;const o=(c=r==null?void 0:r.closest)==null?void 0:c.call(r,"[data-run-id]");if(!o)return null;const l=o.closest("[data-block-id]");if(!l)return null;let s=me((e.textContent??"").slice(0,n)).length;if(e===o){s=0;for(let i=0;i<n&&i<o.childNodes.length;i+=1)s+=me(o.childNodes[i].textContent??"").length}return{runId:o.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),offset:s}}function Xe(){var n;const e=(n=window.getSelection)==null?void 0:n.call(window);return!e||e.rangeCount===0||!e.isCollapsed?null:Ue(e.anchorNode,e.anchorOffset)}function Je(){var r;const e=(r=window.getSelection)==null?void 0:r.call(window);if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=Ue(e.anchorNode,e.anchorOffset),t=Ue(e.focusNode,e.focusOffset);return!n||!t||n.blockId!==t.blockId?null:{blockId:n.blockId,startRunId:n.runId,startOffset:n.offset,endRunId:t.runId,endOffset:t.offset}}function Fe(e){var d;const n=(d=window.getSelection)==null?void 0:d.call(window);if(!n||n.rangeCount===0||n.isCollapsed)return null;const t=Ue(n.anchorNode,n.anchorOffset),r=Ue(n.focusNode,n.focusOffset);if(!t||!r||t.blockId===r.blockId)return null;const o=e.getBlock(t.blockId),l=o&&e.getBlock(o.parentId);if(!l)return null;const s=l.contentIds,c=s.indexOf(t.blockId),i=s.indexOf(r.blockId);if(c===-1||i===-1)return null;const[u,p]=c<=i?[c,i]:[i,c];return{blockIds:s.slice(u,p+1),startBlockId:t.blockId,startRunId:t.runId,startOffset:t.offset,endBlockId:r.blockId,endRunId:r.runId,endOffset:r.offset}}function zn(e,n,t){const o=e.getBlock(n).parentId,s=e.getBlock(o).contentIds.indexOf(n)+1,{block:c,runs:i=[],subtreeBlocks:u=[]}=t(o);return e.applyOperation(G(c,o,s,{blocks:[c,...u],runs:i})),c.id}function ve(e,n,t){const r=zn(e,n,t);return re(e,r),r}function cl(e,n,t){const{block:r,runs:o=[],subtreeBlocks:l=[]}=t(n);return e.applyOperation(G(r,n,0,{blocks:[r,...l],runs:o})),re(e,r.id),r.id}function $t(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function il(e,n,t){const r=e.findIndex(u=>u.id===n);if(r===-1)return null;const o=e[r],l=e.slice(0,r),s=e.slice(r+1);if(o.type==="text"){const u=o.value??"",p=u.slice(0,t),d=u.slice(t);p&&d?(l.push({...o,value:p}),s.unshift({...o,id:T(),value:d})):d?s.unshift(o):l.push(o)}else t>0?l.push(o):s.unshift(o);const c=l.length?l:[{id:T(),type:"text",value:"",marks:{}}],i=s.length?s:[{id:T(),type:"text",value:"",marks:{}}];return{leftRuns:c,rightRuns:i}}function Me(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.parentId),s=l.contentIds.indexOf(n)+1;return Ht(e,n,t,r,{insertParentId:l.id,insertIndex:s,fallback:()=>ve(e,n,r)})}function Pt(e,n,t,r){return Ht(e,n,t,r,{insertParentId:n,insertIndex:0,fallback:()=>cl(e,n,r)})}function Ht(e,n,t,r,{insertParentId:o,insertIndex:l,fallback:s}){const c=Xe();if(!c||c.blockId!==n)return s();const i=t.map(x=>e.getRun(x)).filter(Boolean),u=il(i,c.runId,c.offset);if(!u)return s();const{leftRuns:p,rightRuns:d}=u,{block:b,runs:h=d,subtreeBlocks:m=[]}=r(o,d),g=p.length?p:[{id:T(),type:"text",value:"",marks:{}}];return $t(e,[se(n,g),G(b,o,l,{blocks:[b,...m],runs:h})]),re(e,b.id),b.id}function ul(e){var n;return((n=e==null?void 0:e.props)==null?void 0:n.titleRunIds)??(e==null?void 0:e.contentIds)??[]}function dl(e){var n,t;return!!((n=e==null?void 0:e.props)!=null&&n.titleRunIds)&&(((t=e.contentIds)==null?void 0:t.length)??0)>0}function pl(e,n,t){const o=e.getBlock(n).parentId,s=e.getBlock(o).contentIds.indexOf(n),{block:c,runs:i=[],subtreeBlocks:u=[]}=t(o);return $t(e,[_(n),G(c,o,s,{blocks:[c,...u],runs:i})]),re(e,c.id),c.id}function ne(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,r)+c.slice(o),u=e.getBlock(n),p=ul(u);return p.length===1&&p[0]===t&&i===""&&!dl(u)?pl(e,n,l):(e.applyOperation(J(t,{value:i})),ve(e,n,l))}function $(e,n={}){return function(r,o){const l=T(),s=o!=null&&o.length?o:[{id:T(),type:"text",value:"",marks:{}}];return{block:{id:l,type:e,parentId:r,contentIds:s.map(c=>c.id),props:n},runs:s}}}function Ae(e){const n=e.getRootId(),t=e.getBlock(n);if(!t||t.contentIds.length>0)return null;const{block:r,runs:o}=$("paragraph")(n);return e.applyOperation(G(r,n,0,{blocks:[r],runs:o})),r.id}const fl=new Set(["callout"]),dt=new Set(["paragraph","heading","blockquote"]);function zt(e,n){return e===n||dt.has(e)&&dt.has(n)}function Qe(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.contentIds.length===0||t.contentIds.length===1&&bl(e,t.contentIds[0]);if(o<=0){if(!l)return null;if(r.contentIds.length>1)return Te(e,[_(n)]),e.getBlock(r.id).contentIds[0];if(fl.has(r.type))return ml(e,r);if(t.type==="paragraph")return null;const{block:u,runs:p}=$("paragraph")(r.id);return Te(e,[G(u,r.id,o,{blocks:[u],runs:p}),_(n)]),u.id}const s=r.contentIds[o-1],c=e.getBlock(s);if(l)return Te(e,[_(n)]),s;if(Ve(e,c))return Te(e,[_(s)]),n;if(!c||!zt(c.type,t.type))return null;const i=[...c.contentIds,...t.contentIds];return Te(e,[je(s,i),je(n,[]),_(n)]),s}function bl(e,n){const t=e.getRun(n);return!t||(t.value??"")===""}function ml(e,n){const t=e.getBlock(n.parentId);if(!t)return null;const r=t.contentIds.indexOf(n.id),o=r>0?t.contentIds[r-1]:null,l=r!==-1&&r<t.contentIds.length-1?t.contentIds[r+1]:null;Te(e,[_(n.id)]);const s=Ae(e);return o??l??s}function Te(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function De(e,n,t,r){if(!n||n===t)return;const o=fn(e,n);if(o){X(o);return}r(n),requestAnimationFrame(()=>{var l;(l=document.querySelector(`[data-block-id="${n}"]`))==null||l.focus()})}function hl(e,n,t,r,o){const l=e.getBlock(n),c=e.getBlock(l.parentId).contentIds.indexOf(n),i="titleRunIds"in r,u="titleRunIds"in(l.props??{}),p={id:T(),type:t,parentId:l.parentId,contentIds:[],props:r},d=i?z(p.id,{titleRunIds:o}):je(p.id,o),b=u?z(n,{titleRunIds:[]}):je(n,[]);return{newBlockId:p.id,ops:[G(p,l.parentId,c,{blocks:[p],runs:[]}),d,b,_(n)]}}function gl(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}const xl=[{re:/^(#{1,3})[  ]$/,type:"heading",props:e=>({level:e[1].length})},{re:/^[-*][  ]$/,type:"listItem",props:()=>({ordered:!1,titleRunIds:[]})},{re:/^\d+\.[  ]$/,type:"listItem",props:()=>({ordered:!0,titleRunIds:[]})},{re:/^\[\][  ]$/,type:"listItem",props:()=>({ordered:!1,checked:!1,titleRunIds:[]})},{re:/^>[  ]$/,type:"blockquote",props:()=>({})},{re:/^```$/,type:"code",props:()=>({language:"plaintext"})}];function kl(e,n,t){if(t.length!==1||t[0].type!=="text")return!1;const r=t[0].value??"";for(const o of xl){const l=o.re.exec(r);if(!l)continue;const s=r.slice(l[0].length),{ops:c}=hl(e,n,o.type,o.props(l),[t[0].id]);return gl(e,[J(t[0].id,{value:s}),...c]),Dn(t[0].id),!0}return!1}const yl=new Set(["callout","toggleHeading"]);function vl({id:e}){const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),o=f.useCallback(()=>{const d=n.getBlock(t==null?void 0:t.parentId),b=ae(n,(t==null?void 0:t.contentIds)??[]),h=!!d&&d.contentIds[d.contentIds.length-1]===e;if(b&&h&&yl.has(d==null?void 0:d.type)){ve(n,d.id,$("paragraph"));return}Me(n,e,(t==null?void 0:t.contentIds)??[],$("paragraph"))},[n,e,t]),l=f.useCallback(()=>{var g,x;const d=n.getBlock(t==null?void 0:t.parentId),b=ae(n,(t==null?void 0:t.contentIds)??[]),h=((g=d==null?void 0:d.contentIds)==null?void 0:g.length)===1&&d.contentIds[0]===e;if(b&&h&&(d==null?void 0:d.type)==="toggleHeading"){const k=((x=d.props)==null?void 0:x.titleRunIds)??[],I=k[k.length-1];I&&X(I);return}const m=Qe(n,e);De(n,m,e,r)},[n,e,t,r]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=f.useCallback(d=>kl(n,e,d),[n,e]),u=ee("be-paragraph",t);if(!t)return null;const p=ae(n,t.contentIds);return a.jsx("div",{className:u,"data-block-id":e,"data-empty":p?"":void 0,"data-placeholder":"Type '/' for commands",children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c,onAutoformat:i})})}function Se(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ce(e){return Se(e).replace(/"/g,"&quot;")}function Ie(e,n){var o,l;if(!e)return"";if(e.type!=="text"){const s=(o=n==null?void 0:n.inlineRegistry)==null?void 0:o.get(e.type);return s?s.toHTML(e,n):Se(e.value??"")}const t=e.marks??{};let r=Se(e.value??"");if(t.code&&(r=`<code>${r}</code>`),t.bold&&(r=`<strong>${r}</strong>`),t.italic&&(r=`<em>${r}</em>`),t.underline&&(r=`<u>${r}</u>`),t.strike&&(r=`<s>${r}</s>`),t.subscript&&(r=`<sub>${r}</sub>`),t.superscript&&(r=`<sup>${r}</sup>`),t.color&&(r=`<span style="color:${ce(t.color)}">${r}</span>`),t.highlight&&(r=`<span style="background-color:${ce(t.highlight)}">${r}</span>`),(l=t.link)!=null&&l.href){const s=t.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";r=`<a href="${ce(t.link.href)}"${s}>${r}</a>`}return r}function we(e,n){var t;if(!e)return"";if(e.type!=="text"){const r=(t=n==null?void 0:n.inlineRegistry)==null?void 0:t.get(e.type);return r?r.toPlainText(e,n):e.value??""}return e.value??""}const Il={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function de(e,n,t={}){const r=[],o=(l,s)=>{var u,p;if(l.nodeType===3){const d=l.textContent;d&&r.push({id:T(),type:"text",value:d,marks:{...s}});return}if(l.nodeType!==1)return;if(n!=null&&n.inlineRegistry)for(const d of n.inlineRegistry.listHtmlMatchers()){const b=d.fromHTML(l,n);if(b){r.push(b);return}}let c=s;const i=Il[l.tagName];i&&(c={...c,[i]:!0}),l.tagName==="A"&&l.getAttribute("href")&&(c={...c,link:{href:l.getAttribute("href"),target:l.getAttribute("target")==="_blank"?"_blank":"_self"}}),(u=l.style)!=null&&u.color&&(c={...c,color:l.style.color}),(p=l.style)!=null&&p.backgroundColor&&(c={...c,highlight:l.style.backgroundColor});for(const d of l.childNodes)o(d,c)};return o(e,t),r.length?r:[{id:T(),type:"text",value:"",marks:{}}]}function wl(e,n){return`<p>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>Ie(r,n)).join("")}</p>`}function Cl(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function Bl(e,n){if(e.tagName!=="P")return null;const t=de(e,n);return{block:{id:T(),type:"paragraph",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}const Ut={component:vl,isLeaf:!0,defaultProps:{},toHTML:wl,toPlainText:Cl,fromHTML:Bl,slashCommand:{label:"Text",icon:Mo,keywords:["paragraph","text","p"],run:(e,n)=>ne(e,n,$("paragraph"))}};function Rl({id:e}){var b;const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),o=f.useCallback(()=>{Me(n,e,(t==null?void 0:t.contentIds)??[],$("paragraph"))},[n,e,t]),l=f.useCallback(()=>{const h=Qe(n,e);De(n,h,e,r)},[n,e,r]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=((b=t==null?void 0:t.props)==null?void 0:b.level)??3,u=ee(`be-heading be-heading-${i}`,t);if(!t)return null;const p=`h${i}`,d=ae(n,t.contentIds);return a.jsx(p,{className:u,"data-block-id":e,"data-empty":d?"":void 0,"data-placeholder":`Heading ${i}`,children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})}const yn={1:Ao,2:Do,3:_o},Tl={H1:1,H2:2,H3:3};function jl(e,n){var o;const t=((o=e.props)==null?void 0:o.level)??3,r=e.contentIds.map(l=>n.store.getRun(l));return`<h${t}>${r.map(l=>Ie(l,n)).join("")}</h${t}>`}function Sl(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function El(e,n){const t=Tl[e.tagName];if(!t)return null;const r=de(e,n);return{block:{id:T(),type:"heading",parentId:null,contentIds:r.map(l=>l.id),props:{level:t}},runs:r}}const Ft={component:Rl,isLeaf:!0,defaultProps:{level:3},toHTML:jl,toPlainText:Sl,fromHTML:El,slashCommands:[{label:"Heading 1",icon:yn[1],keywords:["heading","h1","title"],run:(e,n)=>ne(e,n,$("heading",{level:1}))},{label:"Heading 2",icon:yn[2],keywords:["heading","h2","subtitle"],run:(e,n)=>ne(e,n,$("heading",{level:2}))},{label:"Heading 3",icon:yn[3],keywords:["heading","h3","title"],run:(e,n)=>ne(e,n,$("heading",{level:3}))}]},Ol=[];function Un(e){const n=D(),t=f.useCallback(o=>n.subscribe(e,o),[n,e]),r=f.useCallback(()=>{const o=n.getBlock(e);return o?o.contentIds:Ol},[n,e]);return f.useSyncExternalStore(t,r)}class Kt extends f.Component{constructor(){super(...arguments);tt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){var o,l;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",t,r),(l=(o=this.props).onError)==null||l.call(o,t,r),queueMicrotask(()=>this.setState(s=>({hasError:!1,nonce:s.nonce+1})))}render(){return this.state.hasError?null:a.jsx(f.Fragment,{children:this.props.children},this.state.nonce)}}const Fn=f.memo(function({id:n}){const t=Q(n),r=Ne();if(!t)return null;const o=r.get(t.type);if(!o)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${t.type}" (id: ${n})`),null;const l=o.component;return a.jsx(Kt,{children:a.jsx(l,{id:n})})});function bn(e,n,t){f.useEffect(()=>{if(!n)return;const r=Array.isArray(e)?e:[e],o=s=>{r.some(i=>i.current&&i.current.contains(s.target))||t()},l=s=>{s.key==="Escape"&&t()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",l)}},[n,t,e])}function Ze(e,n,t,r){const o={store:e,registry:n,inlineRegistry:r};return{html:Ll(e,n,t,o),text:t.map(l=>{const s=e.getBlock(l);return n.get(s.type).toPlainText(s,o)}).join(`
1899
- `),json:JSON.stringify({version:1,blocks:t.map(l=>Kn(e,l))})}}function Ll(e,n,t,r){let o="",l=0;for(;l<t.length;){const s=e.getBlock(t[l]);if(s.type==="listItem"){const c=!!s.props.ordered;let i="",u=l;for(;u<t.length;){const d=e.getBlock(t[u]);if(d.type!=="listItem"||!!d.props.ordered!==c)break;i+=n.get("listItem").toHTML(d,r),u+=1}const p=c?"ol":"ul";o+=`<${p}>${i}</${p}>`,l=u}else if(s.type==="blockquote"){let c="",i=l;for(;i<t.length;){const u=e.getBlock(t[i]);if(u.type!=="blockquote")break;c+=n.get("blockquote").toHTML(u,r),i+=1}o+=`<blockquote>${c}</blockquote>`,l=i}else o+=n.get(s.type).toHTML(s,r),l+=1}return o}function Kn(e,n){const t=[],r=[],o=l=>{var i;const s=e.getRun(l);if(s){r.push(s);return}const c=e.getBlock(l);if(c){t.push(c);for(const u of c.contentIds)o(u);for(const u of((i=c.props)==null?void 0:i.titleRunIds)??[])o(u)}};return o(n),{rootId:n,blocks:t,runs:r}}function qn({rootId:e,blocks:n,runs:t}){const r=new Map;for(const i of n)r.set(i.id,T());for(const i of t)r.set(i.id,T());const o=i=>r.get(i)??i,l=n.map(i=>{var u;return{...i,id:o(i.id),parentId:i.parentId?o(i.parentId):i.parentId,contentIds:i.contentIds.map(o),props:{...i.props,...(u=i.props)!=null&&u.titleRunIds?{titleRunIds:i.props.titleRunIds.map(o)}:{}}}}),s=t.map(i=>({...i,id:o(i.id)})),c=o(e);return{block:l.find(i=>i.id===c),runs:s,subtreeBlocks:l.filter(i=>i.id!==c)}}function qt(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=Kn(e,n),{block:s,runs:c,subtreeBlocks:i}=qn(l);return e.applyOperation(G(s,r.id,o+1,{blocks:[s,...i],runs:c})),re(e,s.id),s.id}function Wt(e,n){const t=e.getBlock(n),r=t&&e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n);return o<=0?!1:(e.applyOperation(ke(n,r.id,o-1)),!0)}function Vt(e,n){const t=e.getBlock(n),r=t&&e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n);return o===-1||o>=r.contentIds.length-1?!1:(e.applyOperation(ke(n,r.id,o+1)),!0)}function Wn(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=o>0?r.contentIds[o-1]:null,s=o!==-1&&o<r.contentIds.length-1?r.contentIds[o+1]:null;e.applyOperation(_(n));const c=Ae(e),i=l??s??c;return i&&re(e,i),i??null}function Yt({id:e}){var R;const n=D(),t=Q(e),[r,o]=f.useState(!1),[l,s]=f.useState(null),c=f.useRef(null),i=f.useRef(null),u=f.useMemo(()=>[c,i],[]),[p]=We(),d=p.includes(e),b=f.useCallback(()=>o(!1),[]);bn(u,r,b);const h=f.useCallback(()=>{var S;s(((S=c.current)==null?void 0:S.getBoundingClientRect())??null),o(!0)},[]),m=f.useCallback(()=>{ve(n,e,$("paragraph"))},[n,e]),g=f.useCallback(()=>{qt(n,e),b()},[n,e,b]),x=f.useCallback(()=>{Wt(n,e),b()},[n,e,b]),k=f.useCallback(()=>{Vt(n,e),b()},[n,e,b]),I=f.useCallback(()=>{Wn(n,e),b()},[n,e,b]),y=!!((R=t==null?void 0:t.props)!=null&&R.hidden),E=f.useCallback(()=>{n.applyOperation(z(e,{hidden:!y})),b()},[n,e,y,b]);return t?a.jsxs("div",{className:`be-block-row${y?" be-block-row-hidden":""}${d?" be-block-row-range-selected":""}`,"data-block-row-id":e,children:[a.jsxs("div",{className:`be-block-gutter${r?" be-block-gutter-active":""}`,contentEditable:!1,children:[a.jsx("button",{type:"button",className:"be-block-gutter-btn",onClick:m,"aria-label":"Add block below",children:a.jsx(St,{size:16})}),a.jsx("button",{ref:c,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":r,onClick:()=>r?b():h(),children:a.jsx(Lo,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(Fn,{id:e})}),r&&l&&Le.createPortal(a.jsxs("div",{ref:i,role:"menu","aria-label":"Block options",className:"be-block-gutter-menu",style:{position:"fixed",top:l.bottom+4,left:l.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:g,children:[a.jsx(Et,{size:15})," Duplicate"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:x,children:[a.jsx(Ot,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:k,children:[a.jsx(Lt,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:E,children:[y?a.jsx(At,{size:15}):a.jsx(Dt,{size:15}),y?"Show in preview":"Hide in preview"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:I,children:[a.jsx($n,{size:15})," Delete"]})]}),document.body)]}):null}function Ce({parentId:e,isTopLevel:n=!1}){const t=Un(e),r=D(),[o]=Mn(),l=o?t.filter(s=>{var c,i;return!((i=(c=r.getBlock(s))==null?void 0:c.props)!=null&&i.hidden)}):t;return n&&!o?l.map(s=>a.jsx(Yt,{id:s},s)):l.map(s=>a.jsx(Fn,{id:s},s))}const Nl=97,Ml=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function Al(e){let n="";for(;e>0;)e-=1,n=String.fromCharCode(Nl+e%26)+n,e=Math.floor(e/26);return n}function Dl(e){let n="",t=e;for(const[r,o]of Ml)for(;t>=r;)n+=o,t-=r;return n}function _l(e){var n,t;return(e==null?void 0:e.type)==="listItem"&&((n=e.props)==null?void 0:n.checked)===void 0&&((t=e.props)==null?void 0:t.collapsed)===void 0}function pt(e,n){let t=0,r=n;for(;r;){const o=e.getBlock(r.parentId);if(!o||o.type!=="listItem")break;t+=1,r=o}return t}function $l(e,n,t){const r=t.indexOf(n.id);let o=1;for(let l=r-1;l>=0;l-=1){const s=e.getBlock(t[l]);if(!_l(s)||!s.props.ordered)break;o+=1}return o}function Pl(e,n){const t=(e%3+3)%3;return t===0?`${n}.`:t===1?`${Al(n)}.`:`${Dl(n)}.`}const Hl=["•","◦","▪"];function zl(e){const n=(e%3+3)%3;return Hl[n]}function He({ordered:e=!1,checked:n,collapsed:t}={}){return function(o,l){const s=T(),c=l!=null&&l.length?l:[{id:T(),type:"text",value:"",marks:{}}],i={ordered:e,titleRunIds:c.map(b=>b.id)};n!==void 0&&(i.checked=n);let u=[],p=[],d=c;if(t!==void 0){i.collapsed=t;const{block:b,runs:h}=$("paragraph")(s);u=[b.id],p=[b],d=[...c,...h]}return{block:{id:s,type:"listItem",parentId:o,contentIds:u,props:i},runs:d,subtreeBlocks:p}}}function Ul(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=o>0?r.contentIds[o-1]:null,s=l?e.getBlock(l):null;if(!s||s.type!=="listItem"){te(e,n,"down");return}e.applyOperation(ke(n,l,s.contentIds.length)),re(e,n)}function wn(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId);if(!r||r.type!=="listItem")return;const o=r.parentId,s=e.getBlock(o).contentIds.indexOf(r.id);e.applyOperation(ke(n,o,s+1)),re(e,n)}function $e(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Gt(e,n){var t;return n.length===0||n.length===1&&(((t=e.getRun(n[0]))==null?void 0:t.value)??"")===""}function Fl(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const r=e.getBlock(t[0]);return!!r&&r.type==="paragraph"&&ae(e,r.contentIds)}function Kl(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.props.titleRunIds??[],c=Gt(e,l)&&Fl(e,t);if(o>0){const p=r.contentIds[o-1],d=e.getBlock(p);if(c)return $e(e,[_(n)]),{focusBlockId:p,needsRefocus:!0};if(Ve(e,d))return $e(e,[_(p)]),{focusBlockId:n,needsRefocus:!1};if((d==null?void 0:d.type)==="listItem"&&t.contentIds.length===0){const b=[...d.props.titleRunIds??[],...l];return $e(e,[z(p,{titleRunIds:b}),z(n,{titleRunIds:[]}),_(n)]),{focusBlockId:p,needsRefocus:!0}}return null}if(r.type==="listItem")return wn(e,n),{focusBlockId:n,needsRefocus:!0};if(!c)return null;if(r.contentIds.length>1)return $e(e,[_(n)]),{focusBlockId:e.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:i,runs:u}=$("paragraph")(r.id);return $e(e,[G(i,r.id,o,{blocks:[i],runs:u}),_(n)]),{focusBlockId:i.id,needsRefocus:!0}}function ql(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Wl(e,n){const r=e.getBlock(n).parentId,l=e.getBlock(r).contentIds.indexOf(n),{block:s,runs:c}=$("paragraph")(r);return ql(e,[G(s,r,l,{blocks:[s],runs:c}),z(n,{titleRunIds:[]}),_(n)]),re(e,s.id),s.id}function Vl(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Yl({id:e}){var S,C;const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),o=Un(t==null?void 0:t.parentId),l=f.useCallback(()=>{var q,V,H,P,W;const w=((q=t==null?void 0:t.props)==null?void 0:q.titleRunIds)??[],v=n.getBlock(t==null?void 0:t.parentId),j=Gt(n,w);if(j&&(v==null?void 0:v.type)==="listItem"){wn(n,e);return}const B=(((V=t==null?void 0:t.contentIds)==null?void 0:V.length)??0)>0;if(j&&(v==null?void 0:v.type)!=="listItem"&&!B){Wl(n,e);return}const O=((H=t==null?void 0:t.props)==null?void 0:H.checked)!==void 0,N=((P=t==null?void 0:t.props)==null?void 0:P.collapsed)!==void 0,M=He({ordered:(W=t==null?void 0:t.props)==null?void 0:W.ordered,checked:O?!1:void 0,collapsed:N?!1:void 0});B&&!N?Pt(n,e,w,M):Me(n,e,w,M)},[n,e,t]),s=f.useCallback(()=>Ul(n,e),[n,e]),c=f.useCallback(()=>wn(n,e),[n,e]),i=f.useCallback(()=>{const w=Kl(n,e);!w||!w.needsRefocus||De(n,w.focusBlockId,e,r)},[n,e,r]),u=f.useCallback(()=>te(n,e,"up"),[n,e]),p=f.useCallback(()=>te(n,e,"down"),[n,e]),d=f.useCallback(()=>{var w;n.applyOperation(z(e,{checked:!((w=t==null?void 0:t.props)!=null&&w.checked)}))},[n,e,(S=t==null?void 0:t.props)==null?void 0:S.checked]),b=f.useCallback(()=>{var v,j;if(!((((v=t==null?void 0:t.contentIds)==null?void 0:v.length)??0)>0)){const{block:B,runs:O}=$("paragraph")(e);Vl(n,[G(B,e,0,{blocks:[B],runs:O}),z(e,{collapsed:!1})]),X(B.contentIds[0]);return}n.applyOperation(z(e,{collapsed:!((j=t==null?void 0:t.props)!=null&&j.collapsed)}))},[n,e,t==null?void 0:t.contentIds,(C=t==null?void 0:t.props)==null?void 0:C.collapsed]),h=ee("be-list-item",t);if(!t)return null;const{ordered:m,checked:g,collapsed:x,titleRunIds:k=[]}=t.props,I=g!==void 0,y=!I&&x!==void 0,E=t.contentIds.length>0,R=k.map(w=>n.getRun(w)).filter(w=>(w==null?void 0:w.type)==="text").map(w=>w.value).join("").trim();return a.jsxs("div",{className:h,"data-block-id":e,children:[a.jsxs("div",{className:"be-list-item-row",children:[I?a.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!g,onChange:d,"aria-label":R||"To-do item"}):y?a.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:b,"aria-expanded":!x,"aria-label":E?x?"Expand toggle":"Collapse toggle":"Add content to toggle",children:x?a.jsx(pn,{}):a.jsx(_n,{})}):a.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:m?Pl(pt(n,t),$l(n,t,o)):zl(pt(n,t))}),a.jsx("div",{className:"be-list-item-title","data-empty":ae(n,k)?"":void 0,"data-placeholder":I?"To-do":y?"Toggle":"List item",style:g?{textDecoration:"line-through",opacity:.6}:void 0,children:a.jsx(xe,{blockId:e,runIds:k,onEnter:l,onTab:s,onShiftTab:c,onBackspaceAtStart:i,onArrowUp:u,onArrowDown:p})})]}),(!y||!x)&&a.jsx("div",{className:"be-list-item-children",children:a.jsx(Ce,{parentId:e})})]})}function Gl(e,n){const{titleRunIds:t=[],ordered:r}=e.props,o=t.map(c=>Ie(n.store.getRun(c),n)).join(""),l=e.contentIds.map(c=>n.registry.get(n.store.getBlock(c).type).toHTML(n.store.getBlock(c),n)).join(""),s=l?`<${r?"ol":"ul"}>${l}</${r?"ol":"ul"}>`:"";return`<li>${o}${s}</li>`}function Xl(e,n){const{titleRunIds:t=[]}=e.props;return t.map(r=>we(n.store.getRun(r),n)).join("")}function Xt(e,n){const t=[],r=[];for(const d of e.childNodes)d.nodeType===1&&(d.tagName==="UL"||d.tagName==="OL")?r.push(d):t.push(d);const o=e.ownerDocument.createElement("span");for(const d of t)o.appendChild(d.cloneNode(!0));const l=de(o,n),s=T(),c=[...l],i=[],u=[];for(const d of r){const b=d.tagName==="OL";for(const h of d.children){if(h.tagName!=="LI")continue;const m=Xt(h,n);m.block.parentId=s,m.block.props.ordered=b,i.push(m.block,...m.childBlocks),c.push(...m.runs),u.push(m.block.id)}}return{block:{id:s,type:"listItem",parentId:null,contentIds:u,props:{ordered:!1,titleRunIds:l.map(d=>d.id)}},runs:c,childBlocks:i}}function Jl(e,n){if(e.tagName!=="LI")return null;const{block:t,runs:r,childBlocks:o}=Xt(e,n);return{block:t,runs:r,subtreeBlocks:o}}const Jt={component:Yl,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:Gl,toPlainText:Xl,fromHTML:Jl,slashCommands:[{label:"Bulleted list",icon:Ko,keywords:["list","bullet","ul"],run:(e,n)=>ne(e,n,He({ordered:!1}))},{label:"Numbered list",icon:qo,keywords:["list","number","ordered","ol"],run:(e,n)=>ne(e,n,He({ordered:!0}))},{label:"To-do list",icon:Mt,keywords:["todo","checkbox","task","checklist"],run:(e,n)=>ne(e,n,He({ordered:!1,checked:!1}))},{label:"Toggle list",icon:pn,keywords:["toggle","collapse","expand","dropdown","accordion"],run:(e,n)=>ne(e,n,He({ordered:!1,collapsed:!1}))}]},Qt=["text","date","checkbox","select"],mn="text",hn=160,an=80;function Ql(e){return`Column ${e+1}`}function Vn(e){return Array.from({length:e},(n,t)=>({id:T(),label:Ql(t),type:mn,width:hn}))}function ie(e,n){var r;const t=(r=e.props)==null?void 0:r.columns;return!Array.isArray(t)||t.length!==n?Vn(n):t.map(o=>{const l=o.type??mn,s=o.width??hn;return l===o.type&&s===o.width?o:{...o,type:l,width:s}})}function Zt(e){switch(e){case"date":return{id:T(),type:"date",value:"",marks:{},data:{isoDate:""}};case"checkbox":return{id:T(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}};case"select":return{id:T(),type:"tableSelect",value:"",marks:{},data:{selectedValue:"",selectedLabel:""}};default:return{id:T(),type:"text",value:"",marks:{}}}}function gn(e,n){const t=Zt(n==null?void 0:n.type);return{block:{id:T(),type:"tableCell",parentId:e,contentIds:[t.id],props:{}},run:t}}function er(e,n,t){if(e.type===n)return e;let r;if(e.type==="text")r=e.value??"";else{const o=t==null?void 0:t.get(e.type);r=o!=null&&o.toPlainText?o.toPlainText(e):""}if(n==="date"){const o=r?new Date(r):null,l=o&&!Number.isNaN(o.getTime())?o.toISOString().slice(0,10):"";return{id:T(),type:"date",value:"",marks:{},data:{isoDate:l}}}return n==="checkbox"?{id:T(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:r}}:{id:T(),type:"text",value:r,marks:{}}}function Be(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function nr(e,n){const r=e.getBlock(n.parentId).contentIds.indexOf(n.id);Be(e,[_(n.id)]);const o=Ae(e);if(o)return re(e,o),null;const l=e.getBlock(n.parentId),s=l.contentIds[r]??l.contentIds[r-1];return s&&re(e,s),null}function tr(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=ie(r,t.contentIds.length),s=T(),c=[],i=[],u=[];for(const d of l){const b=gn(s,d);c.push(b.block),i.push(b.run),u.push(b.block.id)}const p={id:s,type:"tableRow",parentId:r.id,contentIds:u,props:{}};return e.applyOperation(G(p,r.id,o+1,{blocks:[p,...c],runs:i})),re(e,s),s}function rr(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId);if(r.contentIds.length<=1)return nr(e,r);const o=r.contentIds.indexOf(n);Be(e,[_(n)]);const l=e.getBlock(r.id),s=Math.min(o,l.contentIds.length-1),c=l.contentIds[s];return c&&re(e,c),c??null}function Cn(e,n,t){const r=e.getBlock(n),o=ie(r,r.contentIds[0]?e.getBlock(r.contentIds[0]).contentIds.length:0),l={id:T(),label:"New Column",type:mn,width:hn},s=[];let c=null;for(const u of r.contentIds){const p=gn(u,l);c===null&&(c=p.block.id),s.push(G(p.block,u,t+1,{blocks:[p.block],runs:[p.run]}))}const i=[...o];return i.splice(t+1,0,l),s.push(z(n,{columns:i})),Be(e,s),c&&re(e,c),c}function or(e,n,t){const r=e.getBlock(n),o=e.getBlock(r.contentIds[0]);if(!o||o.contentIds.length<=1)return nr(e,r);const l=ie(r,o.contentIds.length),s=r.contentIds.map(d=>{const b=e.getBlock(d);return _(b.contentIds[t])}),c=l.filter((d,b)=>b!==t);s.push(z(n,{columns:c})),Be(e,s);const i=e.getBlock(r.contentIds[0]),u=Math.min(t,i.contentIds.length-1),p=i.contentIds[u];return p&&re(e,p),p??null}function lr(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),s=ie(o,l?l.contentIds.length:0);if(!s[t])return;const c=[...s];c[t]={...s[t],width:Math.max(an,Math.round(r))},e.applyOperation(z(n,{columns:c}))}function sr(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),c=[...ie(o,l?l.contentIds.length:0)];c[t]&&(c[t]={...c[t],label:r},e.applyOperation(z(n,{columns:c})))}function Yn(e,n,t){return n.contentIds.map(r=>{const l=e.getBlock(r).contentIds[t],s=e.getBlock(l);return{cellId:l,run:e.getRun(s.contentIds[0])}})}function ft(e,n){if(!e)return"";if(e.type==="text")return e.value??"";const t=n==null?void 0:n.get(e.type);return t!=null&&t.toPlainText?t.toPlainText(e):""}function Zl(e,n,t,r){const o=Yn(e,n,t),l=[],s=new Map;for(const{run:i}of o){const u=ft(i,r).trim();if(!u||s.has(u))continue;const p={value:T(),label:u};s.set(u,p),l.push(p)}const c=o.map(({cellId:i,run:u})=>{const p=ft(u,r).trim(),d=s.get(p);return{cellId:i,run:{id:T(),type:"tableSelect",value:"",marks:{},data:{selectedValue:(d==null?void 0:d.value)??"",selectedLabel:(d==null?void 0:d.label)??""}}}});return{options:l,newRuns:c}}function ar(e,n,t,r,o){const l=e.getBlock(n),s=e.getBlock(l.contentIds[0]),c=ie(l,s?s.contentIds.length:0),i=c[t];if(!i||i.type===r)return;const u=[...c];if(r==="select"){const{options:d,newRuns:b}=Zl(e,l,t,o);u[t]={...i,type:r,options:d};const h=[z(n,{columns:u})];for(const{cellId:m,run:g}of b)h.push(se(m,[g]));Be(e,h);return}u[t]={...i,type:r};const p=[z(n,{columns:u})];for(const{cellId:d,run:b}of Yn(e,l,t)){if(!b)continue;const h=er(b,r,o);p.push(se(d,[h]))}Be(e,p)}function ln(e,n,t,r){var d,b;const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),s=ie(o,l?l.contentIds.length:0),c=s[t];if(!c)return;const i=[...s];i[t]={...c,options:r};const u=[z(n,{columns:i})],p=new Map(r.map(h=>[h.value,h]));for(const{run:h}of Yn(e,o,t)){if(!h||h.type!=="tableSelect")continue;const m=((d=h.data)==null?void 0:d.selectedValue)??"",g=p.get(m),x=g?m:"",k=g?g.label:"";(x!==m||k!==(((b=h.data)==null?void 0:b.selectedLabel)??""))&&u.push(J(h.id,{data:{selectedValue:x,selectedLabel:k}}))}Be(e,u)}function es(e,n){return n?e.label.toLowerCase().includes(n.toLowerCase()):!0}function _e({value:e,options:n,onChange:t,placeholder:r="Select…",ariaLabel:o,className:l="",variant:s="default",selectedLabel:c,selectedColor:i,onManageOptions:u,manageOptionsLabel:p="Manage options…",mention:d=!1}){var fe,Y;const[b,h]=f.useState(!1),[m,g]=f.useState(""),[x,k]=f.useState(0),[I,y]=f.useState(null),[E,R]=f.useState([]),[S,C]=f.useState(!1),[w,v]=f.useState(!1),j=f.useRef(null),B=f.useRef(null),O=f.useRef(null),N=f.useRef(null),M=f.useRef(null),q=f.useMemo(()=>[j,O],[]),V=s==="tag",H=typeof n=="function",P=H?void 0:n.find(L=>L.value===e),W=e?P??(c?{label:c,color:i}:void 0):void 0,K=f.useMemo(()=>H?E:n.filter(L=>es(L,m)),[H,E,n,m]);f.useEffect(()=>{if(!H||!b)return;let L=!1;C(!0),v(!1);const F=setTimeout(()=>{Promise.resolve(n(m)).then(ue=>{L||(R(ue??[]),C(!1))}).catch(()=>{L||(R([]),C(!1),v(!0))})},250);return()=>{L=!0,clearTimeout(F)}},[H,b,n,m]);const oe=f.useCallback(()=>h(!1),[]);bn(q,b,oe);const Re=f.useCallback(()=>{var L;y(((L=B.current)==null?void 0:L.getBoundingClientRect())??null),g(""),k(0),h(!0)},[]);f.useEffect(()=>{var L;b&&((L=N.current)==null||L.focus())},[b]),f.useEffect(()=>{var L,F;(F=(L=M.current)==null?void 0:L.scrollIntoView)==null||F.call(L,{block:"nearest"})},[x]);const Z=f.useCallback(L=>{var F;t(L.value,L),oe(),(F=B.current)==null||F.focus()},[t,oe]),le=f.useCallback(L=>{var F;L.key==="ArrowDown"?(L.preventDefault(),k(ue=>Math.min(ue+1,Math.max(K.length-1,0)))):L.key==="ArrowUp"?(L.preventDefault(),k(ue=>Math.max(ue-1,0))):L.key==="Enter"?(L.preventDefault(),K[x]&&Z(K[x])):L.key==="Escape"&&(L.preventDefault(),oe(),(F=B.current)==null||F.focus())},[K,x,Z,oe]);return a.jsxs("span",{className:`be-select ${l}`.trim(),ref:j,children:[a.jsx("button",{type:"button",ref:B,className:`be-select-trigger${V?" be-select-trigger-tag":""}${d?" be-select-trigger-mention":""}`,"aria-haspopup":"listbox","aria-expanded":b,"aria-label":o,onClick:()=>b?oe():Re(),children:V?W?a.jsx("span",{className:`be-select-tag${d?" be-select-tag-mention":""}`,style:d?void 0:{background:(fe=W.color)==null?void 0:fe.bg,color:(Y=W.color)==null?void 0:Y.text},children:d?`@${W.label}`:W.label}):a.jsx("span",{className:"be-select-value be-select-value-placeholder",children:r}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"be-select-value",children:W?W.label:r}),a.jsx(_n,{size:14,className:"be-select-chevron"})]})}),b&&I&&Le.createPortal(a.jsxs("div",{ref:O,className:"be-select-popover",style:{position:"fixed",top:I.bottom+4,left:I.left,minWidth:I.width},children:[a.jsx("input",{ref:N,type:"text",className:"be-select-search",value:m,onChange:L=>{g(L.target.value),k(0)},onKeyDown:le,placeholder:"Search…","aria-label":o?`Search ${o}`:"Search options"}),a.jsxs("div",{className:"be-select-options",role:"listbox",children:[H&&S&&a.jsx("div",{className:"be-select-empty",children:"Loading…"}),H&&!S&&w&&a.jsx("div",{className:"be-select-empty be-select-error",children:"Couldn't load options"}),!S&&!w&&K.length===0&&a.jsx("div",{className:"be-select-empty",children:"No results"}),!S&&!w&&K.map((L,F)=>{var ue,nt;return a.jsx("div",{ref:F===x?M:void 0,role:"option","aria-selected":L.value===e,className:`be-select-option${F===x?" be-select-option-active":""}${L.value===e?" be-select-option-selected":""}`,onMouseDown:uo=>{uo.preventDefault(),Z(L)},onMouseEnter:()=>k(F),children:V?a.jsx("span",{className:"be-select-tag",style:{background:(ue=L.color)==null?void 0:ue.bg,color:(nt=L.color)==null?void 0:nt.text},children:L.label}):L.label},L.value)})]}),u&&a.jsx("button",{type:"button",className:"be-select-manage-options",onMouseDown:L=>{L.preventDefault(),oe(),u()},children:p})]}),document.body)]})}const nn=[{bg:"#e9e9e7",text:"#32302c"},{bg:"#eee0da",text:"#64473a"},{bg:"#fadec9",text:"#8a4b23"},{bg:"#fdecc8",text:"#8a6116"},{bg:"#dbeddb",text:"#256029"},{bg:"#d3e5ef",text:"#1a5f8a"},{bg:"#e8deee",text:"#5b3a8a"},{bg:"#f5e0e9",text:"#8a3a5f"},{bg:"#ffe2dd",text:"#a13a2f"}];function Ke(e){return nn[(e%nn.length+nn.length)%nn.length]}const ns={text:"Text",date:"Date",checkbox:"Checkbox",select:"Select"},ts=Qt.map(e=>({value:e,label:ns[e]}));function rs({tableId:e,colIndex:n,options:t}){const r=D(),[o,l]=f.useState(""),s=f.useCallback((u,p)=>{ln(r,e,n,t.map(d=>d.value===u?{...d,label:p}:d))},[r,e,n,t]),c=f.useCallback(u=>ln(r,e,n,t.filter(p=>p.value!==u)),[r,e,n,t]),i=f.useCallback(()=>{const u=o.trim();l(""),u&&ln(r,e,n,[...t,{value:T(),label:u,color:Ke(t.length)}])},[r,e,n,t,o]);return a.jsxs("div",{className:"be-table-header-menu-options",children:[a.jsx("div",{className:"be-table-header-menu-options-label",children:"Options"}),t.map((u,p)=>a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(u.color??Ke(p)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:u.label,onChange:d=>s(u.value,d.target.value),"aria-label":`Rename option ${u.label}`}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>c(u.value),"aria-label":`Remove option ${u.label}`,children:a.jsx(Ge,{size:14})})]},u.value)),a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("input",{className:"be-table-header-menu-option-input",value:o,onChange:u=>l(u.target.value),placeholder:"New option…",onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),i())}}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:i,"aria-label":"Add option",children:"+"})]})]})}function os({tableId:e,column:n,colIndex:t,colCount:r}){const o=D(),l=he(),[s,c]=f.useState(!1),[i,u]=f.useState(null),[p,d]=f.useState(null),b=f.useRef(null),h=f.useRef(null),m=f.useRef(null),g=f.useMemo(()=>[b,h],[]),x=f.useCallback(()=>c(!1),[]);bn(g,s,x);const k=f.useCallback(()=>{var w;u(((w=m.current)==null?void 0:w.getBoundingClientRect())??null),c(!0)},[]),I=f.useCallback(w=>sr(o,e,t,w.target.value),[o,e,t]),y=f.useCallback(()=>{Cn(o,e,t-1),x()},[o,e,t,x]),E=f.useCallback(()=>{Cn(o,e,t),x()},[o,e,t,x]),R=f.useCallback(()=>{or(o,e,t),x()},[o,e,t,x]),S=f.useCallback(w=>ar(o,e,t,w,l),[o,e,t,l]),C=f.useCallback(w=>{var V;w.preventDefault();const v=(V=m.current)==null?void 0:V.closest("table"),j=v==null?void 0:v.querySelector(`col[data-col-index="${t}"]`);if(!j)return;const B=m.current.getBoundingClientRect().width,O=w.clientX,N=H=>Math.max(an,Math.round(B+(H.clientX-O))),M=H=>{const P=N(H);j.style.width=`${P}px`,d(P)},q=H=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",q),lr(o,e,t,N(H)),d(null)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",q)},[o,e,t]);return a.jsxs("th",{ref:m,className:"be-table-header-cell",contentEditable:!1,children:[a.jsx("input",{className:"be-table-header-label",value:n.label,onChange:I,"aria-label":`Column ${t+1} name`}),a.jsx("button",{ref:b,type:"button",className:"be-table-header-menu-trigger","aria-label":`Column ${t+1} options`,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?x():k(),children:"⋮"}),a.jsx("div",{className:"be-table-col-resize-handle",onMouseDown:C,role:"slider","aria-label":`Resize column ${t+1}`,"aria-valuemin":an,"aria-valuenow":p??n.width}),s&&i&&Le.createPortal(a.jsxs("div",{ref:h,role:"menu",className:"be-table-header-menu",style:{position:"fixed",top:i.bottom+4,left:i.right,transform:"translateX(-100%)"},children:[a.jsxs("div",{className:"be-table-header-menu-type",children:[a.jsx("span",{id:`be-table-col-type-${n.id}`,children:"Type"}),a.jsx(_e,{value:n.type,options:ts,onChange:S,ariaLabel:"Column type",className:""})]}),n.type==="select"&&a.jsx(rs,{tableId:e,colIndex:t,options:n.options??[]}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:y,children:"Insert column left"}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:E,children:"Insert column right"}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item be-table-header-menu-item-danger",onClick:R,disabled:r<=1,children:"Delete column"})]}),document.body)]})}function cr({tableId:e,columns:n}){return a.jsx("thead",{children:a.jsxs("tr",{className:"be-table-header-row",children:[n.map((t,r)=>a.jsx(os,{tableId:e,column:t,colIndex:r,colCount:n.length},t.id)),a.jsx("th",{className:"be-table-header-spacer","aria-hidden":"true"})]})})}function ls({id:e}){var c;const n=D(),t=Q(e),r=f.useCallback(()=>{var u;const i=(u=t==null?void 0:t.contentIds)==null?void 0:u[t.contentIds.length-1];i&&tr(n,i)},[n,t]),o=ee("be-table-wrapper",t);if(!t)return null;const l=n.getBlock(t.contentIds[0]),s=ie(t,((c=l==null?void 0:l.contentIds)==null?void 0:c.length)??0);return a.jsx("div",{className:"be-table-scroll",children:a.jsxs("div",{className:o,"data-block-id":e,children:[a.jsxs("table",{className:"be-table",children:[a.jsxs("colgroup",{children:[s.map((i,u)=>a.jsx("col",{"data-col-index":u,style:{width:i.width}},i.id)),a.jsx("col",{className:"be-table-header-spacer-col"})]}),a.jsx(cr,{tableId:e,columns:s}),a.jsx("tbody",{children:a.jsx(Ce,{parentId:e})})]}),a.jsxs("button",{type:"button",className:"be-table-add-row",contentEditable:!1,onClick:r,children:[a.jsx(St,{size:14})," Add row"]})]})})}function ss({id:e}){const n=D(),t=Q(e),r=ee("be-table-row",t),o=f.useCallback(()=>rr(n,e),[n,e]);return a.jsxs("tr",{className:r,"data-block-id":e,children:[a.jsx(Ce,{parentId:e}),a.jsx("td",{className:"be-table-row-actions",contentEditable:!1,children:a.jsx("button",{type:"button",className:"be-table-delete-row",onClick:o,"aria-label":"Delete row",title:"Delete row",children:a.jsx(Ge,{size:14})})})]})}function ir(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=e.getBlock(r.parentId);return{table:o,row:r,rowIndex:o.contentIds.indexOf(r.id),colIndex:r.contentIds.indexOf(n)}}function as(e,n,t){const{table:r,row:o,rowIndex:l,colIndex:s}=ir(e,n);if(t==="left"||t==="right"){const p=t==="right"?1:-1,d=s+p;if(d>=0&&d<o.contentIds.length)return o.contentIds[d];const b=l+p;if(b<0||b>=r.contentIds.length)return null;const h=e.getBlock(r.contentIds[b]),m=t==="right"?0:h.contentIds.length-1;return h.contentIds[m]}const i=l+(t==="down"?1:-1);if(i<0||i>=r.contentIds.length)return null;const u=e.getBlock(r.contentIds[i]);return u.contentIds[s]??u.contentIds[u.contentIds.length-1]??null}function cs(e,n){const t=_t(e,n,"down");if(t){X(t);return}ve(e,n,$("paragraph"))}function Pe(e,n,t){var o;const r=as(e,n,t);if(r){const l=e.getBlock(r),s=(o=l==null?void 0:l.contentIds)==null?void 0:o[0];s&&X(s);return}if(t==="right"){const{table:l}=ir(e,n);cs(e,l.id)}}function is({id:e}){const n=D(),t=Q(e),r=f.useCallback(()=>Pe(n,e,"right"),[n,e]),o=f.useCallback(()=>Pe(n,e,"left"),[n,e]),l=f.useCallback(()=>Pe(n,e,"up"),[n,e]),s=f.useCallback(()=>Pe(n,e,"down"),[n,e]),c=f.useCallback(()=>Pe(n,e,"down"),[n,e]),i=ee("be-table-cell",t);return t?a.jsx("td",{className:i,"data-block-id":e,children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onTab:r,onShiftTab:o,onArrowUp:l,onArrowDown:s,onEnter:c})}):null}function us(e,n){const t=T(),r=[],o=[],l=[];for(const s of n){const c=gn(t,s);r.push(c.block),o.push(c.run),l.push(c.block.id)}return{block:{id:t,type:"tableRow",parentId:e,contentIds:l,props:{}},blocks:r,runs:o}}function ds({rows:e=2,cols:n=2}={}){return function(r){const o=T(),l=Vn(n),s=[],c=[],i=[];for(let p=0;p<e;p+=1){const d=us(o,l);s.push(d.block,...d.blocks),c.push(...d.runs),i.push(d.block.id)}return{block:{id:o,type:"table",parentId:r,contentIds:i,props:{columns:l}},runs:c,subtreeBlocks:s}}}function ps(e,n){return`<td>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>Ie(r,n)).join("")}</td>`}function fs(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function bs(e,n){if(e.tagName!=="TD"&&e.tagName!=="TH")return null;const t=de(e,n);return{block:{id:T(),type:"tableCell",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}function ms(e,n){return`<tr>${e.contentIds.map(r=>{const o=n.store.getBlock(r);return n.registry.get(o.type).toHTML(o,n)}).join("")}</tr>`}function hs(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(" ")}function gs(e,n){if(e.tagName!=="TR")return null;const t=[...e.children].filter(i=>i.tagName==="TD"||i.tagName==="TH"),r=T(),o=[],l=[],s=[];for(const i of t){const u=n.registry.get("tableCell").fromHTML(i,n);u&&(u.block.parentId=r,o.push(u.block),l.push(...u.runs),s.push(u.block.id))}return{block:{id:r,type:"tableRow",parentId:null,contentIds:s,props:{}},runs:l,subtreeBlocks:o}}function xs(e,n){var s;const t=e.contentIds[0]&&n.store.getBlock(e.contentIds[0]),r=ie(e,((s=t==null?void 0:t.contentIds)==null?void 0:s.length)??0),o=r.length?`<thead><tr>${r.map(c=>`<th>${Se(c.label??"")}</th>`).join("")}</tr></thead>`:"",l=e.contentIds.map(c=>{const i=n.store.getBlock(c);return n.registry.get(i.type).toHTML(i,n)}).join("");return`<table>${o}<tbody>${l}</tbody></table>`}function ks(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(`
1900
- `)}function ys(e,n){if(e.tagName!=="TABLE")return null;const t=e.querySelector("thead tr"),r=e.querySelector("tbody")?[...e.querySelectorAll("tbody tr")]:[...e.querySelectorAll("tr")].filter(p=>p!==t),o=T(),l=[],s=[],c=[];for(const p of r){const d=n.registry.get("tableRow").fromHTML(p,n);if(d){d.block.parentId=o;for(const b of d.subtreeBlocks)b.parentId=d.block.id;l.push(d.block,...d.subtreeBlocks),s.push(...d.runs),c.push(d.block.id)}}const i={};if(t){const p=[...t.children].filter(d=>d.tagName==="TH"||d.tagName==="TD");i.columns=p.map(d=>({id:T(),label:d.textContent??""}))}return{block:{id:o,type:"table",parentId:null,contentIds:c,props:i},runs:s,subtreeBlocks:l}}const ur={component:is,isLeaf:!0,defaultProps:{},toHTML:ps,toPlainText:fs,fromHTML:bs},dr={component:ss,isLeaf:!1,defaultProps:{},toHTML:ms,toPlainText:hs,fromHTML:gs},pr={component:ls,isLeaf:!1,defaultProps:{},toHTML:xs,toPlainText:ks,fromHTML:ys,slashCommand:{label:"Table",icon:Uo,keywords:["table","grid"],run:(e,n)=>ne(e,n,ds({rows:2,cols:2}))}};function vs({id:e}){const n=Q(e),t=ee("be-layout",n);return a.jsx("div",{className:t,"data-block-id":e,style:{display:"flex",gap:"1em"},children:a.jsx(Ce,{parentId:e})})}function Is({id:e}){const n=Q(e),t=ee("be-layout-column",n);return a.jsx("div",{className:t,"data-block-id":e,children:a.jsx(Ce,{parentId:e})})}function ws({columns:e=2}={}){return function(t){const r=T(),o=[],l=[],s=[];for(let i=0;i<e;i+=1){const u=T(),{block:p,runs:d}=$("paragraph")(u),b={id:u,type:"layoutColumn",parentId:r,contentIds:[p.id],props:{}};o.push(b,p),l.push(...d),s.push(u)}return{block:{id:r,type:"layout",parentId:t,contentIds:s,props:{}},runs:l,subtreeBlocks:o}}}function fr(e,n){return(t,r)=>`${e}${t.contentIds.map(o=>{const l=r.store.getBlock(o);return r.registry.get(l.type).toHTML(l,r)}).join("")}${n}`}function br(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(`
1901
- `)}const mr={component:Is,isLeaf:!1,defaultProps:{},toHTML:fr("<div>","</div>"),toPlainText:br},hr={component:vs,isLeaf:!1,defaultProps:{},toHTML:fr('<div style="display:flex;gap:1em">',"</div>"),toPlainText:br,slashCommands:[2,3,4,5].map(e=>({label:`${e} columns`,icon:Fo,keywords:["layout","columns","column",String(e)],run:(n,t)=>ne(n,t,ws({columns:e}))}))};function Cs({id:e}){const n=Q(e),t=ee("be-divider",n);return a.jsx("hr",{className:t,"data-block-id":e,contentEditable:!1,tabIndex:-1})}function Bs(){return function(n){return{block:{id:T(),type:"divider",parentId:n,contentIds:[],props:{}},runs:[]}}}function Rs(){return"<hr />"}function Ts(){return"---"}function js(e){return e.tagName!=="HR"?null:{block:{id:T(),type:"divider",parentId:null,contentIds:[],props:{}},runs:[]}}const gr={component:Cs,isLeaf:!0,defaultProps:{},toHTML:Rs,toPlainText:Ts,fromHTML:js,slashCommand:{label:"Divider",icon:Po,keywords:["divider","hr","separator","line"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>{const l=e.getRun(t),s=(l==null?void 0:l.value)??"";e.applyOperation(J(t,{value:s.slice(0,r)+s.slice(o)}));const c=zn(e,n,Bs());return ve(e,c,$("paragraph")),c}}},en="💡",xr="gray";function Ss({icon:e=en,color:n=xr}={}){return function(r){const o=T(),{block:l,runs:s}=$("paragraph")(o);return{block:{id:o,type:"callout",parentId:r,contentIds:[l.id],props:{icon:e,color:n}},runs:s,subtreeBlocks:[l]}}}const Es=[{value:"gray",label:"Gray"},{value:"blue",label:"Blue"},{value:"green",label:"Green"},{value:"yellow",label:"Yellow"},{value:"orange",label:"Orange"},{value:"red",label:"Red"},{value:"purple",label:"Purple"},{value:"pink",label:"Pink"}];function Os({id:e}){var k,I;const n=D(),t=Q(e),[r,o]=f.useState(!1),[l,s]=f.useState(!1),c=f.useRef(null),i=f.useRef(null),u=f.useMemo(()=>[c,i],[]),p=f.useCallback(()=>s(!1),[]);bn(u,l,p);const d=((k=t==null?void 0:t.props)==null?void 0:k.icon)??en,b=((I=t==null?void 0:t.props)==null?void 0:I.color)??xr,h=f.useCallback(y=>{const E=y.target.value.trim();E&&n.applyOperation(z(e,{icon:E})),o(!1)},[n,e]),m=f.useCallback(y=>{y.key==="Enter"&&y.currentTarget.blur(),y.key==="Escape"&&o(!1)},[]),g=f.useCallback(y=>{n.applyOperation(z(e,{color:y})),s(!1)},[n,e]),x=ee("be-callout",t);return t?a.jsxs("div",{className:x,"data-block-id":e,"data-color":b,children:[a.jsx("div",{className:"be-callout-icon-wrap",children:r?a.jsx("input",{type:"text",className:"be-callout-icon-input",defaultValue:d,autoFocus:!0,onBlur:h,onKeyDown:m,"aria-label":"Callout icon (paste or type an emoji)"}):a.jsx("button",{type:"button",className:"be-callout-icon",onClick:()=>o(!0),"aria-label":"Change callout icon",title:"Change icon",children:d})}),a.jsx("div",{className:"be-callout-content",children:a.jsx(Ce,{parentId:e})}),a.jsxs("div",{className:"be-callout-color-wrap",contentEditable:!1,children:[a.jsx("button",{ref:c,type:"button",className:"be-callout-color-trigger","aria-label":"Callout color","aria-haspopup":"true","aria-expanded":l,title:"Callout color",onClick:()=>s(y=>!y),children:a.jsx("span",{className:`be-callout-color-dot be-callout-color-dot-${b}`})}),l&&a.jsx("div",{ref:i,className:"be-callout-color-picker",role:"menu","aria-label":"Callout color",children:Es.map(y=>a.jsx("button",{type:"button",role:"menuitem",className:`be-callout-color-option be-callout-color-option-${y.value}${y.value===b?" be-callout-color-option-active":""}`,title:y.label,"aria-label":y.label,onClick:()=>g(y.value)},y.value))})]})]}):null}function Ls(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toHTML(r,n)}).join("")}function Ns(e,n){var r;const t=((r=e.props)==null?void 0:r.icon)??en;return`<div class="callout" data-icon="${t}"><div class="callout-icon">${t}</div><div class="callout-content">${Ls(e,n)}</div></div>`}function Ms(e,n){var o;const t=((o=e.props)==null?void 0:o.icon)??en,r=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
1902
- `);return`${t} ${r}`}const kr={component:Os,isLeaf:!1,defaultProps:{icon:en},toHTML:Ns,toPlainText:Ms,slashCommand:{label:"Callout",icon:Ho,keywords:["callout","aside","note","info","tip","warning"],run:(e,n)=>ne(e,n,Ss())}};function As({id:e}){const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),o=f.useCallback(()=>{Me(n,e,(t==null?void 0:t.contentIds)??[],$("paragraph"))},[n,e,t]),l=f.useCallback(()=>{const p=Qe(n,e);De(n,p,e,r)},[n,e,r]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=ee("be-blockquote",t);if(!t)return null;const u=ae(n,t.contentIds);return a.jsx("blockquote",{className:i,"data-block-id":e,"data-empty":u?"":void 0,"data-placeholder":"Empty quote",children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})}function Ds(e,n){return`<p>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>Ie(r,n)).join("")}</p>`}function _s(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function $s(e,n){if(e.tagName!=="BLOCKQUOTE")return null;const t=de(e,n);return{block:{id:T(),type:"blockquote",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}const yr={component:As,isLeaf:!0,defaultProps:{},toHTML:Ds,toPlainText:_s,fromHTML:$s,slashCommand:{label:"Quote",icon:$o,keywords:["quote","blockquote","citation"],run:(e,n)=>ne(e,n,$("blockquote"))}},Ps=["plaintext","javascript","python","html","css","json","bash","sql"],Hs=Ps.map(e=>({value:e,label:e}));function bt(e,n,t){const r=Xe();if(!r||r.blockId!==n)return;const o=e.getRun(r.runId);if(!o||o.type!=="text")return;const l=o.value??"",s=l.slice(0,r.offset)+t+l.slice(r.offset);e.applyOperation(J(o.id,{value:s})),be(o.id,r.offset+t.length)}function zs({id:e}){var h;const n=D(),t=Q(e),r=f.useCallback(()=>bt(n,e,`
1903
- `),[n,e]),o=f.useCallback(()=>bt(n,e," "),[n,e]),l=f.useCallback(()=>{var k;const m=Qe(n,e);if(!m||m===e)return;const g=n.getBlock(m),x=(k=g==null?void 0:g.contentIds)==null?void 0:k[g.contentIds.length-1];x&&X(x)},[n,e]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=f.useCallback(m=>n.applyOperation(z(e,{language:m})),[n,e]),u=f.useCallback(()=>Wn(n,e),[n,e]),p=ee("be-code-block",t);if(!t)return null;const d=((h=t.props)==null?void 0:h.language)??"plaintext",b=ae(n,t.contentIds);return a.jsxs("div",{className:p,"data-block-id":e,children:[a.jsxs("div",{className:"be-code-block-header",contentEditable:!1,children:[a.jsx(_e,{className:"be-code-block-language",value:d,options:Hs,onChange:i,ariaLabel:"Code language"}),a.jsx("button",{type:"button",className:"be-code-block-delete",onClick:u,"aria-label":"Delete code block",title:"Delete code block",children:a.jsx($n,{size:14})})]}),a.jsx("pre",{className:"be-code-block-pre",children:a.jsx("code",{"data-empty":b?"":void 0,"data-placeholder":"Empty code block",children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:r,onTab:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})})]})}function Us(e,n){var l;const t=e.contentIds.map(s=>n.store.getRun(s)),r=(l=e.props)==null?void 0:l.language;return`<pre><code${r&&r!=="plaintext"?` data-language="${Se(r)}"`:""}>${t.map(s=>Ie(s,n)).join("")}</code></pre>`}function Fs(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function Ks(e,n){var s;if(e.tagName!=="PRE")return null;const t=e.querySelector("code")??e,r=(s=t.getAttribute)==null?void 0:s.call(t,"data-language"),o=T();return{block:{id:T(),type:"code",parentId:null,contentIds:[o],props:r?{language:r}:{}},runs:[{id:o,type:"text",value:t.textContent??"",marks:{}}]}}const vr={component:zs,isLeaf:!0,defaultProps:{language:"plaintext"},toHTML:Us,toPlainText:Fs,fromHTML:Ks,slashCommand:{label:"Code",icon:Nt,keywords:["code","codeblock","snippet","pre"],run:(e,n)=>ne(e,n,$("code"))}};function qs(e,n){var t;return n.length===0||n.length===1&&(((t=e.getRun(n[0]))==null?void 0:t.value)??"")===""}function Ws(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const r=e.getBlock(t[0]);return!!r&&r.type==="paragraph"&&ae(e,r.contentIds)}function tn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Vs(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.props.titleRunIds??[],s=qs(e,l)&&Ws(e,t);if(o<=0){if(!s)return null;if(r.contentIds.length>1)return tn(e,[_(n)]),{focusBlockId:e.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:u,runs:p}=$("paragraph")(r.id);return tn(e,[G(u,r.id,o,{blocks:[u],runs:p}),_(n)]),{focusBlockId:u.id,needsRefocus:!0}}const c=r.contentIds[o-1],i=e.getBlock(c);return s?(tn(e,[_(n)]),{focusBlockId:c,needsRefocus:!0}):Ve(e,i)?(tn(e,[_(c)]),{focusBlockId:n,needsRefocus:!1}):null}function Ys(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Gs({id:e}){var g;const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),o=f.useCallback(()=>{var y,E;const x=((y=t==null?void 0:t.props)==null?void 0:y.titleRunIds)??[],k=(((E=t==null?void 0:t.contentIds)==null?void 0:E.length)??0)>0,I=$("paragraph");k?Pt(n,e,x,I):Me(n,e,x,I)},[n,e,t]),l=f.useCallback(()=>{const x=Vs(n,e);!x||!x.needsRefocus||De(n,x.focusBlockId,e,r)},[n,e,r]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=f.useCallback(()=>{var k,I;if(!((((k=t==null?void 0:t.contentIds)==null?void 0:k.length)??0)>0)){const{block:y,runs:E}=$("paragraph")(e);Ys(n,[G(y,e,0,{blocks:[y],runs:E}),z(e,{collapsed:!1})]),X(y.contentIds[0]);return}n.applyOperation(z(e,{collapsed:!((I=t==null?void 0:t.props)!=null&&I.collapsed)}))},[n,e,t==null?void 0:t.contentIds,(g=t==null?void 0:t.props)==null?void 0:g.collapsed]),u=ee("be-toggle-heading",t);if(!t)return null;const{level:p=2,collapsed:d,titleRunIds:b=[]}=t.props,h=t.contentIds.length>0,m=`h${p}`;return a.jsxs("div",{className:u,"data-block-id":e,children:[a.jsxs("div",{className:"be-toggle-heading-row",children:[a.jsx("button",{type:"button",className:"be-toggle-heading-marker",onClick:i,"aria-expanded":!d,"aria-label":h?d?"Expand section":"Collapse section":"Add content to section",children:d?a.jsx(pn,{}):a.jsx(_n,{})}),a.jsx(m,{className:`be-heading be-heading-${p} be-toggle-heading-title`,"data-empty":ae(n,b)?"":void 0,"data-placeholder":`Toggle heading ${p}`,children:a.jsx(xe,{blockId:e,runIds:b,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})]}),!d&&a.jsx("div",{className:"be-toggle-heading-children",children:a.jsx(Ce,{parentId:e})})]})}function Xs({level:e=2,collapsed:n=!1}={}){return function(r,o){const l=T(),s=o!=null&&o.length?o:[{id:T(),type:"text",value:"",marks:{}}],{block:c,runs:i}=$("paragraph")(l);return{block:{id:l,type:"toggleHeading",parentId:r,contentIds:[c.id],props:{level:e,collapsed:n,titleRunIds:s.map(u=>u.id)}},runs:[...s,...i],subtreeBlocks:[c]}}}function Js(e,n){const{titleRunIds:t=[],level:r=2,collapsed:o}=e.props,l=t.map(c=>Ie(n.store.getRun(c),n)).join(""),s=e.contentIds.map(c=>{const i=n.store.getBlock(c);return n.registry.get(i.type).toHTML(i,n)}).join("");return`<details${o?"":" open"}><summary><h${r}>${l}</h${r}></summary>${s}</details>`}function Qs(e,n){const{titleRunIds:t=[]}=e.props,r=t.map(l=>we(n.store.getRun(l),n)).join(""),o=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
2060
+ \r
2061
+ /* --- voice typing: caret-anchored listening/processing indicator --- */\r
2062
+ \r
2063
+ .be-voice-indicator {\r
2064
+ z-index: 1000;\r
2065
+ display: flex;\r
2066
+ align-items: center;\r
2067
+ gap: 5px;\r
2068
+ background: var(--noteloom-bg);\r
2069
+ border: 1px solid var(--noteloom-border);\r
2070
+ border-radius: var(--noteloom-radius-md);\r
2071
+ padding: 4px 9px;\r
2072
+ box-shadow: var(--noteloom-shadow);\r
2073
+ font-size: 0.78rem;\r
2074
+ color: var(--noteloom-text-muted);\r
2075
+ white-space: nowrap;\r
2076
+ pointer-events: none;\r
2077
+ animation: be-voice-indicator-in 0.12s ease-out;\r
2078
+ }\r
2079
+ \r
2080
+ @keyframes be-voice-indicator-in {\r
2081
+ from {\r
2082
+ opacity: 0;\r
2083
+ transform: translate(-50%, calc(-100% + 4px));\r
2084
+ }\r
2085
+ to {\r
2086
+ opacity: 1;\r
2087
+ transform: translate(-50%, -100%);\r
2088
+ }\r
2089
+ }\r
2090
+ \r
2091
+ .be-voice-indicator-dot {\r
2092
+ width: 7px;\r
2093
+ height: 7px;\r
2094
+ border-radius: 50%;\r
2095
+ background: var(--noteloom-danger, #dc2626);\r
2096
+ flex: none;\r
2097
+ animation: be-voice-indicator-pulse 1.4s ease-in-out infinite;\r
2098
+ }\r
2099
+ \r
2100
+ .be-voice-indicator-processing .be-voice-indicator-dot {\r
2101
+ background: var(--noteloom-accent);\r
2102
+ animation-duration: 0.6s;\r
2103
+ }\r
2104
+ \r
2105
+ @keyframes be-voice-indicator-pulse {\r
2106
+ 0%,\r
2107
+ 100% {\r
2108
+ opacity: 1;\r
2109
+ box-shadow: 0 0 0 0 currentColor;\r
2110
+ }\r
2111
+ 50% {\r
2112
+ opacity: 0.5;\r
2113
+ box-shadow: 0 0 0 4px transparent;\r
2114
+ }\r
2115
+ }\r
2116
+ \r
2117
+ /* --- print --- */\r
2118
+ /*\r
2119
+ * Printing (or "Save as PDF" via the browser's own print dialog — this\r
2120
+ * package deliberately doesn't bundle a PDF-generation library, which\r
2121
+ * would conflict with staying zero-runtime-dependency) always renders a\r
2122
+ * clean, chrome-free document: every piece of editing-only UI is hidden\r
2123
+ * here, regardless of whether the app happens to be in preview mode at\r
2124
+ * the moment of printing. \`.be-block-row-hidden\` is included on purpose —\r
2125
+ * a block hidden via "Hide in preview" stays in the DOM (just dimmed) in\r
2126
+ * edit mode, so without this rule printing while NOT toggled into preview\r
2127
+ * mode would print blocks the user explicitly marked as hidden. A host\r
2128
+ * app's own outer chrome (nav bars, its own toolbar) needs its own print\r
2129
+ * rules the same way — see examples/basic's own style.css for a worked\r
2130
+ * example, since that chrome lives outside this package entirely.\r
2131
+ */\r
2132
+ @media print {\r
2133
+ .be-block-gutter,\r
2134
+ .be-block-gutter-menu,\r
2135
+ .be-block-gutter-menu-item,\r
2136
+ .be-block-range-menu,\r
2137
+ .be-block-range-menu-item,\r
2138
+ .be-block-row-hidden,\r
2139
+ .be-slash-menu,\r
2140
+ #be-emoji-menu,\r
2141
+ #be-at-menu,\r
2142
+ .be-floating-toolbar,\r
2143
+ .be-link-hover-card,\r
2144
+ .be-voice-indicator,\r
2145
+ .be-table-header-menu-trigger,\r
2146
+ .be-table-header-menu,\r
2147
+ .be-table-col-resize-handle,\r
2148
+ .be-table-delete-row,\r
2149
+ .be-table-add-row,\r
2150
+ .be-embed-toolbar,\r
2151
+ .be-embed-remove,\r
2152
+ .be-embed-resize-handle,\r
2153
+ .be-embed-dropzone,\r
2154
+ .be-embed-upload-btn,\r
2155
+ .be-embed-url-row,\r
2156
+ .be-callout-color-wrap,\r
2157
+ .be-modal-overlay,\r
2158
+ .be-mobile-action-bar,\r
2159
+ .be-mobile-picker-list,\r
2160
+ .be-export-trigger,\r
2161
+ .be-export-tabs,\r
2162
+ .be-trailing-space,\r
2163
+ .be-select-popover {\r
2164
+ display: none !important;\r
2165
+ }\r
2166
+ \r
2167
+ /* .be-block-row-range-selected and .be-block-selected mark real content\r
2168
+ (the row/block itself, not a standalone chrome element) with a\r
2169
+ highlight background/outline — reset just that styling rather than\r
2170
+ hiding the element the way the chrome above is hidden, or printing\r
2171
+ mid-drag-selection would print blank space instead of the block's own\r
2172
+ content. */\r
2173
+ .be-block-row-range-selected {\r
2174
+ background: none !important;\r
2175
+ }\r
2176
+ \r
2177
+ .be-block-selected {\r
2178
+ outline: none !important;\r
2179
+ }\r
2180
+ \r
2181
+ /* No background colors/shadows on paper, and text that's always legible\r
2182
+ regardless of the screen theme the page happened to be rendered in\r
2183
+ (dark mode's near-white text would otherwise print as barely-there). */\r
2184
+ .be-editable,\r
2185
+ .be-paragraph,\r
2186
+ .be-heading,\r
2187
+ .be-list-item,\r
2188
+ .be-blockquote,\r
2189
+ .be-code-block,\r
2190
+ .be-callout,\r
2191
+ .be-table-cell {\r
2192
+ background: none !important;\r
2193
+ box-shadow: none !important;\r
2194
+ color: #000 !important;\r
2195
+ }\r
2196
+ \r
2197
+ /* Don't split a table/code block/callout/image awkwardly across a page\r
2198
+ boundary when it would otherwise fit on one page. */\r
2199
+ .be-table,\r
2200
+ .be-code-block,\r
2201
+ .be-callout,\r
2202
+ .be-embed-image {\r
2203
+ break-inside: avoid;\r
2204
+ }\r
2205
+ }\r
2206
+ `,_t="noteloom-default-styles";function sr(){if(typeof document>"u"||document.getElementById(_t))return;const e=document.createElement("style");e.id=_t,e.textContent=Cl,document.head.appendChild(e)}const ar=p.createContext(null);function Bl({store:e,registry:n,inlineRegistry:t=null,history:r=null,className:o,style:l,theme:s="default",getBlockClassName:i,children:c}){p.useEffect(()=>{s!=="none"&&sr()},[s]);const[u,f]=p.useState(!1),[d,b]=p.useState([]),[h,m]=p.useState(!1),[g,k]=p.useState(null),x=p.useCallback(()=>k("new"),[]),w=p.useCallback(S=>k(S),[]),v=p.useCallback(()=>k(null),[]),B=p.useRef(null),C=p.useCallback(()=>B.current,[]),y=p.useCallback(S=>{var T,L;const I=B.current;I!==S&&(I&&((T=document.querySelector(`[data-block-id="${I}"]`))==null||T.classList.remove("be-block-selected")),B.current=S,S&&((L=document.querySelector(`[data-block-id="${S}"]`))==null||L.classList.add("be-block-selected")))},[]),R=p.useMemo(()=>({store:e,registry:n,inlineRegistry:t,history:r,isWholeDocumentSelected:u,setIsWholeDocumentSelected:f,selectedBlockRange:d,setSelectedBlockRange:b,getSelectedBlockId:C,setSelectedBlockId:y,isPreviewMode:h,setIsPreviewMode:m,fieldTypeEditorTarget:g,openCreateFieldType:x,openEditFieldType:w,closeFieldTypeEditor:v,getBlockClassName:i}),[e,n,t,r,u,d,C,y,h,g,x,w,v,i]),j=o||l?a.jsx("div",{className:o?`be-root ${o}`:"be-root",style:l,children:c}):c;return a.jsx(ar.Provider,{value:R,children:j})}function xe(){const e=p.useContext(ar);if(!e)throw new Error("Editor hooks must be used within an <EditorProvider>");return e}function _(){return xe().store}function Ee(){return xe().registry}function ye(){return xe().inlineRegistry}function Jn(){const{isWholeDocumentSelected:e,setIsWholeDocumentSelected:n}=xe();return[e,n]}function rn(){const{selectedBlockRange:e,setSelectedBlockRange:n}=xe();return[e,n]}function Ce(){const{getSelectedBlockId:e,setSelectedBlockId:n}=xe();return{getSelectedBlockId:e,setSelectedBlockId:n}}function Xn(){const{isPreviewMode:e,setIsPreviewMode:n}=xe();return[e,n]}function le(e,n){const{getBlockClassName:t}=xe(),r=n&&t?t(n):void 0;return r?`${e} ${r}`:e}function Qn(){const{fieldTypeEditorTarget:e,openCreateFieldType:n,openEditFieldType:t,closeFieldTypeEditor:r}=xe();return{target:e,openCreate:n,openEdit:t,close:r}}function ne(e){const n=_(),t=p.useCallback(o=>n.subscribe(e,o),[n,e]),r=p.useCallback(()=>n.getBlock(e),[n,e]);return p.useSyncExternalStore(t,r)}function Le(e){const n=_(),t=p.useCallback(o=>n.subscribe(e,o),[n,e]),r=p.useCallback(()=>n.getRun(e),[n,e]);return p.useSyncExternalStore(t,r)}function E(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const ir="​",Rl=/​/g;function ve(e){return(e??"").replace(Rl,"")}function Pt(e){return ve(e.textContent)}function Tl(e,n){var i;const t=new Map(n.map(c=>[c.id,c])),r=new Set,o=[];let l=!0;for(const c of e.childNodes){const u=c.nodeType===1?(i=c.dataset)==null?void 0:i.runId:void 0;if(u&&t.has(u)){r.add(u);const d=t.get(u);if(d.type!=="text"){o.push(d);continue}const b=Pt(c);o.push(b===d.value?d:{...d,value:b});continue}l=!1;const f=Pt(c);f&&o.push({id:E(),type:"text",value:f,marks:{}})}if(n.some(c=>!r.has(c.id))&&(l=!1),o.length!==n.length&&(l=!1),l){for(let c=0;c<o.length;c+=1)if(o[c].id!==n[c].id){l=!1;break}}const s=!l||o.some((c,u)=>c!==n[u]);return{runs:o,changed:s,onlyValueChanges:l}}function cr(e){return e?e.type!=="text"?!1:(e.value??"")==="":!0}function de(e,n){return!n||n.length===0?!0:n.every(t=>cr(e.getRun(t)))}function on(e,n){var o,l;if(!n)return!1;const t=n.contentIds.length>0,r=(((l=(o=n.props)==null?void 0:o.titleRunIds)==null?void 0:l.length)??0)>0;return!t&&!r}function ur(e,n){const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const r=t.firstChild,o=document.createRange();if(r&&r.nodeType===3){const s=Math.max(0,Math.min(n,r.length));o.setStart(r,s),o.setEnd(r,s)}else o.selectNodeContents(t),o.collapse(n<=0);const l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(o)}function dr(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const r=document.createRange();r.selectNodeContents(t),r.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)})}function ee(e){dr(e,!1)}function vn(e){dr(e,!0)}function he(e,n){requestAnimationFrame(()=>ur(e,n))}function $t(e,n){ur(e,n)}const jl='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function Be({isOpen:e,onClose:n,title:t,size:r="default",variant:o="dialog",children:l}){const s=p.useRef(null),i=p.useRef(null);if(p.useEffect(()=>{if(!e)return;const u=f=>{f.key==="Escape"&&n()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,n]),p.useEffect(()=>{var u,f,d;if(e){i.current=document.activeElement;const b=s.current;(u=(b==null?void 0:b.querySelector(jl))??b)==null||u.focus();return}(d=(f=i.current)==null?void 0:f.focus)==null||d.call(f),i.current=null},[e]),!e)return null;const c=o==="sheet";return a.jsx("div",{className:`be-modal-overlay${c?" be-modal-overlay-sheet":""}`,onMouseDown:u=>{u.target===u.currentTarget&&n()},children:a.jsxs("div",{ref:s,className:`be-modal${r==="large"?" be-modal-large":""}${c?" be-modal-sheet":""}`,role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,children:[t&&a.jsx("div",{className:"be-modal-title",children:t}),l]})})}function pr({isOpen:e,initialHref:n,initialTarget:t,hasExistingLink:r,onSave:o,onRemove:l,onClose:s}){const[i,c]=p.useState(""),[u,f]=p.useState("_self");p.useEffect(()=>{e&&(c(n),f(t))},[e]);const d=i.trim(),b=p.useCallback(h=>{h.preventDefault(),d&&o(d,u)},[d,u,o]);return a.jsx(Be,{isOpen:e,onClose:s,title:r?"Edit link":"Add link",children:a.jsxs("form",{onSubmit:b,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"URL"}),a.jsx("input",{type:"text",value:i,onChange:h=>c(h.target.value),placeholder:"https://example.com",autoFocus:!0})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Open in"}),a.jsxs("select",{value:u,onChange:h=>f(h.target.value),children:[a.jsx("option",{value:"_self",children:"Same tab"}),a.jsx("option",{value:"_blank",children:"New tab"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[r&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:l,children:"Remove link"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:s,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",disabled:!d,children:"Save"})]})]})})}const Pe=8;function wn(e,n){const t=Math.max(Pe,window.innerWidth-n-Pe);return Math.min(Math.max(e,Pe),t)}function Sl(e,n){const t=Math.max(Pe,window.innerHeight-n-Pe);return Math.min(Math.max(e,Pe),t)}function In(e,n,t,r){const[o,l]=p.useState(null);return p.useLayoutEffect(()=>{if(t==null||r==null){l(null);return}l({top:t,left:r})},[t,r]),p.useLayoutEffect(()=>{if(!n||!e.current||!o)return;const s=e.current.getBoundingClientRect(),i=wn(o.left,s.width),c=Sl(o.top,s.height);(i!==o.left||c!==o.top)&&l({top:c,left:i})},[n,e,o]),o}function D({children:e,size:n=16,strokeWidth:t=2,...r}){return a.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:e})}function Me(e){return a.jsx(D,{...e,children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Cn(e){return a.jsx(D,{...e,children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ln(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function El(e){return a.jsxs(D,{...e,fill:"currentColor",stroke:"none",children:[a.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),a.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),a.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]})}function fr(e){return a.jsx(D,{...e,children:a.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function Zn(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function br(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),a.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}function mr(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),a.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}function hr(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M6 3v7a6 6 0 0 0 12 0V3"}),a.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}function Ll(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M12 20h9"}),a.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function gr(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function Ol(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),a.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function kr(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"17",y1:"18",x2:"3",y2:"18"})]})}function Nl(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"18",y1:"18",x2:"6",y2:"18"})]})}function xr(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),a.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),a.jsx("line",{x1:"21",y1:"18",x2:"7",y2:"18"})]})}function Ml(e){return a.jsx(D,{...e,children:[5,12,19].flatMap(n=>[9,15].map(t=>a.jsx("circle",{cx:t,cy:n,r:"1.3",fill:"currentColor",stroke:"none"},`${t}-${n}`)))})}function Bn(e){return a.jsxs(D,{...e,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),a.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function et(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function nt(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function tt(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Al(e){return a.jsxs(D,{...e,children:[a.jsx("circle",{cx:"6",cy:"6",r:"3"}),a.jsx("circle",{cx:"6",cy:"18",r:"3"}),a.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),a.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),a.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}function yr(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"17",y1:"6",x2:"3",y2:"6"}),a.jsx("line",{x1:"21",y1:"12",x2:"3",y2:"12"}),a.jsx("line",{x1:"15",y1:"18",x2:"3",y2:"18"})]})}function rt({level:e=1,size:n=16,...t}){return a.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",...t,children:a.jsxs("text",{x:"2",y:"18",fontSize:"14",fontWeight:"700",fill:"currentColor",fontFamily:"inherit",children:["H",e]})})}function vr(e){return a.jsx(rt,{level:1,...e})}function wr(e){return a.jsx(rt,{level:2,...e})}function Ir(e){return a.jsx(rt,{level:3,...e})}function Cr(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M7 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H6a3 3 0 0 1 3-3z"}),a.jsx("path",{d:"M17 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2a3 3 0 0 1 3-3z"})]})}function ot(e){return a.jsxs(D,{...e,children:[a.jsx("polyline",{points:"9 8 4 12 9 16"}),a.jsx("polyline",{points:"15 8 20 12 15 16"})]})}function Dl(e){return a.jsx(D,{...e,children:a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function Br(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M4 5h16a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H9l-4 4v-4H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z"}),a.jsx("line",{x1:"7",y1:"9",x2:"17",y2:"9"}),a.jsx("line",{x1:"7",y1:"12.5",x2:"13",y2:"12.5"})]})}function _l(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"8",width:"18",height:"8",rx:"3"}),a.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function Pl(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),a.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),a.jsx("line",{x1:"3",y1:"16",x2:"21",y2:"16"}),a.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function $l(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),a.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),a.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function Rr(e){return a.jsxs(D,{...e,children:[a.jsx("circle",{cx:"4.5",cy:"6",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"4.5",cy:"12",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"4.5",cy:"18",r:"1.2",fill:"currentColor",stroke:"none"}),a.jsx("line",{x1:"9",y1:"6",x2:"21",y2:"6"}),a.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),a.jsx("line",{x1:"9",y1:"18",x2:"21",y2:"18"})]})}function Tr(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),a.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),a.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),a.jsx("text",{x:"2",y:"8.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"1"}),a.jsx("text",{x:"2",y:"14.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"2"}),a.jsx("text",{x:"2",y:"20.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"3"})]})}function lt(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3"}),a.jsx("polyline",{points:"8 12 11 15 16 9"})]})}function Hl(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2"}),a.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),a.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"7"}),a.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"7"})]})}function jr(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M12 3h7a2 2 0 0 1 2 2v7a2 2 0 0 1-.59 1.41l-8 8a2 2 0 0 1-2.82 0l-7-7a2 2 0 0 1 0-2.82l8-8A2 2 0 0 1 12 3z"}),a.jsx("circle",{cx:"15.5",cy:"8.5",r:"1.2",fill:"currentColor",stroke:"none"})]})}function zl(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),a.jsx("circle",{cx:"9",cy:"10",r:"1.5",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4 17l5-5 4 4 4-5 4 6"})]})}function Fl(e){return a.jsxs(D,{...e,children:[a.jsx("rect",{x:"3",y:"5",width:"14",height:"14",rx:"2"}),a.jsx("path",{d:"M17 10l4-2.5v9L17 14"})]})}function st(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function at(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 19c-6.5 0-10-7-10-7a18.5 18.5 0 0 1 5.06-5.94M9.9 4.24A10.94 10.94 0 0 1 12 4c6.5 0 10 7 10 7a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Ul(e){return a.jsxs(D,{...e,children:[a.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"14"}),a.jsx("line",{x1:"8",y1:"7",x2:"8",y2:"17"}),a.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"}),a.jsx("line",{x1:"16",y1:"7",x2:"16",y2:"17"}),a.jsx("line",{x1:"20",y1:"10",x2:"20",y2:"14"})]})}function Kl(e){return a.jsxs(D,{...e,children:[a.jsx("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),a.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),a.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function Vl({containerRef:e,store:n}){var w;const[t,r]=p.useState(null),[o,l]=p.useState(!1),s=p.useRef(null),i=p.useRef(null),c=p.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),u=p.useCallback(()=>{c(),s.current=setTimeout(()=>{r(v=>o?v:null)},250)},[c,o]);p.useEffect(()=>{const v=e.current;if(!v)return;const B=y=>{var I,T,L;const R=(T=(I=y.target).closest)==null?void 0:T.call(I,"[data-run-id]");if(!R||!v.contains(R))return;const j=R.dataset.runId,S=n.getRun(j);(L=S==null?void 0:S.marks)!=null&&L.link&&(c(),r(M=>(M==null?void 0:M.runId)===j?M:{runId:j,rect:R.getBoundingClientRect()}))},C=()=>u();return v.addEventListener("mouseover",B),v.addEventListener("mouseout",C),()=>{v.removeEventListener("mouseover",B),v.removeEventListener("mouseout",C)}},[e,n,c,u]),p.useEffect(()=>()=>c(),[c]);const f=p.useCallback(()=>l(!0),[]),d=p.useCallback(()=>{l(!1),r(null)},[]),b=p.useCallback((v,B)=>{if(!t)return;const C=n.getRun(t.runId);C&&(n.applyOperation(G(t.runId,{marks:{...C.marks,link:{href:v,target:B}}})),d())},[t,n,d]),h=p.useCallback(()=>{if(!t)return;const v=n.getRun(t.runId);if(!v)return;const B={...v.marks};delete B.link,n.applyOperation(G(t.runId,{marks:B})),d()},[t,n,d]),m=t&&n.getRun(t.runId),g=(w=m==null?void 0:m.marks)==null?void 0:w.link,k=!!(t&&g&&!o),x=In(i,k,t?t.rect.bottom+6:null,t?t.rect.left:null);return a.jsxs(a.Fragment,{children:[k&&x?ge.createPortal(a.jsxs("div",{ref:i,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:x.top,left:x.left},onMouseEnter:c,onMouseLeave:u,children:[a.jsx("a",{className:"be-link-hover-card-url",href:g.href,target:g.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:g.href}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:f,"aria-label":"Edit link",title:"Edit link",children:a.jsx(Ll,{size:13})}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:h,"aria-label":"Remove link",title:"Remove link",children:a.jsx(ln,{size:13})})]}),document.body):null,a.jsx(pr,{isOpen:o,initialHref:(g==null?void 0:g.href)??"",initialTarget:(g==null?void 0:g.target)??"_self",hasExistingLink:!!g,onSave:b,onRemove:h,onClose:d})]})}function Ht(e,n){const t=e==null?void 0:e.parentElement;if(!t||!t.hasAttribute("data-placeholder"))return;n.length===0||n.every(cr)?t.setAttribute("data-empty",""):t.removeAttribute("data-empty")}function ql(e={}){return{fontWeight:e.bold?"bold":void 0,fontStyle:e.italic?"italic":void 0,textDecoration:[(e.underline||e.link)&&"underline",e.strike&&"line-through"].filter(Boolean).join(" ")||void 0,verticalAlign:e.subscript?"sub":e.superscript?"super":void 0,fontSize:e.subscript||e.superscript?"smaller":void 0,color:e.color||(e.link?"var(--noteloom-accent)":void 0),backgroundColor:e.highlight||void 0,cursor:e.link?"pointer":void 0}}function Wl(e,n){const t=e.childNodes.length===1?e.firstChild:null;t&&t.nodeType===3?t.nodeValue!==n&&(t.nodeValue=n):e.textContent=n}function Yl({id:e,host:n,onValueSynced:t}){const r=Le(e);return p.useLayoutEffect(()=>{var u;if(!n||!r)return;const o=r.value??"";(ve(n.textContent)!==o||o===""&&n.textContent==="")&&Wl(n,o===""?ir:o);const i=ql(r.marks);n.style.fontWeight=i.fontWeight??"",n.style.fontStyle=i.fontStyle??"",n.style.textDecoration=i.textDecoration??"",n.style.verticalAlign=i.verticalAlign??"",n.style.fontSize=i.fontSize??"",n.style.color=i.color??"",n.style.backgroundColor=i.backgroundColor??"",n.style.cursor=i.cursor??"";const c=(u=r.marks)==null?void 0:u.link;n.title=c!=null&&c.href?`${c.href} — Ctrl+Click to open`:"",n.onclick=c!=null&&c.href?f=>{!f.ctrlKey&&!f.metaKey||(f.preventDefault(),window.open(c.href,c.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,t==null||t()},[n,r,t]),null}function zt(e,n,t,r){var d,b,h;const o=(d=window.getSelection)==null?void 0:d.call(window);if(!o||!o.isCollapsed||o.rangeCount===0)return null;const{anchorNode:l,anchorOffset:s}=o;if(!l||!e.contains(l))return null;const i=m=>{const g=n.indexOf(m);if(g===-1)return null;const k=r?n[g-1]:n[g+1];if(!k)return null;const x=t(k);return x&&x.type!=="text"?k:null};if(l===e){const m=r?s-1:s,g=e.childNodes[m],k=(g==null?void 0:g.nodeType)===1?(b=g.dataset)==null?void 0:b.runId:void 0;if(!k||n.indexOf(k)===-1)return null;const x=t(k);return x&&x.type!=="text"?k:null}const c=l.nodeType===1?l:l.parentElement,u=(h=c==null?void 0:c.closest)==null?void 0:h.call(c,"[data-run-id]");return!u||!e.contains(u)||!(r?s===0:s===(l.textContent??"").length)?null:i(u.getAttribute("data-run-id"))}function Ft(e,n,t){var c,u;const r=(c=window.getSelection)==null?void 0:c.call(window);if(!r||r.isCollapsed||r.rangeCount===0)return null;const o=r.getRangeAt(0);if(o.startContainer!==o.endContainer||!e.contains(o.startContainer)||o.endOffset!==o.startOffset+1)return null;const l=o.startContainer.childNodes[o.startOffset],s=(l==null?void 0:l.nodeType)===1?(u=l.dataset)==null?void 0:u.runId:void 0;if(!s||n.indexOf(s)===-1)return null;const i=t(s);return i&&i.type!=="text"?s:null}function Ut(e,n,t){var i;if(n===e)return{childIndex:t,charOffset:null};const r=n.nodeType===1?n:n.parentElement,o=(i=r==null?void 0:r.closest)==null?void 0:i.call(r,"[data-run-id]");if(!o||!e.contains(o))return null;const l=Array.prototype.indexOf.call(e.childNodes,o),s=n===o?t===0?0:(o.textContent??"").length:t;return{childIndex:l,charOffset:s}}function Gl(e,n,t,r){const o=Ut(e,r.startContainer,r.startOffset),l=Ut(e,r.endContainer,r.endOffset);if(!o||!l)return null;const s=Array.from(e.childNodes).filter(f=>{var d;return f.nodeType===1&&((d=f.dataset)==null?void 0:d.runId)&&n.indexOf(f.dataset.runId)!==-1});let i=!1;const c=[];let u=null;return s.forEach((f,d)=>{const b=f.dataset.runId,h=t(b);if(!h)return;const m=d<o.childIndex,g=l.charOffset===null?d>=l.childIndex:d>l.childIndex;if(m||g){c.push(h);return}const k=o.charOffset!==null&&d===o.childIndex,x=l.charOffset!==null&&d===l.childIndex;if(h.type!=="text"){i=!0,u===null&&(u=c.length);return}const w=h.value??"";if(k&&x){const v=w.slice(0,o.charOffset)+w.slice(l.charOffset);v&&c.push({...h,value:v}),u=c.length}else if(k){const v=w.slice(0,o.charOffset);v&&c.push({...h,value:v}),u===null&&(u=c.length)}else if(x){const v=w.slice(l.charOffset);v&&c.push({id:E(),type:"text",value:v,marks:h.marks})}}),i?{nextRuns:c,insertionIndex:u??c.length}:null}function Jl(e){var l;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||!n.isCollapsed)return!1;const t=e.firstChild;if(!t)return!0;if(n.anchorNode===e)return n.anchorOffset===0;let r=t;for(;r&&r.firstChild;)r=r.firstChild;if(n.anchorNode!==r&&n.anchorNode!==t)return!1;const o=r.nodeType===3&&r.textContent===ir?1:0;return n.anchorOffset<=o}function Xl(e){var l;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||!n.isCollapsed)return!1;const t=e.lastChild;if(!t)return!0;if(n.anchorNode===e)return n.anchorOffset>=e.childNodes.length;let r=t;for(;r&&r.lastChild;)r=r.lastChild;if(n.anchorNode!==r&&n.anchorNode!==t)return!1;const o=r.nodeType===3?(r.textContent??"").length:0;return n.anchorOffset>=o}function Kt(e,n,t){const r=e.getBlock(n),o=e.getBlock(r==null?void 0:r.parentId);if(!o)return null;const l=o.contentIds.indexOf(n),s=t==="backward"?l-1:l+1;if(s<0||s>=o.contentIds.length)return null;const i=o.contentIds[s];return on(e,e.getBlock(i))?i:null}function Ql({id:e,blockId:n,host:t,inlineRegistry:r,onValueSynced:o}){const l=Le(e);if(!l)return null;if(l.type==="text")return a.jsx(Yl,{id:e,host:t,onValueSynced:o});const s=r==null?void 0:r.get(l.type);if(!s)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No inline type registered for "${l.type}" (run: ${e})`),null;const i=s.component;return a.jsx(i,{id:e,blockId:n})}function Zl(e,n,t){let r=e.get(t);if(!r){r=document.createElement("span"),r.dataset.runId=t;const o=n.getRun(t);o&&o.type!=="text"&&r.setAttribute("contenteditable","false"),e.set(t,r)}return r}function Re({blockId:e,runIds:n,dir:t="auto",onEnter:r,onBackspaceAtStart:o,onDeleteAtEnd:l,onArrowUp:s,onArrowDown:i,onTab:c,onShiftTab:u,onAutoformat:f}){const d=_(),b=ye(),{getSelectedBlockId:h,setSelectedBlockId:m}=Ce(),g=p.useRef(null),k=p.useRef(!1),x=p.useRef(new Map);p.useLayoutEffect(()=>{const I=g.current;if(!I)return;const T=new Set(n);for(const[M,A]of x.current)T.has(M)||(A.remove(),x.current.delete(M));let L=null;for(const M of n){const A=x.current.get(M);if(!A)continue;const P=L?L.nextSibling:I.firstChild;P!==A&&I.insertBefore(A,P),L=A}},[n]);const w=p.useCallback(()=>{if(k.current)return;const I=g.current;if(!I)return;const T=n.map(P=>d.getRun(P)).filter(Boolean),{runs:L,changed:M,onlyValueChanges:A}=Tl(I,T);if(M){if(A){if(L.forEach((P,X)=>{P!==T[X]&&d.applyOperation(G(P.id,{value:P.value}))}),f!=null&&f(L))return}else d.applyOperation(ue(e,L.length?L:[{id:E(),type:"text",value:"",marks:{}}]));Ht(I,L)}},[d,e,n,f]),v=p.useCallback(()=>{Ht(g.current,n.map(I=>d.getRun(I)).filter(Boolean))},[d,n]),B=p.useCallback(()=>{k.current=!0},[]),C=p.useCallback(()=>{k.current=!1,w()},[w]),y=p.useCallback(I=>{const L=n.map(M=>d.getRun(M)).filter(Boolean).filter(M=>M.id!==I);d.applyOperation(ue(e,L.length?L:[{id:E(),type:"text",value:"",marks:{}}]))},[d,e,n]),R=p.useCallback(I=>{h()===I?(d.applyOperation($(I)),m(null)):m(I)},[d,h,m]),j=p.useCallback(I=>{var pe,Y,se,te;if(k.current)return;if(I.target instanceof Node){const O=I.target.nodeType===1?I.target:I.target.parentElement;if((pe=O==null?void 0:O.closest)!=null&&pe.call(O,'[contenteditable="false"]'))return}const T=I.inputType??"",L=T.startsWith("delete"),M=T==="insertText"||T==="insertReplacementText";if(!L&&!M)return;const A=g.current;if(!A)return;const P=(Y=I.getTargetRanges)==null?void 0:Y.call(I),X=(se=window.getSelection)==null?void 0:se.call(window),J=(P==null?void 0:P[0])??(X!=null&&X.rangeCount?X.getRangeAt(0):null);if(!J||!A.contains(J.startContainer)||!A.contains(J.endContainer))return;const H=Gl(A,n,O=>d.getRun(O),J);if(!H)return;I.preventDefault();let{nextRuns:W,insertionIndex:N}=H,U=null,K=!1;if(M&&I.data){const O={id:E(),type:"text",value:I.data,marks:{}};W=[...W.slice(0,N),O,...W.slice(N)],U=O.id,K=!1}else N>0?(U=(te=W[N-1])==null?void 0:te.id,K=!1):W.length>0&&(U=W[0].id,K=!0);const q=W.length?W:[{id:E(),type:"text",value:"",marks:{}}];d.applyOperation(ue(e,q));const re=U??q[0].id;K?vn(re):ee(re)},[d,e,n]);p.useEffect(()=>{const I=g.current;if(I)return I.addEventListener("beforeinput",j),()=>I.removeEventListener("beforeinput",j)},[j]);const S=p.useCallback(I=>{if(!k.current){if(I.key==="Enter"&&r){I.preventDefault(),r(I);return}if(I.key==="Backspace"){const T=g.current,L=T&&Ft(T,n,d.getRun.bind(d));if(L){I.preventDefault(),y(L);return}const M=T&&zt(T,n,d.getRun.bind(d),!0);if(M){I.preventDefault(),y(M);return}if(T&&Jl(T)){if(!de(d,n)){const P=Kt(d,e,"backward");if(P){I.preventDefault(),R(P);return}}I.preventDefault(),o&&o(I)}return}if(I.key==="Delete"){const T=g.current,L=T&&Ft(T,n,d.getRun.bind(d));if(L){I.preventDefault(),y(L);return}const M=T&&zt(T,n,d.getRun.bind(d),!1);if(M){I.preventDefault(),y(M);return}if(T&&Xl(T)){const A=Kt(d,e,"forward");if(A){I.preventDefault(),R(A);return}l&&l(I)}return}if(I.key==="ArrowUp"&&s){I.preventDefault(),s(I);return}if(I.key==="ArrowDown"&&i){I.preventDefault(),i(I);return}I.key==="Tab"&&(I.shiftKey&&u?(I.preventDefault(),u(I)):!I.shiftKey&&c&&(I.preventDefault(),c(I)))}},[r,o,l,s,i,c,u,y,R,n,e,d]);return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:g,className:"be-editable",dir:t,contentEditable:!0,suppressContentEditableWarning:!0,onInput:w,onCompositionStart:B,onCompositionEnd:C,onKeyDown:S,children:n.map(I=>{const T=Zl(x.current,d,I);return ge.createPortal(a.jsx(Ql,{id:I,blockId:e,host:T,inlineRegistry:b,onValueSynced:v},I),T)})}),a.jsx(Vl,{containerRef:g,store:d})]})}function es(e,n,t){const r=e.getBlock(n),o=r&&e.getBlock(r.parentId);if(!o)return null;const l=o.contentIds.indexOf(n),s=t==="up"?l-1:l+1;return s<0||s>=o.contentIds.length?null:o.contentIds[s]}function Sr(e,n,t){let r=n;for(;;){const o=es(e,r,t);if(!o)return null;const l=t==="up"?Rn(e,o):it(e,o);if(l)return l;r=o}}function ie(e,n,t){const r=Sr(e,n,t);r&&ee(r)}function it(e,n){var l;const t=e.getBlock(n);if(!t)return null;const r=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!r||r.length===0)return null;const o=r[0];return e.getRun(o)?o:it(e,o)}function oe(e,n){const t=it(e,n);t&&ee(t)}function Rn(e,n){var l;const t=e.getBlock(n);if(!t)return null;const r=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!r||r.length===0)return null;const o=r[r.length-1];return e.getRun(o)?o:Rn(e,o)}function Vt(e,n){const t=Rn(e,n);t&&ee(t)}function ns(){var i,c;const e=(i=window.getSelection)==null?void 0:i.call(window);if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(n.collapsed||n.startContainer!==n.endContainer)return null;const t=n.startContainer,r=t.nodeType===1?t:t.parentElement,o=(c=r==null?void 0:r.closest)==null?void 0:c.call(r,"[data-run-id]");if(!o)return null;const l=o.closest("[data-block-id]");if(!l)return null;const s=t.textContent??"";return{runId:o.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),startOffset:ve(s.slice(0,n.startOffset)).length,endOffset:ve(s.slice(0,n.endOffset)).length}}function ts(e,n){var i,c;if((e==null?void 0:e.nodeType)!==1||((i=e.getAttribute)==null?void 0:i.call(e,"contenteditable"))!=="true")return null;const t=e.childNodes;if(t.length===0)return null;const r=n>=t.length,o=t[r?t.length-1:Math.max(0,n)],l=(o==null?void 0:o.nodeType)===1?(c=o.dataset)==null?void 0:c.runId:void 0;if(!l)return null;const s=o.closest("[data-block-id]");return s?{runId:l,blockId:s.getAttribute("data-block-id"),offset:r?ve(o.textContent??"").length:0}:null}function en(e,n){var i;const t=ts(e,n);if(t)return t;let r=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;const o=(i=r==null?void 0:r.closest)==null?void 0:i.call(r,"[data-run-id]");if(!o)return null;const l=o.closest("[data-block-id]");if(!l)return null;let s=ve((e.textContent??"").slice(0,n)).length;if(e===o){s=0;for(let c=0;c<n&&c<o.childNodes.length;c+=1)s+=ve(o.childNodes[c].textContent??"").length}return{runId:o.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),offset:s}}function we(){var n;const e=(n=window.getSelection)==null?void 0:n.call(window);return!e||e.rangeCount===0||!e.isCollapsed?null:en(e.anchorNode,e.anchorOffset)}function Ve(){var r;const e=(r=window.getSelection)==null?void 0:r.call(window);if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=en(e.anchorNode,e.anchorOffset),t=en(e.focusNode,e.focusOffset);return!n||!t||n.blockId!==t.blockId?null:{blockId:n.blockId,startRunId:n.runId,startOffset:n.offset,endRunId:t.runId,endOffset:t.offset}}function He(e){var d;const n=(d=window.getSelection)==null?void 0:d.call(window);if(!n||n.rangeCount===0||n.isCollapsed)return null;const t=en(n.anchorNode,n.anchorOffset),r=en(n.focusNode,n.focusOffset);if(!t||!r||t.blockId===r.blockId)return null;const o=e.getBlock(t.blockId),l=o&&e.getBlock(o.parentId);if(!l)return null;const s=l.contentIds,i=s.indexOf(t.blockId),c=s.indexOf(r.blockId);if(i===-1||c===-1)return null;const[u,f]=i<=c?[i,c]:[c,i];return{blockIds:s.slice(u,f+1),startBlockId:t.blockId,startRunId:t.runId,startOffset:t.offset,endBlockId:r.blockId,endRunId:r.runId,endOffset:r.offset}}function ct(e,n,t){const o=e.getBlock(n).parentId,s=e.getBlock(o).contentIds.indexOf(n)+1,{block:i,runs:c=[],subtreeBlocks:u=[]}=t(o);return e.applyOperation(Q(i,o,s,{blocks:[i,...u],runs:c})),i.id}function Te(e,n,t){const r=ct(e,n,t);return oe(e,r),r}function rs(e,n,t){const{block:r,runs:o=[],subtreeBlocks:l=[]}=t(n);return e.applyOperation(Q(r,n,0,{blocks:[r,...l],runs:o})),oe(e,r.id),r.id}function Er(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function os(e,n,t){const r=e.findIndex(u=>u.id===n);if(r===-1)return null;const o=e[r],l=e.slice(0,r),s=e.slice(r+1);if(o.type==="text"){const u=o.value??"",f=u.slice(0,t),d=u.slice(t);f&&d?(l.push({...o,value:f}),s.unshift({...o,id:E(),value:d})):d?s.unshift(o):l.push(o)}else t>0?l.push(o):s.unshift(o);const i=l.length?l:[{id:E(),type:"text",value:"",marks:{}}],c=s.length?s:[{id:E(),type:"text",value:"",marks:{}}];return{leftRuns:i,rightRuns:c}}function qe(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.parentId),s=l.contentIds.indexOf(n)+1;return Or(e,n,t,r,{insertParentId:l.id,insertIndex:s,fallback:()=>Te(e,n,r)})}function Lr(e,n,t,r){return Or(e,n,t,r,{insertParentId:n,insertIndex:0,fallback:()=>rs(e,n,r)})}function Or(e,n,t,r,{insertParentId:o,insertIndex:l,fallback:s}){const i=we();if(!i||i.blockId!==n)return s();const c=t.map(k=>e.getRun(k)).filter(Boolean),u=os(c,i.runId,i.offset);if(!u)return s();const{leftRuns:f,rightRuns:d}=u,{block:b,runs:h=d,subtreeBlocks:m=[]}=r(o,d),g=f.length?f:[{id:E(),type:"text",value:"",marks:{}}];return Er(e,[ue(n,g),Q(b,o,l,{blocks:[b,...m],runs:h})]),oe(e,b.id),b.id}function ls(e){var n;return((n=e==null?void 0:e.props)==null?void 0:n.titleRunIds)??(e==null?void 0:e.contentIds)??[]}function ss(e){var n,t;return!!((n=e==null?void 0:e.props)!=null&&n.titleRunIds)&&(((t=e.contentIds)==null?void 0:t.length)??0)>0}function as(e,n,t){const o=e.getBlock(n).parentId,s=e.getBlock(o).contentIds.indexOf(n),{block:i,runs:c=[],subtreeBlocks:u=[]}=t(o);return Er(e,[$(n),Q(i,o,s,{blocks:[i,...u],runs:c})]),oe(e,i.id),i.id}function ae(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},l){const s=e.getRun(t),i=(s==null?void 0:s.value)??"",c=i.slice(0,r)+i.slice(o),u=e.getBlock(n),f=ls(u);return f.length===1&&f[0]===t&&c===""&&!ss(u)?as(e,n,l):(e.applyOperation(G(t,{value:c})),Te(e,n,l))}function z(e,n={}){return function(r,o){const l=E(),s=o!=null&&o.length?o:[{id:E(),type:"text",value:"",marks:{}}];return{block:{id:l,type:e,parentId:r,contentIds:s.map(i=>i.id),props:n},runs:s}}}function We(e){const n=e.getRootId(),t=e.getBlock(n);if(!t||t.contentIds.length>0)return null;const{block:r,runs:o}=z("paragraph")(n);return e.applyOperation(Q(r,n,0,{blocks:[r],runs:o})),r.id}const is=new Set(["callout"]),qt=new Set(["paragraph","heading","blockquote"]);function Nr(e,n){return e===n||qt.has(e)&&qt.has(n)}function sn(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.contentIds.length===0||t.contentIds.length===1&&cs(e,t.contentIds[0]);if(o<=0){if(!l)return null;if(r.contentIds.length>1)return _e(e,[$(n)]),e.getBlock(r.id).contentIds[0];if(is.has(r.type))return us(e,r);if(t.type==="paragraph")return null;const{block:u,runs:f}=z("paragraph")(r.id);return _e(e,[Q(u,r.id,o,{blocks:[u],runs:f}),$(n)]),u.id}const s=r.contentIds[o-1],i=e.getBlock(s);if(l)return _e(e,[$(n)]),s;if(on(e,i))return _e(e,[$(s)]),n;if(!i||!Nr(i.type,t.type))return null;const c=[...i.contentIds,...t.contentIds];return _e(e,[$e(s,c),$e(n,[]),$(n)]),s}function cs(e,n){const t=e.getRun(n);return!t||(t.value??"")===""}function us(e,n){const t=e.getBlock(n.parentId);if(!t)return null;const r=t.contentIds.indexOf(n.id),o=r>0?t.contentIds[r-1]:null,l=r!==-1&&r<t.contentIds.length-1?t.contentIds[r+1]:null;_e(e,[$(n.id)]);const s=We(e);return o??l??s}function _e(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Ye(e,n,t,r){if(!n||n===t)return;const o=Rn(e,n);if(o){ee(o);return}r(n),requestAnimationFrame(()=>{var l;(l=document.querySelector(`[data-block-id="${n}"]`))==null||l.focus()})}function Ie(e,n){var r,o;if(!n)return"auto";if((r=n.props)!=null&&r.dir)return n.props.dir;const t=e.getBlock(e.getRootId());return((o=t==null?void 0:t.props)==null?void 0:o.dir)??"auto"}function ut(e,n,t,r,o,l){const s=e.getBlock(n),c=e.getBlock(s.parentId).contentIds.indexOf(n),u="titleRunIds"in r,f="titleRunIds"in(s.props??{}),d=l?!l.isLeaf(s.type)&&s.contentIds.length>0:!1,b={id:E(),type:t,parentId:s.parentId,contentIds:[],props:r},h=u?F(b.id,{titleRunIds:o}):$e(b.id,o),m=[Q(b,s.parentId,c,{blocks:[b],runs:[]}),h];return d&&(!l.isLeaf(t)?s.contentIds.forEach((k,x)=>m.push(ke(k,b.id,x))):s.contentIds.forEach((k,x)=>m.push(ke(k,s.parentId,c+1+x)))),f?m.push(F(n,{titleRunIds:[]})):d||m.push($e(n,[])),m.push($(n)),{newBlockId:b.id,ops:m}}function ds(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}const ps=[{re:/^(#{1,3})[  ]$/,type:"heading",props:e=>({level:e[1].length})},{re:/^[-*][  ]$/,type:"listItem",props:()=>({ordered:!1,titleRunIds:[]})},{re:/^\d+\.[  ]$/,type:"listItem",props:()=>({ordered:!0,titleRunIds:[]})},{re:/^\[\][  ]$/,type:"listItem",props:()=>({ordered:!1,checked:!1,titleRunIds:[]})},{re:/^>[  ]$/,type:"blockquote",props:()=>({})},{re:/^```$/,type:"code",props:()=>({language:"plaintext"})}];function fs(e,n,t){if(t.length!==1||t[0].type!=="text")return!1;const r=t[0].value??"";for(const o of ps){const l=o.re.exec(r);if(!l)continue;const s=r.slice(l[0].length),{ops:i}=ut(e,n,o.type,o.props(l),[t[0].id]);return ds(e,[G(t[0].id,{value:s}),...i]),vn(t[0].id),!0}return!1}const bs=new Set(["callout","toggleHeading"]);function ms({id:e}){const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),o=p.useCallback(()=>{const b=n.getBlock(t==null?void 0:t.parentId),h=de(n,(t==null?void 0:t.contentIds)??[]),m=!!b&&b.contentIds[b.contentIds.length-1]===e;if(h&&m&&bs.has(b==null?void 0:b.type)){Te(n,b.id,z("paragraph"));return}qe(n,e,(t==null?void 0:t.contentIds)??[],z("paragraph"))},[n,e,t]),l=p.useCallback(()=>{var k,x;const b=n.getBlock(t==null?void 0:t.parentId),h=de(n,(t==null?void 0:t.contentIds)??[]),m=((k=b==null?void 0:b.contentIds)==null?void 0:k.length)===1&&b.contentIds[0]===e;if(h&&m&&(b==null?void 0:b.type)==="toggleHeading"){const w=((x=b.props)==null?void 0:x.titleRunIds)??[],v=w[w.length-1];v&&ee(v);return}const g=sn(n,e);Ye(n,g,e,r)},[n,e,t,r]),s=p.useCallback(()=>ie(n,e,"up"),[n,e]),i=p.useCallback(()=>ie(n,e,"down"),[n,e]),c=p.useCallback(b=>fs(n,e,b),[n,e]),u=le("be-paragraph",t);if(!t)return null;const f=de(n,t.contentIds),d=Ie(n,t);return a.jsx("div",{className:u,"data-block-id":e,"data-empty":f?"":void 0,"data-placeholder":"Type '/' for commands",dir:d,children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:d,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:i,onAutoformat:c})})}function ze(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fe(e){return ze(e).replace(/"/g,"&quot;")}function je(e,n){var o,l;if(!e)return"";if(e.type!=="text"){const s=(o=n==null?void 0:n.inlineRegistry)==null?void 0:o.get(e.type);return s?s.toHTML(e,n):ze(e.value??"")}const t=e.marks??{};let r=ze(e.value??"");if(t.code&&(r=`<code>${r}</code>`),t.bold&&(r=`<strong>${r}</strong>`),t.italic&&(r=`<em>${r}</em>`),t.underline&&(r=`<u>${r}</u>`),t.strike&&(r=`<s>${r}</s>`),t.subscript&&(r=`<sub>${r}</sub>`),t.superscript&&(r=`<sup>${r}</sup>`),t.color&&(r=`<span style="color:${fe(t.color)}">${r}</span>`),t.highlight&&(r=`<span style="background-color:${fe(t.highlight)}">${r}</span>`),(l=t.link)!=null&&l.href){const s=t.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";r=`<a href="${fe(t.link.href)}"${s}>${r}</a>`}return r}function An(e,n){return(e??[]).map(t=>je(t,n)).join("")}function Oe(e,n){var t;if(!e)return"";if(e.type!=="text"){const r=(t=n==null?void 0:n.inlineRegistry)==null?void 0:t.get(e.type);return r?r.toPlainText(e,n):e.value??""}return e.value??""}const hs={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function me(e,n,t={}){const r=[],o=(l,s)=>{var u,f;if(l.nodeType===3){const d=l.textContent;d&&r.push({id:E(),type:"text",value:d,marks:{...s}});return}if(l.nodeType!==1)return;if(n!=null&&n.inlineRegistry)for(const d of n.inlineRegistry.listHtmlMatchers()){const b=d.fromHTML(l,n);if(b){r.push(b);return}}let i=s;const c=hs[l.tagName];c&&(i={...i,[c]:!0}),l.tagName==="A"&&l.getAttribute("href")&&(i={...i,link:{href:l.getAttribute("href"),target:l.getAttribute("target")==="_blank"?"_blank":"_self"}}),(u=l.style)!=null&&u.color&&(i={...i,color:l.style.color}),(f=l.style)!=null&&f.backgroundColor&&(i={...i,highlight:l.style.backgroundColor});for(const d of l.childNodes)o(d,i)};return o(e,t),r.length?r:[{id:E(),type:"text",value:"",marks:{}}]}function gs(e,n){return`<p>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>je(r,n)).join("")}</p>`}function ks(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function xs(e,n){if(e.tagName!=="P")return null;const t=me(e,n);return{block:{id:E(),type:"paragraph",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}const Mr={component:ms,isLeaf:!0,defaultProps:{},toHTML:gs,toPlainText:ks,fromHTML:xs,slashCommand:{label:"Text",icon:yr,keywords:["paragraph","text","p"],run:(e,n)=>ae(e,n,z("paragraph"))}};function ys({id:e}){var h;const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),o=p.useCallback(()=>{qe(n,e,(t==null?void 0:t.contentIds)??[],z("paragraph"))},[n,e,t]),l=p.useCallback(()=>{const m=sn(n,e);Ye(n,m,e,r)},[n,e,r]),s=p.useCallback(()=>ie(n,e,"up"),[n,e]),i=p.useCallback(()=>ie(n,e,"down"),[n,e]),c=((h=t==null?void 0:t.props)==null?void 0:h.level)??3,u=le(`be-heading be-heading-${c}`,t);if(!t)return null;const f=`h${c}`,d=de(n,t.contentIds),b=Ie(n,t);return a.jsx(f,{className:u,"data-block-id":e,"data-empty":d?"":void 0,"data-placeholder":`Heading ${c}`,dir:b,children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:b,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:i})})}const Dn={1:vr,2:wr,3:Ir},vs={H1:1,H2:2,H3:3};function ws(e,n){var o;const t=((o=e.props)==null?void 0:o.level)??3,r=e.contentIds.map(l=>n.store.getRun(l));return`<h${t}>${r.map(l=>je(l,n)).join("")}</h${t}>`}function Is(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function Cs(e,n){const t=vs[e.tagName];if(!t)return null;const r=me(e,n);return{block:{id:E(),type:"heading",parentId:null,contentIds:r.map(l=>l.id),props:{level:t}},runs:r}}const Ar={component:ys,isLeaf:!0,defaultProps:{level:3},toHTML:ws,toPlainText:Is,fromHTML:Cs,slashCommands:[{label:"Heading 1",icon:Dn[1],keywords:["heading","h1","title"],run:(e,n)=>ae(e,n,z("heading",{level:1}))},{label:"Heading 2",icon:Dn[2],keywords:["heading","h2","subtitle"],run:(e,n)=>ae(e,n,z("heading",{level:2}))},{label:"Heading 3",icon:Dn[3],keywords:["heading","h3","title"],run:(e,n)=>ae(e,n,z("heading",{level:3}))}]},Bs=[];function dt(e){const n=_(),t=p.useCallback(o=>n.subscribe(e,o),[n,e]),r=p.useCallback(()=>{const o=n.getBlock(e);return o?o.contentIds:Bs},[n,e]);return p.useSyncExternalStore(t,r)}class Dr extends p.Component{constructor(){super(...arguments);Mt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){var o,l;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",t,r),(l=(o=this.props).onError)==null||l.call(o,t,r),queueMicrotask(()=>this.setState(s=>({hasError:!1,nonce:s.nonce+1})))}render(){return this.state.hasError?null:a.jsx(p.Fragment,{children:this.props.children},this.state.nonce)}}const pt=p.memo(function({id:n}){const t=ne(n),r=Ee();if(!t)return null;const o=r.get(t.type);if(!o)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${t.type}" (id: ${n})`),null;const l=o.component;return a.jsx(Dr,{children:a.jsx(l,{id:n})})});function an(e,n,t){p.useEffect(()=>{if(!n)return;const r=Array.isArray(e)?e:[e],o=s=>{r.some(c=>c.current&&c.current.contains(s.target))||t()},l=s=>{s.key==="Escape"&&t()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",l)}},[n,t,e])}function Tn(e,n,t,r){const o=p.useRef(!1),l=p.useRef(!1);p.useEffect(()=>{var f,d;if(!n){l.current=!1,o.current&&(o.current=!1,(d=(f=r==null?void 0:r.current)==null?void 0:f.focus)==null||d.call(f));return}o.current=!0;const s=e.current;if(!s)return;const i=()=>Array.from(s.querySelectorAll('[role="menuitem"]')),c=b=>{var g;const h=i();if(h.length===0)return;const m=(b%h.length+h.length)%h.length;(g=h[m])==null||g.focus()};l.current||(l.current=!0,c(0));const u=b=>{if(b.key==="Escape"){b.preventDefault(),t();return}const h=i(),m=h.indexOf(document.activeElement);m!==-1&&(b.key==="ArrowDown"?(b.preventDefault(),c(m+1)):b.key==="ArrowUp"?(b.preventDefault(),c(m-1)):b.key==="Home"?(b.preventDefault(),c(0)):b.key==="End"&&(b.preventDefault(),c(h.length-1)))};return s.addEventListener("keydown",u),()=>s.removeEventListener("keydown",u)})}const Wt="be-live-region";function Rs(){if(typeof document>"u")return null;let e=document.getElementById(Wt);return e||(e=document.createElement("div"),e.id=Wt,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(e),e)}function Z(e){const n=Rs();n&&(n.textContent="",setTimeout(()=>{n.textContent=e},0))}const Ge="💡",_r="gray";function Ts({icon:e=Ge,color:n=_r}={}){return function(r){const o=E(),{block:l,runs:s}=z("paragraph")(o);return{block:{id:o,type:"callout",parentId:r,contentIds:[l.id],props:{icon:e,color:n}},runs:s,subtreeBlocks:[l]}}}const Pr=[{type:"paragraph",props:{},label:"Text",icon:yr},{type:"heading",props:{level:1},label:"Heading 1",icon:vr},{type:"heading",props:{level:2},label:"Heading 2",icon:wr},{type:"heading",props:{level:3},label:"Heading 3",icon:Ir},{type:"listItem",props:{ordered:!1,titleRunIds:[]},label:"Bulleted list",icon:Rr},{type:"listItem",props:{ordered:!0,titleRunIds:[]},label:"Numbered list",icon:Tr},{type:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]},label:"To-do list",icon:lt},{type:"listItem",props:{ordered:!1,collapsed:!1,titleRunIds:[]},label:"Toggle list",icon:Me},{type:"toggleHeading",props:{level:2,collapsed:!1,titleRunIds:[]},label:"Toggle heading",icon:Me},{type:"blockquote",props:{},label:"Quote",icon:Cr},{type:"callout",props:{icon:Ge},label:"Callout",icon:Br},{type:"code",props:{language:"plaintext"},label:"Code",icon:ot}],js=new Set(Pr.map(e=>e.type));function ft(e){return js.has(e)}function Ss(e){var n;return((n=e==null?void 0:e.props)==null?void 0:n.titleRunIds)??(e==null?void 0:e.contentIds)??[]}function $r(e,n,t,r){const o=e.getBlock(t),l=Ss(o),s=[];if(r.type==="code")for(const f of l){const d=e.getRun(f);d!=null&&d.marks&&Object.keys(d.marks).length>0&&s.push(G(f,{marks:{}}))}const i={...r.props},{ops:c,newBlockId:u}=ut(e,t,r.type,i,l,n);return{ops:[...s,...c],newBlockId:u}}function Hr({onSelect:e,onClose:n,containerRef:t,menuClassName:r="be-block-gutter-menu",itemClassName:o="be-block-gutter-menu-item"}){const[l,s]=p.useState(!1),[i,c]=p.useState(null),u=p.useRef(null),f=p.useRef(null),d=p.useCallback(w=>{f.current=w,t&&(t.current=w)},[t]),b=p.useCallback(()=>{s(!1),n==null||n()},[n]);an([u,f],l,b),Tn(f,l,b,u);const h=In(f,l,i==null?void 0:i.top,i?i.right+4:null),m=p.useCallback(()=>{var w;c(((w=u.current)==null?void 0:w.getBoundingClientRect())??null),s(!0)},[]),g=p.useCallback(w=>{e(w),b()},[e,b]),k=p.useCallback(w=>{w.key==="ArrowRight"&&!l&&(w.preventDefault(),m())},[l,m]),x=p.useCallback(w=>{w.key==="ArrowLeft"&&(w.preventDefault(),b())},[b]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:u,type:"button",role:"menuitem",className:o,"aria-haspopup":"menu","aria-expanded":l,onClick:()=>l?b():m(),onKeyDown:k,children:[a.jsx(Me,{size:15})," Turn into"]}),l&&h&&ge.createPortal(a.jsx("div",{ref:d,role:"menu","aria-label":"Turn into",className:r,style:{position:"fixed",top:h.top,left:h.left},onKeyDown:x,children:Pr.map((w,v)=>{const B=w.icon;return a.jsxs("button",{type:"button",role:"menuitem",className:o,onClick:()=>g(w),children:[a.jsx(B,{size:15})," ",w.label]},`${w.type}-${v}`)})}),document.body)]})}function cn(e,n,t,r){const o={store:e,registry:n,inlineRegistry:r};return{html:Es(e,n,t,o),text:t.map(l=>{const s=e.getBlock(l);return n.get(s.type).toPlainText(s,o)}).join(`
2207
+ `),json:JSON.stringify({version:1,blocks:t.map(l=>bt(e,l))})}}function Es(e,n,t,r){let o="",l=0;for(;l<t.length;){const s=e.getBlock(t[l]);if(s.type==="listItem"){const i=!!s.props.ordered;let c="",u=l;for(;u<t.length;){const d=e.getBlock(t[u]);if(d.type!=="listItem"||!!d.props.ordered!==i)break;c+=n.get("listItem").toHTML(d,r),u+=1}const f=i?"ol":"ul";o+=`<${f}>${c}</${f}>`,l=u}else if(s.type==="blockquote"){let i="",c=l;for(;c<t.length;){const u=e.getBlock(t[c]);if(u.type!=="blockquote")break;i+=n.get("blockquote").toHTML(u,r),c+=1}o+=`<blockquote>${i}</blockquote>`,l=c}else o+=n.get(s.type).toHTML(s,r),l+=1}return o}function bt(e,n){const t=[],r=[],o=l=>{var c;const s=e.getRun(l);if(s){r.push(s);return}const i=e.getBlock(l);if(i){t.push(i);for(const u of i.contentIds)o(u);for(const u of((c=i.props)==null?void 0:c.titleRunIds)??[])o(u)}};return o(n),{rootId:n,blocks:t,runs:r}}function mt({rootId:e,blocks:n,runs:t}){const r=new Map;for(const c of n)r.set(c.id,E());for(const c of t)r.set(c.id,E());const o=c=>r.get(c)??c,l=n.map(c=>{var u;return{...c,id:o(c.id),parentId:c.parentId?o(c.parentId):c.parentId,contentIds:c.contentIds.map(o),props:{...c.props,...(u=c.props)!=null&&u.titleRunIds?{titleRunIds:c.props.titleRunIds.map(o)}:{}}}}),s=t.map(c=>({...c,id:o(c.id)})),i=o(e);return{block:l.find(c=>c.id===i),runs:s,subtreeBlocks:l.filter(c=>c.id!==i)}}function ht(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=bt(e,n),{block:s,runs:i,subtreeBlocks:c}=mt(l);return e.applyOperation(Q(s,r.id,o+1,{blocks:[s,...c],runs:i})),oe(e,s.id),s.id}function gt(e,n){const t=e.getBlock(n),r=t&&e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n);return o<=0?!1:(e.applyOperation(ke(n,r.id,o-1)),!0)}function kt(e,n){const t=e.getBlock(n),r=t&&e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n);return o===-1||o>=r.contentIds.length-1?!1:(e.applyOperation(ke(n,r.id,o+1)),!0)}function jn(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=o>0?r.contentIds[o-1]:null,s=o!==-1&&o<r.contentIds.length-1?r.contentIds[o+1]:null;e.applyOperation($(n));const i=We(e),c=l??s??i;return c&&oe(e,c),c??null}function Ls(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function zr({id:e}){var T;const n=_(),t=Ee(),r=ne(e),[o,l]=p.useState(!1),[s,i]=p.useState(null),c=p.useRef(null),u=p.useRef(null),f=p.useRef(null),d=p.useMemo(()=>[c,u,f],[]),[b]=rn(),h=b.includes(e),m=p.useCallback(()=>l(!1),[]);an(d,o,m),Tn(u,o,m,c);const g=p.useCallback(()=>{var L;i(((L=c.current)==null?void 0:L.getBoundingClientRect())??null),l(!0)},[]),k=In(u,o,(s==null?void 0:s.bottom)!=null?s.bottom+4:null,s==null?void 0:s.left),x=p.useCallback(()=>{Te(n,e,z("paragraph"))},[n,e]),w=p.useCallback(()=>{ht(n,e),Z("Block duplicated"),m()},[n,e,m]),v=p.useCallback(()=>{gt(n,e)&&Z("Block moved up"),m()},[n,e,m]),B=p.useCallback(()=>{kt(n,e)&&Z("Block moved down"),m()},[n,e,m]),C=p.useCallback(()=>{jn(n,e),Z("Block deleted"),m()},[n,e,m]),y=!!((T=r==null?void 0:r.props)!=null&&T.hidden),R=p.useCallback(()=>{n.applyOperation(F(e,{hidden:!y})),Z(y?"Block shown in preview":"Block hidden in preview"),m()},[n,e,y,m]),j=Ie(n,r)==="rtl",S=p.useCallback(()=>{n.applyOperation(F(e,{dir:j?"ltr":"rtl"})),Z(j?"Block set to left-to-right":"Block set to right-to-left"),m()},[n,e,j,m]),I=p.useCallback(L=>{const{ops:M}=$r(n,t,e,L);Ls(n,M),Z(`Turned into ${L.label}`),m()},[n,t,e,m]);return r?a.jsxs("div",{className:`be-block-row${y?" be-block-row-hidden":""}${h?" be-block-row-range-selected":""}`,"data-block-row-id":e,dir:Ie(n,r),children:[a.jsxs("div",{className:`be-block-gutter${o?" be-block-gutter-active":""}`,contentEditable:!1,children:[a.jsx("button",{type:"button",className:"be-block-gutter-btn",onClick:x,"aria-label":"Add block below",children:a.jsx(Zn,{size:16})}),a.jsx("button",{ref:c,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,onClick:()=>o?m():g(),children:a.jsx(Ml,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(pt,{id:e})}),o&&k&&ge.createPortal(a.jsxs("div",{ref:u,role:"menu","aria-label":"Block options",className:"be-block-gutter-menu",style:{position:"fixed",top:k.top,left:k.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:w,children:[a.jsx(et,{size:15})," Duplicate"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:v,children:[a.jsx(nt,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:B,children:[a.jsx(tt,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:R,children:[y?a.jsx(st,{size:15}):a.jsx(at,{size:15}),y?"Show in preview":"Hide in preview"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:S,children:[j?a.jsx(kr,{size:15}):a.jsx(xr,{size:15}),j?"Switch to left-to-right":"Switch to right-to-left"]}),ft(r.type)&&a.jsx(Hr,{onSelect:I,onClose:()=>{},containerRef:f}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:C,children:[a.jsx(Bn,{size:15})," Delete"]})]}),document.body)]}):null}function Ne({parentId:e,isTopLevel:n=!1}){const t=dt(e),r=_(),[o]=Xn(),l=o?t.filter(s=>{var i,c;return!((c=(i=r.getBlock(s))==null?void 0:i.props)!=null&&c.hidden)}):t;return n&&!o?l.map(s=>a.jsx(zr,{id:s},s)):l.map(s=>a.jsx(pt,{id:s},s))}const Os=97,Ns=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function Ms(e){let n="";for(;e>0;)e-=1,n=String.fromCharCode(Os+e%26)+n,e=Math.floor(e/26);return n}function As(e){let n="",t=e;for(const[r,o]of Ns)for(;t>=r;)n+=o,t-=r;return n}function Ds(e){var n,t;return(e==null?void 0:e.type)==="listItem"&&((n=e.props)==null?void 0:n.checked)===void 0&&((t=e.props)==null?void 0:t.collapsed)===void 0}function Yt(e,n){let t=0,r=n;for(;r;){const o=e.getBlock(r.parentId);if(!o||o.type!=="listItem")break;t+=1,r=o}return t}function _s(e,n,t){const r=t.indexOf(n.id);let o=1;for(let l=r-1;l>=0;l-=1){const s=e.getBlock(t[l]);if(!Ds(s)||!s.props.ordered)break;o+=1}return o}function Ps(e,n){const t=(e%3+3)%3;return t===0?`${n}.`:t===1?`${Ms(n)}.`:`${As(n)}.`}const $s=["•","◦","▪"];function Hs(e){const n=(e%3+3)%3;return $s[n]}function Qe({ordered:e=!1,checked:n,collapsed:t}={}){return function(o,l){const s=E(),i=l!=null&&l.length?l:[{id:E(),type:"text",value:"",marks:{}}],c={ordered:e,titleRunIds:i.map(b=>b.id)};n!==void 0&&(c.checked=n);let u=[],f=[],d=i;if(t!==void 0){c.collapsed=t;const{block:b,runs:h}=z("paragraph")(s);u=[b.id],f=[b],d=[...i,...h]}return{block:{id:s,type:"listItem",parentId:o,contentIds:u,props:c},runs:d,subtreeBlocks:f}}}function zs(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=o>0?r.contentIds[o-1]:null,s=l?e.getBlock(l):null;if(!s||s.type!=="listItem"){ie(e,n,"down");return}e.applyOperation(ke(n,l,s.contentIds.length)),oe(e,n)}function $n(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId);if(!r||r.type!=="listItem")return;const o=r.parentId,s=e.getBlock(o).contentIds.indexOf(r.id);e.applyOperation(ke(n,o,s+1)),oe(e,n)}function Je(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Fr(e,n){var t;return n.length===0||n.length===1&&(((t=e.getRun(n[0]))==null?void 0:t.value)??"")===""}function Fs(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const r=e.getBlock(t[0]);return!!r&&r.type==="paragraph"&&de(e,r.contentIds)}function Us(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.props.titleRunIds??[],i=Fr(e,l)&&Fs(e,t);if(o>0){const f=r.contentIds[o-1],d=e.getBlock(f);if(i)return Je(e,[$(n)]),{focusBlockId:f,needsRefocus:!0};if(on(e,d))return Je(e,[$(f)]),{focusBlockId:n,needsRefocus:!1};if((d==null?void 0:d.type)==="listItem"&&t.contentIds.length===0){const b=[...d.props.titleRunIds??[],...l];return Je(e,[F(f,{titleRunIds:b}),F(n,{titleRunIds:[]}),$(n)]),{focusBlockId:f,needsRefocus:!0}}return null}if(r.type==="listItem")return $n(e,n),{focusBlockId:n,needsRefocus:!0};if(!i)return null;if(r.contentIds.length>1)return Je(e,[$(n)]),{focusBlockId:e.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:c,runs:u}=z("paragraph")(r.id);return Je(e,[Q(c,r.id,o,{blocks:[c],runs:u}),$(n)]),{focusBlockId:c.id,needsRefocus:!0}}function Ks(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Vs(e,n){const r=e.getBlock(n).parentId,l=e.getBlock(r).contentIds.indexOf(n),{block:s,runs:i}=z("paragraph")(r);return Ks(e,[Q(s,r,l,{blocks:[s],runs:i}),F(n,{titleRunIds:[]}),$(n)]),oe(e,s.id),s.id}function qs(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Ws({id:e}){var R,j;const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),o=dt(t==null?void 0:t.parentId),l=p.useCallback(()=>{var X,J,H,W,N;const S=((X=t==null?void 0:t.props)==null?void 0:X.titleRunIds)??[],I=n.getBlock(t==null?void 0:t.parentId),T=Fr(n,S);if(T&&(I==null?void 0:I.type)==="listItem"){$n(n,e);return}const L=(((J=t==null?void 0:t.contentIds)==null?void 0:J.length)??0)>0;if(T&&(I==null?void 0:I.type)!=="listItem"&&!L){Vs(n,e);return}const M=((H=t==null?void 0:t.props)==null?void 0:H.checked)!==void 0,A=((W=t==null?void 0:t.props)==null?void 0:W.collapsed)!==void 0,P=Qe({ordered:(N=t==null?void 0:t.props)==null?void 0:N.ordered,checked:M?!1:void 0,collapsed:A?!1:void 0});L&&!A?Lr(n,e,S,P):qe(n,e,S,P)},[n,e,t]),s=p.useCallback(()=>zs(n,e),[n,e]),i=p.useCallback(()=>$n(n,e),[n,e]),c=p.useCallback(()=>{const S=Us(n,e);!S||!S.needsRefocus||Ye(n,S.focusBlockId,e,r)},[n,e,r]),u=p.useCallback(()=>ie(n,e,"up"),[n,e]),f=p.useCallback(()=>ie(n,e,"down"),[n,e]),d=p.useCallback(()=>{var S;n.applyOperation(F(e,{checked:!((S=t==null?void 0:t.props)!=null&&S.checked)}))},[n,e,(R=t==null?void 0:t.props)==null?void 0:R.checked]),b=p.useCallback(()=>{var I,T;if(!((((I=t==null?void 0:t.contentIds)==null?void 0:I.length)??0)>0)){const{block:L,runs:M}=z("paragraph")(e);qs(n,[Q(L,e,0,{blocks:[L],runs:M}),F(e,{collapsed:!1})]),ee(L.contentIds[0]);return}n.applyOperation(F(e,{collapsed:!((T=t==null?void 0:t.props)!=null&&T.collapsed)}))},[n,e,t==null?void 0:t.contentIds,(j=t==null?void 0:t.props)==null?void 0:j.collapsed]),h=le("be-list-item",t);if(!t)return null;const{ordered:m,checked:g,collapsed:k,titleRunIds:x=[]}=t.props,w=g!==void 0,v=!w&&k!==void 0,B=t.contentIds.length>0,C=x.map(S=>n.getRun(S)).filter(S=>(S==null?void 0:S.type)==="text").map(S=>S.value).join("").trim(),y=Ie(n,t);return a.jsxs("div",{className:h,"data-block-id":e,dir:y,children:[a.jsxs("div",{className:"be-list-item-row",children:[w?a.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!g,onChange:d,"aria-label":C||"To-do item"}):v?a.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:b,"aria-expanded":!k,"aria-label":B?k?"Expand toggle":"Collapse toggle":"Add content to toggle",children:k?a.jsx(Me,{}):a.jsx(Cn,{})}):a.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:m?Ps(Yt(n,t),_s(n,t,o)):Hs(Yt(n,t))}),a.jsx("div",{className:"be-list-item-title","data-empty":de(n,x)?"":void 0,"data-placeholder":w?"To-do":v?"Toggle":"List item",style:g?{textDecoration:"line-through",opacity:.6}:void 0,children:a.jsx(Re,{blockId:e,runIds:x,dir:y,onEnter:l,onTab:s,onShiftTab:i,onBackspaceAtStart:c,onArrowUp:u,onArrowDown:f})})]}),(!v||!k)&&a.jsx("div",{className:"be-list-item-children",children:a.jsx(Ne,{parentId:e})})]})}function Ys(e,n){const{titleRunIds:t=[],ordered:r}=e.props,o=t.map(i=>je(n.store.getRun(i),n)).join(""),l=e.contentIds.map(i=>n.registry.get(n.store.getBlock(i).type).toHTML(n.store.getBlock(i),n)).join(""),s=l?`<${r?"ol":"ul"}>${l}</${r?"ol":"ul"}>`:"";return`<li>${o}${s}</li>`}function Gs(e,n){const{titleRunIds:t=[]}=e.props;return t.map(r=>Oe(n.store.getRun(r),n)).join("")}function Ur(e,n){const t=[],r=[];for(const d of e.childNodes)d.nodeType===1&&(d.tagName==="UL"||d.tagName==="OL")?r.push(d):t.push(d);const o=e.ownerDocument.createElement("span");for(const d of t)o.appendChild(d.cloneNode(!0));const l=me(o,n),s=E(),i=[...l],c=[],u=[];for(const d of r){const b=d.tagName==="OL";for(const h of d.children){if(h.tagName!=="LI")continue;const m=Ur(h,n);m.block.parentId=s,m.block.props.ordered=b,c.push(m.block,...m.childBlocks),i.push(...m.runs),u.push(m.block.id)}}return{block:{id:s,type:"listItem",parentId:null,contentIds:u,props:{ordered:!1,titleRunIds:l.map(d=>d.id)}},runs:i,childBlocks:c}}function Js(e,n){if(e.tagName!=="LI")return null;const{block:t,runs:r,childBlocks:o}=Ur(e,n);return{block:t,runs:r,subtreeBlocks:o}}const Kr={component:Ws,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:Ys,toPlainText:Gs,fromHTML:Js,slashCommands:[{label:"Bulleted list",icon:Rr,keywords:["list","bullet","ul"],run:(e,n)=>ae(e,n,Qe({ordered:!1}))},{label:"Numbered list",icon:Tr,keywords:["list","number","ordered","ol"],run:(e,n)=>ae(e,n,Qe({ordered:!0}))},{label:"To-do list",icon:lt,keywords:["todo","checkbox","task","checklist"],run:(e,n)=>ae(e,n,Qe({ordered:!1,checked:!1}))},{label:"Toggle list",icon:Me,keywords:["toggle","collapse","expand","dropdown","accordion"],run:(e,n)=>ae(e,n,Qe({ordered:!1,collapsed:!1}))}]},Vr=["text","date","checkbox","select"],Sn="text",En=160,hn=80;function Xs(e){return`Column ${e+1}`}function xt(e){return Array.from({length:e},(n,t)=>({id:E(),label:Xs(t),type:Sn,width:En}))}function be(e,n){var r;const t=(r=e.props)==null?void 0:r.columns;return!Array.isArray(t)||t.length!==n?xt(n):t.map(o=>{const l=o.type??Sn,s=o.width??En;return l===o.type&&s===o.width?o:{...o,type:l,width:s}})}function qr(e){switch(e){case"date":return{id:E(),type:"date",value:"",marks:{},data:{isoDate:""}};case"checkbox":return{id:E(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}};case"select":return{id:E(),type:"tableSelect",value:"",marks:{},data:{selectedValue:"",selectedLabel:""}};default:return{id:E(),type:"text",value:"",marks:{}}}}function Ln(e,n){const t=qr(n==null?void 0:n.type);return{block:{id:E(),type:"tableCell",parentId:e,contentIds:[t.id],props:{}},run:t}}function Wr(e,n,t){if(e.type===n)return e;let r;if(e.type==="text")r=e.value??"";else{const o=t==null?void 0:t.get(e.type);r=o!=null&&o.toPlainText?o.toPlainText(e):""}if(n==="date"){const o=r?new Date(r):null,l=o&&!Number.isNaN(o.getTime())?o.toISOString().slice(0,10):"";return{id:E(),type:"date",value:"",marks:{},data:{isoDate:l}}}return n==="checkbox"?{id:E(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:r}}:{id:E(),type:"text",value:r,marks:{}}}function Ae(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Yr(e,n){const r=e.getBlock(n.parentId).contentIds.indexOf(n.id);Ae(e,[$(n.id)]);const o=We(e);if(o)return oe(e,o),null;const l=e.getBlock(n.parentId),s=l.contentIds[r]??l.contentIds[r-1];return s&&oe(e,s),null}function yt(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=be(r,t.contentIds.length),s=E(),i=[],c=[],u=[];for(const d of l){const b=Ln(s,d);i.push(b.block),c.push(b.run),u.push(b.block.id)}const f={id:s,type:"tableRow",parentId:r.id,contentIds:u,props:{}};return e.applyOperation(Q(f,r.id,o+1,{blocks:[f,...i],runs:c})),oe(e,s),s}function Gr(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId);if(r.contentIds.length<=1)return Yr(e,r);const o=r.contentIds.indexOf(n);Ae(e,[$(n)]);const l=e.getBlock(r.id),s=Math.min(o,l.contentIds.length-1),i=l.contentIds[s];return i&&oe(e,i),i??null}function gn(e,n,t){const r=e.getBlock(n),o=be(r,r.contentIds[0]?e.getBlock(r.contentIds[0]).contentIds.length:0),l={id:E(),label:"New Column",type:Sn,width:En},s=[];let i=null;for(const u of r.contentIds){const f=Ln(u,l);i===null&&(i=f.block.id),s.push(Q(f.block,u,t+1,{blocks:[f.block],runs:[f.run]}))}const c=[...o];return c.splice(t+1,0,l),s.push(F(n,{columns:c})),Ae(e,s),i&&oe(e,i),i}function Jr(e,n,t){const r=e.getBlock(n),o=e.getBlock(r.contentIds[0]);if(!o||o.contentIds.length<=1)return Yr(e,r);const l=be(r,o.contentIds.length),s=r.contentIds.map(d=>{const b=e.getBlock(d);return $(b.contentIds[t])}),i=l.filter((d,b)=>b!==t);s.push(F(n,{columns:i})),Ae(e,s);const c=e.getBlock(r.contentIds[0]),u=Math.min(t,c.contentIds.length-1),f=c.contentIds[u];return f&&oe(e,f),f??null}function Xr(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),s=be(o,l?l.contentIds.length:0);if(!s[t])return;const i=[...s];i[t]={...s[t],width:Math.max(hn,Math.round(r))},e.applyOperation(F(n,{columns:i}))}function Qr(e,n,t,r){const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),i=[...be(o,l?l.contentIds.length:0)];i[t]&&(i[t]={...i[t],label:r},e.applyOperation(F(n,{columns:i})))}function vt(e,n,t){return n.contentIds.map(r=>{const l=e.getBlock(r).contentIds[t],s=e.getBlock(l);return{cellId:l,run:e.getRun(s.contentIds[0])}})}function Gt(e,n){if(!e)return"";if(e.type==="text")return e.value??"";const t=n==null?void 0:n.get(e.type);return t!=null&&t.toPlainText?t.toPlainText(e):""}function Qs(e,n,t,r){const o=vt(e,n,t),l=[],s=new Map;for(const{run:c}of o){const u=Gt(c,r).trim();if(!u||s.has(u))continue;const f={value:E(),label:u};s.set(u,f),l.push(f)}const i=o.map(({cellId:c,run:u})=>{const f=Gt(u,r).trim(),d=s.get(f);return{cellId:c,run:{id:E(),type:"tableSelect",value:"",marks:{},data:{selectedValue:(d==null?void 0:d.value)??"",selectedLabel:(d==null?void 0:d.label)??""}}}});return{options:l,newRuns:i}}function Zr(e,n,t,r,o){const l=e.getBlock(n),s=e.getBlock(l.contentIds[0]),i=be(l,s?s.contentIds.length:0),c=i[t];if(!c||c.type===r)return;const u=[...i];if(r==="select"){const{options:d,newRuns:b}=Qs(e,l,t,o);u[t]={...c,type:r,options:d};const h=[F(n,{columns:u})];for(const{cellId:m,run:g}of b)h.push(ue(m,[g]));Ae(e,h);return}u[t]={...c,type:r};const f=[F(n,{columns:u})];for(const{cellId:d,run:b}of vt(e,l,t)){if(!b)continue;const h=Wr(b,r,o);f.push(ue(d,[h]))}Ae(e,f)}function bn(e,n,t,r){var d,b;const o=e.getBlock(n),l=e.getBlock(o.contentIds[0]),s=be(o,l?l.contentIds.length:0),i=s[t];if(!i)return;const c=[...s];c[t]={...i,options:r};const u=[F(n,{columns:c})],f=new Map(r.map(h=>[h.value,h]));for(const{run:h}of vt(e,o,t)){if(!h||h.type!=="tableSelect")continue;const m=((d=h.data)==null?void 0:d.selectedValue)??"",g=f.get(m),k=g?m:"",x=g?g.label:"";(k!==m||x!==(((b=h.data)==null?void 0:b.selectedLabel)??""))&&u.push(G(h.id,{data:{selectedValue:k,selectedLabel:x}}))}Ae(e,u)}function eo(e,n,t){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(t??null)},[t]),p.useLayoutEffect(()=>{if(!n||!e.current||r==null)return;const l=e.current.getBoundingClientRect(),s=wn(r,l.width);s!==r&&o(s)},[n,e,r]),r}function no(e,n,t){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(t??null)},[t]),p.useLayoutEffect(()=>{if(!n||!e.current||r==null)return;const l=e.current.getBoundingClientRect(),s=l.width/2,c=wn(r-s,l.width)+s;c!==r&&o(c)},[n,e,r]),r}function Zs(e,n,t){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(t??null)},[t]),p.useLayoutEffect(()=>{if(!n||!e.current||r==null)return;const l=e.current.getBoundingClientRect(),i=wn(r-l.width,l.width)+l.width;i!==r&&o(i)},[n,e,r]),r}function Jt(){if(typeof window>"u"||!window.visualViewport)return 0;const e=window.visualViewport,n=window.innerHeight-(e.height+e.offsetTop);return n>0?Math.round(n):0}function On(){const[e,n]=p.useState(Jt);return p.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const t=window.visualViewport,r=()=>n(Jt());return r(),t.addEventListener("resize",r),t.addEventListener("scroll",r),()=>{t.removeEventListener("resize",r),t.removeEventListener("scroll",r)}},[]),e}const ea=280;function na(e,n){return n?e.label.toLowerCase().includes(n.toLowerCase()):!0}function De({value:e,options:n,onChange:t,placeholder:r="Select…",ariaLabel:o,className:l="",variant:s="default",selectedLabel:i,selectedColor:c,onManageOptions:u,manageOptionsLabel:f="Manage options…",mention:d=!1}){var se,te;const[b,h]=p.useState(!1),[m,g]=p.useState(""),[k,x]=p.useState(0),[w,v]=p.useState(null),B=On(),[C,y]=p.useState([]),[R,j]=p.useState(!1),[S,I]=p.useState(!1),T=p.useRef(null),L=p.useRef(null),M=p.useRef(null),A=p.useRef(null),P=p.useRef(null),X=p.useMemo(()=>[T,M],[]),J=s==="tag",H=typeof n=="function",W=H?void 0:n.find(O=>O.value===e),N=e?W??(i?{label:i,color:c}:void 0):void 0,U=p.useMemo(()=>H?C:n.filter(O=>na(O,m)),[H,C,n,m]);p.useEffect(()=>{if(!H||!b)return;let O=!1;j(!0),I(!1);const ce=setTimeout(()=>{Promise.resolve(n(m)).then(Se=>{O||(y(Se??[]),j(!1))}).catch(()=>{O||(y([]),j(!1),I(!0))})},250);return()=>{O=!0,clearTimeout(ce)}},[H,b,n,m]);const K=p.useCallback(()=>h(!1),[]);an(X,b,K);const q=eo(M,b,w==null?void 0:w.left),re=p.useCallback(()=>{var O;v(((O=L.current)==null?void 0:O.getBoundingClientRect())??null),g(""),x(0),h(!0)},[]);p.useEffect(()=>{var O;b&&((O=A.current)==null||O.focus())},[b]),p.useEffect(()=>{var O,ce;(ce=(O=P.current)==null?void 0:O.scrollIntoView)==null||ce.call(O,{block:"nearest"})},[k]);const pe=p.useCallback(O=>{var ce;t(O.value,O),K(),(ce=L.current)==null||ce.focus()},[t,K]),Y=p.useCallback(O=>{var ce;O.key==="ArrowDown"?(O.preventDefault(),x(Se=>Math.min(Se+1,Math.max(U.length-1,0)))):O.key==="ArrowUp"?(O.preventDefault(),x(Se=>Math.max(Se-1,0))):O.key==="Enter"?(O.preventDefault(),U[k]&&pe(U[k])):O.key==="Escape"&&(O.preventDefault(),K(),(ce=L.current)==null||ce.focus())},[U,k,pe,K]);return a.jsxs("span",{className:`be-select ${l}`.trim(),ref:T,children:[a.jsx("button",{type:"button",ref:L,className:`be-select-trigger${J?" be-select-trigger-tag":""}${d?" be-select-trigger-mention":""}`,"aria-haspopup":"listbox","aria-expanded":b,"aria-label":o,onClick:()=>b?K():re(),children:J?N?a.jsx("span",{className:`be-select-tag${d?" be-select-tag-mention":""}`,style:d?void 0:{background:(se=N.color)==null?void 0:se.bg,color:(te=N.color)==null?void 0:te.text},children:d?`@${N.label}`:N.label}):a.jsx("span",{className:"be-select-value be-select-value-placeholder",children:r}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"be-select-value",children:N?N.label:r}),a.jsx(Cn,{size:14,className:"be-select-chevron"})]})}),b&&w&&q!=null&&ge.createPortal(a.jsxs("div",{ref:M,className:"be-select-popover",style:{position:"fixed",left:q,minWidth:w.width,...w.bottom+ea>window.innerHeight-B?{bottom:window.innerHeight-w.top+4}:{top:w.bottom+4}},children:[a.jsx("input",{ref:A,type:"text",className:"be-select-search",value:m,onChange:O=>{g(O.target.value),x(0)},onKeyDown:Y,placeholder:"Search…","aria-label":o?`Search ${o}`:"Search options"}),a.jsxs("div",{className:"be-select-options",role:"listbox",children:[H&&R&&a.jsx("div",{className:"be-select-empty",children:"Loading…"}),H&&!R&&S&&a.jsx("div",{className:"be-select-empty be-select-error",children:"Couldn't load options"}),!R&&!S&&U.length===0&&a.jsx("div",{className:"be-select-empty",children:"No results"}),!R&&!S&&U.map((O,ce)=>{var Se,Nt;return a.jsx("div",{ref:ce===k?P:void 0,role:"option","aria-selected":O.value===e,className:`be-select-option${ce===k?" be-select-option-active":""}${O.value===e?" be-select-option-selected":""}`,onMouseDown:ml=>{ml.preventDefault(),pe(O)},onMouseEnter:()=>x(ce),children:J?a.jsx("span",{className:"be-select-tag",style:{background:(Se=O.color)==null?void 0:Se.bg,color:(Nt=O.color)==null?void 0:Nt.text},children:O.label}):O.label},O.value)})]}),u&&a.jsx("button",{type:"button",className:"be-select-manage-options",onMouseDown:O=>{O.preventDefault(),K(),u()},children:f})]}),document.body)]})}const un=[{bg:"#e9e9e7",text:"#32302c"},{bg:"#eee0da",text:"#64473a"},{bg:"#fadec9",text:"#8a4b23"},{bg:"#fdecc8",text:"#8a6116"},{bg:"#dbeddb",text:"#256029"},{bg:"#d3e5ef",text:"#1a5f8a"},{bg:"#e8deee",text:"#5b3a8a"},{bg:"#f5e0e9",text:"#8a3a5f"},{bg:"#ffe2dd",text:"#a13a2f"}];function nn(e){return un[(e%un.length+un.length)%un.length]}const ta={text:"Text",date:"Date",checkbox:"Checkbox",select:"Select"},ra=Vr.map(e=>({value:e,label:ta[e]})),oa=800;function la({tableId:e,colIndex:n,options:t}){const r=_(),[o,l]=p.useState(""),s=p.useCallback((u,f)=>{bn(r,e,n,t.map(d=>d.value===u?{...d,label:f}:d))},[r,e,n,t]),i=p.useCallback(u=>bn(r,e,n,t.filter(f=>f.value!==u)),[r,e,n,t]),c=p.useCallback(()=>{const u=o.trim();l(""),u&&bn(r,e,n,[...t,{value:E(),label:u,color:nn(t.length)}])},[r,e,n,t,o]);return a.jsxs("div",{className:"be-table-header-menu-options",children:[a.jsx("div",{className:"be-table-header-menu-options-label",children:"Options"}),t.map((u,f)=>a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(u.color??nn(f)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:u.label,onChange:d=>s(u.value,d.target.value),"aria-label":`Rename option ${u.label}`}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>i(u.value),"aria-label":`Remove option ${u.label}`,children:a.jsx(ln,{size:14})})]},u.value)),a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("input",{className:"be-table-header-menu-option-input",value:o,onChange:u=>l(u.target.value),placeholder:"New option…",onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:c,"aria-label":"Add option",children:"+"})]})]})}function sa({tableId:e,column:n,colIndex:t,colCount:r}){const o=_(),l=ye(),[s,i]=p.useState(!1),[c,u]=p.useState(null),[f,d]=p.useState(null),b=p.useRef(null),h=p.useRef(null),m=p.useRef(null),g=p.useMemo(()=>[b,h],[]),k=p.useCallback(()=>i(!1),[]);an(g,s,k),Tn(h,s,k,b);const x=Zs(h,s,c==null?void 0:c.right),w=p.useCallback(()=>{var S;u(((S=m.current)==null?void 0:S.getBoundingClientRect())??null),i(!0)},[]),v=p.useCallback(S=>Qr(o,e,t,S.target.value),[o,e,t]),B=p.useCallback(()=>{gn(o,e,t-1),k()},[o,e,t,k]),C=p.useCallback(()=>{gn(o,e,t),k()},[o,e,t,k]),y=p.useCallback(()=>{Jr(o,e,t),k()},[o,e,t,k]),R=p.useCallback(S=>Zr(o,e,t,S,l),[o,e,t,l]),j=p.useCallback(S=>{var J;S.preventDefault();const I=(J=m.current)==null?void 0:J.closest("table"),T=I==null?void 0:I.querySelector(`col[data-col-index="${t}"]`);if(!T)return;const L=m.current.getBoundingClientRect().width,M=S.clientX,A=H=>Math.max(hn,Math.round(L+(H.clientX-M))),P=H=>{const W=A(H);T.style.width=`${W}px`,d(W)},X=H=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",X),Xr(o,e,t,A(H)),d(null)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",X)},[o,e,t]);return a.jsxs("th",{ref:m,scope:"col",className:"be-table-header-cell",contentEditable:!1,children:[a.jsx("input",{className:"be-table-header-label",value:n.label,onChange:v,"aria-label":`Column ${t+1} name`}),a.jsx("button",{ref:b,type:"button",className:"be-table-header-menu-trigger","aria-label":`Column ${t+1} options`,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?k():w(),children:"⋮"}),a.jsx("div",{className:"be-table-col-resize-handle",onMouseDown:j,role:"slider","aria-label":`Resize column ${t+1}`,"aria-valuemin":hn,"aria-valuemax":oa,"aria-valuenow":f??n.width}),s&&c&&x!=null&&ge.createPortal(a.jsxs("div",{ref:h,role:"menu","aria-label":`Column ${t+1} options`,className:"be-table-header-menu",style:{position:"fixed",top:c.bottom+4,left:x,transform:"translateX(-100%)"},children:[a.jsxs("div",{className:"be-table-header-menu-type",children:[a.jsx("span",{id:`be-table-col-type-${n.id}`,children:"Type"}),a.jsx(De,{value:n.type,options:ra,onChange:R,ariaLabel:"Column type",className:""})]}),n.type==="select"&&a.jsx(la,{tableId:e,colIndex:t,options:n.options??[]}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:B,children:"Insert column left"}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:C,children:"Insert column right"}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item be-table-header-menu-item-danger",onClick:y,disabled:r<=1,children:"Delete column"})]}),document.body)]})}function to({tableId:e,columns:n}){return a.jsx("thead",{children:a.jsxs("tr",{className:"be-table-header-row",children:[n.map((t,r)=>a.jsx(sa,{tableId:e,column:t,colIndex:r,colCount:n.length},t.id)),a.jsx("th",{className:"be-table-header-spacer","aria-hidden":"true"})]})})}function aa({id:e}){var i;const n=_(),t=ne(e),r=p.useCallback(()=>{var u;const c=(u=t==null?void 0:t.contentIds)==null?void 0:u[t.contentIds.length-1];c&&yt(n,c)},[n,t]),o=le("be-table-wrapper",t);if(!t)return null;const l=n.getBlock(t.contentIds[0]),s=be(t,((i=l==null?void 0:l.contentIds)==null?void 0:i.length)??0);return a.jsx("div",{className:"be-table-scroll",children:a.jsxs("div",{className:o,"data-block-id":e,children:[a.jsxs("table",{className:"be-table",children:[a.jsxs("colgroup",{children:[s.map((c,u)=>a.jsx("col",{"data-col-index":u,style:{width:c.width}},c.id)),a.jsx("col",{className:"be-table-header-spacer-col"})]}),a.jsx(to,{tableId:e,columns:s}),a.jsx("tbody",{children:a.jsx(Ne,{parentId:e})})]}),a.jsxs("button",{type:"button",className:"be-table-add-row",contentEditable:!1,onClick:r,children:[a.jsx(Zn,{size:14})," Add row"]})]})})}function ia({id:e}){const n=_(),t=ne(e),r=le("be-table-row",t),o=p.useCallback(()=>Gr(n,e),[n,e]);return a.jsxs("tr",{className:r,"data-block-id":e,children:[a.jsx(Ne,{parentId:e}),a.jsx("td",{className:"be-table-row-actions",contentEditable:!1,children:a.jsx("button",{type:"button",className:"be-table-delete-row",onClick:o,"aria-label":"Delete row",title:"Delete row",children:a.jsx(ln,{size:14})})})]})}function ro(e,n){const t=e.getBlock(n),r=e.getBlock(t.parentId),o=e.getBlock(r.parentId);return{table:o,row:r,rowIndex:o.contentIds.indexOf(r.id),colIndex:r.contentIds.indexOf(n)}}function ca(e,n,t){const{table:r,row:o,rowIndex:l,colIndex:s}=ro(e,n);if(t==="left"||t==="right"){const f=t==="right"?1:-1,d=s+f;if(d>=0&&d<o.contentIds.length)return o.contentIds[d];const b=l+f;if(b<0||b>=r.contentIds.length)return null;const h=e.getBlock(r.contentIds[b]),m=t==="right"?0:h.contentIds.length-1;return h.contentIds[m]}const c=l+(t==="down"?1:-1);if(c<0||c>=r.contentIds.length)return null;const u=e.getBlock(r.contentIds[c]);return u.contentIds[s]??u.contentIds[u.contentIds.length-1]??null}function ua(e,n){const t=Sr(e,n,"down");if(t){ee(t);return}Te(e,n,z("paragraph"))}function Xe(e,n,t){var o;const r=ca(e,n,t);if(r){const l=e.getBlock(r),s=(o=l==null?void 0:l.contentIds)==null?void 0:o[0];s&&ee(s);return}if(t==="right"){const{table:l}=ro(e,n);ua(e,l.id)}}function da({id:e}){const n=_(),t=ne(e),r=p.useCallback(()=>Xe(n,e,"right"),[n,e]),o=p.useCallback(()=>Xe(n,e,"left"),[n,e]),l=p.useCallback(()=>Xe(n,e,"up"),[n,e]),s=p.useCallback(()=>Xe(n,e,"down"),[n,e]),i=p.useCallback(()=>Xe(n,e,"down"),[n,e]),c=le("be-table-cell",t);if(!t)return null;const u=Ie(n,t);return a.jsx("td",{className:c,"data-block-id":e,dir:u,children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:u,onTab:r,onShiftTab:o,onArrowUp:l,onArrowDown:s,onEnter:i})})}function pa(e,n){const t=E(),r=[],o=[],l=[];for(const s of n){const i=Ln(t,s);r.push(i.block),o.push(i.run),l.push(i.block.id)}return{block:{id:t,type:"tableRow",parentId:e,contentIds:l,props:{}},blocks:r,runs:o}}function fa({rows:e=2,cols:n=2}={}){return function(r){const o=E(),l=xt(n),s=[],i=[],c=[];for(let f=0;f<e;f+=1){const d=pa(o,l);s.push(d.block,...d.blocks),i.push(...d.runs),c.push(d.block.id)}return{block:{id:o,type:"table",parentId:r,contentIds:c,props:{columns:l}},runs:i,subtreeBlocks:s}}}function ba(e,n){return`<td>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>je(r,n)).join("")}</td>`}function ma(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function ha(e,n){if(e.tagName!=="TD"&&e.tagName!=="TH")return null;const t=me(e,n);return{block:{id:E(),type:"tableCell",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}function ga(e,n){return`<tr>${e.contentIds.map(r=>{const o=n.store.getBlock(r);return n.registry.get(o.type).toHTML(o,n)}).join("")}</tr>`}function ka(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(" ")}function xa(e,n){if(e.tagName!=="TR")return null;const t=[...e.children].filter(c=>c.tagName==="TD"||c.tagName==="TH"),r=E(),o=[],l=[],s=[];for(const c of t){const u=n.registry.get("tableCell").fromHTML(c,n);u&&(u.block.parentId=r,o.push(u.block),l.push(...u.runs),s.push(u.block.id))}return{block:{id:r,type:"tableRow",parentId:null,contentIds:s,props:{}},runs:l,subtreeBlocks:o}}function ya(e,n){var s;const t=e.contentIds[0]&&n.store.getBlock(e.contentIds[0]),r=be(e,((s=t==null?void 0:t.contentIds)==null?void 0:s.length)??0),o=r.length?`<thead><tr>${r.map(i=>`<th>${ze(i.label??"")}</th>`).join("")}</tr></thead>`:"",l=e.contentIds.map(i=>{const c=n.store.getBlock(i);return n.registry.get(c.type).toHTML(c,n)}).join("");return`<table>${o}<tbody>${l}</tbody></table>`}function va(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(`
2208
+ `)}function wa(e,n){if(e.tagName!=="TABLE")return null;const t=e.querySelector("thead tr"),r=e.querySelector("tbody")?[...e.querySelectorAll("tbody tr")]:[...e.querySelectorAll("tr")].filter(f=>f!==t),o=E(),l=[],s=[],i=[];for(const f of r){const d=n.registry.get("tableRow").fromHTML(f,n);if(d){d.block.parentId=o;for(const b of d.subtreeBlocks)b.parentId=d.block.id;l.push(d.block,...d.subtreeBlocks),s.push(...d.runs),i.push(d.block.id)}}const c={};if(t){const f=[...t.children].filter(d=>d.tagName==="TH"||d.tagName==="TD");c.columns=f.map(d=>({id:E(),label:d.textContent??""}))}return{block:{id:o,type:"table",parentId:null,contentIds:i,props:c},runs:s,subtreeBlocks:l}}const oo={component:da,isLeaf:!0,defaultProps:{},toHTML:ba,toPlainText:ma,fromHTML:ha},lo={component:ia,isLeaf:!1,defaultProps:{},toHTML:ga,toPlainText:ka,fromHTML:xa},so={component:aa,isLeaf:!1,defaultProps:{},toHTML:ya,toPlainText:va,fromHTML:wa,slashCommand:{label:"Table",icon:Pl,keywords:["table","grid"],run:(e,n)=>ae(e,n,fa({rows:2,cols:2}))}};function Ia({id:e}){const n=ne(e),t=le("be-layout",n);return a.jsx("div",{className:t,"data-block-id":e,style:{display:"flex",gap:"1em"},children:a.jsx(Ne,{parentId:e})})}function Ca({id:e}){const n=ne(e),t=le("be-layout-column",n);return a.jsx("div",{className:t,"data-block-id":e,children:a.jsx(Ne,{parentId:e})})}function Ba({columns:e=2}={}){return function(t){const r=E(),o=[],l=[],s=[];for(let c=0;c<e;c+=1){const u=E(),{block:f,runs:d}=z("paragraph")(u),b={id:u,type:"layoutColumn",parentId:r,contentIds:[f.id],props:{}};o.push(b,f),l.push(...d),s.push(u)}return{block:{id:r,type:"layout",parentId:t,contentIds:s,props:{}},runs:l,subtreeBlocks:o}}}function ao(e,n){return(t,r)=>`${e}${t.contentIds.map(o=>{const l=r.store.getBlock(o);return r.registry.get(l.type).toHTML(l,r)}).join("")}${n}`}function io(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toPlainText(r,n)}).join(`
2209
+ `)}const co={component:Ca,isLeaf:!1,defaultProps:{},toHTML:ao("<div>","</div>"),toPlainText:io},uo={component:Ia,isLeaf:!1,defaultProps:{},toHTML:ao('<div style="display:flex;gap:1em">',"</div>"),toPlainText:io,slashCommands:[2,3,4,5].map(e=>({label:`${e} columns`,icon:$l,keywords:["layout","columns","column",String(e)],run:(n,t)=>ae(n,t,Ba({columns:e}))}))};function Ra({id:e}){const n=ne(e),t=le("be-divider",n);return a.jsx("hr",{className:t,"data-block-id":e,contentEditable:!1,tabIndex:-1})}function Ta(){return function(n){return{block:{id:E(),type:"divider",parentId:n,contentIds:[],props:{}},runs:[]}}}function ja(){return"<hr />"}function Sa(){return"---"}function Ea(e){return e.tagName!=="HR"?null:{block:{id:E(),type:"divider",parentId:null,contentIds:[],props:{}},runs:[]}}const po={component:Ra,isLeaf:!0,defaultProps:{},toHTML:ja,toPlainText:Sa,fromHTML:Ea,slashCommand:{label:"Divider",icon:Dl,keywords:["divider","hr","separator","line"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>{const l=e.getRun(t),s=(l==null?void 0:l.value)??"";e.applyOperation(G(t,{value:s.slice(0,r)+s.slice(o)}));const i=ct(e,n,Ta());return Te(e,i,z("paragraph")),i}}},fo=[{value:"gray",label:"Gray"},{value:"blue",label:"Blue"},{value:"green",label:"Green"},{value:"yellow",label:"Yellow"},{value:"orange",label:"Orange"},{value:"red",label:"Red"},{value:"purple",label:"Purple"},{value:"pink",label:"Pink"}];function La({id:e}){var x,w;const n=_(),t=ne(e),[r,o]=p.useState(!1),[l,s]=p.useState(!1),i=p.useRef(null),c=p.useRef(null),u=p.useMemo(()=>[i,c],[]),f=p.useCallback(()=>s(!1),[]);an(u,l,f);const d=((x=t==null?void 0:t.props)==null?void 0:x.icon)??Ge,b=((w=t==null?void 0:t.props)==null?void 0:w.color)??_r,h=p.useCallback(v=>{const B=v.target.value.trim();B&&n.applyOperation(F(e,{icon:B})),o(!1)},[n,e]),m=p.useCallback(v=>{v.key==="Enter"&&v.currentTarget.blur(),v.key==="Escape"&&o(!1)},[]),g=p.useCallback(v=>{n.applyOperation(F(e,{color:v})),s(!1)},[n,e]),k=le("be-callout",t);return t?a.jsxs("div",{className:k,"data-block-id":e,"data-color":b,children:[a.jsx("div",{className:"be-callout-icon-wrap",children:r?a.jsx("input",{type:"text",className:"be-callout-icon-input",defaultValue:d,autoFocus:!0,onBlur:h,onKeyDown:m,"aria-label":"Callout icon (paste or type an emoji)"}):a.jsx("button",{type:"button",className:"be-callout-icon",onClick:()=>o(!0),"aria-label":"Change callout icon",title:"Change icon",children:d})}),a.jsx("div",{className:"be-callout-content",children:a.jsx(Ne,{parentId:e})}),a.jsxs("div",{className:"be-callout-color-wrap",contentEditable:!1,children:[a.jsx("button",{ref:i,type:"button",className:"be-callout-color-trigger","aria-label":"Callout color","aria-haspopup":"true","aria-expanded":l,title:"Callout color",onClick:()=>s(v=>!v),children:a.jsx("span",{className:`be-callout-color-dot be-callout-color-dot-${b}`})}),l&&a.jsx("div",{ref:c,className:"be-callout-color-picker",role:"menu","aria-label":"Callout color",children:fo.map(v=>a.jsx("button",{type:"button",role:"menuitem",className:`be-callout-color-option be-callout-color-option-${v.value}${v.value===b?" be-callout-color-option-active":""}`,title:v.label,"aria-label":v.label,onClick:()=>g(v.value)},v.value))})]})]}):null}function Oa(e,n){return e.contentIds.map(t=>{const r=n.store.getBlock(t);return n.registry.get(r.type).toHTML(r,n)}).join("")}function Na(e,n){var r;const t=((r=e.props)==null?void 0:r.icon)??Ge;return`<div class="callout" data-icon="${t}"><div class="callout-icon">${t}</div><div class="callout-content">${Oa(e,n)}</div></div>`}function Ma(e,n){var o;const t=((o=e.props)==null?void 0:o.icon)??Ge,r=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
2210
+ `);return`${t} ${r}`}const bo={component:La,isLeaf:!1,defaultProps:{icon:Ge},toHTML:Na,toPlainText:Ma,slashCommand:{label:"Callout",icon:Br,keywords:["callout","aside","note","info","tip","warning"],run:(e,n)=>ae(e,n,Ts())}};function Aa({id:e}){const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),o=p.useCallback(()=>{qe(n,e,(t==null?void 0:t.contentIds)??[],z("paragraph"))},[n,e,t]),l=p.useCallback(()=>{const d=sn(n,e);Ye(n,d,e,r)},[n,e,r]),s=p.useCallback(()=>ie(n,e,"up"),[n,e]),i=p.useCallback(()=>ie(n,e,"down"),[n,e]),c=le("be-blockquote",t);if(!t)return null;const u=de(n,t.contentIds),f=Ie(n,t);return a.jsx("blockquote",{className:c,"data-block-id":e,"data-empty":u?"":void 0,"data-placeholder":"Empty quote",dir:f,children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:f,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:i})})}function Da(e,n){return`<p>${e.contentIds.map(r=>n.store.getRun(r)).map(r=>je(r,n)).join("")}</p>`}function _a(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function Pa(e,n){if(e.tagName!=="BLOCKQUOTE")return null;const t=me(e,n);return{block:{id:E(),type:"blockquote",parentId:null,contentIds:t.map(o=>o.id),props:{}},runs:t}}const mo={component:Aa,isLeaf:!0,defaultProps:{},toHTML:Da,toPlainText:_a,fromHTML:Pa,slashCommand:{label:"Quote",icon:Cr,keywords:["quote","blockquote","citation"],run:(e,n)=>ae(e,n,z("blockquote"))}},ho=["plaintext","javascript","python","html","css","json","bash","sql"],$a=ho.map(e=>({value:e,label:e}));function Xt(e,n,t){const r=we();if(!r||r.blockId!==n)return;const o=e.getRun(r.runId);if(!o||o.type!=="text")return;const l=o.value??"",s=l.slice(0,r.offset)+t+l.slice(r.offset);e.applyOperation(G(o.id,{value:s})),he(o.id,r.offset+t.length)}function Ha({id:e}){var h;const n=_(),t=ne(e),r=p.useCallback(()=>Xt(n,e,`
2211
+ `),[n,e]),o=p.useCallback(()=>Xt(n,e," "),[n,e]),l=p.useCallback(()=>{var x;const m=sn(n,e);if(!m||m===e)return;const g=n.getBlock(m),k=(x=g==null?void 0:g.contentIds)==null?void 0:x[g.contentIds.length-1];k&&ee(k)},[n,e]),s=p.useCallback(()=>ie(n,e,"up"),[n,e]),i=p.useCallback(()=>ie(n,e,"down"),[n,e]),c=p.useCallback(m=>n.applyOperation(F(e,{language:m})),[n,e]),u=p.useCallback(()=>jn(n,e),[n,e]),f=le("be-code-block",t);if(!t)return null;const d=((h=t.props)==null?void 0:h.language)??"plaintext",b=de(n,t.contentIds);return a.jsxs("div",{className:f,"data-block-id":e,children:[a.jsxs("div",{className:"be-code-block-header",contentEditable:!1,children:[a.jsx(De,{className:"be-code-block-language",value:d,options:$a,onChange:c,ariaLabel:"Code language"}),a.jsx("button",{type:"button",className:"be-code-block-delete",onClick:u,"aria-label":"Delete code block",title:"Delete code block",children:a.jsx(Bn,{size:14})})]}),a.jsx("pre",{className:"be-code-block-pre",dir:"ltr",children:a.jsx("code",{"data-empty":b?"":void 0,"data-placeholder":"Empty code block",children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:"ltr",onEnter:r,onTab:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:i})})})]})}function za(e,n){var l;const t=e.contentIds.map(s=>n.store.getRun(s)),r=(l=e.props)==null?void 0:l.language;return`<pre><code${r&&r!=="plaintext"?` data-language="${ze(r)}"`:""}>${t.map(s=>je(s,n)).join("")}</code></pre>`}function Fa(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function Ua(e,n){var s;if(e.tagName!=="PRE")return null;const t=e.querySelector("code")??e,r=(s=t.getAttribute)==null?void 0:s.call(t,"data-language"),o=E();return{block:{id:E(),type:"code",parentId:null,contentIds:[o],props:r?{language:r}:{}},runs:[{id:o,type:"text",value:t.textContent??"",marks:{}}]}}const go={component:Ha,isLeaf:!0,defaultProps:{language:"plaintext"},toHTML:za,toPlainText:Fa,fromHTML:Ua,slashCommand:{label:"Code",icon:ot,keywords:["code","codeblock","snippet","pre"],run:(e,n)=>ae(e,n,z("code"))}};function Ka(e,n){var t;return n.length===0||n.length===1&&(((t=e.getRun(n[0]))==null?void 0:t.value)??"")===""}function Va(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const r=e.getBlock(t[0]);return!!r&&r.type==="paragraph"&&de(e,r.contentIds)}function dn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function qa(e,n){const t=e.getBlock(n);if(!t)return null;const r=e.getBlock(t.parentId),o=r.contentIds.indexOf(n),l=t.props.titleRunIds??[],s=Ka(e,l)&&Va(e,t);if(o<=0){if(!s)return null;if(r.contentIds.length>1)return dn(e,[$(n)]),{focusBlockId:e.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:u,runs:f}=z("paragraph")(r.id);return dn(e,[Q(u,r.id,o,{blocks:[u],runs:f}),$(n)]),{focusBlockId:u.id,needsRefocus:!0}}const i=r.contentIds[o-1],c=e.getBlock(i);return s?(dn(e,[$(n)]),{focusBlockId:i,needsRefocus:!0}):on(e,c)?(dn(e,[$(i)]),{focusBlockId:n,needsRefocus:!1}):null}function Wa(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Ya({id:e}){var k;const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),o=p.useCallback(()=>{var B,C;const x=((B=t==null?void 0:t.props)==null?void 0:B.titleRunIds)??[],w=(((C=t==null?void 0:t.contentIds)==null?void 0:C.length)??0)>0,v=z("paragraph");w?Lr(n,e,x,v):qe(n,e,x,v)},[n,e,t]),l=p.useCallback(()=>{const x=qa(n,e);!x||!x.needsRefocus||Ye(n,x.focusBlockId,e,r)},[n,e,r]),s=p.useCallback(()=>ie(n,e,"up"),[n,e]),i=p.useCallback(()=>ie(n,e,"down"),[n,e]),c=p.useCallback(()=>{var w,v;if(!((((w=t==null?void 0:t.contentIds)==null?void 0:w.length)??0)>0)){const{block:B,runs:C}=z("paragraph")(e);Wa(n,[Q(B,e,0,{blocks:[B],runs:C}),F(e,{collapsed:!1})]),ee(B.contentIds[0]);return}n.applyOperation(F(e,{collapsed:!((v=t==null?void 0:t.props)!=null&&v.collapsed)}))},[n,e,t==null?void 0:t.contentIds,(k=t==null?void 0:t.props)==null?void 0:k.collapsed]),u=le("be-toggle-heading",t);if(!t)return null;const{level:f=2,collapsed:d,titleRunIds:b=[]}=t.props,h=t.contentIds.length>0,m=`h${f}`,g=Ie(n,t);return a.jsxs("div",{className:u,"data-block-id":e,dir:g,children:[a.jsxs("div",{className:"be-toggle-heading-row",children:[a.jsx("button",{type:"button",className:"be-toggle-heading-marker",onClick:c,"aria-expanded":!d,"aria-label":h?d?"Expand section":"Collapse section":"Add content to section",children:d?a.jsx(Me,{}):a.jsx(Cn,{})}),a.jsx(m,{className:`be-heading be-heading-${f} be-toggle-heading-title`,"data-empty":de(n,b)?"":void 0,"data-placeholder":`Toggle heading ${f}`,children:a.jsx(Re,{blockId:e,runIds:b,dir:g,onEnter:o,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:i})})]}),!d&&a.jsx("div",{className:"be-toggle-heading-children",children:a.jsx(Ne,{parentId:e})})]})}function Ga({level:e=2,collapsed:n=!1}={}){return function(r,o){const l=E(),s=o!=null&&o.length?o:[{id:E(),type:"text",value:"",marks:{}}],{block:i,runs:c}=z("paragraph")(l);return{block:{id:l,type:"toggleHeading",parentId:r,contentIds:[i.id],props:{level:e,collapsed:n,titleRunIds:s.map(u=>u.id)}},runs:[...s,...c],subtreeBlocks:[i]}}}function Ja(e,n){const{titleRunIds:t=[],level:r=2,collapsed:o}=e.props,l=t.map(i=>je(n.store.getRun(i),n)).join(""),s=e.contentIds.map(i=>{const c=n.store.getBlock(i);return n.registry.get(c.type).toHTML(c,n)}).join("");return`<details${o?"":" open"}><summary><h${r}>${l}</h${r}></summary>${s}</details>`}function Xa(e,n){const{titleRunIds:t=[]}=e.props,r=t.map(l=>Oe(n.store.getRun(l),n)).join(""),o=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
1904
2212
  `);return o?`${r}
1905
- ${o}`:r}function Zs(e,n){if(e.tagName!=="DETAILS")return null;const t=[...e.children].find(d=>d.tagName==="SUMMARY"),r=t==null?void 0:t.querySelector("h1,h2,h3,h4,h5,h6"),o=r?Math.min(6,Math.max(1,Number(r.tagName[1]))):2,l=r?de(r,n):[{id:T(),type:"text",value:"",marks:{}}],s=T(),c=[],i=[],u=[];for(const d of e.children){if(d===t||d.tagName!=="P")continue;const b=de(d,n),h={id:T(),type:"paragraph",parentId:s,contentIds:b.map(m=>m.id),props:{}};c.push(h),i.push(...b),u.push(h.id)}if(u.length===0){const{block:d,runs:b}=$("paragraph")(s);c.push(d),i.push(...b),u.push(d.id)}return{block:{id:s,type:"toggleHeading",parentId:null,contentIds:u,props:{level:o,collapsed:!e.hasAttribute("open"),titleRunIds:l.map(d=>d.id)}},runs:[...l,...i],subtreeBlocks:c}}const Ir={component:Gs,isLeaf:!1,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:Js,toPlainText:Qs,fromHTML:Zs,slashCommands:[1,2,3].map(e=>({label:`Toggle heading ${e}`,icon:pn,keywords:["toggle","heading","collapse","section"],run:(n,t)=>ne(n,t,Xs({level:e}))}))},vn=[{label:"Blue",value:"#2b6fd6"},{label:"Green",value:"#2f9e44"},{label:"Red",value:"#e03131"},{label:"Purple",value:"#9c36b5"},{label:"Gray",value:"#495057"},{label:"Black",value:"#1a1a1a"}];function ea(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function na({isOpen:e,onClose:n,store:t,blockId:r}){const[o,l]=f.useState(""),[s,c]=f.useState(""),[i,u]=f.useState(vn[0].value),[p,d]=f.useState([{key:"",value:""}]);f.useEffect(()=>{var I,y,E;if(!e)return;const g=t.getBlock(r);if(!g)return;const x=g.contentIds.map(R=>{var S;return((S=t.getRun(R))==null?void 0:S.value)??""}).join(""),k=((I=g.props)==null?void 0:I.customAttrs)??[];l(x),c(((y=g.props)==null?void 0:y.href)??""),u(((E=g.props)==null?void 0:E.color)??vn[0].value),d([...k,{key:"",value:""}])},[e,r,t]);const b=f.useCallback((g,x)=>{d(k=>{const I=k.map((E,R)=>R===g?{...E,...x}:E),y=I[I.length-1];return(y.key.trim()||y.value.trim())&&I.push({key:"",value:""}),I})},[]),h=f.useCallback(g=>{d(x=>x.filter((k,I)=>I!==g))},[]),m=f.useCallback(()=>{const g={id:T(),type:"text",value:o,marks:{}},x=p.filter(k=>k.key.trim());ea(t,[se(r,[g]),z(r,{href:s.trim(),color:i,customAttrs:x})]),n()},[t,r,o,s,i,p,n]);return a.jsxs(Ye,{isOpen:e,onClose:n,title:"Edit button",children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Label"}),a.jsx("input",{type:"text",value:o,onChange:g=>l(g.target.value),placeholder:"Button"})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Link URL"}),a.jsx("input",{type:"url",value:s,onChange:g=>c(g.target.value),placeholder:"https://example.com"})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Color"}),a.jsx("div",{className:"be-modal-color-row",children:vn.map(g=>a.jsx("button",{type:"button",className:`be-modal-color-swatch${i===g.value?" be-modal-color-swatch-active":""}`,style:{backgroundColor:g.value},title:g.label,"aria-label":g.label,onClick:()=>u(g.value)},g.value))})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Custom attributes"}),p.map((g,x)=>a.jsxs("div",{className:"be-modal-attr-row",children:[a.jsx("input",{type:"text",placeholder:"name",value:g.key,onChange:k=>b(x,{key:k.target.value})}),a.jsx("input",{type:"text",placeholder:"value",value:g.value,onChange:k=>b(x,{value:k.target.value})}),(g.key||g.value)&&a.jsx("button",{type:"button",className:"be-modal-attr-remove",onClick:()=>h(x),"aria-label":"Remove attribute",children:a.jsx(Ge,{size:14})})]},x))]}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:"Save"})]})]})}const ta="#2b6fd6";function ra({id:e}){var k,I,y,E;const n=D(),t=Q(e),{setSelectedBlockId:r}=ge(),[o,l]=f.useState(!1),s=f.useCallback(()=>{Me(n,e,(t==null?void 0:t.contentIds)??[],$("paragraph"))},[n,e,t]),c=f.useCallback(()=>{const R=Qe(n,e);De(n,R,e,r)},[n,e,r]),i=f.useCallback(()=>te(n,e,"up"),[n,e]),u=f.useCallback(()=>te(n,e,"down"),[n,e]),p=f.useCallback(()=>{var S;const R=(S=t==null?void 0:t.props)==null?void 0:S.href;R&&window.open(R,"_blank","noopener,noreferrer")},[(k=t==null?void 0:t.props)==null?void 0:k.href]),d=ee("be-button-block",t);if(!t)return null;const b=((I=t.props)==null?void 0:I.href)??"",h=((y=t.props)==null?void 0:y.color)??ta,m=((E=t.props)==null?void 0:E.customAttrs)??[],g=ae(n,t.contentIds),x={};for(const{key:R,value:S}of m)R.trim()&&(x[`data-${R.trim()}`]=S);return a.jsxs("div",{className:d,"data-block-id":e,children:[a.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:h},...x,children:[a.jsx("span",{className:"be-button-block-label","data-empty":g?"":void 0,"data-placeholder":"Button",children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:s,onBackspaceAtStart:c,onArrowUp:i,onArrowDown:u})}),a.jsx("button",{type:"button",className:"be-button-block-open",onClick:p,disabled:!b,title:b||"No link set","aria-label":"Open link",children:"↗"}),a.jsx("button",{type:"button",className:"be-button-block-settings",onClick:()=>l(!0),"aria-label":"Edit button",title:"Edit label, link, color…",children:"⚙"})]}),a.jsx(na,{isOpen:o,onClose:()=>l(!1),store:n,blockId:e})]})}function oa({href:e="",label:n="Button",color:t="",customAttrs:r=[]}={}){return function(l,s){const c=T(),i=s!=null&&s.length?s:[{id:T(),type:"text",value:n,marks:{}}];return{block:{id:c,type:"button",parentId:l,contentIds:i.map(u=>u.id),props:{href:e,color:t,customAttrs:r}},runs:i}}}const wr="be-button-block-link";function la(e,n){var i,u,p;const t=e.contentIds.map(d=>n.store.getRun(d)),r=((i=e.props)==null?void 0:i.href)??"",o=(u=e.props)==null?void 0:u.color,l=o?` style="background-color:${ce(o)}"`:"",c=(((p=e.props)==null?void 0:p.customAttrs)??[]).filter(d=>{var b;return(b=d.key)==null?void 0:b.trim()}).map(d=>` data-${ce(d.key.trim())}="${ce(d.value??"")}"`).join("");return`<a class="${wr}" href="${ce(r)}"${l}${c}>${t.map(d=>Ie(d,n)).join("")}</a>`}function sa(e,n){return e.contentIds.map(t=>we(n.store.getRun(t),n)).join("")}function aa(e,n){var l;if(e.tagName!=="A"||!e.classList.contains(wr))return null;const t=de(e,n),r=[];for(const s of e.attributes)s.name.startsWith("data-")&&r.push({key:s.name.slice(5),value:s.value});return{block:{id:T(),type:"button",parentId:null,contentIds:t.map(s=>s.id),props:{href:e.getAttribute("href")??"",color:((l=e.style)==null?void 0:l.backgroundColor)||void 0,customAttrs:r}},runs:t}}const Cr={component:ra,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:la,toPlainText:sa,fromHTML:aa,slashCommand:{label:"Button",icon:zo,keywords:["button","link","cta","action"],run:(e,n)=>ne(e,n,oa())}};function mt(e){return new Promise((n,t)=>{const r=new FileReader;r.onload=()=>n(r.result),r.onerror=()=>t(r.error),r.readAsDataURL(e)})}const rn={image:"image",video:"video",audio:"audio",file:"file"},ca={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},Br=20,Rr=100,ia=[{value:"left",Icon:So,label:"Align left"},{value:"center",Icon:Eo,label:"Align center"},{value:"right",Icon:Oo,label:"Align right"}];function ua(e){return Math.min(Rr,Math.max(Br,Math.round(e)))}function da({kind:e,src:n,name:t}){return e==="image"?a.jsx("img",{className:"be-embed-image",src:n,alt:t||""}):e==="video"?a.jsx("video",{className:"be-embed-video",src:n,controls:!0}):e==="audio"?a.jsx("audio",{className:"be-embed-audio",src:n,controls:!0}):a.jsxs("a",{className:"be-embed-file-link",href:n,download:t||void 0,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(jt,{size:14})," ",t||n]})}function pa({id:e}){const n=D(),t=Q(e),[r,o]=f.useState(""),[l,s]=f.useState(!1),[c,i]=f.useState(null),u=f.useRef(null),p=f.useRef(null),d=f.useCallback(B=>n.applyOperation(z(e,B)),[n,e]),b=f.useCallback(async B=>{var M;const O=(M=B.target.files)==null?void 0:M[0];if(!O)return;const N=await mt(O);d({src:N,name:O.name,mimeType:O.type})},[d]),h=f.useCallback(async B=>{var M;B.preventDefault(),s(!1);const O=(M=B.dataTransfer.files)==null?void 0:M[0];if(!O)return;const N=await mt(O);d({src:N,name:O.name,mimeType:O.type})},[d]),m=f.useCallback(B=>{B.preventDefault(),s(!0)},[]),g=f.useCallback(()=>s(!1),[]),x=f.useCallback(()=>{const B=r.trim();B&&(d({src:B,name:B}),o(""))},[r,d]),k=f.useCallback(()=>d({src:"",name:"",mimeType:""}),[d]),I=f.useCallback(B=>{B.preventDefault();const O=u.current,N=p.current;if(!O||!N)return;const M=O.getBoundingClientRect().width,q=N.getBoundingClientRect().width,V=B.clientX,H=K=>ua((q+(K.clientX-V))/M*100),P=K=>i(H(K)),W=K=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",W),d({width:H(K)}),i(null)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",W)},[d]),y=ee("be-embed",t);if(!t)return null;const{kind:E="file",src:R,name:S,align:C="left",width:w=100}=t.props,v=E==="image"||E==="video",j=c??w;return a.jsx("div",{className:y,"data-block-id":e,"data-kind":E,contentEditable:!1,tabIndex:-1,children:R?a.jsx("div",{ref:u,className:`be-embed-preview be-embed-align-${C}`,children:a.jsxs("div",{ref:p,className:"be-embed-frame",style:v?{width:`${j}%`}:void 0,children:[a.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[ia.map(({value:B,Icon:O,label:N})=>a.jsx("button",{type:"button",className:`be-embed-toolbar-btn${C===B?" be-embed-toolbar-btn-active":""}`,title:N,"aria-label":N,"aria-pressed":C===B,onClick:()=>d({align:B}),children:a.jsx(O,{size:14})},B)),a.jsx("button",{type:"button",className:"be-embed-remove",onClick:k,"aria-label":`Remove ${rn[E]}`,children:"Remove"})]}),a.jsx(da,{kind:E,src:R,name:S}),v&&a.jsx("div",{className:"be-embed-resize-handle",onMouseDown:I,role:"slider","aria-label":`Resize ${rn[E]}`,"aria-valuemin":Br,"aria-valuemax":Rr,"aria-valuenow":j})]})}):a.jsxs("div",{className:`be-embed-dropzone${l?" be-embed-dropzone-active":""}`,onDrop:h,onDragOver:m,onDragLeave:g,children:[a.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",rn[E],a.jsx("input",{type:"file",accept:ca[E],onChange:b,hidden:!0})]}),a.jsx("span",{className:"be-embed-dropzone-hint",children:"or drop a file, or paste a URL below"}),a.jsxs("div",{className:"be-embed-url-row",children:[a.jsx("input",{type:"text",className:"be-embed-url-input",placeholder:`https://... ${rn[E]} URL`,value:r,onChange:B=>o(B.target.value),onKeyDown:B=>B.key==="Enter"&&x()}),a.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:x,children:"Embed"})]})]})})}function fa({kind:e="file",src:n="",name:t="",mimeType:r="",align:o="left",width:l=100}={}){return function(c){return{block:{id:T(),type:"embed",parentId:c,contentIds:[],props:{kind:e,src:n,name:t,mimeType:r,align:o,width:l}},runs:[]}}}const ba={image:Yo,video:Go,audio:Xo,file:jt},Tr="be-embed-file-link";function ma(e,n,t){if(e!=="image"&&e!=="video")return"";const r=[];return t!==100&&r.push(`width:${t}%`),n==="center"?r.push("display:block","margin-left:auto","margin-right:auto"):n==="right"&&r.push("display:block","margin-left:auto"),r.length?` style="${r.join(";")}"`:""}function ht(e){var o,l,s,c;const n=(o=e.style)==null?void 0:o.width,t=n&&n.endsWith("%")?parseInt(n,10):100;let r="left";return((l=e.style)==null?void 0:l.marginLeft)==="auto"&&((s=e.style)==null?void 0:s.marginRight)==="auto"?r="center":((c=e.style)==null?void 0:c.marginLeft)==="auto"&&(r="right"),{align:r,width:Number.isFinite(t)?t:100}}function ha(e){const{kind:n,src:t,name:r,align:o="left",width:l=100}=e.props;if(!t)return"<p></p>";const s=ma(n,o,l);return n==="image"?`<img src="${ce(t)}" alt="${ce(r||"")}"${s}>`:n==="video"?`<video src="${ce(t)}" controls${s}></video>`:n==="audio"?`<audio src="${ce(t)}" controls></audio>`:`<a class="${Tr}" href="${ce(t)}">${Se(r||t)}</a>`}function ga(e){const{kind:n,src:t,name:r}=e.props;return t?`[${n}: ${r||t}]`:""}function xa(e){return e.tagName==="IMG"?on("image",e.getAttribute("src")??"",e.getAttribute("alt")??"",ht(e)):e.tagName==="VIDEO"?on("video",e.getAttribute("src")??"","",ht(e)):e.tagName==="AUDIO"?on("audio",e.getAttribute("src")??"",""):e.tagName==="A"&&e.classList.contains(Tr)?on("file",e.getAttribute("href")??"",e.textContent??""):null}function on(e,n,t,{align:r="left",width:o=100}={}){return{block:{id:T(),type:"embed",parentId:null,contentIds:[],props:{kind:e,src:n,name:t,align:r,width:o}},runs:[]}}function ka(e){return(n,{blockId:t,runId:r,sliceStart:o,sliceEnd:l})=>{const s=n.getRun(r),c=(s==null?void 0:s.value)??"";n.applyOperation(J(r,{value:c.slice(0,o)+c.slice(l)}));const i=zn(n,t,fa({kind:e}));return ve(n,i,$("paragraph")),i}}const jr={component:pa,isLeaf:!0,defaultProps:{kind:"file",src:"",name:"",mimeType:"",align:"left",width:100},toHTML:ha,toPlainText:ga,fromHTML:xa,slashCommands:["image","video","audio","file"].map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),icon:ba[e],keywords:["embed","upload","insert",e],run:ka(e)}))};function ya(e){Sr(e,{paragraph:Ut,heading:Ft,listItem:Jt,...Er,...Or,divider:gr,callout:kr,blockquote:yr,code:vr,toggleHeading:Ir,button:Cr,embed:jr})}function Sr(e,n){for(const[t,r]of Object.entries(n))e.register(t,r)}const Er={table:pr,tableRow:dr,tableCell:ur},Or={layout:hr,layoutColumn:mr};function va({id:e}){const n=D(),t=ye(e),r=f.useCallback(c=>{n.applyOperation(J(e,{data:{...t==null?void 0:t.data,selectedValue:c}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{options:o=[],selectedValue:l="",placeholder:s="Select…"}=t.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onKeyDown:c=>c.stopPropagation(),children:a.jsx(_e,{value:l,options:o,onChange:r,placeholder:s,ariaLabel:"Select an option"})})}function xn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,r),u=c.slice(o),p=l(),d={...s,value:i},b={id:T(),type:"text",value:u,marks:{...s==null?void 0:s.marks}};e.applyOperation(qe(n,[t],[d,p,b])),X(b.id)}function Ia(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Lr(e){var r;const{options:n=[],selectedValue:t=""}=e.data??{};return((r=n.find(o=>o.value===t))==null?void 0:r.label)??""}function wa(e){var t,r;const n=Lr(e)||((t=e.data)==null?void 0:t.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${Ia(((r=e.data)==null?void 0:r.selectedValue)??"")}">${n}</span>`}function Ca(e){return Lr(e)}function Ba(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="select"?null:{id:T(),type:"select",value:"",marks:{},data:{options:[],selectedValue:e.getAttribute("data-selected-value")??""}}}const Nr={component:va,isAtomic:!0,toHTML:wa,toPlainText:Ca,fromHTML:Ba,slashCommand:{label:"Select",icon:Vo,keywords:["select","dropdown","choice","picker"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>xn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:T(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}))}};function Ra({id:e}){const n=D(),t=ye(e),r=f.useCallback(l=>{n.applyOperation(J(e,{data:{...t==null?void 0:t.data,isoDate:l.target.value}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{isoDate:o=""}=t.data??{};return a.jsx("span",{className:"be-inline-date",onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation(),children:a.jsx("input",{type:"date",value:o,onChange:r})})}function Ta(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Mr(e){if(!e)return"";const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ja(e){var t;const n=((t=e.data)==null?void 0:t.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${Ta(n)}">${Mr(n)}</span>`}function Sa(e){var n;return Mr(((n=e.data)==null?void 0:n.isoDate)??"")}function Ea(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="date"?null:{id:T(),type:"date",value:"",marks:{},data:{isoDate:e.getAttribute("data-iso-date")??""}}}function Oa(){return new Date().toISOString().slice(0,10)}const Ar={component:Ra,isAtomic:!0,toHTML:ja,toPlainText:Sa,fromHTML:Ea,slashCommand:{label:"Date",icon:Wo,keywords:["date","when","schedule","calendar"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>xn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:T(),type:"date",value:"",marks:{},data:{isoDate:Oa()}}))}};function La({id:e}){const n=D(),t=ye(e),r=f.useCallback(c=>{n.applyOperation(J(e,{data:{...t==null?void 0:t.data,checked:c.target.checked}}))},[n,e,t==null?void 0:t.data]),o=f.useCallback(c=>{n.applyOperation(J(e,{data:{...t==null?void 0:t.data,label:c.target.value}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{checked:l=!1,label:s=""}=t.data??{};return a.jsxs("span",{className:"be-inline-checkbox",onMouseDown:c=>c.stopPropagation(),onKeyDown:c=>c.stopPropagation(),children:[a.jsx("input",{type:"checkbox",className:"be-inline-checkbox-input",checked:l,onChange:r}),a.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:s,onChange:o,placeholder:"Label…"})]})}function Na(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ma(e){const{checked:n=!1,label:t=""}=e.data??{};return`<span data-inline-type="checkbox" data-checked="${n}">${n?"☑":"☐"} ${Na(t)}</span>`}function Aa(e){const{checked:n=!1,label:t=""}=e.data??{};return`${n?"[x]":"[ ]"} ${t}`.trim()}function Da(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="checkbox"?null:{id:T(),type:"checkbox",value:"",marks:{},data:{checked:e.getAttribute("data-checked")==="true",label:(e.textContent??"").replace(/^[☑☐]\s*/,"")}}}const Dr={component:La,isAtomic:!0,toHTML:Ma,toPlainText:Aa,fromHTML:Da,slashCommand:{label:"Checkbox",icon:Mt,keywords:["checkbox","todo","check","toggle"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>xn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:T(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function _a({id:e,blockId:n}){var h;const t=D(),r=ye(e),o=n?t.getBlock(n):null,l=o?t.getBlock(o.parentId):null,s=(l==null?void 0:l.parentId)??null,c=Q(s),i=l?l.contentIds.indexOf(n):-1,p=(((h=(c&&l?ie(c,l.contentIds.length):[])[i])==null?void 0:h.options)??[]).map((m,g)=>({...m,color:m.color??Ke(g)})),d=f.useCallback((m,g)=>{t.applyOperation(J(e,{data:{selectedValue:m,selectedLabel:(g==null?void 0:g.label)??""}}))},[t,e]);if(!r)return null;const{selectedValue:b=""}=r.data??{};return a.jsx("span",{className:"be-inline-table-select",onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onKeyDown:m=>m.stopPropagation(),children:a.jsx(_e,{value:b,options:p,onChange:d,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function _r(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $a(e){return _r(e).replace(/"/g,"&quot;")}function Pa(e){const{selectedValue:n="",selectedLabel:t=""}=e.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${$a(n)}">${_r(t)}</span>`}function Ha(e){var n;return((n=e.data)==null?void 0:n.selectedLabel)??""}function za(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="tableSelect"?null:{id:T(),type:"tableSelect",value:"",marks:{},data:{selectedValue:e.getAttribute("data-selected-value")??"",selectedLabel:e.textContent??""}}}const $r={component:_a,isAtomic:!0,toHTML:Pa,toPlainText:Ha,fromHTML:za},Pr={};function Ua(e){Hr(e,{select:Nr,date:Ar,checkbox:Dr,...zr,emoji:Pr})}function Hr(e,n){for(const[t,r]of Object.entries(n))e.register(t,r)}const zr={tableSelect:$r},Fa="$fieldTypes";function Ur(){const e=D(),n=f.useCallback(r=>e.subscribe(Fa,r),[e]),t=f.useCallback(()=>e.getFieldTypes(),[e]);return f.useSyncExternalStore(n,t)}const Ka={canUndo:!1,canRedo:!1};function qa(){const{history:e}=pe(),n=f.useCallback(o=>e?e.subscribeToHistory(o):()=>{},[e]),t=f.useCallback(()=>e?e.getUndoRedoSnapshot():Ka,[e]),r=f.useSyncExternalStore(n,t);return e?{...r,undo:()=>e.undo(),redo:()=>e.redo(),getHistoryLog:()=>e.getHistoryLog()}:null}const cn="application/x-block-editor-blocks+json";function Gn(e){return e.split(/\r\n|\r|\n/).filter(n=>n.length>0).map(n=>{const t=T();return{block:{id:T(),type:"paragraph",parentId:null,contentIds:[t],props:{}},runs:[{id:t,type:"text",value:n,marks:{}}]}})}function Fr(e,n,t){const r=new DOMParser().parseFromString(e,"text/html"),o={registry:n,inlineRegistry:t},l=n.listHtmlMatchers(),s=[],c=u=>{var b;const p=u.tagName==="OL",d=[];for(const h of u.children){if(h.tagName!=="LI")continue;const m=(b=n.get("listItem"))==null?void 0:b.fromHTML(h,o);m&&(m.block.props.ordered=p,d.push(m))}return d},i=u=>{var d;const p=Array.from(u.children).filter(b=>b.tagName==="P");if(p.length===0){const b=(d=n.get("blockquote"))==null?void 0:d.fromHTML(u,o);return b?[b]:[]}return p.map(b=>{const h=de(b,o);return{block:{id:T(),type:"blockquote",parentId:null,contentIds:h.map(m=>m.id),props:{}},runs:h}})};for(const u of r.body.childNodes){if(u.nodeType===3){const d=u.textContent.trim();d&&s.push(...Gn(d));continue}if(u.nodeType!==1)continue;if(u.tagName==="UL"||u.tagName==="OL"){s.push(...c(u));continue}if(u.tagName==="BLOCKQUOTE"){s.push(...i(u));continue}let p=null;for(const d of l){const b=d.fromHTML(u,o);if(b){p=b;break}}if(p)s.push(p);else if(u.textContent.trim()){const d=de(u,o);s.push({block:{id:T(),type:"paragraph",parentId:null,contentIds:d.map(b=>b.id),props:{}},runs:d})}}return s}function Kr(e,n,t){const r=e.types??[];if(r.includes(cn)){const l=e.getData(cn);if(l)return Wa(l)}if(r.includes("text/html")){const l=e.getData("text/html");if(l)return Fr(l,n,t)}const o=e.getData("text/plain")??"";return Gn(o)}function Wa(e){return JSON.parse(e).blocks.map(t=>qn(t))}function Bn(e,n){var r;const t=e.getBlock(n);return((r=t.props)==null?void 0:r.titleRunIds)??t.contentIds}function sn(){return{id:T(),type:"text",value:"",marks:{}}}function Rn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Xn(e,n,t){const{startRunId:r,startOffset:o,endRunId:l,endOffset:s}=t,c=Bn(e,n),i=c.indexOf(r),u=c.indexOf(l);if(i===-1||u===-1)return null;const[p,d]=i<=u?[i,u]:[u,i],b=i<=u?o:s,h=i<=u?s:o,m=c.slice(0,p).map(R=>e.getRun(R)),g=c.slice(d+1).map(R=>e.getRun(R)),x=c.slice(p,d+1).map(R=>e.getRun(R)),k=[];let I=null,y=0;if(p===d){const R=x[0];if(R.type==="text"){const S=Math.max(0,Math.min(b,h)),C=Math.min(R.value.length,Math.max(b,h)),w={...R,value:R.value.slice(0,S)+R.value.slice(C)};k.push(w),I=w.id,y=S}}else x.forEach((R,S)=>{if(R.type!=="text")return;const C=S===0,w=S===x.length-1,v=C?R.value.slice(0,b):"";if(C&&v){const j={...R,value:v};k.push(j),I=j.id,y=v.length}if(w&&!C){const j=R.value.slice(h);if(j){const B={id:T(),type:"text",value:j,marks:R.marks};k.push(B),I===null&&(I=B.id,y=0)}}});let E=[...m,...k,...g];if(E.length===0){const R=sn();E=[R],I=R.id,y=0}else if(I===null){const R=m[m.length-1];R?(I=R.id,y=R.type==="text"?R.value.length:0):g[0]&&(I=g[0].id,y=0)}return e.applyOperation(se(n,E)),{blockId:n,runId:I,offset:y}}function Jn(e,n){const{blockIds:t,startBlockId:r,startRunId:o,startOffset:l,endBlockId:s,endRunId:c,endOffset:i}=n;if(!t||t.length===0)return null;const u=t.indexOf(r),p=t.indexOf(s);if(u===-1||p===-1)return null;const[d,b]=u<=p?[u,p]:[p,u],h=u<=p,m=h?o:c,g=h?l:i,x=h?c:o,k=h?i:l;if(d===b)return Xn(e,t[d],{startRunId:m,startOffset:g,endRunId:x,endOffset:k});const I=t[d],y=t[b],E=e.getBlock(I),R=e.getBlock(y),S=Bn(e,I),C=S.indexOf(m),w=S.slice(0,C).map(Y=>e.getRun(Y)),v=e.getRun(m),j=v.type==="text"&&g>0?{...v,value:v.value.slice(0,g)}:null,B=Bn(e,y),O=B.indexOf(x),N=B.slice(O+1).map(Y=>e.getRun(Y)),M=e.getRun(x),q=M.type==="text"&&k<M.value.length?{id:T(),type:"text",value:M.value.slice(k),marks:M.marks}:null,V=[...w,...j?[j]:[]],H=[...q?[q]:[],...N],P=[];for(let Y=d+1;Y<b;Y+=1)P.push(_(t[Y]));const W=zt(E.type,R.type),K=e.getBlock(E.parentId),oe=b-d-1+(W?1:0),Re=K&&K.contentIds.length-oe===1;let Z,le,fe;if(W){const Y=[...V,...H];if(Y.length===0&&Re&&E.type!=="paragraph"){const{block:F,runs:ue}=$("paragraph")(K.id);return P.push({type:"insertBlock",block:F,parentId:K.id,index:0,subtree:{blocks:[F],runs:ue}}),P.push(_(I)),P.push(_(y)),Rn(e,P),{blockId:F.id,runId:F.contentIds[0],offset:0}}const L=Y.length?Y:[sn()];if(P.push(se(I,L)),P.push(_(y)),fe=I,j)Z=j.id,le=j.value.length;else if(w.length){const F=w[w.length-1];Z=F.id,le=F.type==="text"?F.value.length:0}else q?(Z=q.id,le=0):N.length?(Z=N[0].id,le=0):(Z=L[0].id,le=0)}else{const Y=V.length?V:[sn()];if(P.push(se(I,Y)),P.push(se(y,H.length?H:[sn()])),fe=I,j)Z=j.id,le=j.value.length;else if(w.length){const L=w[w.length-1];Z=L.id,le=L.type==="text"?L.value.length:0}else Z=Y[0].id,le=0}return Rn(e,P),{blockId:fe,runId:Z,offset:le}}function un(e,n=""){var c;const t=e.getRootId(),r=((c=e.getBlock(t))==null?void 0:c.contentIds)??[];if(r.length===0)return null;const o=r.map(i=>_(i)),{block:l,runs:s}=$("paragraph")(t);return n&&(s[0].value=n),o.push(G(l,t,0,{blocks:[l],runs:s})),Rn(e,o),{blockId:l.id,runId:l.contentIds[0],offset:n.length}}function qr(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function ze(e,n){n.length!==0&&qr(e,n.map(t=>_(t)))}function Wr(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const r=e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n[0]),l=r.contentIds.indexOf(n[n.length-1]);if(o<=0)return!1;const s=r.contentIds[o-1];return e.applyOperation(ke(s,t.parentId,l)),!0}function Vr(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const r=e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n[0]),l=r.contentIds.indexOf(n[n.length-1]);if(l===-1||l>=r.contentIds.length-1)return!1;const s=r.contentIds[l+1];return e.applyOperation(ke(s,t.parentId,o)),!0}function Yr(e,n){return n.length>0&&n.every(t=>{var r,o;return!!((o=(r=e.getBlock(t))==null?void 0:r.props)!=null&&o.hidden)})}function Gr(e,n,t){n.length!==0&&qr(e,n.map(r=>z(r,{hidden:t})))}function Va(e,n){if(n.length===0)return[];const t=e.getBlock(n[0]),r=t&&e.getBlock(t.parentId);if(!r)return n;const o=new Set(n);return r.contentIds.filter(l=>o.has(l))}function Tn(e){var t;let n=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;for(;n&&typeof n.hasAttribute=="function"&&!n.hasAttribute("data-block-id");)n=n.parentElement;return((t=n==null?void 0:n.getAttribute)==null?void 0:t.call(n,"data-block-id"))??null}function Ya(e){var d;const n=(d=window.getSelection)==null?void 0:d.call(window);if(!n||n.rangeCount===0)return[];const t=Tn(n.anchorNode),r=Tn(n.focusNode);if(!t)return[];if(!r||t===r)return[t];const o=e.getBlock(t),l=o&&e.getBlock(o.parentId);if(!l)return[t];const s=l.contentIds,c=s.indexOf(t),i=s.indexOf(r);if(c===-1||i===-1)return[t];const[u,p]=c<=i?[c,i]:[i,c];return s.slice(u,p+1)}function gt(e){const n=Je();if(n)return Xn(e,n.blockId,n);const t=Fe(e);return t?Jn(e,t):null}function Ga(e,n,t){const r=e.getRun(n.runId);if(!r||r.type!=="text")return null;const o=r.value??"",l=o.slice(0,n.offset)+t+o.slice(n.offset);return e.applyOperation(J(r.id,{value:l})),{blockId:n.blockId,runId:r.id,offset:n.offset+t.length}}function In(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Xa(){const e=D(),n=Ne(),t=he(),[r,o]=Nn(),[l,s]=We(),c=f.useCallback(p=>{var g;const d=r?((g=e.getBlock(e.getRootId()))==null?void 0:g.contentIds)??[]:l.length>0?l:Ya(e);if(d.length===0)return;const{html:b,text:h,json:m}=Ze(e,n,d,t);p.clipboardData.setData("text/plain",h),p.clipboardData.setData("text/html",b),p.clipboardData.setData(cn,m),p.preventDefault()},[e,n,t,r,l]),i=f.useCallback(p=>{if(c(p),r){const b=un(e);o(!1),b!=null&&b.runId&&be(b.runId,b.offset);return}if(l.length>0){ze(e,l),s([]);return}const d=gt(e);d!=null&&d.runId&&be(d.runId,d.offset)},[c,e,r,o,l,s]),u=f.useCallback(p=>{var y,E,R;const d=Kr(p.clipboardData,n,t);if(d.length===0)return;if(r){const S=e.getRootId(),w=(((y=e.getBlock(S))==null?void 0:y.contentIds)??[]).map(j=>_(j));let v=0;for(const{block:j,runs:B,subtreeBlocks:O=[]}of d)j.parentId=S,w.push(G(j,S,v,{blocks:[j,...O],runs:B})),v+=1;In(e,w),o(!1),p.preventDefault();return}if(l.length>0){const S=e.getBlock(l[0]),C=(S==null?void 0:S.parentId)??null,w=C&&e.getBlock(C);let v=w?w.contentIds.indexOf(l[0]):0;const j=l.map(B=>_(B));for(const{block:B,runs:O,subtreeBlocks:N=[]}of d)B.parentId=C,j.push(G(B,C,v,{blocks:[B,...N],runs:O})),v+=1;In(e,j),s([]),p.preventDefault();return}const b=gt(e);if(d.length===1&&d[0].runs.every(S=>S.type==="text")&&(d[0].subtreeBlocks??[]).length===0){const S=b?{blockId:b.blockId,runId:b.runId,offset:b.offset}:Xe();if(S){const C=d[0].runs.map(v=>v.value).join(""),w=Ga(e,S,C);if(w){be(w.runId,w.offset),p.preventDefault();return}}}const m=(b==null?void 0:b.blockId)??Tn((R=(E=window.getSelection)==null?void 0:E.call(window))==null?void 0:R.anchorNode);if(!m)return;const g=e.getBlock(m);if(!g)return;let k=e.getBlock(g.parentId).contentIds.indexOf(m)+1;const I=[];for(const{block:S,runs:C,subtreeBlocks:w=[]}of d)S.parentId=g.parentId,I.push(G(S,g.parentId,k,{blocks:[S,...w],runs:C})),k+=1;In(e,I),p.preventDefault()},[e,n,t,r,o,l,s]);return{onCopy:c,onCut:i,onPaste:u}}const Ja=["bold","italic","underline","strike","subscript","superscript","code"],Qa=["color","highlight","link"];function Ee(e,n){var r;const t=e.getBlock(n);return((r=t.props)==null?void 0:r.titleRunIds)??t.contentIds}function Za(e,n){return e===n?!0:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function Xr(e){var t;const n={};if(e.length===0)return n;for(const r of Ja)n[r]=e.every(o=>{var l;return(l=o.marks)==null?void 0:l[r]});for(const r of Qa){const o=((t=e[0].marks)==null?void 0:t[r])??null;n[r]=e.every(l=>{var s;return Za(((s=l.marks)==null?void 0:s[r])??null,o)})?o:null}return n}function Jr(e,n,t){const{startRunId:r,startOffset:o,endRunId:l,endOffset:s}=t,c=Ee(e,n),i=c.indexOf(r),u=c.indexOf(l);if(i===-1||u===-1)return{};const[p,d]=i<=u?[i,u]:[u,i],b=c.slice(p,d+1).map(h=>e.getRun(h)).filter(h=>h&&h.type==="text");return Xr(b)}function Qr(e,n){const{blockIds:t,startBlockId:r,endBlockId:o}=n,l=t.indexOf(r),s=t.indexOf(o);if(l===-1||s===-1)return{};const[c,i]=l<=s?[l,s]:[s,l],u=[];for(let p=c;p<=i;p+=1)for(const d of Ee(e,t[p])){const b=e.getRun(d);b&&b.type==="text"&&u.push(b)}return Xr(u)}function Zr(e,n){const t={...e};for(const[r,o]of Object.entries(n))o!=null?t[r]=o:delete t[r];return t}function eo(e,n,t,r,o,l){const s=Zr(t.marks,l);if(r===0&&o===t.value.length)return e.applyOperation({type:"updateRun",id:t.id,patch:{marks:s}}),t.id;const c=t.value.slice(0,r),i=t.value.slice(r,o),u=t.value.slice(o),p=[];c&&p.push({id:T(),type:"text",value:c,marks:{...t.marks}});const d={id:T(),type:"text",value:i,marks:s};return p.push(d),u&&p.push({id:T(),type:"text",value:u,marks:{...t.marks}}),e.applyOperation(qe(n,[t.id],p)),d.id}function ec(e,n,t,r){const{startRunId:o,startOffset:l,endRunId:s,endOffset:c}=t,i=Ee(e,n),u=i.indexOf(o),p=i.indexOf(s);if(u===-1||p===-1)return null;const[d,b]=u<=p?[u,p]:[p,u],h=u<=p?l:c,m=u<=p?c:l,g=i.slice(d,b+1),x=g.map(y=>e.getRun(y));if(d===b){const y=x[0];if(y.type!=="text")return y.id;const E=Math.max(0,Math.min(h,m)),R=Math.min(y.value.length,Math.max(h,m));return E===R?y.id:eo(e,n,y,E,R,r)}const k=[];let I=null;return x.forEach((y,E)=>{if(y.type!=="text"){k.push(y),I=y.id;return}const R=E===0,S=E===x.length-1,C=R?h:0,w=S?m:y.value.length,v=y.value.slice(0,C),j=y.value.slice(C,w),B=y.value.slice(w);v&&k.push({id:T(),type:"text",value:v,marks:{...y.marks}});const O={id:T(),type:"text",value:j,marks:Zr(y.marks,r)};k.push(O),I=O.id,B&&k.push({id:T(),type:"text",value:B,marks:{...y.marks}})}),e.applyOperation(qe(n,g,k)),I}function nc(e,n,t,r){var m;const{startRunId:o,startOffset:l,endRunId:s,endOffset:c}=t,i=Ee(e,n),u=i.indexOf(o),p=i.indexOf(s);if(u===-1||p===-1)return!0;const[d,b]=u<=p?[u,p]:[p,u],h=i.slice(d,b+1).map(g=>e.getRun(g)).filter(g=>g.type==="text");if(h.length===0)return!0;if(d===b){const g=Math.max(0,Math.min(l,c)),x=Math.min(h[0].value.length,Math.max(l,c));if(g===x)return!((m=h[0].marks)!=null&&m[r])}return!h.every(g=>{var x;return(x=g.marks)==null?void 0:x[r]})}function tc(e,n,t,r,o,l){var d;const s=e.getRun(t),c=s.value??"",i=Math.max(0,Math.min(r,o)),u=Math.min(c.length,Math.max(r,o));if(i===u)return t;const p=!((d=s.marks)!=null&&d[l]);return eo(e,n,s,i,u,{[l]:p?!0:null})}function Oe(e,n,t,r){return ec(e,n,t,r)}function Qn(e,n,t,r){const o=nc(e,n,t,r);return Oe(e,n,t,{[r]:o?!0:null})}function Zn(e,n,t){return dn(e,n,r=>({[t]:r?null:!0}),t)}function dn(e,n,t,r){var S;const{blockIds:o,startBlockId:l,startRunId:s,startOffset:c,endBlockId:i,endRunId:u,endOffset:p}=n;if(!o||o.length===0)return null;const d=o.indexOf(l),b=o.indexOf(i);if(d===-1||b===-1)return null;const[h,m]=d<=b?[d,b]:[b,d],g=d<=b,x=g?s:u,k=g?c:p,I=g?u:s,y=g?p:c;let E=t;if(typeof t=="function"){let C=!1,w=!0;for(let v=h;v<=m;v+=1){const j=Ee(e,o[v]).map(B=>e.getRun(B)).filter(B=>B.type==="text");j.length!==0&&(C=!0,j.every(B=>{var O;return(O=B.marks)==null?void 0:O[r]})||(w=!1))}E=t(C&&w)}if(h===m)return Oe(e,o[h],{startRunId:x,startOffset:k,endRunId:I,endOffset:y},E);let R=null;for(let C=h;C<=m;C+=1){const w=o[C],v=Ee(e,w),j=v[0],B=v[v.length-1],O=e.getRun(B),N=((S=O==null?void 0:O.value)==null?void 0:S.length)??0;let M;C===h&&C===m?M={startRunId:x,startOffset:k,endRunId:I,endOffset:y}:C===h?M={startRunId:x,startOffset:k,endRunId:B,endOffset:N}:C===m?M={startRunId:j,startOffset:0,endRunId:I,endOffset:y}:M={startRunId:j,startOffset:0,endRunId:B,endOffset:N},R=Oe(e,w,M,E)}return R}function no(e,n){var r;const t=e.getBlock(n);return((r=t==null?void 0:t.props)==null?void 0:r.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function to(e){const n=Je();if(!n)return!1;const{blockId:t,startRunId:r,startOffset:o,endRunId:l,endOffset:s}=n,c=no(e,t);if(c.length===0)return!1;const i=c.indexOf(r),u=c.indexOf(l);if(i===-1||u===-1)return!1;const[p,d]=i<=u?[i,u]:[u,i],b=i<=u?o:s,h=i<=u?s:o;if(p!==0||d!==c.length-1||b!==0)return!1;const m=e.getRun(c[c.length-1]),g=(m==null?void 0:m.type)==="text"?(m.value??"").length:1;return h===g}function rc(e){const n=Xe();return n?ae(e,no(e,n.blockId)):!1}function oc(e,n,t){var h,m;const r=e.getBlock(n);if(!r){t(null);return}const o=e.getBlock(r.parentId),l=o?o.contentIds.indexOf(n):-1,s=l>0?o.contentIds[l-1]:null,c=l!==-1&&l<o.contentIds.length-1?o.contentIds[l+1]:null;e.applyOperation(_(n)),t(null);const i=Ae(e),u=s??c??i;if(!u)return;const p=e.getBlock(u);if(Ve(e,p)){t(u),requestAnimationFrame(()=>{var g;return(g=document.querySelector(`[data-block-id="${u}"]`))==null?void 0:g.focus()});return}const d=(h=p==null?void 0:p.props)==null?void 0:h.titleRunIds,b=((m=p==null?void 0:p.contentIds)==null?void 0:m[p.contentIds.length-1])??(d==null?void 0:d[d.length-1]);b&&X(b)}const xt={b:"bold",i:"italic",u:"underline"};function lc(e){const n=D(),[t,r]=Nn(),{getSelectedBlockId:o,setSelectedBlockId:l}=ge();f.useEffect(()=>{const s=e.current;if(!s)return;const c=u=>{var d,b;if(o()&&(u.key==="Backspace"||u.key==="Delete")&&!u.defaultPrevented){u.preventDefault(),u.stopPropagation(),oc(n,o(),l);return}if(o()&&u.key!=="Backspace"&&u.key!=="Delete"&&l(null),u.metaKey||u.ctrlKey){const h=u.key.toLowerCase();if(h==="z"&&!u.shiftKey){u.preventDefault(),(d=n.undo)==null||d.call(n);return}if(h==="z"&&u.shiftKey||h==="y"){u.preventDefault(),(b=n.redo)==null||b.call(n);return}if(h==="a"){if(t)return;(to(n)||rc(n))&&(u.preventDefault(),r(!0));return}if(xt[h]){if(t)return;u.preventDefault();const m=xt[h],g=Je();if(g){const k=Qn(n,g.blockId,g,m);k&&X(k);return}const x=Fe(n);if(x){const k=Zn(n,x,m);k&&X(k)}}return}if(t){if(u.key==="Backspace"||u.key==="Delete"){u.preventDefault(),u.stopPropagation();const h=un(n);r(!1),h!=null&&h.runId&&be(h.runId,h.offset);return}if(u.key.length===1){u.preventDefault(),u.stopPropagation();const h=un(n,u.key);r(!1),h!=null&&h.runId&&be(h.runId,h.offset);return}if(r(!1),u.key==="Escape")return}if(u.key==="Backspace"||u.key==="Delete"){const h=Fe(n);if(!h)return;u.preventDefault(),u.stopPropagation();const m=Jn(n,h);m!=null&&m.runId&&be(m.runId,m.offset)}},i=()=>{t&&r(!1),o()&&l(null)};return s.addEventListener("keydown",c),s.addEventListener("mousedown",i),()=>{s.removeEventListener("keydown",c),s.removeEventListener("mousedown",i)}},[e,n,t,r,o,l])}async function jn(e,n,t,r){var s,c,i;const{html:o,text:l}=Ze(e,n,r,t);if(typeof ClipboardItem<"u"&&((s=navigator.clipboard)!=null&&s.write)){await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([l],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})})]);return}await((i=(c=navigator.clipboard)==null?void 0:c.writeText)==null?void 0:i.call(c,l))}function sc(){const e=D(),n=Ne(),t=he(),[r,o]=We(),[l,s]=f.useState(null),c=f.useRef(null),i=r.length>0,u=f.useCallback(()=>o([]),[o]);f.useEffect(()=>{if(!i){s(null);return}const k=()=>{const I=r[r.length-1],y=document.querySelector(`[data-block-row-id="${I}"]`);s((y==null?void 0:y.getBoundingClientRect())??null)};return k(),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i,r]),f.useEffect(()=>{if(!i)return;const k=y=>{var E,R,S;(E=c.current)!=null&&E.contains(y.target)||(S=(R=y.target).closest)!=null&&S.call(R,".be-block-gutter")||u()},I=y=>{y.key==="Escape"?u():(y.key==="Delete"||y.key==="Backspace")&&(y.preventDefault(),ze(e,r),u())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",I)}},[i,e,r,u]);const p=f.useCallback(()=>{jn(e,n,t,r),u()},[e,n,t,r,u]),d=f.useCallback(async()=>{await jn(e,n,t,r),ze(e,r),u()},[e,n,t,r,u]),b=f.useCallback(()=>{ze(e,r),u()},[e,r,u]),h=f.useCallback(()=>{Wr(e,r),u()},[e,r,u]),m=f.useCallback(()=>{Vr(e,r),u()},[e,r,u]),g=Yr(e,r),x=f.useCallback(()=>{Gr(e,r,!g),u()},[e,r,g,u]);return!i||!l?null:Le.createPortal(a.jsxs("div",{ref:c,role:"menu","aria-label":"Selected blocks options",className:"be-block-range-menu",style:{position:"fixed",top:l.bottom+4,left:l.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:p,children:[a.jsx(Et,{size:15})," Copy"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:d,children:[a.jsx(No,{size:15})," Cut"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:h,children:[a.jsx(Ot,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[a.jsx(Lt,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:x,children:[g?a.jsx(At,{size:15}):a.jsx(Dt,{size:15}),g?"Show in preview":"Hide in preview"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item be-block-range-menu-item-danger",onClick:b,children:[a.jsx($n,{size:15})," Delete"]})]}),document.body)}const ac=4;function cc(e,n,t){const r=e.getBlock(n);if(!r)return[];const o=e.getBlock(r.parentId);if(!o)return[n];const l=o.contentIds,s=l.indexOf(n),c=t?l.indexOf(t):s;if(s===-1)return[n];const[i,u]=c===-1?[s,s]:[Math.min(s,c),Math.max(s,c)];return l.slice(i,u+1)}function ic(){var e,n;return typeof window<"u"&&((n=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:n.matches)===!0}function uc(e){const n=D(),[,t]=We(),r=f.useRef(null),o=f.useRef(!1),l=f.useRef(null),s=f.useCallback(p=>{var h,m,g,x,k;if(!r.current)return;if(!o.current){const{x:I,y}=l.current??{x:p.clientX,y:p.clientY};if(Math.hypot(p.clientX-I,p.clientY-y)<ac)return;o.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(m=(h=window.getSelection)==null?void 0:h.call(window))==null||m.removeAllRanges()}(x=(g=window.getSelection)==null?void 0:g.call(window))==null||x.removeAllRanges(),p.preventDefault();const d=(k=document.elementFromPoint(p.clientX,p.clientY))==null?void 0:k.closest("[data-block-row-id]"),b=(d==null?void 0:d.getAttribute("data-block-row-id"))??null;t(cc(n,r.current,b))},[n,t]),c=f.useCallback(()=>{r.current=null,o.current=!1,l.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),i=f.useCallback((p,d)=>{r.current=p,o.current=!1,l.current={x:d.clientX,y:d.clientY}},[]),u=f.useCallback(p=>{var g,x;if(p.button!==0||ic()||(x=(g=p.target).closest)!=null&&x.call(g,"button, input, textarea, select"))return;const d=p.target.closest("[data-block-row-id]");if(d){if(p.target.closest(".be-block-row-content"))return;i(d.getAttribute("data-block-row-id"),p);return}const b=e==null?void 0:e.current;if(!b)return;const m=[...b.querySelectorAll("[data-block-row-id]")].find(k=>{const I=k.getBoundingClientRect();return p.clientY>=I.top&&p.clientY<=I.bottom});m&&i(m.getAttribute("data-block-row-id"),p)},[e,i]);f.useEffect(()=>(document.addEventListener("mousedown",u),document.addEventListener("mousemove",s),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",c),document.documentElement.classList.remove("be-block-range-dragging")}),[u,s,c])}function dc({minHeight:e=180,className:n="be-trailing-space"}){const t=D(),[r]=Mn(),o=f.useCallback(()=>{var u;if(r)return;const l=t.getRootId(),s=t.getBlock(l),c=(u=s==null?void 0:s.contentIds)==null?void 0:u[s.contentIds.length-1];if(!c){const p=Ae(t);p&&ut(t,p);return}const i=t.getBlock(c);(i==null?void 0:i.type)==="paragraph"?ut(t,c):ve(t,c,$("paragraph"))},[t,r]);return a.jsx("div",{className:n,style:{minHeight:e},onClick:o})}function ro(e,{pretty:n=!0}={}){const t=e.getRootId(),{blocks:r,runs:o}=Kn(e,t);return JSON.stringify({version:1,rootId:t,blocks:r,runs:o},null,n?2:0)}function oo(e,n,t){const r=e.getBlock(e.getRootId());return r?Ze(e,n,r.contentIds,t).html:""}function lo(e,n,t){const r=e.getBlock(e.getRootId());return r?Ze(e,n,r.contentIds,t).text:""}const pc=[{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"text",label:"Text"}];function fc({label:e="View source",className:n=""}){const t=D(),r=Ne(),o=he(),[l,s]=f.useState(!1),[c,i]=f.useState("json"),[u,p]=f.useState(!1),d=f.useCallback(()=>{p(!1),s(!0)},[]),b=f.useCallback(()=>s(!1),[]),h=f.useMemo(()=>l?c==="json"?ro(t):c==="html"?oo(t,r,o):lo(t,r,o):"",[l,c,t,r,o]),m=f.useCallback(async()=>{try{await navigator.clipboard.writeText(h),p(!0),setTimeout(()=>p(!1),1500)}catch{}},[h]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:`be-export-trigger ${n}`.trim(),onClick:d,children:[a.jsx(Nt,{size:14})," ",e]}),a.jsxs(Ye,{isOpen:l,onClose:b,title:"Document source",size:"large",children:[a.jsx("div",{className:"be-export-tabs",role:"tablist",children:pc.map(g=>a.jsx("button",{type:"button",role:"tab","aria-selected":c===g.value,className:`be-export-tab${c===g.value?" be-export-tab-active":""}`,onClick:()=>i(g.value),children:g.label},g.value))}),a.jsx("pre",{className:"be-export-pre",children:a.jsx("code",{children:h})}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:b,children:"Close"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:u?"Copied!":"Copy"})]})]})]})}function bc(e,n,t,r){f.useEffect(()=>{if(!e||!n)return;const o=document.querySelector(`[data-run-id="${n}"]`);if(o)return o.setAttribute("aria-expanded","true"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-controls",r),t&&o.setAttribute("aria-activedescendant",t),()=>{o.removeAttribute("aria-expanded"),o.removeAttribute("aria-haspopup"),o.removeAttribute("aria-controls"),o.removeAttribute("aria-activedescendant")}},[e,n,t,r])}function mc({isOpen:e,rect:n,commands:t,runId:r,onSelect:o,onClose:l,menuId:s="be-slash-menu",ariaLabel:c="Slash commands"}){const[i,u]=f.useState(0),p=f.useRef(null);f.useEffect(()=>{u(0)},[t.length]),f.useEffect(()=>{var h,m;(m=(h=p.current)==null?void 0:h.scrollIntoView)==null||m.call(h,{block:"nearest"})},[i]),f.useEffect(()=>{if(!e)return;const h=m=>{m.key==="ArrowDown"?(m.preventDefault(),m.stopPropagation(),u(g=>Math.min(g+1,Math.max(t.length-1,0)))):m.key==="ArrowUp"?(m.preventDefault(),m.stopPropagation(),u(g=>Math.max(g-1,0))):m.key==="Enter"?(m.preventDefault(),m.stopPropagation(),t[i]&&o(t[i])):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l())};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[e,t,i,o,l]);const b=t[i]?`${s}-option-${i}`:null;return bc(e,r,b,s),!e||t.length===0||!n?null:a.jsx("div",{id:s,role:"listbox","aria-label":c,className:"be-slash-menu",style:{position:"fixed",top:n.bottom+4,left:n.left,zIndex:1e3},children:t.map((h,m)=>{const g=h.icon;return a.jsxs("div",{ref:m===i?p:void 0,id:`${s}-option-${m}`,role:"option","aria-selected":m===i,className:`be-slash-menu-item${m===i?" be-slash-menu-item-active":""}`,onMouseDown:x=>{x.preventDefault(),o(h)},onMouseEnter:()=>u(m),children:[g&&a.jsx("span",{className:"be-slash-menu-item-icon",children:a.jsx(g,{size:16})}),a.jsx("span",{className:"be-slash-menu-item-label",children:h.label})]},h.label)})})}function hc(e,n){var r;if(!n)return!0;const t=n.toLowerCase();return e.label.toLowerCase().includes(t)||((r=e.keywords)==null?void 0:r.some(o=>o.toLowerCase().includes(t)))}function gc(e,n){const t=n.anchorNode,r=n.anchorOffset;let o;if(t===e){o="";for(let l=0;l<r&&l<e.childNodes.length;l+=1)o+=e.childNodes[l].textContent??""}else t&&t.parentElement===e?o=(t.textContent??"").slice(0,r):o=e.textContent??"";return me(o).length}function et(e,n,t){const r=D(),[o,l]=f.useState(null);f.useEffect(()=>{const u=e.current;if(!u)return;const p=()=>{var R,S,C,w;const b=(R=window.getSelection)==null?void 0:R.call(window),h=b==null?void 0:b.anchorNode;let m=(h==null?void 0:h.nodeType)===1?h:h==null?void 0:h.parentElement;for(;m&&typeof m.hasAttribute=="function"&&!m.hasAttribute("data-run-id");)m=m.parentElement;const g=(S=m==null?void 0:m.getAttribute)==null?void 0:S.call(m,"data-run-id");if(!g||!b){l(null);return}const x=gc(m,b),k=me(m.textContent).slice(0,x),I=n.exec(k);if(!I){l(null);return}const y=(w=(C=m.closest)==null?void 0:C.call(m,"[data-block-id]"))==null?void 0:w.getAttribute("data-block-id");if(!y){l(null);return}const E=I.index+I[1].length;l({query:I[2],blockId:y,runId:g,sliceStart:E,sliceEnd:x,rect:m.getBoundingClientRect()})},d=b=>{b.key==="Escape"&&l(null)};return u.addEventListener("input",p),u.addEventListener("keydown",d),()=>{u.removeEventListener("input",p),u.removeEventListener("keydown",d)}},[e,n]);const s=o?t().filter(u=>hc(u,o.query)):[],c=f.useCallback(u=>{o&&(u.run(r,{blockId:o.blockId,runId:o.runId,sliceStart:o.sliceStart,sliceEnd:o.sliceEnd}),l(null))},[o,r]),i=f.useCallback(()=>l(null),[]);return{isOpen:!!o,query:(o==null?void 0:o.query)??"",rect:(o==null?void 0:o.rect)??null,runId:(o==null?void 0:o.runId)??null,commands:s,selectCommand:c,close:i}}const xc=/(^|\s)\/(\w*)$/;function kc(e){const n=Ne(),t=he(),r=f.useCallback(()=>[...n.listSlashCommands(),...(t==null?void 0:t.listSlashCommands())??[]],[n,t]);return et(e,xc,r)}const yc=[{char:"😀",name:"grinning face",keywords:["smile","happy"]},{char:"😂",name:"face with tears of joy",keywords:["laugh","lol"]},{char:"😍",name:"heart eyes",keywords:["love","crush"]},{char:"😎",name:"cool",keywords:["sunglasses"]},{char:"🤔",name:"thinking face",keywords:["hmm"]},{char:"😉",name:"winking face",keywords:["wink"]},{char:"😢",name:"crying face",keywords:["sad","tear"]},{char:"😡",name:"angry face",keywords:["mad","rage"]},{char:"😱",name:"screaming face",keywords:["shock","scared"]},{char:"🥳",name:"party face",keywords:["celebrate","birthday"]},{char:"🙏",name:"folded hands",keywords:["please","pray","thanks"]},{char:"👍",name:"thumbs up",keywords:["approve","yes","like"]},{char:"👎",name:"thumbs down",keywords:["disapprove","no"]},{char:"👏",name:"clapping hands",keywords:["applause","congrats"]},{char:"🙌",name:"raised hands",keywords:["hooray","yay"]},{char:"👋",name:"waving hand",keywords:["hello","bye"]},{char:"✌️",name:"victory hand",keywords:["peace"]},{char:"💪",name:"flexed biceps",keywords:["strong","muscle"]},{char:"🤝",name:"handshake",keywords:["deal","agree"]},{char:"❤️",name:"red heart",keywords:["love"]},{char:"🔥",name:"fire",keywords:["hot","lit"]},{char:"⭐",name:"star",keywords:["favorite"]},{char:"✨",name:"sparkles",keywords:["shiny","magic"]},{char:"🎉",name:"party popper",keywords:["celebrate","congrats"]},{char:"🎊",name:"confetti ball",keywords:["celebrate"]},{char:"💡",name:"light bulb",keywords:["idea","tip"]},{char:"✅",name:"check mark",keywords:["done","yes","complete"]},{char:"❌",name:"cross mark",keywords:["no","wrong","delete"]},{char:"⚠️",name:"warning",keywords:["caution","alert"]},{char:"❓",name:"question mark",keywords:["question","help"]},{char:"❗",name:"exclamation mark",keywords:["important","alert"]},{char:"🚀",name:"rocket",keywords:["launch","fast","ship"]},{char:"🐛",name:"bug",keywords:["bug","issue"]},{char:"🔧",name:"wrench",keywords:["fix","tool","settings"]},{char:"📌",name:"pushpin",keywords:["pin","note"]},{char:"📎",name:"paperclip",keywords:["attachment","clip"]},{char:"📅",name:"calendar",keywords:["date","schedule"]},{char:"⏰",name:"alarm clock",keywords:["time","reminder"]},{char:"📈",name:"chart increasing",keywords:["growth","stats"]},{char:"📉",name:"chart decreasing",keywords:["decline","stats"]},{char:"💰",name:"money bag",keywords:["money","cash"]},{char:"💬",name:"speech balloon",keywords:["comment","chat"]},{char:"📝",name:"memo",keywords:["note","write"]},{char:"📚",name:"books",keywords:["reading","docs"]},{char:"🔗",name:"link",keywords:["url","chain"]},{char:"🔒",name:"locked",keywords:["private","secure"]},{char:"🔑",name:"key",keywords:["password","access"]},{char:"☕",name:"coffee",keywords:["coffee","break"]},{char:"🍕",name:"pizza",keywords:["food"]},{char:"🎂",name:"birthday cake",keywords:["birthday","cake"]},{char:"🎁",name:"gift",keywords:["present"]},{char:"🌟",name:"glowing star",keywords:["star","shiny"]},{char:"🌈",name:"rainbow",keywords:["colorful"]},{char:"☀️",name:"sun",keywords:["sunny","weather"]},{char:"🌧️",name:"rain cloud",keywords:["rainy","weather"]},{char:"🐶",name:"dog face",keywords:["dog","pet"]},{char:"🐱",name:"cat face",keywords:["cat","pet"]},{char:"🌍",name:"globe",keywords:["world","earth"]},{char:"🎯",name:"direct hit",keywords:["target","goal"]},{char:"🏆",name:"trophy",keywords:["win","award"]},{char:"🕐",name:"clock",keywords:["time"]},{char:"📣",name:"megaphone",keywords:["announce","shout"]},{char:"🧠",name:"brain",keywords:["smart","idea","mind"]},{char:"👀",name:"eyes",keywords:["look","watching"]}];function vc(e,{runId:n,sliceStart:t,sliceEnd:r},o){const l=e.getRun(n),s=(l==null?void 0:l.value)??"",c=s.slice(0,t)+o+s.slice(r);e.applyOperation(J(n,{value:c})),be(n,t+o.length)}const Ic=yc.map(({char:e,name:n,keywords:t})=>({label:`${e} ${n}`,keywords:t,run:(r,o)=>vc(r,o,e)})),wc=/(^|\s):(\w*)$/,Cc=()=>Ic;function Bc(e){return et(e,wc,Cc)}const Rc=/(^|\s)@(\w*)$/;function Tc(e){const n=he(),t=f.useCallback(()=>(n==null?void 0:n.listAtCommands())??[],[n]);return et(e,Rc,t)}const jc=[{markName:"bold",Icon:wo,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:Co,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:Bo,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:jo,title:"Strikethrough"}],Sc=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Ec=[{label:"None",value:null},{label:"Yellow",value:"#fff3bf"},{label:"Green",value:"#d3f9d8"},{label:"Blue",value:"#d0ebff"},{label:"Pink",value:"#ffdeeb"},{label:"Gray",value:"#e9ecef"}];function Oc({isOpen:e,rect:n,kind:t,selection:r,crossSelection:o,marks:l,store:s}){var R,S;const[c,i]=f.useState(null),[u,p]=f.useState(!1),d=f.useRef(null);f.useEffect(()=>{if(!c)return;const C=v=>{d.current&&!d.current.contains(v.target)&&i(null)},w=v=>{v.key==="Escape"&&i(null)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",w)}},[c]),f.useEffect(()=>{i(null)},[n,t]);const b=f.useCallback(C=>{const w=t==="same-block"?Oe(s,r.blockId,r,C):dn(s,o,C);w&&X(w),i(null)},[s,t,r,o]),h=f.useCallback(C=>{const w=t==="same-block"?Qn(s,r.blockId,r,C):Zn(s,o,C);w&&X(w)},[s,t,r,o]),m=f.useCallback(C=>{const w=C==="subscript"?"superscript":"subscript",v=!l[C];b({[C]:v?!0:null,[w]:null})},[l,b]),g=f.useRef(null),x=f.useCallback(()=>{g.current={kind:t,selection:r,crossSelection:o},p(!0)},[t,r,o]),k=f.useCallback(()=>p(!1),[]),I=f.useCallback(C=>{const w=g.current;if(!w)return;const v=w.kind==="same-block"?Oe(s,w.selection.blockId,w.selection,C):dn(s,w.crossSelection,C);v&&X(v),p(!1)},[s]),y=f.useCallback((C,w)=>I({link:{href:C,target:w}}),[I]),E=f.useCallback(()=>I({link:null}),[I]);return(!e||!n)&&!u?null:a.jsxs(a.Fragment,{children:[e&&n&&a.jsxs("div",{ref:d,className:"be-floating-toolbar",role:"toolbar","aria-label":"Text formatting",style:{position:"fixed",top:n.top-44,left:n.left+n.width/2,transform:"translateX(-50%)"},onMouseDown:C=>C.preventDefault(),children:[jc.map(({markName:C,Icon:w,title:v})=>a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l[C]?" be-floating-toolbar-btn-active":""}`,title:v,"aria-label":v,"aria-pressed":!!l[C],onClick:()=>h(C),children:a.jsx(w,{})},C)),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.subscript?" be-floating-toolbar-btn-active":""}`,title:"Subscript","aria-pressed":!!l.subscript,onClick:()=>m("subscript"),children:"X₂"}),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.superscript?" be-floating-toolbar-btn-active":""}`,title:"Superscript","aria-pressed":!!l.superscript,onClick:()=>m("superscript"),children:"X²"}),a.jsx("span",{className:"be-floating-toolbar-divider"}),a.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[a.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Text color","aria-haspopup":"true","aria-expanded":c==="color",onClick:()=>i(C=>C==="color"?null:"color"),children:a.jsx("span",{style:{color:l.color||"inherit",fontWeight:700},children:"A"})}),c==="color"&&a.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Text color",children:Sc.map(C=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:C.label,onClick:()=>b({color:C.value}),children:a.jsx("span",{style:{color:C.value||"#1a1a1a",fontWeight:700},children:"A"})},C.label))})]}),a.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[a.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Highlight","aria-haspopup":"true","aria-expanded":c==="highlight",onClick:()=>i(C=>C==="highlight"?null:"highlight"),children:a.jsx("span",{style:{backgroundColor:l.highlight||"transparent",padding:"0 2px",borderRadius:2},children:"H"})}),c==="highlight"&&a.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Highlight color",children:Ec.map(C=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:C.value||"transparent"},title:C.label,onClick:()=>b({highlight:C.value})},C.label))})]}),a.jsx("span",{className:"be-floating-toolbar-divider"}),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.link?" be-floating-toolbar-btn-active":""}`,title:"Link","aria-label":"Link","aria-pressed":!!l.link,onClick:x,children:a.jsx(To,{})})]}),a.jsx(Tt,{isOpen:u,initialHref:((R=l.link)==null?void 0:R.href)??"",initialTarget:((S=l.link)==null?void 0:S.target)??"_self",hasExistingLink:!!l.link,onSave:y,onRemove:E,onClose:k})]})}function Lc(e){const n=D(),[t,r]=f.useState(null);return f.useEffect(()=>{const o=e.current;if(!o)return;const l=()=>{var p,d,b;const s=(p=window.getSelection)==null?void 0:p.call(window);if(!s||s.rangeCount===0||s.isCollapsed){r(null);return}if(!o.contains(s.anchorNode)||!o.contains(s.focusNode)){r(null);return}const c=((b=(d=s.getRangeAt(0)).getBoundingClientRect)==null?void 0:b.call(d))??{top:0,left:0,right:0,bottom:0,width:0,height:0},i=Je();if(i){r({kind:"same-block",rect:c,selection:i,marks:Jr(n,i.blockId,i)});return}const u=Fe(n);if(u){r({kind:"cross-block",rect:c,crossSelection:u,marks:Qr(n,u)});return}r(null)};return document.addEventListener("selectionchange",l),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{document.removeEventListener("selectionchange",l),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l)}},[e,n]),{isOpen:!!t,rect:(t==null?void 0:t.rect)??null,kind:(t==null?void 0:t.kind)??null,selection:(t==null?void 0:t.selection)??null,crossSelection:(t==null?void 0:t.crossSelection)??null,marks:(t==null?void 0:t.marks)??{},close:()=>r(null)}}function Nc({id:e,label:n,placeholder:t,variant:r,options:o,onManage:l,mention:s=!1}){const c=D(),i=ye(e),u=f.useCallback((h,m)=>{c.applyOperation(J(e,{data:{selectedValue:h,selectedLabel:(m==null?void 0:m.label)??"",selectedColor:m==null?void 0:m.color}}))},[c,e]);if(!i)return null;const{selectedValue:p="",selectedLabel:d="",selectedColor:b}=i.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:h=>{h.preventDefault(),h.stopPropagation()},onKeyDown:h=>h.stopPropagation(),children:a.jsx(_e,{value:p,selectedLabel:d,selectedColor:b,options:o,onChange:u,placeholder:t,variant:r,ariaLabel:n,onManageOptions:l,mention:s})})}function so(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function kt(e){return so(e).replace(/"/g,"&quot;")}function ao({type:e,label:n,placeholder:t="Select…",variant:r="default",icon:o,options:l,onManage:s,triggers:c=["slash"],mention:i=c.includes("at")}){function u(m){var k,I;const g=((k=m.data)==null?void 0:k.selectedLabel)||"",x=i&&g?`@${g}`:g;return`<span data-inline-type="${kt(e)}" data-selected-value="${kt(((I=m.data)==null?void 0:I.selectedValue)??"")}">${so(x)}</span>`}function p(m){var x;const g=((x=m.data)==null?void 0:x.selectedLabel)??"";return i&&g?`@${g}`:g}function d(m){var k;if(((k=m.getAttribute)==null?void 0:k.call(m,"data-inline-type"))!==e)return null;const g=m.textContent??"",x=i&&g.startsWith("@")?g.slice(1):g;return{id:T(),type:e,value:"",marks:{},data:{selectedValue:m.getAttribute("data-selected-value")??"",selectedLabel:x}}}function b({id:m}){return a.jsx(Nc,{id:m,label:n,placeholder:t,variant:r,options:l,onManage:s,mention:i})}const h={label:n,icon:o,keywords:[n.toLowerCase(),"select","field"],run:(m,{blockId:g,runId:x,sliceStart:k,sliceEnd:I})=>xn(m,{blockId:g,runId:x,sliceStart:k,sliceEnd:I},()=>({id:T(),type:e,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}))};return{component:b,isAtomic:!0,toHTML:u,toPlainText:p,fromHTML:d,slashCommand:c.includes("slash")?h:void 0,atCommand:c.includes("at")?h:void 0}}function co(e,n,{onManage:t}={}){for(const r of e.getFieldTypes())n.register(r.id,ao({type:r.id,label:r.label,placeholder:r.placeholder,variant:r.variant,options:r.options??[],onManage:t?()=>t(r.id):void 0}))}function io(){const e=D(),n=he(),t=Ur(),{openEdit:r}=An(),o=f.useRef([]);f.useEffect(()=>{if(!n)return;const l=new Set(t.map(s=>s.id));for(const s of o.current)l.has(s)||n.unregister(s);co(e,n,{onManage:r}),o.current=[...l]},[e,n,t,r])}function Mc(){io();const e=D(),{target:n,close:t}=An(),r=n!==null,o=r&&n!=="new",[l,s]=f.useState(""),[c,i]=f.useState([]),[u,p]=f.useState("");f.useEffect(()=>{if(r){if(o){const x=e.getFieldType(n);s((x==null?void 0:x.label)??""),i((x==null?void 0:x.options)??[])}else s(""),i([]);p("")}},[r,o,n,e]);const d=f.useCallback((x,k)=>{i(I=>I.map(y=>y.value===x?{...y,label:k}:y))},[]),b=f.useCallback(x=>{i(k=>k.filter(I=>I.value!==x))},[]),h=f.useCallback(()=>{const x=u.trim();p(""),x&&i(k=>[...k,{value:T(),label:x,color:Ke(k.length)}])},[u]),m=f.useCallback(()=>{const x=l.trim();x&&(o?e.applyOperation(En(n,{label:x,options:c})):e.applyOperation(Sn({id:T(),label:x,placeholder:"Select…",variant:"tag",options:c})),t())},[e,o,n,l,c,t]),g=f.useCallback(()=>{o&&e.applyOperation(On(n)),t()},[e,o,n,t]);return a.jsxs(Ye,{isOpen:r,onClose:t,title:o?"Edit field type":"New field type",children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Name"}),a.jsx("input",{type:"text",value:l,onChange:x=>s(x.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Options"}),c.map((x,k)=>a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(x.color??Ke(k)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:x.label,onChange:I=>d(x.value,I.target.value),"aria-label":`Rename option ${x.label}`}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>b(x.value),"aria-label":`Remove option ${x.label}`,children:a.jsx(Ge,{size:14})})]},x.value)),a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("input",{className:"be-table-header-menu-option-input",value:u,onChange:x=>p(x.target.value),placeholder:"New option…",onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),h())}}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:h,"aria-label":"Add option",children:"+"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[o&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:g,children:"Delete field type"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:t,children:"Cancel"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:"Save"})]})]})}exports.APP_MIME=cn;exports.BlockChildren=Ce;exports.BlockErrorBoundary=Kt;exports.BlockGutterRow=Yt;exports.BlockRangeActionMenu=sc;exports.BlockRegistry=yt;exports.BlockRenderer=Fn;exports.COLUMN_TYPES=Qt;exports.DEFAULT_COLUMN_TYPE=mn;exports.DEFAULT_COLUMN_WIDTH=hn;exports.DocumentExportButton=fc;exports.EditableBlockContent=xe;exports.EditorProvider=yo;exports.EditorStore=Ln;exports.EditorTrailingSpace=dc;exports.FieldTypeEditorModal=Mc;exports.FloatingToolbar=Oc;exports.History=ho;exports.InlineRegistry=vt;exports.LAYOUT_BLOCKS=Or;exports.MIN_COLUMN_WIDTH=an;exports.Modal=Ye;exports.Select=_e;exports.SlashMenu=mc;exports.TABLE_BLOCKS=Er;exports.TABLE_SELECT_INLINE_TYPES=zr;exports.TableHeaderRow=cr;exports.blankRunForType=Zt;exports.blockquoteBlockType=yr;exports.buttonBlockType=Cr;exports.calloutBlockType=kr;exports.checkboxInlineType=Dr;exports.codeBlockType=vr;exports.convertRunToType=er;exports.copyBlockRangeToClipboard=jn;exports.createBlockRegistry=go;exports.createCellForColumn=gn;exports.createDefaultColumns=Vn;exports.createInlineRegistry=xo;exports.createSelectFieldType=ao;exports.dateInlineType=Ar;exports.deleteBlockAndFocusSibling=Wn;exports.deleteBlockRange=ze;exports.deleteColumn=or;exports.deleteEntireDocument=un;exports.deleteOverBlockRange=Jn;exports.deleteRow=rr;exports.deleteRunRangeInBlock=Xn;exports.deserializeClipboard=Kr;exports.dividerBlockType=gr;exports.duplicateBlock=qt;exports.embedBlockType=jr;exports.emojiInlineType=Pr;exports.ensureRootNonEmpty=Ae;exports.exportDocumentHTML=oo;exports.exportDocumentJSON=ro;exports.exportDocumentText=lo;exports.focusRunAtOffset=be;exports.focusRunEnd=X;exports.focusRunStart=Dn;exports.getMarksSummaryOverBlockRange=Qr;exports.getMarksSummaryOverSelection=Jr;exports.headingBlockType=Ft;exports.injectDefaultStyles=It;exports.insertColumnAfter=Cn;exports.insertRowAfter=tr;exports.isEntireBlockRangeHidden=Yr;exports.isEntireBlockSelected=to;exports.layoutBlockType=hr;exports.layoutColumnBlockType=mr;exports.listItemBlockType=Jt;exports.moveBlockDown=Vt;exports.moveBlockRangeDown=Vr;exports.moveBlockRangeUp=Wr;exports.moveBlockUp=Wt;exports.operations=bo;exports.paragraphBlockType=Ut;exports.registerBlocks=Sr;exports.registerBuiltInBlocks=ya;exports.registerBuiltInInlineTypes=Ua;exports.registerInlineTypes=Hr;exports.registerStoredFieldTypes=co;exports.remapSubtreeIds=qn;exports.renameColumn=sr;exports.reorderBlockRangeFromStore=Va;exports.resolveCollapsedCaret=Xe;exports.resolveColumns=ie;exports.resolveCrossBlockSelection=Fe;exports.resolveMultiRunSelection=Je;exports.resolveRunSelection=sl;exports.selectInlineType=Nr;exports.serializeBlockRange=Ze;exports.setBlockRangeHidden=Gr;exports.setColumnOptions=ln;exports.setColumnType=ar;exports.setColumnWidth=lr;exports.setMarksOverBlockRange=dn;exports.setMarksOverSelection=Oe;exports.tableBlockType=pr;exports.tableCellBlockType=ur;exports.tableRowBlockType=dr;exports.tableSelectInlineType=$r;exports.textToParagraphs=Gn;exports.toggleHeadingBlockType=Ir;exports.toggleMarkOnRunRange=tc;exports.toggleMarkOverBlockRange=Zn;exports.toggleMarkOverSelection=Qn;exports.useAtMenuTrigger=Tc;exports.useBlock=Q;exports.useBlockChildren=Un;exports.useBlockClassName=ee;exports.useBlockRangeDrag=uc;exports.useBlockRangeSelection=We;exports.useBlockRegistry=Ne;exports.useClipboardHandlers=Xa;exports.useEditorKeyboardShortcuts=lc;exports.useEditorStore=D;exports.useEmojiMenuTrigger=Bc;exports.useFieldTypeEditor=An;exports.useFieldTypes=Ur;exports.useFloatingToolbarTrigger=Lc;exports.useHistory=qa;exports.useInlineRegistry=he;exports.usePreviewMode=Mn;exports.useRegisterFieldTypes=io;exports.useRun=ye;exports.useSelectedBlock=ge;exports.useSlashMenuTrigger=kc;exports.useWholeDocumentSelection=Nn;exports.walkDomToBlocks=Fr;
2213
+ ${o}`:r}function Qa(e,n){if(e.tagName!=="DETAILS")return null;const t=[...e.children].find(d=>d.tagName==="SUMMARY"),r=t==null?void 0:t.querySelector("h1,h2,h3,h4,h5,h6"),o=r?Math.min(6,Math.max(1,Number(r.tagName[1]))):2,l=r?me(r,n):[{id:E(),type:"text",value:"",marks:{}}],s=E(),i=[],c=[],u=[];for(const d of e.children){if(d===t||d.tagName!=="P")continue;const b=me(d,n),h={id:E(),type:"paragraph",parentId:s,contentIds:b.map(m=>m.id),props:{}};i.push(h),c.push(...b),u.push(h.id)}if(u.length===0){const{block:d,runs:b}=z("paragraph")(s);i.push(d),c.push(...b),u.push(d.id)}return{block:{id:s,type:"toggleHeading",parentId:null,contentIds:u,props:{level:o,collapsed:!e.hasAttribute("open"),titleRunIds:l.map(d=>d.id)}},runs:[...l,...c],subtreeBlocks:i}}const ko={component:Ya,isLeaf:!1,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:Ja,toPlainText:Xa,fromHTML:Qa,slashCommands:[1,2,3].map(e=>({label:`Toggle heading ${e}`,icon:Me,keywords:["toggle","heading","collapse","section"],run:(n,t)=>ae(n,t,Ga({level:e}))}))},_n=[{label:"Blue",value:"#2b6fd6"},{label:"Green",value:"#2f9e44"},{label:"Red",value:"#e03131"},{label:"Purple",value:"#9c36b5"},{label:"Gray",value:"#495057"},{label:"Black",value:"#1a1a1a"}];function Za(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function ei({isOpen:e,onClose:n,store:t,blockId:r}){const[o,l]=p.useState(""),[s,i]=p.useState(""),[c,u]=p.useState(_n[0].value),[f,d]=p.useState([{key:"",value:""}]);p.useEffect(()=>{var w,v,B;if(!e)return;const g=t.getBlock(r);if(!g)return;const k=g.contentIds.map(C=>{var y;return((y=t.getRun(C))==null?void 0:y.value)??""}).join(""),x=((w=g.props)==null?void 0:w.customAttrs)??[];l(k),i(((v=g.props)==null?void 0:v.href)??""),u(((B=g.props)==null?void 0:B.color)??_n[0].value),d([...x,{key:"",value:""}])},[e,r,t]);const b=p.useCallback((g,k)=>{d(x=>{const w=x.map((B,C)=>C===g?{...B,...k}:B),v=w[w.length-1];return(v.key.trim()||v.value.trim())&&w.push({key:"",value:""}),w})},[]),h=p.useCallback(g=>{d(k=>k.filter((x,w)=>w!==g))},[]),m=p.useCallback(()=>{const g={id:E(),type:"text",value:o,marks:{}},k=f.filter(x=>x.key.trim());Za(t,[ue(r,[g]),F(r,{href:s.trim(),color:c,customAttrs:k})]),n()},[t,r,o,s,c,f,n]);return a.jsxs(Be,{isOpen:e,onClose:n,title:"Edit button",children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Label"}),a.jsx("input",{type:"text",value:o,onChange:g=>l(g.target.value),placeholder:"Button"})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Link URL"}),a.jsx("input",{type:"url",value:s,onChange:g=>i(g.target.value),placeholder:"https://example.com"})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Color"}),a.jsx("div",{className:"be-modal-color-row",children:_n.map(g=>a.jsx("button",{type:"button",className:`be-modal-color-swatch${c===g.value?" be-modal-color-swatch-active":""}`,style:{backgroundColor:g.value},title:g.label,"aria-label":g.label,onClick:()=>u(g.value)},g.value))})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Custom attributes"}),f.map((g,k)=>a.jsxs("div",{className:"be-modal-attr-row",children:[a.jsx("input",{type:"text",placeholder:"name",value:g.key,onChange:x=>b(k,{key:x.target.value})}),a.jsx("input",{type:"text",placeholder:"value",value:g.value,onChange:x=>b(k,{value:x.target.value})}),(g.key||g.value)&&a.jsx("button",{type:"button",className:"be-modal-attr-remove",onClick:()=>h(k),"aria-label":"Remove attribute",children:a.jsx(ln,{size:14})})]},k))]}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:"Save"})]})]})}const ni="#2b6fd6";function ti({id:e}){var w,v,B,C;const n=_(),t=ne(e),{setSelectedBlockId:r}=Ce(),[o,l]=p.useState(!1),s=p.useCallback(()=>{qe(n,e,(t==null?void 0:t.contentIds)??[],z("paragraph"))},[n,e,t]),i=p.useCallback(()=>{const y=sn(n,e);Ye(n,y,e,r)},[n,e,r]),c=p.useCallback(()=>ie(n,e,"up"),[n,e]),u=p.useCallback(()=>ie(n,e,"down"),[n,e]),f=p.useCallback(()=>{var R;const y=(R=t==null?void 0:t.props)==null?void 0:R.href;y&&window.open(y,"_blank","noopener,noreferrer")},[(w=t==null?void 0:t.props)==null?void 0:w.href]),d=le("be-button-block",t);if(!t)return null;const b=((v=t.props)==null?void 0:v.href)??"",h=((B=t.props)==null?void 0:B.color)??ni,m=((C=t.props)==null?void 0:C.customAttrs)??[],g=de(n,t.contentIds),k={};for(const{key:y,value:R}of m)y.trim()&&(k[`data-${y.trim()}`]=R);const x=Ie(n,t);return a.jsxs("div",{className:d,"data-block-id":e,dir:x,children:[a.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:h},...k,children:[a.jsx("span",{className:"be-button-block-label","data-empty":g?"":void 0,"data-placeholder":"Button",children:a.jsx(Re,{blockId:e,runIds:t.contentIds,dir:x,onEnter:s,onBackspaceAtStart:i,onArrowUp:c,onArrowDown:u})}),a.jsx("button",{type:"button",className:"be-button-block-open",onClick:f,disabled:!b,title:b||"No link set","aria-label":"Open link",children:"↗"}),a.jsx("button",{type:"button",className:"be-button-block-settings",onClick:()=>l(!0),"aria-label":"Edit button",title:"Edit label, link, color…",children:"⚙"})]}),a.jsx(ei,{isOpen:o,onClose:()=>l(!1),store:n,blockId:e})]})}function ri({href:e="",label:n="Button",color:t="",customAttrs:r=[]}={}){return function(l,s){const i=E(),c=s!=null&&s.length?s:[{id:E(),type:"text",value:n,marks:{}}];return{block:{id:i,type:"button",parentId:l,contentIds:c.map(u=>u.id),props:{href:e,color:t,customAttrs:r}},runs:c}}}const xo="be-button-block-link";function oi(e,n){var c,u,f;const t=e.contentIds.map(d=>n.store.getRun(d)),r=((c=e.props)==null?void 0:c.href)??"",o=(u=e.props)==null?void 0:u.color,l=o?` style="background-color:${fe(o)}"`:"",i=(((f=e.props)==null?void 0:f.customAttrs)??[]).filter(d=>{var b;return(b=d.key)==null?void 0:b.trim()}).map(d=>` data-${fe(d.key.trim())}="${fe(d.value??"")}"`).join("");return`<a class="${xo}" href="${fe(r)}"${l}${i}>${t.map(d=>je(d,n)).join("")}</a>`}function li(e,n){return e.contentIds.map(t=>Oe(n.store.getRun(t),n)).join("")}function si(e,n){var l;if(e.tagName!=="A"||!e.classList.contains(xo))return null;const t=me(e,n),r=[];for(const s of e.attributes)s.name.startsWith("data-")&&r.push({key:s.name.slice(5),value:s.value});return{block:{id:E(),type:"button",parentId:null,contentIds:t.map(s=>s.id),props:{href:e.getAttribute("href")??"",color:((l=e.style)==null?void 0:l.backgroundColor)||void 0,customAttrs:r}},runs:t}}const yo={component:ti,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:oi,toPlainText:li,fromHTML:si,slashCommand:{label:"Button",icon:_l,keywords:["button","link","cta","action"],run:(e,n)=>ae(e,n,ri())}};function Qt(e){return new Promise((n,t)=>{const r=new FileReader;r.onload=()=>n(r.result),r.onerror=()=>t(r.error),r.readAsDataURL(e)})}const pn={image:"image",video:"video",audio:"audio",file:"file"},ai={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},vo=20,wo=100,ii=[{value:"left",Icon:kr,label:"Align left"},{value:"center",Icon:Nl,label:"Align center"},{value:"right",Icon:xr,label:"Align right"}];function ci(e){return Math.min(wo,Math.max(vo,Math.round(e)))}function ui({kind:e,src:n,name:t,alt:r}){return e==="image"?a.jsx("img",{className:"be-embed-image",src:n,alt:r||""}):e==="video"?a.jsx("video",{className:"be-embed-video",src:n,controls:!0}):e==="audio"?a.jsx("audio",{className:"be-embed-audio",src:n,controls:!0}):a.jsxs("a",{className:"be-embed-file-link",href:n,download:t||void 0,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(fr,{size:14})," ",t||n]})}function di({id:e}){var W;const n=_(),t=ne(e),[r,o]=p.useState(""),[l,s]=p.useState(!1),[i,c]=p.useState(null),[u,f]=p.useState(!1),[d,b]=p.useState(""),h=p.useRef(null),m=p.useRef(null),g=p.useCallback(N=>n.applyOperation(F(e,N)),[n,e]),k=p.useCallback(()=>{var N;b(((N=t==null?void 0:t.props)==null?void 0:N.alt)??""),f(!0)},[(W=t==null?void 0:t.props)==null?void 0:W.alt]),x=p.useCallback(()=>f(!1),[]),w=p.useCallback(N=>{N.preventDefault(),g({alt:d.trim()}),f(!1)},[d,g]),v=p.useCallback(async N=>{var q;const U=(q=N.target.files)==null?void 0:q[0];if(!U)return;const K=await Qt(U);g({src:K,name:U.name,mimeType:U.type})},[g]),B=p.useCallback(async N=>{var q;N.preventDefault(),s(!1);const U=(q=N.dataTransfer.files)==null?void 0:q[0];if(!U)return;const K=await Qt(U);g({src:K,name:U.name,mimeType:U.type})},[g]),C=p.useCallback(N=>{N.preventDefault(),s(!0)},[]),y=p.useCallback(()=>s(!1),[]),R=p.useCallback(()=>{const N=r.trim();N&&(g({src:N,name:N}),o(""))},[r,g]),j=p.useCallback(()=>g({src:"",name:"",mimeType:""}),[g]),S=p.useCallback(N=>{N.preventDefault();const U=h.current,K=m.current;if(!U||!K)return;const q=U.getBoundingClientRect().width,re=K.getBoundingClientRect().width,pe=N.clientX,Y=O=>ci((re+(O.clientX-pe))/q*100),se=O=>c(Y(O)),te=O=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",te),g({width:Y(O)}),c(null)};document.addEventListener("mousemove",se),document.addEventListener("mouseup",te)},[g]),I=le("be-embed",t);if(!t)return null;const{kind:T="file",src:L,name:M,alt:A="",align:P="left",width:X=100}=t.props,J=T==="image"||T==="video",H=i??X;return a.jsxs("div",{className:I,"data-block-id":e,"data-kind":T,contentEditable:!1,tabIndex:-1,children:[L?a.jsx("div",{ref:h,className:`be-embed-preview be-embed-align-${P}`,children:a.jsxs("div",{ref:m,className:"be-embed-frame",style:J?{width:`${H}%`}:void 0,children:[a.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[ii.map(({value:N,Icon:U,label:K})=>a.jsx("button",{type:"button",className:`be-embed-toolbar-btn${P===N?" be-embed-toolbar-btn-active":""}`,title:K,"aria-label":K,"aria-pressed":P===N,onClick:()=>g({align:N}),children:a.jsx(U,{size:14})},N)),T==="image"&&a.jsx("button",{type:"button",className:"be-embed-toolbar-btn be-embed-alt-text-btn",onClick:k,children:"Alt text"}),a.jsx("button",{type:"button",className:"be-embed-remove",onClick:j,"aria-label":`Remove ${pn[T]}`,children:"Remove"})]}),a.jsx(ui,{kind:T,src:L,name:M,alt:A}),J&&a.jsx("div",{className:"be-embed-resize-handle",onMouseDown:S,role:"slider","aria-label":`Resize ${pn[T]}`,"aria-valuemin":vo,"aria-valuemax":wo,"aria-valuenow":H})]})}):a.jsxs("div",{className:`be-embed-dropzone${l?" be-embed-dropzone-active":""}`,onDrop:B,onDragOver:C,onDragLeave:y,children:[a.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",pn[T],a.jsx("input",{type:"file",accept:ai[T],onChange:v,hidden:!0})]}),a.jsx("span",{className:"be-embed-dropzone-hint",children:"or drop a file, or paste a URL below"}),a.jsxs("div",{className:"be-embed-url-row",children:[a.jsx("input",{type:"text",className:"be-embed-url-input",placeholder:`https://... ${pn[T]} URL`,value:r,onChange:N=>o(N.target.value),onKeyDown:N=>N.key==="Enter"&&R()}),a.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:R,children:"Embed"})]})]}),a.jsx(Be,{isOpen:u,onClose:x,title:"Alt text",children:a.jsxs("form",{onSubmit:w,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Describe this image for screen readers"}),a.jsx("input",{type:"text",value:d,onChange:N=>b(N.target.value),placeholder:"e.g. A hand-drawn diagram of the release process",autoFocus:!0})]}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:x,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",children:"Save"})]})]})})]})}function pi({kind:e="file",src:n="",name:t="",alt:r="",mimeType:o="",align:l="left",width:s=100}={}){return function(c){return{block:{id:E(),type:"embed",parentId:c,contentIds:[],props:{kind:e,src:n,name:t,alt:r,mimeType:o,align:l,width:s}},runs:[]}}}const fi={image:zl,video:Fl,audio:Ul,file:fr},Io="be-embed-file-link";function bi(e,n,t){if(e!=="image"&&e!=="video")return"";const r=[];return t!==100&&r.push(`width:${t}%`),n==="center"?r.push("display:block","margin-left:auto","margin-right:auto"):n==="right"&&r.push("display:block","margin-left:auto"),r.length?` style="${r.join(";")}"`:""}function Zt(e){var o,l,s,i;const n=(o=e.style)==null?void 0:o.width,t=n&&n.endsWith("%")?parseInt(n,10):100;let r="left";return((l=e.style)==null?void 0:l.marginLeft)==="auto"&&((s=e.style)==null?void 0:s.marginRight)==="auto"?r="center":((i=e.style)==null?void 0:i.marginLeft)==="auto"&&(r="right"),{align:r,width:Number.isFinite(t)?t:100}}function mi(e){const{kind:n,src:t,name:r,alt:o="",align:l="left",width:s=100}=e.props;if(!t)return"<p></p>";const i=bi(n,l,s);return n==="image"?`<img src="${fe(t)}" alt="${fe(o)}"${i}>`:n==="video"?`<video src="${fe(t)}" controls${i}></video>`:n==="audio"?`<audio src="${fe(t)}" controls></audio>`:`<a class="${Io}" href="${fe(t)}">${ze(r||t)}</a>`}function hi(e){const{kind:n,src:t,name:r}=e.props;return t?`[${n}: ${r||t}]`:""}function gi(e){return e.tagName==="IMG"?fn("image",e.getAttribute("src")??"","",{...Zt(e),alt:e.getAttribute("alt")??""}):e.tagName==="VIDEO"?fn("video",e.getAttribute("src")??"","",Zt(e)):e.tagName==="AUDIO"?fn("audio",e.getAttribute("src")??"",""):e.tagName==="A"&&e.classList.contains(Io)?fn("file",e.getAttribute("href")??"",e.textContent??""):null}function fn(e,n,t,{align:r="left",width:o=100,alt:l=""}={}){return{block:{id:E(),type:"embed",parentId:null,contentIds:[],props:{kind:e,src:n,name:t,alt:l,align:r,width:o}},runs:[]}}function ki(e){return(n,{blockId:t,runId:r,sliceStart:o,sliceEnd:l})=>{const s=n.getRun(r),i=(s==null?void 0:s.value)??"";n.applyOperation(G(r,{value:i.slice(0,o)+i.slice(l)}));const c=ct(n,t,pi({kind:e}));return Te(n,c,z("paragraph")),c}}const Co={component:di,isLeaf:!0,defaultProps:{kind:"file",src:"",name:"",alt:"",mimeType:"",align:"left",width:100},toHTML:mi,toPlainText:hi,fromHTML:gi,slashCommands:["image","video","audio","file"].map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),icon:fi[e],keywords:["embed","upload","insert",e],run:ki(e)}))};function xi(e){Bo(e,{paragraph:Mr,heading:Ar,listItem:Kr,...Ro,...To,divider:po,callout:bo,blockquote:mo,code:go,toggleHeading:ko,button:yo,embed:Co})}function Bo(e,n){for(const[t,r]of Object.entries(n))e.register(t,r)}const Ro={table:so,tableRow:lo,tableCell:oo},To={layout:uo,layoutColumn:co};function yi({id:e}){const n=_(),t=Le(e),r=p.useCallback(i=>{n.applyOperation(G(e,{data:{...t==null?void 0:t.data,selectedValue:i}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{options:o=[],selectedValue:l="",placeholder:s="Select…"}=t.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:i=>{i.preventDefault(),i.stopPropagation()},onKeyDown:i=>i.stopPropagation(),children:a.jsx(De,{value:l,options:o,onChange:r,placeholder:s,ariaLabel:"Select an option"})})}function Nn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},l){const s=e.getRun(t),i=(s==null?void 0:s.value)??"",c=i.slice(0,r),u=i.slice(o),f=l(),d={...s,value:c},b={id:E(),type:"text",value:u,marks:{...s==null?void 0:s.marks}};e.applyOperation(tn(n,[t],[d,f,b])),ee(b.id)}function vi(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function jo(e){var r;const{options:n=[],selectedValue:t=""}=e.data??{};return((r=n.find(o=>o.value===t))==null?void 0:r.label)??""}function wi(e){var t,r;const n=jo(e)||((t=e.data)==null?void 0:t.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${vi(((r=e.data)==null?void 0:r.selectedValue)??"")}">${n}</span>`}function Ii(e){return jo(e)}function Ci(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="select"?null:{id:E(),type:"select",value:"",marks:{},data:{options:[],selectedValue:e.getAttribute("data-selected-value")??""}}}const So={component:yi,isAtomic:!0,toHTML:wi,toPlainText:Ii,fromHTML:Ci,slashCommand:{label:"Select",icon:jr,keywords:["select","dropdown","choice","picker"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>Nn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:E(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}))}};function Bi({id:e}){const n=_(),t=Le(e),r=p.useCallback(l=>{n.applyOperation(G(e,{data:{...t==null?void 0:t.data,isoDate:l.target.value}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{isoDate:o=""}=t.data??{};return a.jsx("span",{className:"be-inline-date",onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation(),children:a.jsx("input",{type:"date",value:o,onChange:r})})}function Ri(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Eo(e){if(!e)return"";const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ti(e){var t;const n=((t=e.data)==null?void 0:t.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${Ri(n)}">${Eo(n)}</span>`}function ji(e){var n;return Eo(((n=e.data)==null?void 0:n.isoDate)??"")}function Si(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="date"?null:{id:E(),type:"date",value:"",marks:{},data:{isoDate:e.getAttribute("data-iso-date")??""}}}function Ei(){return new Date().toISOString().slice(0,10)}const Lo={component:Bi,isAtomic:!0,toHTML:Ti,toPlainText:ji,fromHTML:Si,slashCommand:{label:"Date",icon:Hl,keywords:["date","when","schedule","calendar"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>Nn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:E(),type:"date",value:"",marks:{},data:{isoDate:Ei()}}))}};function Li({id:e}){const n=_(),t=Le(e),r=p.useCallback(i=>{n.applyOperation(G(e,{data:{...t==null?void 0:t.data,checked:i.target.checked}}))},[n,e,t==null?void 0:t.data]),o=p.useCallback(i=>{n.applyOperation(G(e,{data:{...t==null?void 0:t.data,label:i.target.value}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{checked:l=!1,label:s=""}=t.data??{};return a.jsxs("span",{className:"be-inline-checkbox",onMouseDown:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[a.jsx("input",{type:"checkbox",className:"be-inline-checkbox-input",checked:l,onChange:r}),a.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:s,onChange:o,placeholder:"Label…"})]})}function Oi(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ni(e){const{checked:n=!1,label:t=""}=e.data??{};return`<span data-inline-type="checkbox" data-checked="${n}">${n?"☑":"☐"} ${Oi(t)}</span>`}function Mi(e){const{checked:n=!1,label:t=""}=e.data??{};return`${n?"[x]":"[ ]"} ${t}`.trim()}function Ai(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="checkbox"?null:{id:E(),type:"checkbox",value:"",marks:{},data:{checked:e.getAttribute("data-checked")==="true",label:(e.textContent??"").replace(/^[☑☐]\s*/,"")}}}const Oo={component:Li,isAtomic:!0,toHTML:Ni,toPlainText:Mi,fromHTML:Ai,slashCommand:{label:"Checkbox",icon:lt,keywords:["checkbox","todo","check","toggle"],run:(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o})=>Nn(e,{blockId:n,runId:t,sliceStart:r,sliceEnd:o},()=>({id:E(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function Di({id:e,blockId:n}){var h;const t=_(),r=Le(e),o=n?t.getBlock(n):null,l=o?t.getBlock(o.parentId):null,s=(l==null?void 0:l.parentId)??null,i=ne(s),c=l?l.contentIds.indexOf(n):-1,f=(((h=(i&&l?be(i,l.contentIds.length):[])[c])==null?void 0:h.options)??[]).map((m,g)=>({...m,color:m.color??nn(g)})),d=p.useCallback((m,g)=>{t.applyOperation(G(e,{data:{selectedValue:m,selectedLabel:(g==null?void 0:g.label)??""}}))},[t,e]);if(!r)return null;const{selectedValue:b=""}=r.data??{};return a.jsx("span",{className:"be-inline-table-select",onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onKeyDown:m=>m.stopPropagation(),children:a.jsx(De,{value:b,options:f,onChange:d,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function No(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _i(e){return No(e).replace(/"/g,"&quot;")}function Pi(e){const{selectedValue:n="",selectedLabel:t=""}=e.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${_i(n)}">${No(t)}</span>`}function $i(e){var n;return((n=e.data)==null?void 0:n.selectedLabel)??""}function Hi(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="tableSelect"?null:{id:E(),type:"tableSelect",value:"",marks:{},data:{selectedValue:e.getAttribute("data-selected-value")??"",selectedLabel:e.textContent??""}}}const Mo={component:Di,isAtomic:!0,toHTML:Pi,toPlainText:$i,fromHTML:Hi},Ao={};function zi(e){Do(e,{select:So,date:Lo,checkbox:Oo,..._o,emoji:Ao})}function Do(e,n){for(const[t,r]of Object.entries(n))e.register(t,r)}const _o={tableSelect:Mo},Fi="$fieldTypes";function Po(){const e=_(),n=p.useCallback(r=>e.subscribe(Fi,r),[e]),t=p.useCallback(()=>e.getFieldTypes(),[e]);return p.useSyncExternalStore(n,t)}function Fe(e){var o,l;const n=(o=e.getPendingSelection)==null?void 0:o.call(e);if(n){he(n.runId,n.offset);return}const r=(((l=e.getPendingAffectedBlockIds)==null?void 0:l.call(e))??[]).find(s=>e.getBlock(s));r&&oe(e,r)}const Ui={canUndo:!1,canRedo:!1};function $o(){const{history:e}=xe(),n=p.useCallback(o=>e?e.subscribeToHistory(o):()=>{},[e]),t=p.useCallback(()=>e?e.getUndoRedoSnapshot():Ui,[e]),r=p.useSyncExternalStore(n,t);return e?{...r,undo:()=>{const o=e.undo();return o&&Fe(e),o},redo:()=>{const o=e.redo();return o&&Fe(e),o},getHistoryLog:()=>e.getHistoryLog()}:null}const Ho=[{phrases:["new paragraph","next paragraph"],description:"Start a new paragraph",action:{type:"insertParagraph"}},{phrases:["heading one","heading 1"],description:"Convert the current block to a heading 1",action:{type:"convertBlock",blockType:"heading",props:{level:1}}},{phrases:["heading two","heading 2"],description:"Convert the current block to a heading 2",action:{type:"convertBlock",blockType:"heading",props:{level:2}}},{phrases:["heading three","heading 3"],description:"Convert the current block to a heading 3",action:{type:"convertBlock",blockType:"heading",props:{level:3}}},{phrases:["bulleted list","bullet point","bullet list"],description:"Convert the current block to a bulleted list item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!1,titleRunIds:[]}}},{phrases:["numbered list","ordered list"],description:"Convert the current block to a numbered list item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!0,titleRunIds:[]}}},{phrases:["checklist","to-do","to do","to-do list","to do list"],description:"Convert the current block to a to-do item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]}}},{phrases:["quote"],description:"Convert the current block to a quote",action:{type:"convertBlock",blockType:"blockquote",props:{}}},{phrases:["code block","code"],description:"Convert the current block to a code block",action:{type:"convertBlock",blockType:"code",props:{language:"plaintext"}}},{phrases:["undo"],description:"Undo the last edit",action:{type:"undo"}},{phrases:["redo"],description:"Redo the last undone edit",action:{type:"redo"}},{phrases:["stop dictation","stop listening","stop"],description:"Stop dictation",action:{type:"stopDictation"}}],zo=new Map;for(const{phrases:e,action:n}of Ho)for(const t of e)zo.set(t,n);function Ki(e){return(e??"").toLowerCase().trim().replace(/\s+/g," ").replace(/[.,!?]+$/,"")}function Vi(e){return zo.get(Ki(e))??null}function qi(){return Ho.map(({phrases:e,description:n})=>({phrases:[...e],description:n}))}function Wi(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Yi(e){var n;return((n=e==null?void 0:e.props)==null?void 0:n.titleRunIds)??(e==null?void 0:e.contentIds)??[]}function Gi(e,n,t){var r,o;if(t.type==="insertParagraph"){Te(e,n,z("paragraph"));return}if(t.type==="convertBlock"){const l=e.getBlock(n);if(!l)return;const s=Yi(l),{ops:i}=ut(e,n,t.blockType,t.props,s);Wi(e,i),s[0]&&vn(s[0]);return}if(t.type==="undo"){(r=e.undo)!=null&&r.call(e)&&Fe(e);return}t.type==="redo"&&(o=e.redo)!=null&&o.call(e)&&Fe(e)}function er(){return typeof window>"u"?null:window.SpeechRecognition??window.webkitSpeechRecognition??null}const Ji="Microphone access is blocked. Enable it in your browser's site settings, then try again.";function Xi({shortcut:e=!0}={}){const n=_(),[t,r]=p.useState(!1),[o,l]=p.useState("idle"),[s,i]=p.useState("unknown"),[c,u]=p.useState(null),f=p.useRef(null),d=p.useRef(null),b=p.useRef(null),h=p.useRef(0),m=er()!==null;p.useEffect(()=>{var R;if(!((R=navigator.permissions)!=null&&R.query))return;let C,y=!1;return navigator.permissions.query({name:"microphone"}).then(j=>{y||(C=j,i(j.state),C.onchange=()=>i(C.state))}).catch(()=>{}),()=>{y=!0,C&&(C.onchange=null)}},[]);const g=p.useCallback(()=>{if(!d.current){const C=we();if(!C)return null;d.current=C}return{runId:d.current.runId,blockId:d.current.blockId,startOffset:d.current.offset,insertedLength:0}},[]),k=p.useCallback((C,y)=>{const R=n.getRun(C.runId);if(!R||R.type!=="text")return;const j=R.value??"",S=j.slice(0,C.startOffset);if(C.needsLeadingSpace===void 0){const L=S[S.length-1];C.needsLeadingSpace=C.startOffset>0&&L!==void 0&&!/\s/.test(L)}const I=(C.needsLeadingSpace?" ":"")+y,T=j.slice(C.startOffset+C.insertedLength);ge.flushSync(()=>n.applyOperation(G(C.runId,{value:S+I+T}))),C.insertedLength=I.length,$t(C.runId,C.startOffset+I.length),d.current={runId:C.runId,blockId:C.blockId,offset:C.startOffset+I.length}},[n]),x=p.useCallback(C=>{const y=n.getRun(C.runId);if(!y||y.type!=="text")return;const R=y.value??"",j=R.slice(0,C.startOffset)+R.slice(C.startOffset+C.insertedLength);ge.flushSync(()=>n.applyOperation(G(C.runId,{value:j}))),$t(C.runId,C.startOffset),d.current={runId:C.runId,blockId:C.blockId,offset:C.startOffset}},[n]),w=p.useCallback(C=>{var S,I;let y="",R=!1;const j=Math.max(C.resultIndex,h.current);for(let T=j;T<C.results.length;T+=1){const L=C.results[T],M=((S=L[0])==null?void 0:S.transcript)??"";if(!L.isFinal){y+=(y?" ":"")+M,R=!0;continue}const A=b.current??g();if(b.current=null,h.current=T+1,!A)continue;const P=Vi(M);P?(x(A),P.type==="stopDictation"?(I=f.current)==null||I.stop():(Gi(n,A.blockId,P),d.current=null,l("listening"))):(k(A,M),l("listening"))}if(R){const T=b.current??g();T&&(b.current=T,k(T,y))}},[n,g,k,x]),v=p.useCallback(()=>{if(!m||f.current)return;u(null),d.current=we(),b.current=null,h.current=0;const C=er(),y=new C;y.continuous=!0,y.interimResults=!0,y.onresult=w,y.onstart=()=>l("listening"),y.onspeechstart=()=>l("listening"),y.onspeechend=()=>l("processing"),y.onerror=R=>{R.error==="not-allowed"||R.error==="service-not-allowed"?(i("denied"),u(Ji)):u(R.error??"Voice typing stopped unexpectedly.")},y.onend=()=>{f.current=null,d.current=null,b.current=null,h.current=0,r(!1),l("idle")},f.current=y,y.start(),r(!0)},[m,w]),B=p.useCallback(()=>{var C;(C=f.current)==null||C.stop()},[]);return p.useEffect(()=>()=>{var C;return(C=f.current)==null?void 0:C.stop()},[]),p.useEffect(()=>{if(!e||!m)return;const C=y=>{!(y.metaKey||y.ctrlKey)||!y.shiftKey||y.key.toLowerCase()!=="m"||(y.preventDefault(),f.current?B():v())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[e,m,v,B]),{isSupported:m,isListening:t,status:o,permissionState:s,error:c,start:v,stop:B}}function Qi({voice:e}){const[n,t]=p.useState(!1);p.useEffect(()=>{t(!1)},[e==null?void 0:e.error]);const r=(e==null?void 0:e.permissionState)==="denied"&&!n;return a.jsxs(Be,{isOpen:r,onClose:()=>t(!0),title:"Microphone access blocked",children:[a.jsx("p",{children:(e==null?void 0:e.error)||"Microphone access is blocked. Enable it in your browser's site settings, then try again."}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:()=>t(!0),children:"Dismiss"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:()=>{var o;return(o=e==null?void 0:e.start)==null?void 0:o.call(e)},children:"Try again"})]})]})}function Fo(e){const[n,t]=p.useState(null);return p.useEffect(()=>{if(!e){t(null);return}const r=()=>{var c,u,f,d;const o=(c=window.getSelection)==null?void 0:c.call(window);if(!o||o.rangeCount===0||!o.isCollapsed){t(null);return}const l=o.anchorNode,s=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;if(!((u=s==null?void 0:s.closest)!=null&&u.call(s,"[data-run-id]"))){t(null);return}const i=((d=(f=o.getRangeAt(0)).getBoundingClientRect)==null?void 0:d.call(f))??{top:0,left:0,right:0,bottom:0,width:0,height:0};t(i)};return r(),document.addEventListener("selectionchange",r),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("selectionchange",r),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e]),n}function Zi({voice:e}){const n=!!(e!=null&&e.isListening),t=Fo(n),r=p.useRef(null),o=no(r,!!(n&&t),t==null?void 0:t.left);if(!n||!t||o==null)return null;const l=e.status==="processing";return ge.createPortal(a.jsxs("div",{ref:r,className:`be-voice-indicator${l?" be-voice-indicator-processing":""}`,contentEditable:!1,style:{position:"fixed",top:t.top-8,left:o,transform:"translate(-50%, -100%)"},children:[a.jsx("span",{className:"be-voice-indicator-dot"}),a.jsx(Kl,{size:12}),a.jsx("span",{className:"be-voice-indicator-label",children:l?"Processing…":"Listening…"})]}),document.body)}const kn="application/x-block-editor-blocks+json";function wt(e){return e.split(/\r\n|\r|\n/).filter(n=>n.length>0).map(n=>{const t=E();return{block:{id:E(),type:"paragraph",parentId:null,contentIds:[t],props:{}},runs:[{id:t,type:"text",value:n,marks:{}}]}})}function Uo(e,n,t){const r=new DOMParser().parseFromString(e,"text/html"),o={registry:n,inlineRegistry:t},l=n.listHtmlMatchers(),s=[],i=u=>{var b;const f=u.tagName==="OL",d=[];for(const h of u.children){if(h.tagName!=="LI")continue;const m=(b=n.get("listItem"))==null?void 0:b.fromHTML(h,o);m&&(m.block.props.ordered=f,d.push(m))}return d},c=u=>{var d;const f=Array.from(u.children).filter(b=>b.tagName==="P");if(f.length===0){const b=(d=n.get("blockquote"))==null?void 0:d.fromHTML(u,o);return b?[b]:[]}return f.map(b=>{const h=me(b,o);return{block:{id:E(),type:"blockquote",parentId:null,contentIds:h.map(m=>m.id),props:{}},runs:h}})};for(const u of r.body.childNodes){if(u.nodeType===3){const d=u.textContent.trim();d&&s.push(...wt(d));continue}if(u.nodeType!==1)continue;if(u.tagName==="UL"||u.tagName==="OL"){s.push(...i(u));continue}if(u.tagName==="BLOCKQUOTE"){s.push(...c(u));continue}let f=null;for(const d of l){const b=d.fromHTML(u,o);if(b){f=b;break}}if(f)s.push(f);else if(u.textContent.trim()){const d=me(u,o);s.push({block:{id:E(),type:"paragraph",parentId:null,contentIds:d.map(b=>b.id),props:{}},runs:d})}}return s}function Ko(e,n,t){const r=e.types??[];if(r.includes(kn)){const l=e.getData(kn);if(l)return ec(l)}if(r.includes("text/html")){const l=e.getData("text/html");if(l)return Uo(l,n,t)}const o=e.getData("text/plain")??"";return wt(o)}function ec(e){return JSON.parse(e).blocks.map(t=>mt(t))}function Hn(e,n){var r;const t=e.getBlock(n);return((r=t.props)==null?void 0:r.titleRunIds)??t.contentIds}function mn(){return{id:E(),type:"text",value:"",marks:{}}}function zn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function It(e,n,t){const{startRunId:r,startOffset:o,endRunId:l,endOffset:s}=t,i=Hn(e,n),c=i.indexOf(r),u=i.indexOf(l);if(c===-1||u===-1)return null;const[f,d]=c<=u?[c,u]:[u,c],b=c<=u?o:s,h=c<=u?s:o,m=i.slice(0,f).map(C=>e.getRun(C)),g=i.slice(d+1).map(C=>e.getRun(C)),k=i.slice(f,d+1).map(C=>e.getRun(C)),x=[];let w=null,v=0;if(f===d){const C=k[0];if(C.type==="text"){const y=Math.max(0,Math.min(b,h)),R=Math.min(C.value.length,Math.max(b,h)),j={...C,value:C.value.slice(0,y)+C.value.slice(R)};x.push(j),w=j.id,v=y}}else k.forEach((C,y)=>{if(C.type!=="text")return;const R=y===0,j=y===k.length-1,S=R?C.value.slice(0,b):"";if(R&&S){const I={...C,value:S};x.push(I),w=I.id,v=S.length}if(j&&!R){const I=C.value.slice(h);if(I){const T={id:E(),type:"text",value:I,marks:C.marks};x.push(T),w===null&&(w=T.id,v=0)}}});let B=[...m,...x,...g];if(B.length===0){const C=mn();B=[C],w=C.id,v=0}else if(w===null){const C=m[m.length-1];C?(w=C.id,v=C.type==="text"?C.value.length:0):g[0]&&(w=g[0].id,v=0)}return e.applyOperation(ue(n,B)),{blockId:n,runId:w,offset:v}}function Ct(e,n){const{blockIds:t,startBlockId:r,startRunId:o,startOffset:l,endBlockId:s,endRunId:i,endOffset:c}=n;if(!t||t.length===0)return null;const u=t.indexOf(r),f=t.indexOf(s);if(u===-1||f===-1)return null;const[d,b]=u<=f?[u,f]:[f,u],h=u<=f,m=h?o:i,g=h?l:c,k=h?i:o,x=h?c:l;if(d===b)return It(e,t[d],{startRunId:m,startOffset:g,endRunId:k,endOffset:x});const w=t[d],v=t[b],B=e.getBlock(w),C=e.getBlock(v),y=Hn(e,w),R=y.indexOf(m),j=y.slice(0,R).map(Y=>e.getRun(Y)),S=e.getRun(m),I=S.type==="text"&&g>0?{...S,value:S.value.slice(0,g)}:null,T=Hn(e,v),L=T.indexOf(k),M=T.slice(L+1).map(Y=>e.getRun(Y)),A=e.getRun(k),P=A.type==="text"&&x<A.value.length?{id:E(),type:"text",value:A.value.slice(x),marks:A.marks}:null,X=[...j,...I?[I]:[]],J=[...P?[P]:[],...M],H=[];for(let Y=d+1;Y<b;Y+=1)H.push($(t[Y]));const W=Nr(B.type,C.type),N=e.getBlock(B.parentId),U=b-d-1+(W?1:0),K=N&&N.contentIds.length-U===1;let q,re,pe;if(W){const Y=[...X,...J];if(Y.length===0&&K&&B.type!=="paragraph"){const{block:te,runs:O}=z("paragraph")(N.id);return H.push({type:"insertBlock",block:te,parentId:N.id,index:0,subtree:{blocks:[te],runs:O}}),H.push($(w)),H.push($(v)),zn(e,H),{blockId:te.id,runId:te.contentIds[0],offset:0}}const se=Y.length?Y:[mn()];if(H.push(ue(w,se)),H.push($(v)),pe=w,I)q=I.id,re=I.value.length;else if(j.length){const te=j[j.length-1];q=te.id,re=te.type==="text"?te.value.length:0}else P?(q=P.id,re=0):M.length?(q=M[0].id,re=0):(q=se[0].id,re=0)}else{const Y=X.length?X:[mn()];if(H.push(ue(w,Y)),H.push(ue(v,J.length?J:[mn()])),pe=w,I)q=I.id,re=I.value.length;else if(j.length){const se=j[j.length-1];q=se.id,re=se.type==="text"?se.value.length:0}else q=Y[0].id,re=0}return zn(e,H),{blockId:pe,runId:q,offset:re}}function xn(e,n=""){var i;const t=e.getRootId(),r=((i=e.getBlock(t))==null?void 0:i.contentIds)??[];if(r.length===0)return null;const o=r.map(c=>$(c)),{block:l,runs:s}=z("paragraph")(t);return n&&(s[0].value=n),o.push(Q(l,t,0,{blocks:[l],runs:s})),zn(e,o),{blockId:l.id,runId:l.contentIds[0],offset:n.length}}function Bt(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Ze(e,n){n.length!==0&&Bt(e,n.map(t=>$(t)))}function Vo(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const r=e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n[0]),l=r.contentIds.indexOf(n[n.length-1]);if(o<=0)return!1;const s=r.contentIds[o-1];return e.applyOperation(ke(s,t.parentId,l)),!0}function qo(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const r=e.getBlock(t.parentId);if(!r)return!1;const o=r.contentIds.indexOf(n[0]),l=r.contentIds.indexOf(n[n.length-1]);if(l===-1||l>=r.contentIds.length-1)return!1;const s=r.contentIds[l+1];return e.applyOperation(ke(s,t.parentId,o)),!0}function Wo(e,n){return n.length>0&&n.every(t=>{var r,o;return!!((o=(r=e.getBlock(t))==null?void 0:r.props)!=null&&o.hidden)})}function Yo(e,n,t){n.length!==0&&Bt(e,n.map(r=>F(r,{hidden:t})))}function nc(e,n,t,r){const o=t.filter(s=>{var i;return ft((i=e.getBlock(s))==null?void 0:i.type)});if(o.length===0)return;const l=o.flatMap(s=>$r(e,n,s,r).ops);Bt(e,l)}function tc(e,n){if(n.length===0)return[];const t=e.getBlock(n[0]),r=t&&e.getBlock(t.parentId);if(!r)return n;const o=new Set(n);return r.contentIds.filter(l=>o.has(l))}function Fn(e){var t;let n=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;for(;n&&typeof n.hasAttribute=="function"&&!n.hasAttribute("data-block-id");)n=n.parentElement;return((t=n==null?void 0:n.getAttribute)==null?void 0:t.call(n,"data-block-id"))??null}function rc(e){var d;const n=(d=window.getSelection)==null?void 0:d.call(window);if(!n||n.rangeCount===0)return[];const t=Fn(n.anchorNode),r=Fn(n.focusNode);if(!t)return[];if(!r||t===r)return[t];const o=e.getBlock(t),l=o&&e.getBlock(o.parentId);if(!l)return[t];const s=l.contentIds,i=s.indexOf(t),c=s.indexOf(r);if(i===-1||c===-1)return[t];const[u,f]=i<=c?[i,c]:[c,i];return s.slice(u,f+1)}function nr(e){const n=Ve();if(n)return It(e,n.blockId,n);const t=He(e);return t?Ct(e,t):null}function oc(e,n,t){const r=e.getRun(n.runId);if(!r||r.type!=="text")return null;const o=r.value??"",l=o.slice(0,n.offset)+t+o.slice(n.offset);return e.applyOperation(G(r.id,{value:l})),{blockId:n.blockId,runId:r.id,offset:n.offset+t.length}}function Pn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function lc(){const e=_(),n=Ee(),t=ye(),[r,o]=Jn(),[l,s]=rn(),i=p.useCallback(f=>{var g;const d=r?((g=e.getBlock(e.getRootId()))==null?void 0:g.contentIds)??[]:l.length>0?l:rc(e);if(d.length===0)return;const{html:b,text:h,json:m}=cn(e,n,d,t);f.clipboardData.setData("text/plain",h),f.clipboardData.setData("text/html",b),f.clipboardData.setData(kn,m),f.preventDefault()},[e,n,t,r,l]),c=p.useCallback(f=>{if(i(f),r){const b=xn(e);o(!1),b!=null&&b.runId&&he(b.runId,b.offset);return}if(l.length>0){Ze(e,l),s([]);return}const d=nr(e);d!=null&&d.runId&&he(d.runId,d.offset)},[i,e,r,o,l,s]),u=p.useCallback(f=>{var v,B,C;const d=Ko(f.clipboardData,n,t);if(d.length===0)return;if(r){const y=e.getRootId(),j=(((v=e.getBlock(y))==null?void 0:v.contentIds)??[]).map(I=>$(I));let S=0;for(const{block:I,runs:T,subtreeBlocks:L=[]}of d)I.parentId=y,j.push(Q(I,y,S,{blocks:[I,...L],runs:T})),S+=1;Pn(e,j),o(!1),f.preventDefault();return}if(l.length>0){const y=e.getBlock(l[0]),R=(y==null?void 0:y.parentId)??null,j=R&&e.getBlock(R);let S=j?j.contentIds.indexOf(l[0]):0;const I=l.map(T=>$(T));for(const{block:T,runs:L,subtreeBlocks:M=[]}of d)T.parentId=R,I.push(Q(T,R,S,{blocks:[T,...M],runs:L})),S+=1;Pn(e,I),s([]),f.preventDefault();return}const b=nr(e);if(d.length===1&&d[0].runs.every(y=>y.type==="text")&&(d[0].subtreeBlocks??[]).length===0){const y=b?{blockId:b.blockId,runId:b.runId,offset:b.offset}:we();if(y){const R=d[0].runs.map(S=>S.value).join(""),j=oc(e,y,R);if(j){he(j.runId,j.offset),f.preventDefault();return}}}const m=(b==null?void 0:b.blockId)??Fn((C=(B=window.getSelection)==null?void 0:B.call(window))==null?void 0:C.anchorNode);if(!m)return;const g=e.getBlock(m);if(!g)return;let x=e.getBlock(g.parentId).contentIds.indexOf(m)+1;const w=[];for(const{block:y,runs:R,subtreeBlocks:j=[]}of d)y.parentId=g.parentId,w.push(Q(y,g.parentId,x,{blocks:[y,...j],runs:R})),x+=1;Pn(e,w),f.preventDefault()},[e,n,t,r,o,l,s]);return{onCopy:i,onCut:c,onPaste:u}}const sc=["bold","italic","underline","strike","subscript","superscript","code"],ac=["color","highlight","link"];function Ue(e,n){var r;const t=e.getBlock(n);return((r=t.props)==null?void 0:r.titleRunIds)??t.contentIds}function ic(e,n){return e===n?!0:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function Go(e){var t;const n={};if(e.length===0)return n;for(const r of sc)n[r]=e.every(o=>{var l;return(l=o.marks)==null?void 0:l[r]});for(const r of ac){const o=((t=e[0].marks)==null?void 0:t[r])??null;n[r]=e.every(l=>{var s;return ic(((s=l.marks)==null?void 0:s[r])??null,o)})?o:null}return n}function Rt(e,n,t){const{startRunId:r,startOffset:o,endRunId:l,endOffset:s}=t,i=Ue(e,n),c=i.indexOf(r),u=i.indexOf(l);if(c===-1||u===-1)return{};const[f,d]=c<=u?[c,u]:[u,c],b=i.slice(f,d+1).map(h=>e.getRun(h)).filter(h=>h&&h.type==="text");return Go(b)}function Tt(e,n){const{blockIds:t,startBlockId:r,endBlockId:o}=n,l=t.indexOf(r),s=t.indexOf(o);if(l===-1||s===-1)return{};const[i,c]=l<=s?[l,s]:[s,l],u=[];for(let f=i;f<=c;f+=1)for(const d of Ue(e,t[f])){const b=e.getRun(d);b&&b.type==="text"&&u.push(b)}return Go(u)}function Jo(e,n){const t={...e};for(const[r,o]of Object.entries(n))o!=null?t[r]=o:delete t[r];return t}function Xo(e,n,t,r,o,l){const s=Jo(t.marks,l);if(r===0&&o===t.value.length)return e.applyOperation({type:"updateRun",id:t.id,patch:{marks:s}}),t.id;const i=t.value.slice(0,r),c=t.value.slice(r,o),u=t.value.slice(o),f=[];i&&f.push({id:E(),type:"text",value:i,marks:{...t.marks}});const d={id:E(),type:"text",value:c,marks:s};return f.push(d),u&&f.push({id:E(),type:"text",value:u,marks:{...t.marks}}),e.applyOperation(tn(n,[t.id],f)),d.id}function cc(e,n,t,r){const{startRunId:o,startOffset:l,endRunId:s,endOffset:i}=t,c=Ue(e,n),u=c.indexOf(o),f=c.indexOf(s);if(u===-1||f===-1)return null;const[d,b]=u<=f?[u,f]:[f,u],h=u<=f?l:i,m=u<=f?i:l,g=c.slice(d,b+1),k=g.map(v=>e.getRun(v));if(d===b){const v=k[0];if(v.type!=="text")return v.id;const B=Math.max(0,Math.min(h,m)),C=Math.min(v.value.length,Math.max(h,m));return B===C?v.id:Xo(e,n,v,B,C,r)}const x=[];let w=null;return k.forEach((v,B)=>{if(v.type!=="text"){x.push(v),w=v.id;return}const C=B===0,y=B===k.length-1,R=C?h:0,j=y?m:v.value.length,S=v.value.slice(0,R),I=v.value.slice(R,j),T=v.value.slice(j);S&&x.push({id:E(),type:"text",value:S,marks:{...v.marks}});const L={id:E(),type:"text",value:I,marks:Jo(v.marks,r)};x.push(L),w=L.id,T&&x.push({id:E(),type:"text",value:T,marks:{...v.marks}})}),e.applyOperation(tn(n,g,x)),w}function uc(e,n,t,r){var m;const{startRunId:o,startOffset:l,endRunId:s,endOffset:i}=t,c=Ue(e,n),u=c.indexOf(o),f=c.indexOf(s);if(u===-1||f===-1)return!0;const[d,b]=u<=f?[u,f]:[f,u],h=c.slice(d,b+1).map(g=>e.getRun(g)).filter(g=>g.type==="text");if(h.length===0)return!0;if(d===b){const g=Math.max(0,Math.min(l,i)),k=Math.min(h[0].value.length,Math.max(l,i));if(g===k)return!((m=h[0].marks)!=null&&m[r])}return!h.every(g=>{var k;return(k=g.marks)==null?void 0:k[r]})}function dc(e,n,t,r,o,l){var d;const s=e.getRun(t),i=s.value??"",c=Math.max(0,Math.min(r,o)),u=Math.min(i.length,Math.max(r,o));if(c===u)return t;const f=!((d=s.marks)!=null&&d[l]);return Xo(e,n,s,c,u,{[l]:f?!0:null})}function Ke(e,n,t,r){return cc(e,n,t,r)}function jt(e,n,t,r){const o=uc(e,n,t,r);return Ke(e,n,t,{[r]:o?!0:null})}function St(e,n,t){return yn(e,n,r=>({[t]:r?null:!0}),t)}function yn(e,n,t,r){var y;const{blockIds:o,startBlockId:l,startRunId:s,startOffset:i,endBlockId:c,endRunId:u,endOffset:f}=n;if(!o||o.length===0)return null;const d=o.indexOf(l),b=o.indexOf(c);if(d===-1||b===-1)return null;const[h,m]=d<=b?[d,b]:[b,d],g=d<=b,k=g?s:u,x=g?i:f,w=g?u:s,v=g?f:i;let B=t;if(typeof t=="function"){let R=!1,j=!0;for(let S=h;S<=m;S+=1){const I=Ue(e,o[S]).map(T=>e.getRun(T)).filter(T=>T.type==="text");I.length!==0&&(R=!0,I.every(T=>{var L;return(L=T.marks)==null?void 0:L[r]})||(j=!1))}B=t(R&&j)}if(h===m)return Ke(e,o[h],{startRunId:k,startOffset:x,endRunId:w,endOffset:v},B);let C=null;for(let R=h;R<=m;R+=1){const j=o[R],S=Ue(e,j),I=S[0],T=S[S.length-1],L=e.getRun(T),M=((y=L==null?void 0:L.value)==null?void 0:y.length)??0;let A;R===h&&R===m?A={startRunId:k,startOffset:x,endRunId:w,endOffset:v}:R===h?A={startRunId:k,startOffset:x,endRunId:T,endOffset:M}:R===m?A={startRunId:I,startOffset:0,endRunId:w,endOffset:v}:A={startRunId:I,startOffset:0,endRunId:T,endOffset:M},C=Ke(e,j,A,B)}return C}function Qo(e,n){var r;const t=e.getBlock(n);return((r=t==null?void 0:t.props)==null?void 0:r.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function Zo(e){const n=Ve();if(!n)return!1;const{blockId:t,startRunId:r,startOffset:o,endRunId:l,endOffset:s}=n,i=Qo(e,t);if(i.length===0)return!1;const c=i.indexOf(r),u=i.indexOf(l);if(c===-1||u===-1)return!1;const[f,d]=c<=u?[c,u]:[u,c],b=c<=u?o:s,h=c<=u?s:o;if(f!==0||d!==i.length-1||b!==0)return!1;const m=e.getRun(i[i.length-1]),g=(m==null?void 0:m.type)==="text"?(m.value??"").length:1;return h===g}function pc(e){const n=we();return n?de(e,Qo(e,n.blockId)):!1}function fc(e,n,t){var h,m;const r=e.getBlock(n);if(!r){t(null);return}const o=e.getBlock(r.parentId),l=o?o.contentIds.indexOf(n):-1,s=l>0?o.contentIds[l-1]:null,i=l!==-1&&l<o.contentIds.length-1?o.contentIds[l+1]:null;e.applyOperation($(n)),t(null);const c=We(e),u=s??i??c;if(!u)return;const f=e.getBlock(u);if(on(e,f)){t(u),requestAnimationFrame(()=>{var g;return(g=document.querySelector(`[data-block-id="${u}"]`))==null?void 0:g.focus()});return}const d=(h=f==null?void 0:f.props)==null?void 0:h.titleRunIds,b=((m=f==null?void 0:f.contentIds)==null?void 0:m[f.contentIds.length-1])??(d==null?void 0:d[d.length-1]);b&&ee(b)}const tr={b:"bold",i:"italic",u:"underline"};function bc(e){const n=_(),[t,r]=Jn(),{getSelectedBlockId:o,setSelectedBlockId:l}=Ce();p.useEffect(()=>{const s=e.current;if(!s)return;const i=u=>{var d,b;if(o()&&(u.key==="Backspace"||u.key==="Delete")&&!u.defaultPrevented){u.preventDefault(),u.stopPropagation(),fc(n,o(),l);return}if(o()&&u.key!=="Backspace"&&u.key!=="Delete"&&l(null),u.metaKey||u.ctrlKey){const h=u.key.toLowerCase();if(h==="z"&&!u.shiftKey){u.preventDefault(),(d=n.undo)!=null&&d.call(n)&&Fe(n);return}if(h==="z"&&u.shiftKey||h==="y"){u.preventDefault(),(b=n.redo)!=null&&b.call(n)&&Fe(n);return}if(h==="a"){if(t)return;(Zo(n)||pc(n))&&(u.preventDefault(),r(!0));return}if(tr[h]){if(t)return;u.preventDefault();const m=tr[h],g=Ve();if(g){const x=jt(n,g.blockId,g,m);x&&ee(x);return}const k=He(n);if(k){const x=St(n,k,m);x&&ee(x)}}return}if(t){if(u.key==="Backspace"||u.key==="Delete"){u.preventDefault(),u.stopPropagation();const h=xn(n);r(!1),h!=null&&h.runId&&he(h.runId,h.offset);return}if(u.key.length===1){u.preventDefault(),u.stopPropagation();const h=xn(n,u.key);r(!1),h!=null&&h.runId&&he(h.runId,h.offset);return}if(r(!1),u.key==="Escape")return}if(u.key==="Backspace"||u.key==="Delete"){const h=He(n);if(!h)return;u.preventDefault(),u.stopPropagation();const m=Ct(n,h);m!=null&&m.runId&&he(m.runId,m.offset)}},c=()=>{t&&r(!1),o()&&l(null)};return s.addEventListener("keydown",i),s.addEventListener("mousedown",c),()=>{s.removeEventListener("keydown",i),s.removeEventListener("mousedown",c)}},[e,n,t,r,o,l])}async function Un(e,n,t,r){var s,i,c;const{html:o,text:l}=cn(e,n,r,t);if(typeof ClipboardItem<"u"&&((s=navigator.clipboard)!=null&&s.write)){await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([l],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})})]);return}await((c=(i=navigator.clipboard)==null?void 0:i.writeText)==null?void 0:c.call(i,l))}function mc(){const e=_(),n=Ee(),t=ye(),[r,o]=rn(),[l,s]=p.useState(null),i=p.useRef(null),c=p.useRef(null),u=r.length>0,f=In(i,u,(l==null?void 0:l.bottom)!=null?l.bottom+4:null,l==null?void 0:l.left),d=p.useCallback(()=>o([]),[o]);Tn(i,u,d,void 0),p.useEffect(()=>{if(!u){s(null);return}const y=()=>{const R=r[r.length-1],j=document.querySelector(`[data-block-row-id="${R}"]`);s((j==null?void 0:j.getBoundingClientRect())??null)};return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[u,r]),p.useEffect(()=>{if(!u)return;const y=j=>{var S,I,T,L;(S=i.current)!=null&&S.contains(j.target)||(I=c.current)!=null&&I.contains(j.target)||(L=(T=j.target).closest)!=null&&L.call(T,".be-block-gutter")||d()},R=j=>{j.key==="Escape"?d():(j.key==="Delete"||j.key==="Backspace")&&(j.preventDefault(),Ze(e,r),d())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",R)}},[u,e,r,d]);const b=y=>y===1?"block":"blocks",h=p.useCallback(()=>{Un(e,n,t,r),Z(`${r.length} ${b(r.length)} copied`),d()},[e,n,t,r,d]),m=p.useCallback(async()=>{await Un(e,n,t,r);const y=r.length;Ze(e,r),Z(`${y} ${b(y)} cut`),d()},[e,n,t,r,d]),g=p.useCallback(()=>{const y=r.length;Ze(e,r),Z(`${y} ${b(y)} deleted`),d()},[e,r,d]),k=p.useCallback(()=>{Vo(e,r)&&Z(`${r.length} ${b(r.length)} moved up`),d()},[e,r,d]),x=p.useCallback(()=>{qo(e,r)&&Z(`${r.length} ${b(r.length)} moved down`),d()},[e,r,d]),w=Wo(e,r),v=p.useCallback(()=>{Yo(e,r,!w),Z(w?`${r.length} ${b(r.length)} shown in preview`:`${r.length} ${b(r.length)} hidden in preview`),d()},[e,r,w,d]),B=r.some(y=>{var R;return ft((R=e.getBlock(y))==null?void 0:R.type)}),C=p.useCallback(y=>{const R=r.length;nc(e,n,r,y),Z(`${R} ${b(R)} turned into ${y.label}`),d()},[e,n,r,d]);return!u||!f?null:ge.createPortal(a.jsxs("div",{ref:i,role:"menu","aria-label":"Selected blocks options",className:"be-block-range-menu",style:{position:"fixed",top:f.top,left:f.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:h,children:[a.jsx(et,{size:15})," Copy"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[a.jsx(Al,{size:15})," Cut"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:k,children:[a.jsx(nt,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:x,children:[a.jsx(tt,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:v,children:[w?a.jsx(st,{size:15}):a.jsx(at,{size:15}),w?"Show in preview":"Hide in preview"]}),B&&a.jsx(Hr,{onSelect:C,onClose:()=>{},containerRef:c,menuClassName:"be-block-range-menu",itemClassName:"be-block-range-menu-item"}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item be-block-range-menu-item-danger",onClick:g,children:[a.jsx(Bn,{size:15})," Delete"]})]}),document.body)}const hc=4;function gc(e,n,t){const r=e.getBlock(n);if(!r)return[];const o=e.getBlock(r.parentId);if(!o)return[n];const l=o.contentIds,s=l.indexOf(n),i=t?l.indexOf(t):s;if(s===-1)return[n];const[c,u]=i===-1?[s,s]:[Math.min(s,i),Math.max(s,i)];return l.slice(c,u+1)}function kc(){var e,n;return typeof window<"u"&&((n=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:n.matches)===!0}function xc(e){const n=_(),[,t]=rn(),r=p.useRef(null),o=p.useRef(!1),l=p.useRef(null),s=p.useCallback(f=>{var h,m,g,k,x;if(!r.current)return;if(!o.current){const{x:w,y:v}=l.current??{x:f.clientX,y:f.clientY};if(Math.hypot(f.clientX-w,f.clientY-v)<hc)return;o.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(m=(h=window.getSelection)==null?void 0:h.call(window))==null||m.removeAllRanges()}(k=(g=window.getSelection)==null?void 0:g.call(window))==null||k.removeAllRanges(),f.preventDefault();const d=(x=document.elementFromPoint(f.clientX,f.clientY))==null?void 0:x.closest("[data-block-row-id]"),b=(d==null?void 0:d.getAttribute("data-block-row-id"))??null;t(gc(n,r.current,b))},[n,t]),i=p.useCallback(()=>{r.current=null,o.current=!1,l.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),c=p.useCallback((f,d)=>{r.current=f,o.current=!1,l.current={x:d.clientX,y:d.clientY}},[]),u=p.useCallback(f=>{var g,k;if(f.button!==0||kc()||(k=(g=f.target).closest)!=null&&k.call(g,"button, input, textarea, select"))return;const d=f.target.closest("[data-block-row-id]");if(d){if(f.target.closest(".be-block-row-content"))return;c(d.getAttribute("data-block-row-id"),f);return}const b=e==null?void 0:e.current;if(!b)return;const m=[...b.querySelectorAll("[data-block-row-id]")].find(x=>{const w=x.getBoundingClientRect();return f.clientY>=w.top&&f.clientY<=w.bottom});m&&c(m.getAttribute("data-block-row-id"),f)},[e,c]);p.useEffect(()=>(document.addEventListener("mousedown",u),document.addEventListener("mousemove",s),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i),document.documentElement.classList.remove("be-block-range-dragging")}),[u,s,i])}const yc="be-touch-input";function vc(){var e,n;return typeof window<"u"&&((n=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:n.matches)===!0}function Et(){const[e,n]=p.useState(vc);return p.useEffect(()=>{if(typeof window>"u")return;const t=r=>{n(r.pointerType==="touch"||r.pointerType==="pen")};return window.addEventListener("pointerdown",t,{passive:!0}),()=>window.removeEventListener("pointerdown",t)},[]),p.useEffect(()=>{var t;(t=document.documentElement)==null||t.classList.toggle(yc,e)},[e]),e}function Lt(e,n,t,r,o){const[l,s]=p.useState(!1),i=p.useCallback(k=>{const x=n==="same-block"?Ke(e,t.blockId,t,k):yn(e,r,k);return x&&ee(x),x},[e,n,t,r]),c=p.useCallback(k=>{const x=n==="same-block"?jt(e,t.blockId,t,k):St(e,r,k);x&&ee(x)},[e,n,t,r]),u=p.useCallback(k=>{const x=k==="subscript"?"superscript":"subscript",w=!o[k];i({[k]:w?!0:null,[x]:null})},[o,i]),f=p.useRef(null),d=p.useCallback(()=>{f.current={kind:n,selection:t,crossSelection:r},s(!0)},[n,t,r]),b=p.useCallback(()=>s(!1),[]),h=p.useCallback(k=>{const x=f.current;if(!x)return;const w=x.kind==="same-block"?Ke(e,x.selection.blockId,x.selection,k):yn(e,x.crossSelection,k);w&&ee(w),s(!1)},[e]),m=p.useCallback((k,x)=>h({link:{href:k,target:x}}),[h]),g=p.useCallback(()=>h({link:null}),[h]);return{applyPatch:i,toggleBoolean:c,setSubSuper:u,isLinkModalOpen:l,openLinkModal:d,closeLinkModal:b,handleSaveLink:m,handleRemoveLink:g}}function el({isOpen:e,onClose:n,onSelectCommand:t}){const r=Ee(),o=ye(),l=p.useMemo(()=>[...(r==null?void 0:r.listSlashCommands())??[],...(o==null?void 0:o.listSlashCommands())??[]],[r,o]);return a.jsx(Be,{isOpen:e,onClose:n,title:"Add a block",variant:"sheet",children:a.jsx("div",{className:"be-mobile-picker-list",role:"listbox","aria-label":"Insertable blocks",children:l.map(s=>{const i=s.icon;return a.jsxs("button",{type:"button",role:"option",className:"be-mobile-picker-item",onClick:()=>t(s),children:[i&&a.jsx("span",{className:"be-mobile-picker-item-icon",children:a.jsx(i,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:s.label})]},s.label)})})})}function nl({isOpen:e,onClose:n,store:t,blockId:r}){var i;const o=r?t.getBlock(r):null,l=!!((i=o==null?void 0:o.props)!=null&&i.hidden),s=p.useCallback(c=>{c(),n()},[n]);return a.jsx(Be,{isOpen:e,onClose:n,title:"Block options",variant:"sheet",children:a.jsxs("div",{className:"be-mobile-picker-list",role:"menu","aria-label":"Block options",children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>s(()=>{ht(t,r),Z("Block duplicated")}),children:[a.jsx("span",{className:"be-mobile-picker-item-icon",children:a.jsx(et,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:"Duplicate"})]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>s(()=>{gt(t,r)&&Z("Block moved up")}),children:[a.jsx("span",{className:"be-mobile-picker-item-icon",children:a.jsx(nt,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:"Move up"})]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>s(()=>{kt(t,r)&&Z("Block moved down")}),children:[a.jsx("span",{className:"be-mobile-picker-item-icon",children:a.jsx(tt,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:"Move down"})]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>s(()=>{t.applyOperation(F(r,{hidden:!l})),Z(l?"Block shown in preview":"Block hidden in preview")}),children:[a.jsx("span",{className:"be-mobile-picker-item-icon",children:l?a.jsx(st,{size:18}):a.jsx(at,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:l?"Show in preview":"Hide in preview"})]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item be-mobile-picker-item-danger",onClick:()=>s(()=>{jn(t,r),Z("Block deleted")}),children:[a.jsx("span",{className:"be-mobile-picker-item-icon",children:a.jsx(Bn,{size:18})}),a.jsx("span",{className:"be-mobile-picker-item-label",children:"Delete"})]})]})})}const wc=ho.map(e=>({value:e,label:e}));function Ic(e,n){const[t,r]=p.useState(!1),[o,l]=p.useState(null),[s,i]=p.useState(null),[c,u]=p.useState(null);return p.useEffect(()=>{const f=e.current;if(!f)return;const d=()=>r(!0),b=h=>{f.contains(h.relatedTarget)||r(!1)};return f.addEventListener("focusin",d),f.addEventListener("focusout",b),()=>{f.removeEventListener("focusin",d),f.removeEventListener("focusout",b)}},[e]),p.useEffect(()=>{if(!t){l(null);return}const f=()=>{var m;const d=e.current,b=(m=window.getSelection)==null?void 0:m.call(window);if(!d||!b||b.rangeCount===0){l(null);return}if(!b.isCollapsed){if(!d.contains(b.anchorNode)||!d.contains(b.focusNode)){l(null);return}const g=Ve();if(g){i({kind:"same-block",selection:g,crossSelection:null,marks:Rt(n,g.blockId,g)}),l("selection");return}const k=He(n);if(k){i({kind:"cross-block",selection:null,crossSelection:k,marks:Tt(n,k)}),l("selection");return}l(null);return}const h=we();if(!h||!d.contains(b.anchorNode)){l(null);return}u(h),l("caret")};return f(),document.addEventListener("selectionchange",f),()=>document.removeEventListener("selectionchange",f)},[t,n,e]),{isFocused:t,mode:o,selectionState:s,caretState:c}}function Cc({store:e,selectionState:n}){const{kind:t,selection:r,crossSelection:o,marks:l}=n,{toggleBoolean:s,openLinkModal:i}=Lt(e,t,r,o,l);return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:`be-mobile-bar-btn${l.bold?" be-mobile-bar-btn-active":""}`,"aria-label":"Bold",onClick:()=>s("bold"),children:a.jsx(br,{size:18})}),a.jsx("button",{type:"button",className:`be-mobile-bar-btn${l.italic?" be-mobile-bar-btn-active":""}`,"aria-label":"Italic",onClick:()=>s("italic"),children:a.jsx(mr,{size:18})}),a.jsx("button",{type:"button",className:`be-mobile-bar-btn${l.underline?" be-mobile-bar-btn-active":""}`,"aria-label":"Underline",onClick:()=>s("underline"),children:a.jsx(hr,{size:18})}),a.jsx("button",{type:"button",className:`be-mobile-bar-btn${l.link?" be-mobile-bar-btn-active":""}`,"aria-label":"Link",onClick:i,children:a.jsx(gr,{size:18})})]})}function Bc({store:e,blockId:n}){const t=p.useCallback(()=>{const o=e.getBlock(n),l=o&&e.getBlock(o.parentId);l&&yt(e,l.id)},[e,n]),r=p.useCallback(()=>{const o=e.getBlock(n),l=o&&e.getBlock(o.parentId),s=l&&e.getBlock(l.parentId);if(!s||!l)return;const i=l.contentIds.indexOf(n);i!==-1&&gn(e,s.id,i)},[e,n]);return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert row below",onClick:t,children:"+ Row"}),a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert column right",onClick:r,children:"+ Column"})]})}function Rc({store:e,blockId:n}){var o;const t=e.getBlock(n),r=p.useCallback(l=>e.applyOperation(F(n,{language:l})),[e,n]);return a.jsx(De,{className:"be-mobile-bar-select",value:((o=t==null?void 0:t.props)==null?void 0:o.language)??"plaintext",options:wc,onChange:r,ariaLabel:"Code language"})}function Tc({store:e,blockId:n}){var o;const t=e.getBlock(n),r=(o=t==null?void 0:t.props)==null?void 0:o.color;return a.jsx("div",{className:"be-mobile-bar-swatches",children:fo.map(l=>a.jsx("button",{type:"button",className:`be-callout-color-option be-callout-color-option-${l.value}${l.value===r?" be-callout-color-option-active":""}`,"aria-label":l.label,title:l.label,onClick:()=>e.applyOperation(F(n,{color:l.value}))},l.value))})}const tl={tableCell:Bc,code:Rc,callout:Tc};function jc(e,n){let t=e.getBlock(n);for(;t;){if(tl[t.type])return t;t=t.parentId?e.getBlock(t.parentId):null}return null}function Sc(e,n){const t=e.getRootId();let r=e.getBlock(n);for(;r&&r.parentId!==t;)r=e.getBlock(r.parentId);return r}function Ec({containerRef:e}){var R,j;const n=_(),t=$o(),r=Et(),o=On(),{isFocused:l,mode:s,selectionState:i,caretState:c}=Ic(e,n),[u,f]=p.useState(!1),[d,b]=p.useState(!1),h=p.useCallback(()=>f(!0),[]),m=p.useCallback(()=>f(!1),[]),g=p.useCallback(()=>b(!0),[]),k=p.useCallback(()=>b(!1),[]),x=p.useCallback(S=>{const I=we()??c;I&&(S.run(n,{blockId:I.blockId,runId:I.runId,sliceStart:I.offset,sliceEnd:I.offset}),m())},[n,c,m]),w=p.useCallback(()=>{var S,I;(I=(S=document.activeElement)==null?void 0:S.blur)==null||I.call(S)},[]);if(!r||!l)return null;const v=s==="caret"&&c?jc(n,c.blockId):null,B=v?tl[v.type]:null,C=s==="caret"&&c?c.blockId:((R=i==null?void 0:i.selection)==null?void 0:R.blockId)??((j=i==null?void 0:i.crossSelection)==null?void 0:j.startBlockId)??null,y=C?Sc(n,C):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"be-mobile-action-bar",role:"toolbar","aria-label":"Editor actions",style:{bottom:o},onMouseDown:S=>S.preventDefault(),children:[s==="selection"&&i&&a.jsx(Cc,{store:n,selectionState:i}),s!=="selection"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Add block",onClick:h,children:a.jsx(Zn,{size:18})}),B&&v&&a.jsx(B,{store:n,blockId:v.id}),t&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Undo",disabled:!t.canUndo,onClick:t.undo,children:"↶"}),a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Redo",disabled:!t.canRedo,onClick:t.redo,children:"↷"})]})]}),a.jsx("span",{className:"be-mobile-bar-spacer"}),y&&a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Block options",onClick:g,children:a.jsx(El,{size:18})}),a.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Dismiss keyboard",onClick:w,children:a.jsx(Cn,{size:18})})]}),a.jsx(el,{isOpen:u,onClose:m,onSelectCommand:x}),a.jsx(nl,{isOpen:d,onClose:k,store:n,blockId:y==null?void 0:y.id})]})}function Lc({minHeight:e=180,className:n="be-trailing-space"}){const t=_(),[r]=Xn(),o=p.useCallback(()=>{var u;if(r)return;const l=t.getRootId(),s=t.getBlock(l),i=(u=s==null?void 0:s.contentIds)==null?void 0:u[s.contentIds.length-1];if(!i){const f=We(t);f&&Vt(t,f);return}const c=t.getBlock(i);(c==null?void 0:c.type)==="paragraph"?Vt(t,i):Te(t,i,z("paragraph"))},[t,r]);return a.jsx("div",{className:n,style:{minHeight:e},onClick:o})}function rl(e,{pretty:n=!0}={}){const t=e.getRootId(),{blocks:r,runs:o}=bt(e,t);return JSON.stringify({version:1,rootId:t,blocks:r,runs:o},null,n?2:0)}function ol(e,n,t){const r=e.getBlock(e.getRootId());return r?cn(e,n,r.contentIds,t).html:""}function ll(e,n,t){const r=e.getBlock(e.getRootId());return r?cn(e,n,r.contentIds,t).text:""}const sl={heading:["level"],listItem:["ordered","checked","collapsed"],toggleHeading:["level","collapsed"],code:["language"],button:["href","color","customAttrs"],embed:["kind","src","name","alt","mimeType","align","width"],callout:["icon"]},al=new Set(["listItem","toggleHeading"]),il=new Set(["divider","embed"]);function cl(e,n,t,r){var i,c,u;const o=t.type,l={};for(const f of sl[o]??[])((i=t.props)==null?void 0:i[f])!==void 0&&(l[f]=t.props[f]);if(o==="table"){const f=t.contentIds[0]&&e.getBlock(t.contentIds[0]);return l.columns=be(t,((c=f==null?void 0:f.contentIds)==null?void 0:c.length)??0),l.rows=t.contentIds.map(d=>e.getBlock(d).contentIds.map(h=>{const m=e.getBlock(h);return An(m.contentIds.map(g=>e.getRun(g)),r)})),{id:t.id,type:o,data:l}}if(al.has(o)){const f=((u=t.props)==null?void 0:u.titleRunIds)??[];l.text=An(f.map(d=>e.getRun(d)),r)}else n.isLeaf(o)&&!il.has(o)&&(l.text=An(t.contentIds.map(f=>e.getRun(f)),r));const s={id:t.id,type:o,data:l};return n.isLeaf(o)||(s.children=t.contentIds.map(f=>cl(e,n,e.getBlock(f),r))),s}function ul(e,n,t,{pretty:r=!0}={}){const o={store:e,registry:n,inlineRegistry:t},s=e.getBlock(e.getRootId()).contentIds.map(i=>cl(e,n,e.getBlock(i),o));return JSON.stringify({version:1,blocks:s},null,r?2:0)}function Kn(e,n){const t=new DOMParser().parseFromString(`<div>${e??""}</div>`,"text/html");return me(t.body.firstChild,n)}function Oc(e,n,t,r,o){const{id:l=E(),data:s={}}=e,i=(s.rows??[]).map(u=>{const f=E(),d=u.map(b=>{const h=E(),m=Kn(b,o);return r.push(...m),t.push({id:h,type:"tableCell",parentId:f,contentIds:m.map(g=>g.id),props:{}}),h});return t.push({id:f,type:"tableRow",parentId:n,contentIds:d,props:{}}),f}),c={id:l,type:"table",parentId:n,contentIds:i,props:{columns:s.columns??[]}};return t.push(c),c}function Vn(e,n,t,r,o,l){const{id:s=E(),type:i,data:c={},children:u=[]}=e;if(i==="table")return Oc(e,n,o,l,r);const f={};for(const b of sl[i]??[])c[b]!==void 0&&(f[b]=c[b]);const d={id:s,type:i,parentId:n,contentIds:[],props:f};if(o.push(d),al.has(i)){const b=Kn(c.text,r);l.push(...b),d.props.titleRunIds=b.map(h=>h.id),d.contentIds=u.map(h=>Vn(h,s,t,r,o,l).id)}else if(t.isLeaf(i)){if(!il.has(i)){const b=Kn(c.text,r);l.push(...b),d.contentIds=b.map(h=>h.id)}}else d.contentIds=u.map(b=>Vn(b,s,t,r,o,l).id);return d}function Nc(e,n,t){const r=typeof e=="string"?JSON.parse(e):e,o={registry:n,inlineRegistry:t},l=E(),s=[],i=[],c=(r.blocks??[]).map(u=>Vn(u,l,n,o,s,i).id);return s.push({id:l,type:"page",parentId:null,contentIds:c,props:{}}),{rootId:l,blocks:s,runs:i}}const Mc=[{value:"json",label:"JSON"},{value:"simpleJson",label:"Simple JSON"},{value:"html",label:"HTML"},{value:"text",label:"Text"}];function Ac({label:e="View source",className:n=""}){const t=_(),r=Ee(),o=ye(),[l,s]=p.useState(!1),[i,c]=p.useState("json"),[u,f]=p.useState(!1),d=p.useCallback(()=>{f(!1),s(!0)},[]),b=p.useCallback(()=>s(!1),[]),h=p.useMemo(()=>l?i==="json"?rl(t):i==="simpleJson"?ul(t,r,o):i==="html"?ol(t,r,o):ll(t,r,o):"",[l,i,t,r,o]),m=p.useCallback(async()=>{try{await navigator.clipboard.writeText(h),f(!0),setTimeout(()=>f(!1),1500)}catch{}},[h]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:`be-export-trigger ${n}`.trim(),onClick:d,children:[a.jsx(ot,{size:14})," ",e]}),a.jsxs(Be,{isOpen:l,onClose:b,title:"Document source",size:"large",children:[a.jsx("div",{className:"be-export-tabs",role:"tablist",children:Mc.map(g=>a.jsx("button",{type:"button",role:"tab","aria-selected":i===g.value,className:`be-export-tab${i===g.value?" be-export-tab-active":""}`,onClick:()=>c(g.value),children:g.label},g.value))}),a.jsx("pre",{className:"be-export-pre",children:a.jsx("code",{children:h})}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:b,children:"Close"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:u?"Copied!":"Copy"})]})]})]})}const Dc=340;function _c(e,n,t,r){p.useEffect(()=>{if(!e||!n)return;const o=document.querySelector(`[data-run-id="${n}"]`);if(o)return o.setAttribute("aria-expanded","true"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-controls",r),t&&o.setAttribute("aria-activedescendant",t),()=>{o.removeAttribute("aria-expanded"),o.removeAttribute("aria-haspopup"),o.removeAttribute("aria-controls"),o.removeAttribute("aria-activedescendant")}},[e,n,t,r])}function Pc({isOpen:e,rect:n,commands:t,runId:r,onSelect:o,onClose:l,menuId:s="be-slash-menu",ariaLabel:i="Slash commands"}){const[c,u]=p.useState(0),f=p.useRef(null),d=p.useRef(null),b=On(),h=eo(d,e&&t.length>0&&!!n,n==null?void 0:n.left);p.useEffect(()=>{u(0)},[t.length]),p.useEffect(()=>{var v,B;(B=(v=f.current)==null?void 0:v.scrollIntoView)==null||B.call(v,{block:"nearest"})},[c]),p.useEffect(()=>{if(!e)return;const v=B=>{B.key==="ArrowDown"?(B.preventDefault(),B.stopPropagation(),u(C=>Math.min(C+1,Math.max(t.length-1,0)))):B.key==="ArrowUp"?(B.preventDefault(),B.stopPropagation(),u(C=>Math.max(C-1,0))):B.key==="Enter"?(B.preventDefault(),B.stopPropagation(),t[c]&&o(t[c])):B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),l())};return document.addEventListener("keydown",v,!0),()=>document.removeEventListener("keydown",v,!0)},[e,t,c,o,l]);const g=t[c]?`${s}-option-${c}`:null;if(_c(e,r,g,s),!e||t.length===0||!n||h==null)return null;const k=window.innerHeight-b,w=n.bottom+Dc>k?{bottom:window.innerHeight-n.top+4}:{top:n.bottom+4};return a.jsx("div",{ref:d,id:s,role:"listbox","aria-label":i,className:"be-slash-menu",style:{position:"fixed",left:h,zIndex:1e3,...w},children:t.map((v,B)=>{const C=v.icon;return a.jsxs("div",{ref:B===c?f:void 0,id:`${s}-option-${B}`,role:"option","aria-selected":B===c,className:`be-slash-menu-item${B===c?" be-slash-menu-item-active":""}`,onMouseDown:y=>{y.preventDefault(),o(v)},onMouseEnter:()=>u(B),children:[C&&a.jsx("span",{className:"be-slash-menu-item-icon",children:a.jsx(C,{size:16})}),a.jsx("span",{className:"be-slash-menu-item-label",children:v.label})]},v.label)})})}function $c(e,n){var r;if(!n)return!0;const t=n.toLowerCase();return e.label.toLowerCase().includes(t)||((r=e.keywords)==null?void 0:r.some(o=>o.toLowerCase().includes(t)))}function Hc(e,n){const t=n.anchorNode,r=n.anchorOffset;let o;if(t===e){o="";for(let l=0;l<r&&l<e.childNodes.length;l+=1)o+=e.childNodes[l].textContent??""}else t&&t.parentElement===e?o=(t.textContent??"").slice(0,r):o=e.textContent??"";return ve(o).length}function Ot(e,n,t){const r=_(),[o,l]=p.useState(null);p.useEffect(()=>{const u=e.current;if(!u)return;const f=()=>{var C,y,R,j;const b=(C=window.getSelection)==null?void 0:C.call(window),h=b==null?void 0:b.anchorNode;let m=(h==null?void 0:h.nodeType)===1?h:h==null?void 0:h.parentElement;for(;m&&typeof m.hasAttribute=="function"&&!m.hasAttribute("data-run-id");)m=m.parentElement;const g=(y=m==null?void 0:m.getAttribute)==null?void 0:y.call(m,"data-run-id");if(!g||!b){l(null);return}const k=Hc(m,b),x=ve(m.textContent).slice(0,k),w=n.exec(x);if(!w){l(null);return}const v=(j=(R=m.closest)==null?void 0:R.call(m,"[data-block-id]"))==null?void 0:j.getAttribute("data-block-id");if(!v){l(null);return}const B=w.index+w[1].length;l({query:w[2],blockId:v,runId:g,sliceStart:B,sliceEnd:k,rect:m.getBoundingClientRect()})},d=b=>{b.key==="Escape"&&l(null)};return u.addEventListener("input",f),u.addEventListener("keydown",d),()=>{u.removeEventListener("input",f),u.removeEventListener("keydown",d)}},[e,n]);const s=o?t().filter(u=>$c(u,o.query)):[],i=p.useCallback(u=>{o&&(u.run(r,{blockId:o.blockId,runId:o.runId,sliceStart:o.sliceStart,sliceEnd:o.sliceEnd}),l(null))},[o,r]),c=p.useCallback(()=>l(null),[]);return{isOpen:!!o,query:(o==null?void 0:o.query)??"",rect:(o==null?void 0:o.rect)??null,runId:(o==null?void 0:o.runId)??null,commands:s,selectCommand:i,close:c}}const zc=/(^|\s)\/(\w*)$/;function Fc(e){const n=Ee(),t=ye(),r=p.useCallback(()=>[...n.listSlashCommands(),...(t==null?void 0:t.listSlashCommands())??[]],[n,t]);return Ot(e,zc,r)}const Uc=[{char:"😀",name:"grinning face",keywords:["smile","happy"]},{char:"😂",name:"face with tears of joy",keywords:["laugh","lol"]},{char:"😍",name:"heart eyes",keywords:["love","crush"]},{char:"😎",name:"cool",keywords:["sunglasses"]},{char:"🤔",name:"thinking face",keywords:["hmm"]},{char:"😉",name:"winking face",keywords:["wink"]},{char:"😢",name:"crying face",keywords:["sad","tear"]},{char:"😡",name:"angry face",keywords:["mad","rage"]},{char:"😱",name:"screaming face",keywords:["shock","scared"]},{char:"🥳",name:"party face",keywords:["celebrate","birthday"]},{char:"🙏",name:"folded hands",keywords:["please","pray","thanks"]},{char:"👍",name:"thumbs up",keywords:["approve","yes","like"]},{char:"👎",name:"thumbs down",keywords:["disapprove","no"]},{char:"👏",name:"clapping hands",keywords:["applause","congrats"]},{char:"🙌",name:"raised hands",keywords:["hooray","yay"]},{char:"👋",name:"waving hand",keywords:["hello","bye"]},{char:"✌️",name:"victory hand",keywords:["peace"]},{char:"💪",name:"flexed biceps",keywords:["strong","muscle"]},{char:"🤝",name:"handshake",keywords:["deal","agree"]},{char:"❤️",name:"red heart",keywords:["love"]},{char:"🔥",name:"fire",keywords:["hot","lit"]},{char:"⭐",name:"star",keywords:["favorite"]},{char:"✨",name:"sparkles",keywords:["shiny","magic"]},{char:"🎉",name:"party popper",keywords:["celebrate","congrats"]},{char:"🎊",name:"confetti ball",keywords:["celebrate"]},{char:"💡",name:"light bulb",keywords:["idea","tip"]},{char:"✅",name:"check mark",keywords:["done","yes","complete"]},{char:"❌",name:"cross mark",keywords:["no","wrong","delete"]},{char:"⚠️",name:"warning",keywords:["caution","alert"]},{char:"❓",name:"question mark",keywords:["question","help"]},{char:"❗",name:"exclamation mark",keywords:["important","alert"]},{char:"🚀",name:"rocket",keywords:["launch","fast","ship"]},{char:"🐛",name:"bug",keywords:["bug","issue"]},{char:"🔧",name:"wrench",keywords:["fix","tool","settings"]},{char:"📌",name:"pushpin",keywords:["pin","note"]},{char:"📎",name:"paperclip",keywords:["attachment","clip"]},{char:"📅",name:"calendar",keywords:["date","schedule"]},{char:"⏰",name:"alarm clock",keywords:["time","reminder"]},{char:"📈",name:"chart increasing",keywords:["growth","stats"]},{char:"📉",name:"chart decreasing",keywords:["decline","stats"]},{char:"💰",name:"money bag",keywords:["money","cash"]},{char:"💬",name:"speech balloon",keywords:["comment","chat"]},{char:"📝",name:"memo",keywords:["note","write"]},{char:"📚",name:"books",keywords:["reading","docs"]},{char:"🔗",name:"link",keywords:["url","chain"]},{char:"🔒",name:"locked",keywords:["private","secure"]},{char:"🔑",name:"key",keywords:["password","access"]},{char:"☕",name:"coffee",keywords:["coffee","break"]},{char:"🍕",name:"pizza",keywords:["food"]},{char:"🎂",name:"birthday cake",keywords:["birthday","cake"]},{char:"🎁",name:"gift",keywords:["present"]},{char:"🌟",name:"glowing star",keywords:["star","shiny"]},{char:"🌈",name:"rainbow",keywords:["colorful"]},{char:"☀️",name:"sun",keywords:["sunny","weather"]},{char:"🌧️",name:"rain cloud",keywords:["rainy","weather"]},{char:"🐶",name:"dog face",keywords:["dog","pet"]},{char:"🐱",name:"cat face",keywords:["cat","pet"]},{char:"🌍",name:"globe",keywords:["world","earth"]},{char:"🎯",name:"direct hit",keywords:["target","goal"]},{char:"🏆",name:"trophy",keywords:["win","award"]},{char:"🕐",name:"clock",keywords:["time"]},{char:"📣",name:"megaphone",keywords:["announce","shout"]},{char:"🧠",name:"brain",keywords:["smart","idea","mind"]},{char:"👀",name:"eyes",keywords:["look","watching"]}];function Kc(e,{runId:n,sliceStart:t,sliceEnd:r},o){const l=e.getRun(n),s=(l==null?void 0:l.value)??"",i=s.slice(0,t)+o+s.slice(r);e.applyOperation(G(n,{value:i})),he(n,t+o.length)}const Vc=Uc.map(({char:e,name:n,keywords:t})=>({label:`${e} ${n}`,keywords:t,run:(r,o)=>Kc(r,o,e)})),qc=/(^|\s):(\w*)$/,Wc=()=>Vc;function Yc(e){return Ot(e,qc,Wc)}const Gc=/(^|\s)@(\w*)$/;function Jc(e){const n=ye(),t=p.useCallback(()=>(n==null?void 0:n.listAtCommands())??[],[n]);return Ot(e,Gc,t)}const Xc=[{markName:"bold",Icon:br,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:mr,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:hr,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:Ol,title:"Strikethrough"}],Qc=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Zc=[{label:"None",value:null},{label:"Yellow",value:"#fff3bf"},{label:"Green",value:"#d3f9d8"},{label:"Blue",value:"#d0ebff"},{label:"Pink",value:"#ffdeeb"},{label:"Gray",value:"#e9ecef"}];function eu({isOpen:e,rect:n,kind:t,selection:r,crossSelection:o,marks:l,store:s}){var B,C;const i=Et(),[c,u]=p.useState(null),f=p.useRef(null),{applyPatch:d,toggleBoolean:b,setSubSuper:h,isLinkModalOpen:m,openLinkModal:g,closeLinkModal:k,handleSaveLink:x,handleRemoveLink:w}=Lt(s,t,r,o,l);p.useEffect(()=>{if(!c)return;const y=j=>{f.current&&!f.current.contains(j.target)&&u(null)},R=j=>{j.key==="Escape"&&u(null)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",R)}},[c]),p.useEffect(()=>{u(null)},[n,t]);const v=no(f,!!(e&&n),n?n.left+n.width/2:null);return i||(!e||!n)&&!m?null:a.jsxs(a.Fragment,{children:[e&&n&&v!=null&&a.jsxs("div",{ref:f,className:"be-floating-toolbar",role:"toolbar","aria-label":"Text formatting",style:{position:"fixed",top:n.top-44,left:v,transform:"translateX(-50%)"},onMouseDown:y=>y.preventDefault(),children:[Xc.map(({markName:y,Icon:R,title:j})=>a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l[y]?" be-floating-toolbar-btn-active":""}`,title:j,"aria-label":j,"aria-pressed":!!l[y],onClick:()=>b(y),children:a.jsx(R,{})},y)),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.subscript?" be-floating-toolbar-btn-active":""}`,title:"Subscript","aria-pressed":!!l.subscript,onClick:()=>h("subscript"),children:"X₂"}),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.superscript?" be-floating-toolbar-btn-active":""}`,title:"Superscript","aria-pressed":!!l.superscript,onClick:()=>h("superscript"),children:"X²"}),a.jsx("span",{className:"be-floating-toolbar-divider"}),a.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[a.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Text color","aria-haspopup":"true","aria-expanded":c==="color",onClick:()=>u(y=>y==="color"?null:"color"),children:a.jsx("span",{style:{color:l.color||"inherit",fontWeight:700},children:"A"})}),c==="color"&&a.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Text color",children:Qc.map(y=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:y.label,onClick:()=>{d({color:y.value}),u(null)},children:a.jsx("span",{style:{color:y.value||"#1a1a1a",fontWeight:700},children:"A"})},y.label))})]}),a.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[a.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Highlight","aria-haspopup":"true","aria-expanded":c==="highlight",onClick:()=>u(y=>y==="highlight"?null:"highlight"),children:a.jsx("span",{style:{backgroundColor:l.highlight||"transparent",padding:"0 2px",borderRadius:2},children:"H"})}),c==="highlight"&&a.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Highlight color",children:Zc.map(y=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:y.value||"transparent"},title:y.label,onClick:()=>{d({highlight:y.value}),u(null)}},y.label))})]}),a.jsx("span",{className:"be-floating-toolbar-divider"}),a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l.link?" be-floating-toolbar-btn-active":""}`,title:"Link","aria-label":"Link","aria-pressed":!!l.link,onClick:g,children:a.jsx(gr,{})})]}),a.jsx(pr,{isOpen:m,initialHref:((B=l.link)==null?void 0:B.href)??"",initialTarget:((C=l.link)==null?void 0:C.target)??"_self",hasExistingLink:!!l.link,onSave:x,onRemove:w,onClose:k})]})}function nu(e){const n=_(),[t,r]=p.useState(null);return p.useEffect(()=>{const o=e.current;if(!o)return;const l=()=>{var f,d,b;const s=(f=window.getSelection)==null?void 0:f.call(window);if(!s||s.rangeCount===0||s.isCollapsed){r(null);return}if(!o.contains(s.anchorNode)||!o.contains(s.focusNode)){r(null);return}const i=((b=(d=s.getRangeAt(0)).getBoundingClientRect)==null?void 0:b.call(d))??{top:0,left:0,right:0,bottom:0,width:0,height:0},c=Ve();if(c){r({kind:"same-block",rect:i,selection:c,marks:Rt(n,c.blockId,c)});return}const u=He(n);if(u){r({kind:"cross-block",rect:i,crossSelection:u,marks:Tt(n,u)});return}r(null)};return document.addEventListener("selectionchange",l),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{document.removeEventListener("selectionchange",l),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l)}},[e,n]),{isOpen:!!t,rect:(t==null?void 0:t.rect)??null,kind:(t==null?void 0:t.kind)??null,selection:(t==null?void 0:t.selection)??null,crossSelection:(t==null?void 0:t.crossSelection)??null,marks:(t==null?void 0:t.marks)??{},close:()=>r(null)}}function tu({id:e,label:n,placeholder:t,variant:r,options:o,onManage:l,mention:s=!1}){const i=_(),c=Le(e),u=p.useCallback((h,m)=>{i.applyOperation(G(e,{data:{selectedValue:h,selectedLabel:(m==null?void 0:m.label)??"",selectedColor:m==null?void 0:m.color}}))},[i,e]);if(!c)return null;const{selectedValue:f="",selectedLabel:d="",selectedColor:b}=c.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:h=>{h.preventDefault(),h.stopPropagation()},onKeyDown:h=>h.stopPropagation(),children:a.jsx(De,{value:f,selectedLabel:d,selectedColor:b,options:o,onChange:u,placeholder:t,variant:r,ariaLabel:n,onManageOptions:l,mention:s})})}function dl(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rr(e){return dl(e).replace(/"/g,"&quot;")}function pl({type:e,label:n,placeholder:t="Select…",variant:r="default",icon:o,options:l,onManage:s,triggers:i=["slash"],mention:c=i.includes("at")}){function u(m){var x,w;const g=((x=m.data)==null?void 0:x.selectedLabel)||"",k=c&&g?`@${g}`:g;return`<span data-inline-type="${rr(e)}" data-selected-value="${rr(((w=m.data)==null?void 0:w.selectedValue)??"")}">${dl(k)}</span>`}function f(m){var k;const g=((k=m.data)==null?void 0:k.selectedLabel)??"";return c&&g?`@${g}`:g}function d(m){var x;if(((x=m.getAttribute)==null?void 0:x.call(m,"data-inline-type"))!==e)return null;const g=m.textContent??"",k=c&&g.startsWith("@")?g.slice(1):g;return{id:E(),type:e,value:"",marks:{},data:{selectedValue:m.getAttribute("data-selected-value")??"",selectedLabel:k}}}function b({id:m}){return a.jsx(tu,{id:m,label:n,placeholder:t,variant:r,options:l,onManage:s,mention:c})}const h={label:n,icon:o??jr,keywords:[n.toLowerCase(),"select","field"],run:(m,{blockId:g,runId:k,sliceStart:x,sliceEnd:w})=>Nn(m,{blockId:g,runId:k,sliceStart:x,sliceEnd:w},()=>({id:E(),type:e,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}))};return{component:b,isAtomic:!0,toHTML:u,toPlainText:f,fromHTML:d,slashCommand:i.includes("slash")?h:void 0,atCommand:i.includes("at")?h:void 0}}function fl(e,n,{onManage:t}={}){for(const r of e.getFieldTypes())n.register(r.id,pl({type:r.id,label:r.label,placeholder:r.placeholder,variant:r.variant,options:r.options??[],onManage:t?()=>t(r.id):void 0}))}function bl(){const e=_(),n=ye(),t=Po(),{openEdit:r}=Qn(),o=p.useRef([]);p.useEffect(()=>{if(!n)return;const l=new Set(t.map(s=>s.id));for(const s of o.current)l.has(s)||n.unregister(s);fl(e,n,{onManage:r}),o.current=[...l]},[e,n,t,r])}function ru(){bl();const e=_(),{target:n,close:t}=Qn(),r=n!==null,o=r&&n!=="new",[l,s]=p.useState(""),[i,c]=p.useState([]),[u,f]=p.useState("");p.useEffect(()=>{if(r){if(o){const k=e.getFieldType(n);s((k==null?void 0:k.label)??""),c((k==null?void 0:k.options)??[])}else s(""),c([]);f("")}},[r,o,n,e]);const d=p.useCallback((k,x)=>{c(w=>w.map(v=>v.value===k?{...v,label:x}:v))},[]),b=p.useCallback(k=>{c(x=>x.filter(w=>w.value!==k))},[]),h=p.useCallback(()=>{const k=u.trim();f(""),k&&c(x=>[...x,{value:E(),label:k,color:nn(x.length)}])},[u]),m=p.useCallback(()=>{const k=l.trim();k&&(o?e.applyOperation(Wn(n,{label:k,options:i})):e.applyOperation(qn({id:E(),label:k,placeholder:"Select…",variant:"tag",options:i})),t())},[e,o,n,l,i,t]),g=p.useCallback(()=>{o&&e.applyOperation(Yn(n)),t()},[e,o,n,t]);return a.jsxs(Be,{isOpen:r,onClose:t,title:o?"Edit field type":"New field type",children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Name"}),a.jsx("input",{type:"text",value:l,onChange:k=>s(k.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Options"}),i.map((k,x)=>a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(k.color??nn(x)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:k.label,onChange:w=>d(k.value,w.target.value),"aria-label":`Rename option ${k.label}`}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>b(k.value),"aria-label":`Remove option ${k.label}`,children:a.jsx(ln,{size:14})})]},k.value)),a.jsxs("div",{className:"be-table-header-menu-option-row",children:[a.jsx("input",{className:"be-table-header-menu-option-input",value:u,onChange:k=>f(k.target.value),placeholder:"New option…",onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),h())}}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:h,"aria-label":"Add option",children:"+"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[o&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:g,children:"Delete field type"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:t,children:"Cancel"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:"Save"})]})]})}exports.APP_MIME=kn;exports.BlockChildren=Ne;exports.BlockErrorBoundary=Dr;exports.BlockGutterRow=zr;exports.BlockRangeActionMenu=mc;exports.BlockRegistry=or;exports.BlockRenderer=pt;exports.COLUMN_TYPES=Vr;exports.DEFAULT_COLUMN_TYPE=Sn;exports.DEFAULT_COLUMN_WIDTH=En;exports.DocumentExportButton=Ac;exports.EditableBlockContent=Re;exports.EditorProvider=Bl;exports.EditorStore=Gn;exports.EditorTrailingSpace=Lc;exports.FieldTypeEditorModal=ru;exports.FloatingToolbar=eu;exports.History=vl;exports.InlineRegistry=lr;exports.LAYOUT_BLOCKS=To;exports.MIN_COLUMN_WIDTH=hn;exports.MobileActionBar=Ec;exports.MobileBlockOptionsSheet=nl;exports.MobileBlockPickerSheet=el;exports.Modal=Be;exports.Select=De;exports.SlashMenu=Pc;exports.TABLE_BLOCKS=Ro;exports.TABLE_SELECT_INLINE_TYPES=_o;exports.TableHeaderRow=to;exports.VoiceListeningIndicator=Zi;exports.VoicePermissionModal=Qi;exports.blankRunForType=qr;exports.blockquoteBlockType=mo;exports.buttonBlockType=yo;exports.calloutBlockType=bo;exports.checkboxInlineType=Oo;exports.codeBlockType=go;exports.convertRunToType=Wr;exports.copyBlockRangeToClipboard=Un;exports.createBlockRegistry=wl;exports.createCellForColumn=Ln;exports.createDefaultColumns=xt;exports.createInlineRegistry=Il;exports.createSelectFieldType=pl;exports.dateInlineType=Lo;exports.deleteBlockAndFocusSibling=jn;exports.deleteBlockRange=Ze;exports.deleteColumn=Jr;exports.deleteEntireDocument=xn;exports.deleteOverBlockRange=Ct;exports.deleteRow=Gr;exports.deleteRunRangeInBlock=It;exports.deserializeClipboard=Ko;exports.dividerBlockType=po;exports.duplicateBlock=ht;exports.embedBlockType=Co;exports.emojiInlineType=Ao;exports.ensureRootNonEmpty=We;exports.exportDocumentHTML=ol;exports.exportDocumentJSON=rl;exports.exportDocumentSimpleJSON=ul;exports.exportDocumentText=ll;exports.focusRunAtOffset=he;exports.focusRunEnd=ee;exports.focusRunStart=vn;exports.getMarksSummaryOverBlockRange=Tt;exports.getMarksSummaryOverSelection=Rt;exports.headingBlockType=Ar;exports.importDocumentSimpleJSON=Nc;exports.injectDefaultStyles=sr;exports.insertColumnAfter=gn;exports.insertRowAfter=yt;exports.isEntireBlockRangeHidden=Wo;exports.isEntireBlockSelected=Zo;exports.layoutBlockType=uo;exports.layoutColumnBlockType=co;exports.listItemBlockType=Kr;exports.listVoiceCommands=qi;exports.moveBlockDown=kt;exports.moveBlockRangeDown=qo;exports.moveBlockRangeUp=Vo;exports.moveBlockUp=gt;exports.operations=kl;exports.paragraphBlockType=Mr;exports.registerBlocks=Bo;exports.registerBuiltInBlocks=xi;exports.registerBuiltInInlineTypes=zi;exports.registerInlineTypes=Do;exports.registerStoredFieldTypes=fl;exports.remapSubtreeIds=mt;exports.renameColumn=Qr;exports.reorderBlockRangeFromStore=tc;exports.resolveCollapsedCaret=we;exports.resolveColumns=be;exports.resolveCrossBlockSelection=He;exports.resolveMultiRunSelection=Ve;exports.resolveRunSelection=ns;exports.selectInlineType=So;exports.serializeBlockRange=cn;exports.setBlockRangeHidden=Yo;exports.setColumnOptions=bn;exports.setColumnType=Zr;exports.setColumnWidth=Xr;exports.setMarksOverBlockRange=yn;exports.setMarksOverSelection=Ke;exports.tableBlockType=so;exports.tableCellBlockType=oo;exports.tableRowBlockType=lo;exports.tableSelectInlineType=Mo;exports.textToParagraphs=wt;exports.toggleHeadingBlockType=ko;exports.toggleMarkOnRunRange=dc;exports.toggleMarkOverBlockRange=St;exports.toggleMarkOverSelection=jt;exports.useAtMenuTrigger=Jc;exports.useBlock=ne;exports.useBlockChildren=dt;exports.useBlockClassName=le;exports.useBlockRangeDrag=xc;exports.useBlockRangeSelection=rn;exports.useBlockRegistry=Ee;exports.useCaretRect=Fo;exports.useClipboardHandlers=lc;exports.useCoarsePointer=Et;exports.useEditorKeyboardShortcuts=bc;exports.useEditorStore=_;exports.useEmojiMenuTrigger=Yc;exports.useFieldTypeEditor=Qn;exports.useFieldTypes=Po;exports.useFloatingToolbarTrigger=nu;exports.useHistory=$o;exports.useInlineRegistry=ye;exports.usePreviewMode=Xn;exports.useRegisterFieldTypes=bl;exports.useRun=Le;exports.useSelectedBlock=Ce;exports.useSlashMenuTrigger=Fc;exports.useTextFormattingActions=Lt;exports.useVirtualKeyboardInset=On;exports.useVoiceTyping=Xi;exports.useWholeDocumentSelection=Jn;exports.walkDomToBlocks=Uo;
1906
2214
  //# sourceMappingURL=noteloom.cjs.map