noteloom 0.1.1 → 0.1.2
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/README.md +32 -0
- package/dist/noteloom.cjs +75 -8
- package/dist/noteloom.cjs.map +1 -1
- package/dist/noteloom.es.js +1882 -1733
- package/dist/noteloom.es.js.map +1 -1
- package/dist/style.css +67 -0
- package/package.json +1 -1
package/dist/noteloom.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var cr=Object.defineProperty;var ir=(e,n,t)=>n in e?cr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var nt=(e,n,t)=>ir(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),f=require("react"),Oe=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 Y(e,n,t,o){return{type:U.INSERT_BLOCK,block:e,parentId:n,index:t,subtree:o}}function _(e){return{type:U.REMOVE_BLOCK,id:e}}function ge(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 X(e,n){return{type:U.UPDATE_RUN,id:e,patch:n}}function Te(e,n){return{type:U.SET_BLOCK_CONTENT_IDS,blockId:e,contentIds:n}}function Fe(e,n,t){return{type:U.REPLACE_RUN_SPAN,blockId:e,oldRunIds:n,newRuns:t}}function le(e,n){return{type:U.SET_BLOCK_RUNS,blockId:e,runs:n}}function jn(e){return{type:U.ADD_FIELD_TYPE,fieldType:e}}function Sn(e,n){return{type:U.UPDATE_FIELD_TYPE,id:e,patch:n}}function En(e){return{type:U.REMOVE_FIELD_TYPE,id:e}}const ur=Object.freeze(Object.defineProperty({__proto__:null,OP:U,addFieldType:jn,insertBlock:Y,moveBlock:ge,removeBlock:_,removeFieldType:En,replaceRunSpan:Fe,setBlockContentIds:Te,setBlockRuns:le,updateBlockProps:z,updateFieldType:Sn,updateRun:X},Symbol.toStringTag,{value:"Module"})),gn="$fieldTypes";class On{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 o=this._listeners.get(n);return o||(o=new Set,this._listeners.set(n,o)),o.add(t),()=>{o.delete(t),o.size===0&&this._listeners.delete(n)}}_notify(n){for(const t of n){const o=this._listeners.get(t);if(o)for(const r of[...o])r()}}_captureSubtree(n){const t=[],o=[],r=l=>{var c;if(this.runs.has(l)){o.push(this.runs.get(l));return}const s=this.blocks.get(l);if(s){t.push(s);for(const i of s.contentIds)r(i);for(const i of((c=s.props)==null?void 0:c.titleRunIds)??[])r(i)}};return r(n),{blocks:t,runs:o}}_deleteSubtree(n){const t=o=>{var l;if(this.runs.has(o)){this.runs.delete(o);return}const r=this.blocks.get(o);if(r){for(const s of r.contentIds)t(s);for(const s of((l=r.props)==null?void 0:l.titleRunIds)??[])t(s);this.blocks.delete(o)}};t(n)}applyOperation(n){var t;switch(n.type){case U.UPDATE_RUN:{const o=this.runs.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o[l];return this.runs.set(n.id,{...o,...n.patch}),this._notify([n.id]),X(n.id,r)}case U.UPDATE_BLOCK_PROPS:{const o=this.blocks.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o.props[l];return this.blocks.set(n.id,{...o,props:{...o.props,...n.patch}}),this._notify([n.id]),z(n.id,r)}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 o=this.blocks.get(n.parentId),r=[...o.contentIds],l=n.index??r.length;return r.splice(l,0,n.block.id),this.blocks.set(n.parentId,{...o,contentIds:r}),this._notify([n.block.id,n.parentId]),_(n.block.id)}case U.REMOVE_BLOCK:{const o=this.blocks.get(n.id),r=o.parentId,l=this.blocks.get(r),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(r,{...l,contentIds:i}),this._notify([r]),{type:U.INSERT_BLOCK,block:o,parentId:r,index:s,subtree:c}}case U.MOVE_BLOCK:{const r=this.blocks.get(n.id).parentId,l=this.blocks.get(r),s=l.contentIds.indexOf(n.id),c=l.contentIds.filter(p=>p!==n.id);this.blocks.set(r,{...l,contentIds:c});const i=n.toParentId===r?this.blocks.get(r):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 d=new Set([n.id,r,n.toParentId]);return this._notify(d),ge(n.id,r,s)}case U.SET_BLOCK_CONTENT_IDS:{const o=this.blocks.get(n.blockId),r=o.contentIds;return this.blocks.set(n.blockId,{...o,contentIds:n.contentIds}),this._notify([n.blockId]),Te(n.blockId,r)}case U.REPLACE_RUN_SPAN:{const o=this.blocks.get(n.blockId),r=o.contentIds.indexOf(n.oldRunIds[0])!==-1,l=r?o.contentIds:((t=o.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)),r?this.blocks.set(n.blockId,{...o,contentIds:i}):this.blocks.set(n.blockId,{...o,props:{...o.props,titleRunIds:i}}),this._notify([n.blockId,...n.oldRunIds,...n.newRuns.map(u=>u.id)]),Fe(n.blockId,n.newRuns.map(u=>u.id),c)}case U.SET_BLOCK_RUNS:{const o=this.blocks.get(n.blockId),r=o.props&&"titleRunIds"in o.props,l=r?o.props.titleRunIds:o.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 r?this.blocks.set(n.blockId,{...o,props:{...o.props,titleRunIds:c}}):this.blocks.set(n.blockId,{...o,contentIds:c}),this._notify([n.blockId,...l,...c]),le(n.blockId,s)}case U.ADD_FIELD_TYPE:return this.fieldTypes.set(n.fieldType.id,n.fieldType),this._fieldTypesSnapshot=null,this._notify([gn]),En(n.fieldType.id);case U.UPDATE_FIELD_TYPE:{const o=this.fieldTypes.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o[l];return this.fieldTypes.set(n.id,{...o,...n.patch}),this._fieldTypesSnapshot=null,this._notify([gn]),Sn(n.id,r)}case U.REMOVE_FIELD_TYPE:{const o=this.fieldTypes.get(n.id);return this.fieldTypes.delete(n.id),this._fieldTypesSnapshot=null,this._notify([gn]),jn(o)}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 On(n)}}const dr=500;class pr{constructor(n,{idleMs:t=dr}={}){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(o=>this.perform(o,t))}performBatch(n,t={}){var s;const o=t.actorId??null,r=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:o,timestamp:r});this.redoStack=[],this.undoStack.push({ops:[...n],inverses:l,batchKey:null,actorId:o,timestamp:r,lastTimestamp:r,boundaryHit:!0}),this._notify()}perform(n,t={}){const o=t.actorId??null,r=t.timestamp??Date.now(),l=this.store.applyOperation(n);return this._record(n,l,{actorId:o,timestamp:r}),l}_batchKeyFor(n){return n.type==="updateRun"?`run:${n.id}`:null}_isWordBoundary(n){var o;if(n.type!=="updateRun")return!1;const t=(o=n.patch)==null?void 0:o.value;return typeof t!="string"||t.length===0?!1:/\s/.test(t[t.length-1])}_record(n,t,o){var c;this.redoStack=[];const r=this._batchKeyFor(n),l=this.currentBatch&&o.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&r!==null&&this.currentBatch.batchKey===r&&l&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(n),this.currentBatch.inverses.unshift(t),this.currentBatch.lastTimestamp=o.timestamp,this._isWordBoundary(n)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[n],inverses:[t],batchKey:r,actorId:o.actorId,timestamp:o.timestamp,lastTimestamp:o.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:o.actorId,timestamp:o.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 xt{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 fr(){return new xt}class yt{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 br(){return new yt}const hr=`/*
|
|
1
|
+
"use strict";var pr=Object.defineProperty;var fr=(e,n,t)=>n in e?pr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var tt=(e,n,t)=>fr(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"),F={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,o){return{type:F.INSERT_BLOCK,block:e,parentId:n,index:t,subtree:o}}function _(e){return{type:F.REMOVE_BLOCK,id:e}}function ke(e,n,t){return{type:F.MOVE_BLOCK,id:e,toParentId:n,toIndex:t}}function z(e,n){return{type:F.UPDATE_BLOCK_PROPS,id:e,patch:n}}function J(e,n){return{type:F.UPDATE_RUN,id:e,patch:n}}function je(e,n){return{type:F.SET_BLOCK_CONTENT_IDS,blockId:e,contentIds:n}}function qe(e,n,t){return{type:F.REPLACE_RUN_SPAN,blockId:e,oldRunIds:n,newRuns:t}}function se(e,n){return{type:F.SET_BLOCK_RUNS,blockId:e,runs:n}}function Sn(e){return{type:F.ADD_FIELD_TYPE,fieldType:e}}function En(e,n){return{type:F.UPDATE_FIELD_TYPE,id:e,patch:n}}function On(e){return{type:F.REMOVE_FIELD_TYPE,id:e}}const br=Object.freeze(Object.defineProperty({__proto__:null,OP:F,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 o=this._listeners.get(n);return o||(o=new Set,this._listeners.set(n,o)),o.add(t),()=>{o.delete(t),o.size===0&&this._listeners.delete(n)}}_notify(n){for(const t of n){const o=this._listeners.get(t);if(o)for(const r of[...o])r()}}_captureSubtree(n){const t=[],o=[],r=l=>{var c;if(this.runs.has(l)){o.push(this.runs.get(l));return}const s=this.blocks.get(l);if(s){t.push(s);for(const i of s.contentIds)r(i);for(const i of((c=s.props)==null?void 0:c.titleRunIds)??[])r(i)}};return r(n),{blocks:t,runs:o}}_deleteSubtree(n){const t=o=>{var l;if(this.runs.has(o)){this.runs.delete(o);return}const r=this.blocks.get(o);if(r){for(const s of r.contentIds)t(s);for(const s of((l=r.props)==null?void 0:l.titleRunIds)??[])t(s);this.blocks.delete(o)}};t(n)}applyOperation(n){var t;switch(n.type){case F.UPDATE_RUN:{const o=this.runs.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o[l];return this.runs.set(n.id,{...o,...n.patch}),this._notify([n.id]),J(n.id,r)}case F.UPDATE_BLOCK_PROPS:{const o=this.blocks.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o.props[l];return this.blocks.set(n.id,{...o,props:{...o.props,...n.patch}}),this._notify([n.id]),z(n.id,r)}case F.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 o=this.blocks.get(n.parentId),r=[...o.contentIds],l=n.index??r.length;return r.splice(l,0,n.block.id),this.blocks.set(n.parentId,{...o,contentIds:r}),this._notify([n.block.id,n.parentId]),_(n.block.id)}case F.REMOVE_BLOCK:{const o=this.blocks.get(n.id),r=o.parentId,l=this.blocks.get(r),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(r,{...l,contentIds:i}),this._notify([r]),{type:F.INSERT_BLOCK,block:o,parentId:r,index:s,subtree:c}}case F.MOVE_BLOCK:{const r=this.blocks.get(n.id).parentId,l=this.blocks.get(r),s=l.contentIds.indexOf(n.id),c=l.contentIds.filter(d=>d!==n.id);this.blocks.set(r,{...l,contentIds:c});const i=n.toParentId===r?this.blocks.get(r):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,r,n.toParentId]);return this._notify(p),ke(n.id,r,s)}case F.SET_BLOCK_CONTENT_IDS:{const o=this.blocks.get(n.blockId),r=o.contentIds;return this.blocks.set(n.blockId,{...o,contentIds:n.contentIds}),this._notify([n.blockId]),je(n.blockId,r)}case F.REPLACE_RUN_SPAN:{const o=this.blocks.get(n.blockId),r=o.contentIds.indexOf(n.oldRunIds[0])!==-1,l=r?o.contentIds:((t=o.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)),r?this.blocks.set(n.blockId,{...o,contentIds:i}):this.blocks.set(n.blockId,{...o,props:{...o.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 F.SET_BLOCK_RUNS:{const o=this.blocks.get(n.blockId),r=o.props&&"titleRunIds"in o.props,l=r?o.props.titleRunIds:o.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 r?this.blocks.set(n.blockId,{...o,props:{...o.props,titleRunIds:c}}):this.blocks.set(n.blockId,{...o,contentIds:c}),this._notify([n.blockId,...l,...c]),se(n.blockId,s)}case F.ADD_FIELD_TYPE:return this.fieldTypes.set(n.fieldType.id,n.fieldType),this._fieldTypesSnapshot=null,this._notify([kn]),On(n.fieldType.id);case F.UPDATE_FIELD_TYPE:{const o=this.fieldTypes.get(n.id),r={};for(const l of Object.keys(n.patch))r[l]=o[l];return this.fieldTypes.set(n.id,{...o,...n.patch}),this._fieldTypesSnapshot=null,this._notify([kn]),En(n.id,r)}case F.REMOVE_FIELD_TYPE:{const o=this.fieldTypes.get(n.id);return this.fieldTypes.delete(n.id),this._fieldTypesSnapshot=null,this._notify([kn]),Sn(o)}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 mr=500;class hr{constructor(n,{idleMs:t=mr}={}){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(o=>this.perform(o,t))}performBatch(n,t={}){var s;const o=t.actorId??null,r=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:o,timestamp:r});this.redoStack=[],this.undoStack.push({ops:[...n],inverses:l,batchKey:null,actorId:o,timestamp:r,lastTimestamp:r,boundaryHit:!0}),this._notify()}perform(n,t={}){const o=t.actorId??null,r=t.timestamp??Date.now(),l=this.store.applyOperation(n);return this._record(n,l,{actorId:o,timestamp:r}),l}_batchKeyFor(n){return n.type==="updateRun"?`run:${n.id}`:null}_isWordBoundary(n){var o;if(n.type!=="updateRun")return!1;const t=(o=n.patch)==null?void 0:o.value;return typeof t!="string"||t.length===0?!1:/\s/.test(t[t.length-1])}_record(n,t,o){var c;this.redoStack=[];const r=this._batchKeyFor(n),l=this.currentBatch&&o.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&r!==null&&this.currentBatch.batchKey===r&&l&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(n),this.currentBatch.inverses.unshift(t),this.currentBatch.lastTimestamp=o.timestamp,this._isWordBoundary(n)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[n],inverses:[t],batchKey:r,actorId:o.actorId,timestamp:o.timestamp,lastTimestamp:o.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:o.actorId,timestamp:o.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 gr(){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 xr(){return new vt}const kr=`/*
|
|
2
2
|
* noteloom's default theme — minimal, clean, Notion/Linear-adjacent.
|
|
3
3
|
*
|
|
4
4
|
* Ships as plain CSS custom properties on :root (not scoped to a wrapper
|
|
@@ -1175,6 +1175,69 @@ tr.be-table-row:hover .be-table-delete-row {
|
|
|
1175
1175
|
border-radius: var(--noteloom-radius-sm);
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
|
+
/* --- document export (view source) --- */
|
|
1179
|
+
|
|
1180
|
+
.be-export-trigger {
|
|
1181
|
+
display: inline-flex;
|
|
1182
|
+
align-items: center;
|
|
1183
|
+
gap: 6px;
|
|
1184
|
+
border: 1px solid var(--noteloom-border);
|
|
1185
|
+
background: var(--noteloom-bg);
|
|
1186
|
+
color: var(--noteloom-text-muted);
|
|
1187
|
+
border-radius: var(--noteloom-radius-sm);
|
|
1188
|
+
padding: 5px 10px;
|
|
1189
|
+
font-size: 0.85rem;
|
|
1190
|
+
cursor: pointer;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
.be-export-trigger:hover {
|
|
1194
|
+
background: var(--noteloom-bg-hover);
|
|
1195
|
+
color: var(--noteloom-text);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
.be-export-tabs {
|
|
1199
|
+
display: flex;
|
|
1200
|
+
gap: 4px;
|
|
1201
|
+
margin-bottom: 10px;
|
|
1202
|
+
border-bottom: 1px solid var(--noteloom-border);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
.be-export-tab {
|
|
1206
|
+
border: none;
|
|
1207
|
+
background: transparent;
|
|
1208
|
+
color: var(--noteloom-text-muted);
|
|
1209
|
+
padding: 6px 10px;
|
|
1210
|
+
margin-bottom: -1px;
|
|
1211
|
+
border-bottom: 2px solid transparent;
|
|
1212
|
+
font-size: 0.85rem;
|
|
1213
|
+
font-weight: 500;
|
|
1214
|
+
cursor: pointer;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
.be-export-tab:hover {
|
|
1218
|
+
color: var(--noteloom-text);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
.be-export-tab-active {
|
|
1222
|
+
color: var(--noteloom-accent);
|
|
1223
|
+
border-bottom-color: var(--noteloom-accent);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
.be-export-pre {
|
|
1227
|
+
max-height: 50vh;
|
|
1228
|
+
overflow: auto;
|
|
1229
|
+
margin: 0;
|
|
1230
|
+
padding: 0.9em 1em;
|
|
1231
|
+
border-radius: var(--noteloom-radius-md);
|
|
1232
|
+
background: var(--noteloom-code-bg);
|
|
1233
|
+
color: var(--noteloom-code-text);
|
|
1234
|
+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
|
1235
|
+
font-size: 0.8rem;
|
|
1236
|
+
line-height: 1.5;
|
|
1237
|
+
white-space: pre-wrap;
|
|
1238
|
+
overflow-wrap: anywhere;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1178
1241
|
/* --- trailing click-to-continue space --- */
|
|
1179
1242
|
|
|
1180
1243
|
.be-trailing-space {
|
|
@@ -1209,6 +1272,10 @@ tr.be-table-row:hover .be-table-delete-row {
|
|
|
1209
1272
|
box-shadow: var(--noteloom-shadow);
|
|
1210
1273
|
}
|
|
1211
1274
|
|
|
1275
|
+
.be-modal-large {
|
|
1276
|
+
max-width: 640px;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1212
1279
|
.be-modal-title {
|
|
1213
1280
|
font-weight: 600;
|
|
1214
1281
|
font-size: 1.05rem;
|
|
@@ -1810,12 +1877,12 @@ tr.be-table-row:hover .be-table-delete-row {
|
|
|
1810
1877
|
background: var(--noteloom-bg-hover);
|
|
1811
1878
|
color: var(--noteloom-text);
|
|
1812
1879
|
}
|
|
1813
|
-
`,tt="noteloom-default-styles";function vt(){if(typeof document>"u"||document.getElementById(tt))return;const e=document.createElement("style");e.id=tt,e.textContent=hr,document.head.appendChild(e)}const It=f.createContext(null);function mr({store:e,registry:n,inlineRegistry:t=null,history:o=null,className:r,style:l,theme:s="default",children:c}){f.useEffect(()=>{s!=="none"&&vt()},[s]);const[i,u]=f.useState(!1),[d,p]=f.useState([]),[b,m]=f.useState(!1),[h,g]=f.useState(null),k=f.useCallback(()=>g("new"),[]),x=f.useCallback(B=>g(B),[]),y=f.useCallback(()=>g(null),[]),I=f.useRef(null),E=f.useCallback(()=>I.current,[]),T=f.useCallback(B=>{var C,j;const v=I.current;v!==B&&(v&&((C=document.querySelector(`[data-block-id="${v}"]`))==null||C.classList.remove("be-block-selected")),I.current=B,B&&((j=document.querySelector(`[data-block-id="${B}"]`))==null||j.classList.add("be-block-selected")))},[]),S=f.useMemo(()=>({store:e,registry:n,inlineRegistry:t,history:o,isWholeDocumentSelected:i,setIsWholeDocumentSelected:u,selectedBlockRange:d,setSelectedBlockRange:p,getSelectedBlockId:E,setSelectedBlockId:T,isPreviewMode:b,setIsPreviewMode:m,fieldTypeEditorTarget:h,openCreateFieldType:k,openEditFieldType:x,closeFieldTypeEditor:y}),[e,n,t,o,i,d,E,T,b,h,k,x,y]),w=r||l?a.jsx("div",{className:r?`be-root ${r}`:"be-root",style:l,children:c}):c;return a.jsx(It.Provider,{value:S,children:w})}function be(){const e=f.useContext(It);if(!e)throw new Error("Editor hooks must be used within an <EditorProvider>");return e}function D(){return be().store}function Ke(){return be().registry}function ke(){return be().inlineRegistry}function Ln(){const{isWholeDocumentSelected:e,setIsWholeDocumentSelected:n}=be();return[e,n]}function qe(){const{selectedBlockRange:e,setSelectedBlockRange:n}=be();return[e,n]}function he(){const{getSelectedBlockId:e,setSelectedBlockId:n}=be();return{getSelectedBlockId:e,setSelectedBlockId:n}}function Nn(){const{isPreviewMode:e,setIsPreviewMode:n}=be();return[e,n]}function Mn(){const{fieldTypeEditorTarget:e,openCreateFieldType:n,openEditFieldType:t,closeFieldTypeEditor:o}=be();return{target:e,openCreate:n,openEdit:t,close:o}}function te(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>n.getBlock(e),[n,e]);return f.useSyncExternalStore(t,o)}function xe(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>n.getRun(e),[n,e]);return f.useSyncExternalStore(t,o)}function R(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const wt="",gr=//g;function fe(e){return(e??"").replace(gr,"")}function ot(e){return fe(e.textContent)}function kr(e,n){var c;const t=new Map(n.map(i=>[i.id,i])),o=new Set,r=[];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)){o.add(u);const p=t.get(u);if(p.type!=="text"){r.push(p);continue}const b=ot(i);r.push(b===p.value?p:{...p,value:b});continue}l=!1;const d=ot(i);d&&r.push({id:R(),type:"text",value:d,marks:{}})}if(n.some(i=>!o.has(i.id))&&(l=!1),r.length!==n.length&&(l=!1),l){for(let i=0;i<r.length;i+=1)if(r[i].id!==n[i].id){l=!1;break}}const s=!l||r.some((i,u)=>i!==n[u]);return{runs:r,changed:s,onlyValueChanges:l}}function Ct(e){return e?e.type!=="text"?!1:(e.value??"")==="":!0}function se(e,n){return!n||n.length===0?!0:n.every(t=>Ct(e.getRun(t)))}function We(e,n){var r,l;if(!n)return!1;const t=n.contentIds.length>0,o=(((l=(r=n.props)==null?void 0:r.titleRunIds)==null?void 0:l.length)??0)>0;return!t&&!o}function Bt(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const o=document.createRange();o.selectNodeContents(t),o.collapse(n);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(o)})}function G(e){Bt(e,!1)}function An(e){Bt(e,!0)}function pe(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const o=t.firstChild,r=document.createRange();if(o&&o.nodeType===3){const s=Math.max(0,Math.min(n,o.length));r.setStart(o,s),r.setEnd(o,s)}else r.selectNodeContents(t),r.collapse(n<=0);const l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(r)})}function cn({isOpen:e,onClose:n,title:t,children:o}){return f.useEffect(()=>{if(!e)return;const r=l=>{l.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,n]),e?a.jsx("div",{className:"be-modal-overlay",onMouseDown:r=>{r.target===r.currentTarget&&n()},children:a.jsxs("div",{className:"be-modal",role:"dialog","aria-modal":"true","aria-label":t,children:[t&&a.jsx("div",{className:"be-modal-title",children:t}),o]})}):null}function Rt({isOpen:e,initialHref:n,initialTarget:t,hasExistingLink:o,onSave:r,onRemove:l,onClose:s}){const[c,i]=f.useState(""),[u,d]=f.useState("_self");f.useEffect(()=>{e&&(i(n),d(t))},[e]);const p=c.trim(),b=f.useCallback(m=>{m.preventDefault(),p&&r(p,u)},[p,u,r]);return a.jsx(cn,{isOpen:e,onClose:s,title:o?"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:m=>i(m.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:m=>d(m.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:[o&&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:!p,children:"Save"})]})]})})}function M({children:e,size:n=16,strokeWidth:t=2,...o}){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",...o,children:e})}function un(e){return a.jsx(M,{...e,children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Dn(e){return a.jsx(M,{...e,children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Ve(e){return a.jsxs(M,{...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 Tt(e){return a.jsx(M,{...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 jt(e){return a.jsxs(M,{...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 xr(e){return a.jsxs(M,{...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 yr(e){return a.jsxs(M,{...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 vr(e){return a.jsxs(M,{...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 Ir(e){return a.jsxs(M,{...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 wr(e){return a.jsxs(M,{...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 Cr(e){return a.jsxs(M,{...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 Br(e){return a.jsxs(M,{...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 Rr(e){return a.jsxs(M,{...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 Tr(e){return a.jsxs(M,{...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 jr(e){return a.jsx(M,{...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(M,{...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 St(e){return a.jsxs(M,{...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 Et(e){return a.jsxs(M,{...e,children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ot(e){return a.jsxs(M,{...e,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Sr(e){return a.jsxs(M,{...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 Er(e){return a.jsxs(M,{...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 Or(e){return a.jsx(Pn,{level:1,...e})}function Lr(e){return a.jsx(Pn,{level:2,...e})}function Nr(e){return a.jsx(Pn,{level:3,...e})}function Mr(e){return a.jsxs(M,{...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 Ar(e){return a.jsxs(M,{...e,children:[a.jsx("polyline",{points:"9 8 4 12 9 16"}),a.jsx("polyline",{points:"15 8 20 12 15 16"})]})}function Dr(e){return a.jsx(M,{...e,children:a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function _r(e){return a.jsxs(M,{...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 Pr(e){return a.jsxs(M,{...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 $r(e){return a.jsxs(M,{...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 Hr(e){return a.jsxs(M,{...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 zr(e){return a.jsxs(M,{...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 Ur(e){return a.jsxs(M,{...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(M,{...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 Fr(e){return a.jsxs(M,{...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 Kr(e){return a.jsxs(M,{...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 qr(e){return a.jsxs(M,{...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 Wr(e){return a.jsxs(M,{...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 Nt(e){return a.jsxs(M,{...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 Mt(e){return a.jsxs(M,{...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 Vr(e){return a.jsxs(M,{...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 Yr({containerRef:e,store:n}){var k;const[t,o]=f.useState(null),[r,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(()=>{o(x=>r?x:null)},250)},[i,r]);f.useEffect(()=>{const x=e.current;if(!x)return;const y=E=>{var B,v,C;const T=(v=(B=E.target).closest)==null?void 0:v.call(B,"[data-run-id]");if(!T||!x.contains(T))return;const S=T.dataset.runId,w=n.getRun(S);(C=w==null?void 0:w.marks)!=null&&C.link&&(i(),o(j=>(j==null?void 0:j.runId)===S?j:{runId:S,rect:T.getBoundingClientRect()}))},I=()=>u();return x.addEventListener("mouseover",y),x.addEventListener("mouseout",I),()=>{x.removeEventListener("mouseover",y),x.removeEventListener("mouseout",I)}},[e,n,i,u]),f.useEffect(()=>()=>i(),[i]);const d=f.useCallback(()=>l(!0),[]),p=f.useCallback(()=>{l(!1),o(null)},[]),b=f.useCallback((x,y)=>{if(!t)return;const I=n.getRun(t.runId);I&&(n.applyOperation(X(t.runId,{marks:{...I.marks,link:{href:x,target:y}}})),p())},[t,n,p]),m=f.useCallback(()=>{if(!t)return;const x=n.getRun(t.runId);if(!x)return;const y={...x.marks};delete y.link,n.applyOperation(X(t.runId,{marks:y})),p()},[t,n,p]),h=t&&n.getRun(t.runId),g=(k=h==null?void 0:h.marks)==null?void 0:k.link;return a.jsxs(a.Fragment,{children:[t&&g&&!r?Oe.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:d,"aria-label":"Edit link",title:"Edit link",children:a.jsx(Ir,{size:13})}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:m,"aria-label":"Remove link",title:"Remove link",children:a.jsx(Ve,{size:13})})]}),document.body):null,a.jsx(Rt,{isOpen:r,initialHref:(g==null?void 0:g.href)??"",initialTarget:(g==null?void 0:g.target)??"_self",hasExistingLink:!!g,onSave:b,onRemove:m,onClose:p})]})}function rt(e,n){const t=e==null?void 0:e.parentElement;if(!t||!t.hasAttribute("data-placeholder"))return;n.length===0||n.every(Ct)?t.setAttribute("data-empty",""):t.removeAttribute("data-empty")}function Gr(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 Xr({id:e,host:n,onValueSynced:t}){const o=xe(e);return f.useLayoutEffect(()=>{var u;if(!n||!o)return;const r=o.value??"";(fe(n.textContent)!==r||r===""&&n.textContent==="")&&(n.textContent=r===""?wt:r);const c=Gr(o.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=o.marks)==null?void 0:u.link;n.title=i!=null&&i.href?`${i.href} — Ctrl+Click to open`:"",n.onclick=i!=null&&i.href?d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),window.open(i.href,i.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,t==null||t()},[n,o,t]),null}function lt(e,n,t,o){var p,b,m;const r=(p=window.getSelection)==null?void 0:p.call(window);if(!r||!r.isCollapsed||r.rangeCount===0)return null;const{anchorNode:l,anchorOffset:s}=r;if(!l||!e.contains(l))return null;const c=h=>{const g=n.indexOf(h);if(g===-1)return null;const k=o?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 h=o?s-1:s,g=e.childNodes[h],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 i=l.nodeType===1?l:l.parentElement,u=(m=i==null?void 0:i.closest)==null?void 0:m.call(i,"[data-run-id]");return!u||!e.contains(u)||!(o?s===0:s===(l.textContent??"").length)?null:c(u.getAttribute("data-run-id"))}function st(e,n,t){var i,u;const o=(i=window.getSelection)==null?void 0:i.call(window);if(!o||o.isCollapsed||o.rangeCount===0)return null;const r=o.getRangeAt(0);if(r.startContainer!==r.endContainer||!e.contains(r.startContainer)||r.endOffset!==r.startOffset+1)return null;const l=r.startContainer.childNodes[r.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 at(e,n,t){var c;if(n===e)return{childIndex:t,charOffset:null};const o=n.nodeType===1?n:n.parentElement,r=(c=o==null?void 0:o.closest)==null?void 0:c.call(o,"[data-run-id]");if(!r||!e.contains(r))return null;const l=Array.prototype.indexOf.call(e.childNodes,r),s=n===r?t===0?0:(r.textContent??"").length:t;return{childIndex:l,charOffset:s}}function Jr(e,n,t,o){const r=at(e,o.startContainer,o.startOffset),l=at(e,o.endContainer,o.endOffset);if(!r||!l)return null;const s=Array.from(e.childNodes).filter(d=>{var p;return d.nodeType===1&&((p=d.dataset)==null?void 0:p.runId)&&n.indexOf(d.dataset.runId)!==-1});let c=!1;const i=[];let u=null;return s.forEach((d,p)=>{const b=d.dataset.runId,m=t(b);if(!m)return;const h=p<r.childIndex,g=l.charOffset===null?p>=l.childIndex:p>l.childIndex;if(h||g){i.push(m);return}const k=r.charOffset!==null&&p===r.childIndex,x=l.charOffset!==null&&p===l.childIndex;if(m.type!=="text"){c=!0,u===null&&(u=i.length);return}const y=m.value??"";if(k&&x){const I=y.slice(0,r.charOffset)+y.slice(l.charOffset);I&&i.push({...m,value:I}),u=i.length}else if(k){const I=y.slice(0,r.charOffset);I&&i.push({...m,value:I}),u===null&&(u=i.length)}else if(x){const I=y.slice(l.charOffset);I&&i.push({id:R(),type:"text",value:I,marks:m.marks})}}),c?{nextRuns:i,insertionIndex:u??i.length}:null}function Qr(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 o=t;for(;o&&o.firstChild;)o=o.firstChild;if(n.anchorNode!==o&&n.anchorNode!==t)return!1;const r=o.nodeType===3&&o.textContent===wt?1:0;return n.anchorOffset<=r}function Zr(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 o=t;for(;o&&o.lastChild;)o=o.lastChild;if(n.anchorNode!==o&&n.anchorNode!==t)return!1;const r=o.nodeType===3?(o.textContent??"").length:0;return n.anchorOffset>=r}function ct(e,n,t){const o=e.getBlock(n),r=e.getBlock(o==null?void 0:o.parentId);if(!r)return null;const l=r.contentIds.indexOf(n),s=t==="backward"?l-1:l+1;if(s<0||s>=r.contentIds.length)return null;const c=r.contentIds[s];return We(e,e.getBlock(c))?c:null}function el({id:e,blockId:n,host:t,inlineRegistry:o,onValueSynced:r}){const l=xe(e);if(!l)return null;if(l.type==="text")return a.jsx(Xr,{id:e,host:t,onValueSynced:r});const s=o==null?void 0:o.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 nl(e,n,t){let o=e.get(t);if(!o){o=document.createElement("span"),o.dataset.runId=t;const r=n.getRun(t);r&&r.type!=="text"&&o.setAttribute("contenteditable","false"),e.set(t,o)}return o}function me({blockId:e,runIds:n,onEnter:t,onBackspaceAtStart:o,onDeleteAtEnd:r,onArrowUp:l,onArrowDown:s,onTab:c,onShiftTab:i,onAutoformat:u}){const d=D(),p=ke(),{getSelectedBlockId:b,setSelectedBlockId:m}=he(),h=f.useRef(null),g=f.useRef(!1),k=f.useRef(new Map);f.useLayoutEffect(()=>{const v=h.current;if(!v)return;const C=new Set(n);for(const[L,N]of k.current)C.has(L)||(N.remove(),k.current.delete(L));let j=null;for(const L of n){const N=k.current.get(L);if(!N)continue;const A=j?j.nextSibling:v.firstChild;A!==N&&v.insertBefore(N,A),j=N}},[n]);const x=f.useCallback(()=>{if(g.current)return;const v=h.current;if(!v)return;const C=n.map(A=>d.getRun(A)).filter(Boolean),{runs:j,changed:L,onlyValueChanges:N}=kr(v,C);if(L){if(N){if(j.forEach((A,K)=>{A!==C[K]&&d.applyOperation(X(A.id,{value:A.value}))}),u!=null&&u(j))return}else d.applyOperation(le(e,j.length?j:[{id:R(),type:"text",value:"",marks:{}}]));rt(v,j)}},[d,e,n,u]),y=f.useCallback(()=>{rt(h.current,n.map(v=>d.getRun(v)).filter(Boolean))},[d,n]),I=f.useCallback(()=>{g.current=!0},[]),E=f.useCallback(()=>{g.current=!1,x()},[x]),T=f.useCallback(v=>{const j=n.map(L=>d.getRun(L)).filter(Boolean).filter(L=>L.id!==v);d.applyOperation(le(e,j.length?j:[{id:R(),type:"text",value:"",marks:{}}]))},[d,e,n]),S=f.useCallback(v=>{b()===v?(d.applyOperation(_(v)),m(null)):m(v)},[d,b,m]),w=f.useCallback(v=>{var re,de,V;if(g.current)return;const C=v.inputType??"",j=C.startsWith("delete"),L=C==="insertText"||C==="insertReplacementText";if(!j&&!L)return;const N=h.current;if(!N)return;const A=(re=v.getTargetRanges)==null?void 0:re.call(v),K=(de=window.getSelection)==null?void 0:de.call(window),q=(A==null?void 0:A[0])??(K!=null&&K.rangeCount?K.getRangeAt(0):null);if(!q||!N.contains(q.startContainer)||!N.contains(q.endContainer))return;const H=Jr(N,n,O=>d.getRun(O),q);if(!H)return;v.preventDefault();let{nextRuns:$,insertionIndex:W}=H,J=null,oe=!1;if(L&&v.data){const O={id:R(),type:"text",value:v.data,marks:{}};$=[...$.slice(0,W),O,...$.slice(W)],J=O.id,oe=!1}else W>0?(J=(V=$[W-1])==null?void 0:V.id,oe=!1):$.length>0&&(J=$[0].id,oe=!0);const Be=$.length?$:[{id:R(),type:"text",value:"",marks:{}}];d.applyOperation(le(e,Be));const Q=J??Be[0].id;oe?An(Q):G(Q)},[d,e,n]);f.useEffect(()=>{const v=h.current;if(v)return v.addEventListener("beforeinput",w),()=>v.removeEventListener("beforeinput",w)},[w]);const B=f.useCallback(v=>{if(!g.current){if(v.key==="Enter"&&t){v.preventDefault(),t(v);return}if(v.key==="Backspace"){const C=h.current,j=C&&st(C,n,d.getRun.bind(d));if(j){v.preventDefault(),T(j);return}const L=C&<(C,n,d.getRun.bind(d),!0);if(L){v.preventDefault(),T(L);return}if(C&&Qr(C)){if(!se(d,n)){const A=ct(d,e,"backward");if(A){v.preventDefault(),S(A);return}}v.preventDefault(),o&&o(v)}return}if(v.key==="Delete"){const C=h.current,j=C&&st(C,n,d.getRun.bind(d));if(j){v.preventDefault(),T(j);return}const L=C&<(C,n,d.getRun.bind(d),!1);if(L){v.preventDefault(),T(L);return}if(C&&Zr(C)){const N=ct(d,e,"forward");if(N){v.preventDefault(),S(N);return}r&&r(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,o,r,l,s,c,i,T,S,n,e,d]);return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:h,className:"be-editable",contentEditable:!0,suppressContentEditableWarning:!0,onInput:x,onCompositionStart:I,onCompositionEnd:E,onKeyDown:B,children:n.map(v=>{const C=nl(k.current,d,v);return Oe.createPortal(a.jsx(el,{id:v,blockId:e,host:C,inlineRegistry:p,onValueSynced:y},v),C)})}),a.jsx(Yr,{containerRef:h,store:d})]})}function tl(e,n,t){const o=e.getBlock(n),r=o&&e.getBlock(o.parentId);if(!r)return null;const l=r.contentIds.indexOf(n),s=t==="up"?l-1:l+1;return s<0||s>=r.contentIds.length?null:r.contentIds[s]}function At(e,n,t){let o=n;for(;;){const r=tl(e,o,t);if(!r)return null;const l=t==="up"?dn(e,r):$n(e,r);if(l)return l;o=r}}function ee(e,n,t){const o=At(e,n,t);o&&G(o)}function $n(e,n){var l;const t=e.getBlock(n);if(!t)return null;const o=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!o||o.length===0)return null;const r=o[0];return e.getRun(r)?r:$n(e,r)}function ne(e,n){const t=$n(e,n);t&&G(t)}function dn(e,n){var l;const t=e.getBlock(n);if(!t)return null;const o=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!o||o.length===0)return null;const r=o[o.length-1];return e.getRun(r)?r:dn(e,r)}function it(e,n){const t=dn(e,n);t&&G(t)}function ol(){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,o=t.nodeType===1?t:t.parentElement,r=(i=o==null?void 0:o.closest)==null?void 0:i.call(o,"[data-run-id]");if(!r)return null;const l=r.closest("[data-block-id]");if(!l)return null;const s=t.textContent??"";return{runId:r.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),startOffset:fe(s.slice(0,n.startOffset)).length,endOffset:fe(s.slice(0,n.endOffset)).length}}function rl(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 o=n>=t.length,r=t[o?t.length-1:Math.max(0,n)],l=(r==null?void 0:r.nodeType)===1?(i=r.dataset)==null?void 0:i.runId:void 0;if(!l)return null;const s=r.closest("[data-block-id]");return s?{runId:l,blockId:s.getAttribute("data-block-id"),offset:o?fe(r.textContent??"").length:0}:null}function He(e,n){var c;const t=rl(e,n);if(t)return t;let o=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;const r=(c=o==null?void 0:o.closest)==null?void 0:c.call(o,"[data-run-id]");if(!r)return null;const l=r.closest("[data-block-id]");if(!l)return null;let s=fe((e.textContent??"").slice(0,n)).length;if(e===r){s=0;for(let i=0;i<n&&i<r.childNodes.length;i+=1)s+=fe(r.childNodes[i].textContent??"").length}return{runId:r.getAttribute("data-run-id"),blockId:l.getAttribute("data-block-id"),offset:s}}function Ye(){var n;const e=(n=window.getSelection)==null?void 0:n.call(window);return!e||e.rangeCount===0||!e.isCollapsed?null:He(e.anchorNode,e.anchorOffset)}function Ge(){var o;const e=(o=window.getSelection)==null?void 0:o.call(window);if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=He(e.anchorNode,e.anchorOffset),t=He(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 ze(e){var p;const n=(p=window.getSelection)==null?void 0:p.call(window);if(!n||n.rangeCount===0||n.isCollapsed)return null;const t=He(n.anchorNode,n.anchorOffset),o=He(n.focusNode,n.focusOffset);if(!t||!o||t.blockId===o.blockId)return null;const r=e.getBlock(t.blockId),l=r&&e.getBlock(r.parentId);if(!l)return null;const s=l.contentIds,c=s.indexOf(t.blockId),i=s.indexOf(o.blockId);if(c===-1||i===-1)return null;const[u,d]=c<=i?[c,i]:[i,c];return{blockIds:s.slice(u,d+1),startBlockId:t.blockId,startRunId:t.runId,startOffset:t.offset,endBlockId:o.blockId,endRunId:o.runId,endOffset:o.offset}}function Hn(e,n,t){const r=e.getBlock(n).parentId,s=e.getBlock(r).contentIds.indexOf(n)+1,{block:c,runs:i=[],subtreeBlocks:u=[]}=t(r);return e.applyOperation(Y(c,r,s,{blocks:[c,...u],runs:i})),c.id}function ye(e,n,t){const o=Hn(e,n,t);return ne(e,o),o}function ll(e,n,t){const{block:o,runs:r=[],subtreeBlocks:l=[]}=t(n);return e.applyOperation(Y(o,n,0,{blocks:[o,...l],runs:r})),ne(e,o.id),o.id}function Dt(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function sl(e,n,t){const o=e.findIndex(u=>u.id===n);if(o===-1)return null;const r=e[o],l=e.slice(0,o),s=e.slice(o+1);if(r.type==="text"){const u=r.value??"",d=u.slice(0,t),p=u.slice(t);d&&p?(l.push({...r,value:d}),s.unshift({...r,id:R(),value:p})):p?s.unshift(r):l.push(r)}else t>0?l.push(r):s.unshift(r);const c=l.length?l:[{id:R(),type:"text",value:"",marks:{}}],i=s.length?s:[{id:R(),type:"text",value:"",marks:{}}];return{leftRuns:c,rightRuns:i}}function Le(e,n,t,o){const r=e.getBlock(n),l=e.getBlock(r.parentId),s=l.contentIds.indexOf(n)+1;return Pt(e,n,t,o,{insertParentId:l.id,insertIndex:s,fallback:()=>ye(e,n,o)})}function _t(e,n,t,o){return Pt(e,n,t,o,{insertParentId:n,insertIndex:0,fallback:()=>ll(e,n,o)})}function Pt(e,n,t,o,{insertParentId:r,insertIndex:l,fallback:s}){const c=Ye();if(!c||c.blockId!==n)return s();const i=t.map(k=>e.getRun(k)).filter(Boolean),u=sl(i,c.runId,c.offset);if(!u)return s();const{leftRuns:d,rightRuns:p}=u,{block:b,runs:m=p,subtreeBlocks:h=[]}=o(r,p),g=d.length?d:[{id:R(),type:"text",value:"",marks:{}}];return Dt(e,[le(n,g),Y(b,r,l,{blocks:[b,...h],runs:m})]),ne(e,b.id),b.id}function al(e){var n;return((n=e==null?void 0:e.props)==null?void 0:n.titleRunIds)??(e==null?void 0:e.contentIds)??[]}function cl(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 il(e,n,t){const r=e.getBlock(n).parentId,s=e.getBlock(r).contentIds.indexOf(n),{block:c,runs:i=[],subtreeBlocks:u=[]}=t(r);return Dt(e,[_(n),Y(c,r,s,{blocks:[c,...u],runs:i})]),ne(e,c.id),c.id}function Z(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,o)+c.slice(r),u=e.getBlock(n),d=al(u);return d.length===1&&d[0]===t&&i===""&&!cl(u)?il(e,n,l):(e.applyOperation(X(t,{value:i})),ye(e,n,l))}function P(e,n={}){return function(o,r){const l=R(),s=r!=null&&r.length?r:[{id:R(),type:"text",value:"",marks:{}}];return{block:{id:l,type:e,parentId:o,contentIds:s.map(c=>c.id),props:n},runs:s}}}function Ne(e){const n=e.getRootId(),t=e.getBlock(n);if(!t||t.contentIds.length>0)return null;const{block:o,runs:r}=P("paragraph")(n);return e.applyOperation(Y(o,n,0,{blocks:[o],runs:r})),o.id}const ul=new Set(["callout"]),ut=new Set(["paragraph","heading","blockquote"]);function $t(e,n){return e===n||ut.has(e)&&ut.has(n)}function Xe(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=t.contentIds.length===0||t.contentIds.length===1&&dl(e,t.contentIds[0]);if(r<=0){if(!l)return null;if(o.contentIds.length>1)return Re(e,[_(n)]),e.getBlock(o.id).contentIds[0];if(ul.has(o.type))return pl(e,o);if(t.type==="paragraph")return null;const{block:u,runs:d}=P("paragraph")(o.id);return Re(e,[Y(u,o.id,r,{blocks:[u],runs:d}),_(n)]),u.id}const s=o.contentIds[r-1],c=e.getBlock(s);if(l)return Re(e,[_(n)]),s;if(We(e,c))return Re(e,[_(s)]),n;if(!c||!$t(c.type,t.type))return null;const i=[...c.contentIds,...t.contentIds];return Re(e,[Te(s,i),Te(n,[]),_(n)]),s}function dl(e,n){const t=e.getRun(n);return!t||(t.value??"")===""}function pl(e,n){const t=e.getBlock(n.parentId);if(!t)return null;const o=t.contentIds.indexOf(n.id),r=o>0?t.contentIds[o-1]:null,l=o!==-1&&o<t.contentIds.length-1?t.contentIds[o+1]:null;Re(e,[_(n.id)]);const s=Ne(e);return r??l??s}function Re(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Me(e,n,t,o){if(!n||n===t)return;const r=dn(e,n);if(r){G(r);return}o(n),requestAnimationFrame(()=>{var l;(l=document.querySelector(`[data-block-id="${n}"]`))==null||l.focus()})}function fl(e,n,t,o,r){const l=e.getBlock(n),c=e.getBlock(l.parentId).contentIds.indexOf(n),i="titleRunIds"in o,u="titleRunIds"in(l.props??{}),d={id:R(),type:t,parentId:l.parentId,contentIds:[],props:o},p=i?z(d.id,{titleRunIds:r}):Te(d.id,r),b=u?z(n,{titleRunIds:[]}):Te(n,[]);return{newBlockId:d.id,ops:[Y(d,l.parentId,c,{blocks:[d],runs:[]}),p,b,_(n)]}}function bl(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}const hl=[{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 ml(e,n,t){if(t.length!==1||t[0].type!=="text")return!1;const o=t[0].value??"";for(const r of hl){const l=r.re.exec(o);if(!l)continue;const s=o.slice(l[0].length),{ops:c}=fl(e,n,r.type,r.props(l),[t[0].id]);return bl(e,[X(t[0].id,{value:s}),...c]),An(t[0].id),!0}return!1}const gl=new Set(["callout","toggleHeading"]);function kl({id:e}){const n=D(),t=te(e),{setSelectedBlockId:o}=he(),r=f.useCallback(()=>{const d=n.getBlock(t==null?void 0:t.parentId),p=se(n,(t==null?void 0:t.contentIds)??[]),b=!!d&&d.contentIds[d.contentIds.length-1]===e;if(p&&b&&gl.has(d==null?void 0:d.type)){ye(n,d.id,P("paragraph"));return}Le(n,e,(t==null?void 0:t.contentIds)??[],P("paragraph"))},[n,e,t]),l=f.useCallback(()=>{var h,g;const d=n.getBlock(t==null?void 0:t.parentId),p=se(n,(t==null?void 0:t.contentIds)??[]),b=((h=d==null?void 0:d.contentIds)==null?void 0:h.length)===1&&d.contentIds[0]===e;if(p&&b&&(d==null?void 0:d.type)==="toggleHeading"){const k=((g=d.props)==null?void 0:g.titleRunIds)??[],x=k[k.length-1];x&&G(x);return}const m=Xe(n,e);Me(n,m,e,o)},[n,e,t,o]),s=f.useCallback(()=>ee(n,e,"up"),[n,e]),c=f.useCallback(()=>ee(n,e,"down"),[n,e]),i=f.useCallback(d=>ml(n,e,d),[n,e]);if(!t)return null;const u=se(n,t.contentIds);return a.jsx("div",{className:"be-paragraph","data-block-id":e,"data-empty":u?"":void 0,"data-placeholder":"Type '/' for commands",children:a.jsx(me,{blockId:e,runIds:t.contentIds,onEnter:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c,onAutoformat:i})})}function je(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ae(e){return je(e).replace(/"/g,""")}function ve(e,n){var r,l;if(!e)return"";if(e.type!=="text"){const s=(r=n==null?void 0:n.inlineRegistry)==null?void 0:r.get(e.type);return s?s.toHTML(e,n):je(e.value??"")}const t=e.marks??{};let o=je(e.value??"");if(t.code&&(o=`<code>${o}</code>`),t.bold&&(o=`<strong>${o}</strong>`),t.italic&&(o=`<em>${o}</em>`),t.underline&&(o=`<u>${o}</u>`),t.strike&&(o=`<s>${o}</s>`),t.subscript&&(o=`<sub>${o}</sub>`),t.superscript&&(o=`<sup>${o}</sup>`),t.color&&(o=`<span style="color:${ae(t.color)}">${o}</span>`),t.highlight&&(o=`<span style="background-color:${ae(t.highlight)}">${o}</span>`),(l=t.link)!=null&&l.href){const s=t.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";o=`<a href="${ae(t.link.href)}"${s}>${o}</a>`}return o}function Ie(e,n){var t;if(!e)return"";if(e.type!=="text"){const o=(t=n==null?void 0:n.inlineRegistry)==null?void 0:t.get(e.type);return o?o.toPlainText(e,n):e.value??""}return e.value??""}const xl={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function ue(e,n,t={}){const o=[],r=(l,s)=>{var u,d;if(l.nodeType===3){const p=l.textContent;p&&o.push({id:R(),type:"text",value:p,marks:{...s}});return}if(l.nodeType!==1)return;if(n!=null&&n.inlineRegistry)for(const p of n.inlineRegistry.listHtmlMatchers()){const b=p.fromHTML(l,n);if(b){o.push(b);return}}let c=s;const i=xl[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}),(d=l.style)!=null&&d.backgroundColor&&(c={...c,highlight:l.style.backgroundColor});for(const p of l.childNodes)r(p,c)};return r(e,t),o.length?o:[{id:R(),type:"text",value:"",marks:{}}]}function yl(e,n){return`<p>${e.contentIds.map(o=>n.store.getRun(o)).map(o=>ve(o,n)).join("")}</p>`}function vl(e,n){return e.contentIds.map(t=>Ie(n.store.getRun(t),n)).join("")}function Il(e,n){if(e.tagName!=="P")return null;const t=ue(e,n);return{block:{id:R(),type:"paragraph",parentId:null,contentIds:t.map(r=>r.id),props:{}},runs:t}}const Ht={component:kl,isLeaf:!0,defaultProps:{},toHTML:yl,toPlainText:vl,fromHTML:Il,slashCommand:{label:"Text",icon:Er,keywords:["paragraph","text","p"],run:(e,n)=>Z(e,n,P("paragraph"))}};function wl({id:e}){var p;const n=D(),t=te(e),{setSelectedBlockId:o}=he(),r=f.useCallback(()=>{Le(n,e,(t==null?void 0:t.contentIds)??[],P("paragraph"))},[n,e,t]),l=f.useCallback(()=>{const b=Xe(n,e);Me(n,b,e,o)},[n,e,o]),s=f.useCallback(()=>ee(n,e,"up"),[n,e]),c=f.useCallback(()=>ee(n,e,"down"),[n,e]);if(!t)return null;const i=((p=t.props)==null?void 0:p.level)??3,u=`h${i}`,d=se(n,t.contentIds);return a.jsx(u,{className:"be-heading","data-block-id":e,"data-empty":d?"":void 0,"data-placeholder":`Heading ${i}`,children:a.jsx(me,{blockId:e,runIds:t.contentIds,onEnter:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})}const kn={1:Or,2:Lr,3:Nr},Cl={H1:1,H2:2,H3:3};function Bl(e,n){var r;const t=((r=e.props)==null?void 0:r.level)??3,o=e.contentIds.map(l=>n.store.getRun(l));return`<h${t}>${o.map(l=>ve(l,n)).join("")}</h${t}>`}function Rl(e,n){return e.contentIds.map(t=>Ie(n.store.getRun(t),n)).join("")}function Tl(e,n){const t=Cl[e.tagName];if(!t)return null;const o=ue(e,n);return{block:{id:R(),type:"heading",parentId:null,contentIds:o.map(l=>l.id),props:{level:t}},runs:o}}const zt={component:wl,isLeaf:!0,defaultProps:{level:3},toHTML:Bl,toPlainText:Rl,fromHTML:Tl,slashCommands:[{label:"Heading 1",icon:kn[1],keywords:["heading","h1","title"],run:(e,n)=>Z(e,n,P("heading",{level:1}))},{label:"Heading 2",icon:kn[2],keywords:["heading","h2","subtitle"],run:(e,n)=>Z(e,n,P("heading",{level:2}))},{label:"Heading 3",icon:kn[3],keywords:["heading","h3","title"],run:(e,n)=>Z(e,n,P("heading",{level:3}))}]},jl=[];function zn(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>{const r=n.getBlock(e);return r?r.contentIds:jl},[n,e]);return f.useSyncExternalStore(t,o)}class Ut extends f.Component{constructor(){super(...arguments);nt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,o){var r,l;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",t,o),(l=(r=this.props).onError)==null||l.call(r,t,o),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 Un=f.memo(function({id:n}){const t=te(n),o=Ke();if(!t)return null;const r=o.get(t.type);if(!r)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${t.type}" (id: ${n})`),null;const l=r.component;return a.jsx(Ut,{children:a.jsx(l,{id:n})})});function pn(e,n,t){f.useEffect(()=>{if(!n)return;const o=Array.isArray(e)?e:[e],r=s=>{o.some(i=>i.current&&i.current.contains(s.target))||t()},l=s=>{s.key==="Escape"&&t()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",l)}},[n,t,e])}function Fn(e,n,t,o){const r={store:e,registry:n,inlineRegistry:o};return{html:Sl(e,n,t,r),text:t.map(l=>{const s=e.getBlock(l);return n.get(s.type).toPlainText(s,r)}).join(`
|
|
1814
|
-
`),json:JSON.stringify({version:1,blocks:t.map(l=>Ft(e,l))})}}function Sl(e,n,t,o){let r="",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 p=e.getBlock(t[u]);if(p.type!=="listItem"||!!p.props.ordered!==c)break;i+=n.get("listItem").toHTML(p,o),u+=1}const d=c?"ol":"ul";r+=`<${d}>${i}</${d}>`,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,o),i+=1}r+=`<blockquote>${c}</blockquote>`,l=i}else r+=n.get(s.type).toHTML(s,o),l+=1}return r}function Ft(e,n){const t=[],o=[],r=l=>{var i;const s=e.getRun(l);if(s){o.push(s);return}const c=e.getBlock(l);if(c){t.push(c);for(const u of c.contentIds)r(u);for(const u of((i=c.props)==null?void 0:i.titleRunIds)??[])r(u)}};return r(n),{rootId:n,blocks:t,runs:o}}function Kn({rootId:e,blocks:n,runs:t}){const o=new Map;for(const i of n)o.set(i.id,R());for(const i of t)o.set(i.id,R());const r=i=>o.get(i)??i,l=n.map(i=>{var u;return{...i,id:r(i.id),parentId:i.parentId?r(i.parentId):i.parentId,contentIds:i.contentIds.map(r),props:{...i.props,...(u=i.props)!=null&&u.titleRunIds?{titleRunIds:i.props.titleRunIds.map(r)}:{}}}}),s=t.map(i=>({...i,id:r(i.id)})),c=r(e);return{block:l.find(i=>i.id===c),runs:s,subtreeBlocks:l.filter(i=>i.id!==c)}}function Kt(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=Ft(e,n),{block:s,runs:c,subtreeBlocks:i}=Kn(l);return e.applyOperation(Y(s,o.id,r+1,{blocks:[s,...i],runs:c})),ne(e,s.id),s.id}function qt(e,n){const t=e.getBlock(n),o=t&&e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n);return r<=0?!1:(e.applyOperation(ge(n,o.id,r-1)),!0)}function Wt(e,n){const t=e.getBlock(n),o=t&&e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n);return r===-1||r>=o.contentIds.length-1?!1:(e.applyOperation(ge(n,o.id,r+1)),!0)}function qn(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=r>0?o.contentIds[r-1]:null,s=r!==-1&&r<o.contentIds.length-1?o.contentIds[r+1]:null;e.applyOperation(_(n));const c=Ne(e),i=l??s??c;return i&&ne(e,i),i??null}function Vt({id:e}){var T;const n=D(),t=te(e),[o,r]=f.useState(!1),[l,s]=f.useState(null),c=f.useRef(null),i=f.useRef(null),u=f.useMemo(()=>[c,i],[]),[d]=qe(),p=d.includes(e),b=f.useCallback(()=>r(!1),[]);pn(u,o,b);const m=f.useCallback(()=>{var S;s(((S=c.current)==null?void 0:S.getBoundingClientRect())??null),r(!0)},[]),h=f.useCallback(()=>{ye(n,e,P("paragraph"))},[n,e]),g=f.useCallback(()=>{Kt(n,e),b()},[n,e,b]),k=f.useCallback(()=>{qt(n,e),b()},[n,e,b]),x=f.useCallback(()=>{Wt(n,e),b()},[n,e,b]),y=f.useCallback(()=>{qn(n,e),b()},[n,e,b]),I=!!((T=t==null?void 0:t.props)!=null&&T.hidden),E=f.useCallback(()=>{n.applyOperation(z(e,{hidden:!I})),b()},[n,e,I,b]);return t?a.jsxs("div",{className:`be-block-row${I?" be-block-row-hidden":""}${p?" be-block-row-range-selected":""}`,"data-block-row-id":e,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:h,"aria-label":"Add block below",children:a.jsx(jt,{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?b():m(),children:a.jsx(jr,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(Un,{id:e})}),o&&l&&Oe.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(St,{size:15})," Duplicate"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:k,children:[a.jsx(Et,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:x,children:[a.jsx(Ot,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:E,children:[I?a.jsx(Nt,{size:15}):a.jsx(Mt,{size:15}),I?"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:y,children:[a.jsx(_n,{size:15})," Delete"]})]}),document.body)]}):null}function we({parentId:e,isTopLevel:n=!1}){const t=zn(e),o=D(),[r]=Nn(),l=r?t.filter(s=>{var c,i;return!((i=(c=o.getBlock(s))==null?void 0:c.props)!=null&&i.hidden)}):t;return n&&!r?l.map(s=>a.jsx(Vt,{id:s},s)):l.map(s=>a.jsx(Un,{id:s},s))}const El=97,Ol=[[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 Ll(e){let n="";for(;e>0;)e-=1,n=String.fromCharCode(El+e%26)+n,e=Math.floor(e/26);return n}function Nl(e){let n="",t=e;for(const[o,r]of Ol)for(;t>=o;)n+=r,t-=o;return n}function Ml(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 dt(e,n){let t=0,o=n;for(;o;){const r=e.getBlock(o.parentId);if(!r||r.type!=="listItem")break;t+=1,o=r}return t}function Al(e,n,t){const o=t.indexOf(n.id);let r=1;for(let l=o-1;l>=0;l-=1){const s=e.getBlock(t[l]);if(!Ml(s)||!s.props.ordered)break;r+=1}return r}function Dl(e,n){const t=(e%3+3)%3;return t===0?`${n}.`:t===1?`${Ll(n)}.`:`${Nl(n)}.`}const _l=["•","◦","▪"];function Pl(e){const n=(e%3+3)%3;return _l[n]}function Pe({ordered:e=!1,checked:n,collapsed:t}={}){return function(r,l){const s=R(),c=l!=null&&l.length?l:[{id:R(),type:"text",value:"",marks:{}}],i={ordered:e,titleRunIds:c.map(b=>b.id)};n!==void 0&&(i.checked=n);let u=[],d=[],p=c;if(t!==void 0){i.collapsed=t;const{block:b,runs:m}=P("paragraph")(s);u=[b.id],d=[b],p=[...c,...m]}return{block:{id:s,type:"listItem",parentId:r,contentIds:u,props:i},runs:p,subtreeBlocks:d}}}function $l(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=r>0?o.contentIds[r-1]:null,s=l?e.getBlock(l):null;if(!s||s.type!=="listItem"){ee(e,n,"down");return}e.applyOperation(ge(n,l,s.contentIds.length)),ne(e,n)}function vn(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId);if(!o||o.type!=="listItem")return;const r=o.parentId,s=e.getBlock(r).contentIds.indexOf(o.id);e.applyOperation(ge(n,r,s+1)),ne(e,n)}function De(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Yt(e,n){var t;return n.length===0||n.length===1&&(((t=e.getRun(n[0]))==null?void 0:t.value)??"")===""}function Hl(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const o=e.getBlock(t[0]);return!!o&&o.type==="paragraph"&&se(e,o.contentIds)}function zl(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=t.props.titleRunIds??[],c=Yt(e,l)&&Hl(e,t);if(r>0){const d=o.contentIds[r-1],p=e.getBlock(d);if(c)return De(e,[_(n)]),{focusBlockId:d,needsRefocus:!0};if(We(e,p))return De(e,[_(d)]),{focusBlockId:n,needsRefocus:!1};if((p==null?void 0:p.type)==="listItem"&&t.contentIds.length===0){const b=[...p.props.titleRunIds??[],...l];return De(e,[z(d,{titleRunIds:b}),z(n,{titleRunIds:[]}),_(n)]),{focusBlockId:d,needsRefocus:!0}}return null}if(o.type==="listItem")return vn(e,n),{focusBlockId:n,needsRefocus:!0};if(!c)return null;if(o.contentIds.length>1)return De(e,[_(n)]),{focusBlockId:e.getBlock(o.id).contentIds[0],needsRefocus:!0};const{block:i,runs:u}=P("paragraph")(o.id);return De(e,[Y(i,o.id,r,{blocks:[i],runs:u}),_(n)]),{focusBlockId:i.id,needsRefocus:!0}}function Ul(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Fl(e,n){const o=e.getBlock(n).parentId,l=e.getBlock(o).contentIds.indexOf(n),{block:s,runs:c}=P("paragraph")(o);return Ul(e,[Y(s,o,l,{blocks:[s],runs:c}),z(n,{titleRunIds:[]}),_(n)]),ne(e,s.id),s.id}function Kl(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function ql({id:e}){var T,S;const n=D(),t=te(e),{setSelectedBlockId:o}=he(),r=zn(t==null?void 0:t.parentId),l=f.useCallback(()=>{var A,K,q,H,$;const w=((A=t==null?void 0:t.props)==null?void 0:A.titleRunIds)??[],B=n.getBlock(t==null?void 0:t.parentId),v=Yt(n,w);if(v&&(B==null?void 0:B.type)==="listItem"){vn(n,e);return}const C=(((K=t==null?void 0:t.contentIds)==null?void 0:K.length)??0)>0;if(v&&(B==null?void 0:B.type)!=="listItem"&&!C){Fl(n,e);return}const j=((q=t==null?void 0:t.props)==null?void 0:q.checked)!==void 0,L=((H=t==null?void 0:t.props)==null?void 0:H.collapsed)!==void 0,N=Pe({ordered:($=t==null?void 0:t.props)==null?void 0:$.ordered,checked:j?!1:void 0,collapsed:L?!1:void 0});C&&!L?_t(n,e,w,N):Le(n,e,w,N)},[n,e,t]),s=f.useCallback(()=>$l(n,e),[n,e]),c=f.useCallback(()=>vn(n,e),[n,e]),i=f.useCallback(()=>{const w=zl(n,e);!w||!w.needsRefocus||Me(n,w.focusBlockId,e,o)},[n,e,o]),u=f.useCallback(()=>ee(n,e,"up"),[n,e]),d=f.useCallback(()=>ee(n,e,"down"),[n,e]),p=f.useCallback(()=>{var w;n.applyOperation(z(e,{checked:!((w=t==null?void 0:t.props)!=null&&w.checked)}))},[n,e,(T=t==null?void 0:t.props)==null?void 0:T.checked]),b=f.useCallback(()=>{var B,v;if(!((((B=t==null?void 0:t.contentIds)==null?void 0:B.length)??0)>0)){const{block:C,runs:j}=P("paragraph")(e);Kl(n,[Y(C,e,0,{blocks:[C],runs:j}),z(e,{collapsed:!1})]),G(C.contentIds[0]);return}n.applyOperation(z(e,{collapsed:!((v=t==null?void 0:t.props)!=null&&v.collapsed)}))},[n,e,t==null?void 0:t.contentIds,(S=t==null?void 0:t.props)==null?void 0:S.collapsed]);if(!t)return null;const{ordered:m,checked:h,collapsed:g,titleRunIds:k=[]}=t.props,x=h!==void 0,y=!x&&g!==void 0,I=t.contentIds.length>0,E=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:"be-list-item","data-block-id":e,children:[a.jsxs("div",{className:"be-list-item-row",children:[x?a.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!h,onChange:p,"aria-label":E||"To-do item"}):y?a.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:b,"aria-expanded":!g,"aria-label":I?g?"Expand toggle":"Collapse toggle":"Add content to toggle",children:g?a.jsx(un,{}):a.jsx(Dn,{})}):a.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:m?Dl(dt(n,t),Al(n,t,r)):Pl(dt(n,t))}),a.jsx("div",{className:"be-list-item-title","data-empty":se(n,k)?"":void 0,"data-placeholder":x?"To-do":y?"Toggle":"List item",style:h?{textDecoration:"line-through",opacity:.6}:void 0,children:a.jsx(me,{blockId:e,runIds:k,onEnter:l,onTab:s,onShiftTab:c,onBackspaceAtStart:i,onArrowUp:u,onArrowDown:d})})]}),(!y||!g)&&a.jsx("div",{className:"be-list-item-children",children:a.jsx(we,{parentId:e})})]})}function Wl(e,n){const{titleRunIds:t=[],ordered:o}=e.props,r=t.map(c=>ve(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?`<${o?"ol":"ul"}>${l}</${o?"ol":"ul"}>`:"";return`<li>${r}${s}</li>`}function Vl(e,n){const{titleRunIds:t=[]}=e.props;return t.map(o=>Ie(n.store.getRun(o),n)).join("")}function Gt(e,n){const t=[],o=[];for(const p of e.childNodes)p.nodeType===1&&(p.tagName==="UL"||p.tagName==="OL")?o.push(p):t.push(p);const r=e.ownerDocument.createElement("span");for(const p of t)r.appendChild(p.cloneNode(!0));const l=ue(r,n),s=R(),c=[...l],i=[],u=[];for(const p of o){const b=p.tagName==="OL";for(const m of p.children){if(m.tagName!=="LI")continue;const h=Gt(m,n);h.block.parentId=s,h.block.props.ordered=b,i.push(h.block,...h.childBlocks),c.push(...h.runs),u.push(h.block.id)}}return{block:{id:s,type:"listItem",parentId:null,contentIds:u,props:{ordered:!1,titleRunIds:l.map(p=>p.id)}},runs:c,childBlocks:i}}function Yl(e,n){if(e.tagName!=="LI")return null;const{block:t,runs:o,childBlocks:r}=Gt(e,n);return{block:t,runs:o,subtreeBlocks:r}}const Xt={component:ql,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:Wl,toPlainText:Vl,fromHTML:Yl,slashCommands:[{label:"Bulleted list",icon:zr,keywords:["list","bullet","ul"],run:(e,n)=>Z(e,n,Pe({ordered:!1}))},{label:"Numbered list",icon:Ur,keywords:["list","number","ordered","ol"],run:(e,n)=>Z(e,n,Pe({ordered:!0}))},{label:"To-do list",icon:Lt,keywords:["todo","checkbox","task","checklist"],run:(e,n)=>Z(e,n,Pe({ordered:!1,checked:!1}))},{label:"Toggle list",icon:un,keywords:["toggle","collapse","expand","dropdown","accordion"],run:(e,n)=>Z(e,n,Pe({ordered:!1,collapsed:!1}))}]},Jt=["text","date","checkbox","select"],fn="text",bn=160,rn=80;function Gl(e){return`Column ${e+1}`}function Wn(e){return Array.from({length:e},(n,t)=>({id:R(),label:Gl(t),type:fn,width:bn}))}function ce(e,n){var o;const t=(o=e.props)==null?void 0:o.columns;return!Array.isArray(t)||t.length!==n?Wn(n):t.map(r=>{const l=r.type??fn,s=r.width??bn;return l===r.type&&s===r.width?r:{...r,type:l,width:s}})}function Qt(e){switch(e){case"date":return{id:R(),type:"date",value:"",marks:{},data:{isoDate:""}};case"checkbox":return{id:R(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}};case"select":return{id:R(),type:"tableSelect",value:"",marks:{},data:{selectedValue:"",selectedLabel:""}};default:return{id:R(),type:"text",value:"",marks:{}}}}function hn(e,n){const t=Qt(n==null?void 0:n.type);return{block:{id:R(),type:"tableCell",parentId:e,contentIds:[t.id],props:{}},run:t}}function Zt(e,n,t){if(e.type===n)return e;let o;if(e.type==="text")o=e.value??"";else{const r=t==null?void 0:t.get(e.type);o=r!=null&&r.toPlainText?r.toPlainText(e):""}if(n==="date"){const r=o?new Date(o):null,l=r&&!Number.isNaN(r.getTime())?r.toISOString().slice(0,10):"";return{id:R(),type:"date",value:"",marks:{},data:{isoDate:l}}}return n==="checkbox"?{id:R(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:o}}:{id:R(),type:"text",value:o,marks:{}}}function Ce(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function eo(e,n){const o=e.getBlock(n.parentId).contentIds.indexOf(n.id);Ce(e,[_(n.id)]);const r=Ne(e);if(r)return ne(e,r),null;const l=e.getBlock(n.parentId),s=l.contentIds[o]??l.contentIds[o-1];return s&&ne(e,s),null}function no(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=ce(o,t.contentIds.length),s=R(),c=[],i=[],u=[];for(const p of l){const b=hn(s,p);c.push(b.block),i.push(b.run),u.push(b.block.id)}const d={id:s,type:"tableRow",parentId:o.id,contentIds:u,props:{}};return e.applyOperation(Y(d,o.id,r+1,{blocks:[d,...c],runs:i})),ne(e,s),s}function to(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId);if(o.contentIds.length<=1)return eo(e,o);const r=o.contentIds.indexOf(n);Ce(e,[_(n)]);const l=e.getBlock(o.id),s=Math.min(r,l.contentIds.length-1),c=l.contentIds[s];return c&&ne(e,c),c??null}function In(e,n,t){const o=e.getBlock(n),r=ce(o,o.contentIds[0]?e.getBlock(o.contentIds[0]).contentIds.length:0),l={id:R(),label:"New Column",type:fn,width:bn},s=[];let c=null;for(const u of o.contentIds){const d=hn(u,l);c===null&&(c=d.block.id),s.push(Y(d.block,u,t+1,{blocks:[d.block],runs:[d.run]}))}const i=[...r];return i.splice(t+1,0,l),s.push(z(n,{columns:i})),Ce(e,s),c&&ne(e,c),c}function oo(e,n,t){const o=e.getBlock(n),r=e.getBlock(o.contentIds[0]);if(!r||r.contentIds.length<=1)return eo(e,o);const l=ce(o,r.contentIds.length),s=o.contentIds.map(p=>{const b=e.getBlock(p);return _(b.contentIds[t])}),c=l.filter((p,b)=>b!==t);s.push(z(n,{columns:c})),Ce(e,s);const i=e.getBlock(o.contentIds[0]),u=Math.min(t,i.contentIds.length-1),d=i.contentIds[u];return d&&ne(e,d),d??null}function ro(e,n,t,o){const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),s=ce(r,l?l.contentIds.length:0);if(!s[t])return;const c=[...s];c[t]={...s[t],width:Math.max(rn,Math.round(o))},e.applyOperation(z(n,{columns:c}))}function lo(e,n,t,o){const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),c=[...ce(r,l?l.contentIds.length:0)];c[t]&&(c[t]={...c[t],label:o},e.applyOperation(z(n,{columns:c})))}function Vn(e,n,t){return n.contentIds.map(o=>{const l=e.getBlock(o).contentIds[t],s=e.getBlock(l);return{cellId:l,run:e.getRun(s.contentIds[0])}})}function pt(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 Xl(e,n,t,o){const r=Vn(e,n,t),l=[],s=new Map;for(const{run:i}of r){const u=pt(i,o).trim();if(!u||s.has(u))continue;const d={value:R(),label:u};s.set(u,d),l.push(d)}const c=r.map(({cellId:i,run:u})=>{const d=pt(u,o).trim(),p=s.get(d);return{cellId:i,run:{id:R(),type:"tableSelect",value:"",marks:{},data:{selectedValue:(p==null?void 0:p.value)??"",selectedLabel:(p==null?void 0:p.label)??""}}}});return{options:l,newRuns:c}}function so(e,n,t,o,r){const l=e.getBlock(n),s=e.getBlock(l.contentIds[0]),c=ce(l,s?s.contentIds.length:0),i=c[t];if(!i||i.type===o)return;const u=[...c];if(o==="select"){const{options:p,newRuns:b}=Xl(e,l,t,r);u[t]={...i,type:o,options:p};const m=[z(n,{columns:u})];for(const{cellId:h,run:g}of b)m.push(le(h,[g]));Ce(e,m);return}u[t]={...i,type:o};const d=[z(n,{columns:u})];for(const{cellId:p,run:b}of Vn(e,l,t)){if(!b)continue;const m=Zt(b,o,r);d.push(le(p,[m]))}Ce(e,d)}function tn(e,n,t,o){var p,b;const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),s=ce(r,l?l.contentIds.length:0),c=s[t];if(!c)return;const i=[...s];i[t]={...c,options:o};const u=[z(n,{columns:i})],d=new Map(o.map(m=>[m.value,m]));for(const{run:m}of Vn(e,r,t)){if(!m||m.type!=="tableSelect")continue;const h=((p=m.data)==null?void 0:p.selectedValue)??"",g=d.get(h),k=g?h:"",x=g?g.label:"";(k!==h||x!==(((b=m.data)==null?void 0:b.selectedLabel)??""))&&u.push(X(m.id,{data:{selectedValue:k,selectedLabel:x}}))}Ce(e,u)}function Jl(e,n){return n?e.label.toLowerCase().includes(n.toLowerCase()):!0}function Ae({value:e,options:n,onChange:t,placeholder:o="Select…",ariaLabel:r,className:l="",variant:s="default",selectedLabel:c,selectedColor:i,onManageOptions:u,manageOptionsLabel:d="Manage options…",mention:p=!1}){var de,V;const[b,m]=f.useState(!1),[h,g]=f.useState(""),[k,x]=f.useState(0),[y,I]=f.useState(null),[E,T]=f.useState([]),[S,w]=f.useState(!1),[B,v]=f.useState(!1),C=f.useRef(null),j=f.useRef(null),L=f.useRef(null),N=f.useRef(null),A=f.useRef(null),K=f.useMemo(()=>[C,L],[]),q=s==="tag",H=typeof n=="function",$=H?void 0:n.find(O=>O.value===e),W=e?$??(c?{label:c,color:i}:void 0):void 0,J=f.useMemo(()=>H?E:n.filter(O=>Jl(O,h)),[H,E,n,h]);f.useEffect(()=>{if(!H||!b)return;let O=!1;w(!0),v(!1);const F=setTimeout(()=>{Promise.resolve(n(h)).then(ie=>{O||(T(ie??[]),w(!1))}).catch(()=>{O||(T([]),w(!1),v(!0))})},250);return()=>{O=!0,clearTimeout(F)}},[H,b,n,h]);const oe=f.useCallback(()=>m(!1),[]);pn(K,b,oe);const Be=f.useCallback(()=>{var O;I(((O=j.current)==null?void 0:O.getBoundingClientRect())??null),g(""),x(0),m(!0)},[]);f.useEffect(()=>{var O;b&&((O=N.current)==null||O.focus())},[b]),f.useEffect(()=>{var O,F;(F=(O=A.current)==null?void 0:O.scrollIntoView)==null||F.call(O,{block:"nearest"})},[k]);const Q=f.useCallback(O=>{var F;t(O.value,O),oe(),(F=j.current)==null||F.focus()},[t,oe]),re=f.useCallback(O=>{var F;O.key==="ArrowDown"?(O.preventDefault(),x(ie=>Math.min(ie+1,Math.max(J.length-1,0)))):O.key==="ArrowUp"?(O.preventDefault(),x(ie=>Math.max(ie-1,0))):O.key==="Enter"?(O.preventDefault(),J[k]&&Q(J[k])):O.key==="Escape"&&(O.preventDefault(),oe(),(F=j.current)==null||F.focus())},[J,k,Q,oe]);return a.jsxs("span",{className:`be-select ${l}`.trim(),ref:C,children:[a.jsx("button",{type:"button",ref:j,className:`be-select-trigger${q?" be-select-trigger-tag":""}${p?" be-select-trigger-mention":""}`,"aria-haspopup":"listbox","aria-expanded":b,"aria-label":r,onClick:()=>b?oe():Be(),children:q?W?a.jsx("span",{className:`be-select-tag${p?" be-select-tag-mention":""}`,style:p?void 0:{background:(de=W.color)==null?void 0:de.bg,color:(V=W.color)==null?void 0:V.text},children:p?`@${W.label}`:W.label}):a.jsx("span",{className:"be-select-value be-select-value-placeholder",children:o}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"be-select-value",children:W?W.label:o}),a.jsx(Dn,{size:14,className:"be-select-chevron"})]})}),b&&y&&Oe.createPortal(a.jsxs("div",{ref:L,className:"be-select-popover",style:{position:"fixed",top:y.bottom+4,left:y.left,minWidth:y.width},children:[a.jsx("input",{ref:N,type:"text",className:"be-select-search",value:h,onChange:O=>{g(O.target.value),x(0)},onKeyDown:re,placeholder:"Search…","aria-label":r?`Search ${r}`:"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&&B&&a.jsx("div",{className:"be-select-empty be-select-error",children:"Couldn't load options"}),!S&&!B&&J.length===0&&a.jsx("div",{className:"be-select-empty",children:"No results"}),!S&&!B&&J.map((O,F)=>{var ie,et;return a.jsx("div",{ref:F===k?A:void 0,role:"option","aria-selected":O.value===e,className:`be-select-option${F===k?" be-select-option-active":""}${O.value===e?" be-select-option-selected":""}`,onMouseDown:ar=>{ar.preventDefault(),Q(O)},onMouseEnter:()=>x(F),children:q?a.jsx("span",{className:"be-select-tag",style:{background:(ie=O.color)==null?void 0:ie.bg,color:(et=O.color)==null?void 0:et.text},children:O.label}):O.label},O.value)})]}),u&&a.jsx("button",{type:"button",className:"be-select-manage-options",onMouseDown:O=>{O.preventDefault(),oe(),u()},children:d})]}),document.body)]})}const Qe=[{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 Ue(e){return Qe[(e%Qe.length+Qe.length)%Qe.length]}const Ql={text:"Text",date:"Date",checkbox:"Checkbox",select:"Select"},Zl=Jt.map(e=>({value:e,label:Ql[e]}));function es({tableId:e,colIndex:n,options:t}){const o=D(),[r,l]=f.useState(""),s=f.useCallback((u,d)=>{tn(o,e,n,t.map(p=>p.value===u?{...p,label:d}:p))},[o,e,n,t]),c=f.useCallback(u=>tn(o,e,n,t.filter(d=>d.value!==u)),[o,e,n,t]),i=f.useCallback(()=>{const u=r.trim();l(""),u&&tn(o,e,n,[...t,{value:R(),label:u,color:Ue(t.length)}])},[o,e,n,t,r]);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,d)=>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??Ue(d)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:u.label,onChange:p=>s(u.value,p.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(Ve,{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:r,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 ns({tableId:e,column:n,colIndex:t,colCount:o}){const r=D(),l=ke(),[s,c]=f.useState(!1),[i,u]=f.useState(null),[d,p]=f.useState(null),b=f.useRef(null),m=f.useRef(null),h=f.useRef(null),g=f.useMemo(()=>[b,m],[]),k=f.useCallback(()=>c(!1),[]);pn(g,s,k);const x=f.useCallback(()=>{var B;u(((B=h.current)==null?void 0:B.getBoundingClientRect())??null),c(!0)},[]),y=f.useCallback(B=>lo(r,e,t,B.target.value),[r,e,t]),I=f.useCallback(()=>{In(r,e,t-1),k()},[r,e,t,k]),E=f.useCallback(()=>{In(r,e,t),k()},[r,e,t,k]),T=f.useCallback(()=>{oo(r,e,t),k()},[r,e,t,k]),S=f.useCallback(B=>so(r,e,t,B,l),[r,e,t,l]),w=f.useCallback(B=>{var q;B.preventDefault();const v=(q=h.current)==null?void 0:q.closest("table"),C=v==null?void 0:v.querySelector(`col[data-col-index="${t}"]`);if(!C)return;const j=h.current.getBoundingClientRect().width,L=B.clientX,N=H=>Math.max(rn,Math.round(j+(H.clientX-L))),A=H=>{const $=N(H);C.style.width=`${$}px`,p($)},K=H=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",K),ro(r,e,t,N(H)),p(null)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",K)},[r,e,t]);return a.jsxs("th",{ref:h,className:"be-table-header-cell",contentEditable:!1,children:[a.jsx("input",{className:"be-table-header-label",value:n.label,onChange:y,"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():x(),children:"⋮"}),a.jsx("div",{className:"be-table-col-resize-handle",onMouseDown:w,role:"slider","aria-label":`Resize column ${t+1}`,"aria-valuemin":rn,"aria-valuenow":d??n.width}),s&&i&&Oe.createPortal(a.jsxs("div",{ref:m,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(Ae,{value:n.type,options:Zl,onChange:S,ariaLabel:"Column type",className:""})]}),n.type==="select"&&a.jsx(es,{tableId:e,colIndex:t,options:n.options??[]}),a.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:I,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:T,disabled:o<=1,children:"Delete column"})]}),document.body)]})}function ao({tableId:e,columns:n}){return a.jsx("thead",{children:a.jsxs("tr",{className:"be-table-header-row",children:[n.map((t,o)=>a.jsx(ns,{tableId:e,column:t,colIndex:o,colCount:n.length},t.id)),a.jsx("th",{className:"be-table-header-spacer","aria-hidden":"true"})]})})}function ts({id:e}){var s;const n=D(),t=te(e),o=f.useCallback(()=>{var i;const c=(i=t==null?void 0:t.contentIds)==null?void 0:i[t.contentIds.length-1];c&&no(n,c)},[n,t]);if(!t)return null;const r=n.getBlock(t.contentIds[0]),l=ce(t,((s=r==null?void 0:r.contentIds)==null?void 0:s.length)??0);return a.jsx("div",{className:"be-table-scroll",children:a.jsxs("div",{className:"be-table-wrapper","data-block-id":e,children:[a.jsxs("table",{className:"be-table",children:[a.jsxs("colgroup",{children:[l.map((c,i)=>a.jsx("col",{"data-col-index":i,style:{width:c.width}},c.id)),a.jsx("col",{className:"be-table-header-spacer-col"})]}),a.jsx(ao,{tableId:e,columns:l}),a.jsx("tbody",{children:a.jsx(we,{parentId:e})})]}),a.jsxs("button",{type:"button",className:"be-table-add-row",contentEditable:!1,onClick:o,children:[a.jsx(jt,{size:14})," Add row"]})]})})}function os({id:e}){const n=D(),t=f.useCallback(()=>to(n,e),[n,e]);return a.jsxs("tr",{className:"be-table-row","data-block-id":e,children:[a.jsx(we,{parentId:e}),a.jsx("td",{className:"be-table-row-actions",contentEditable:!1,children:a.jsx("button",{type:"button",className:"be-table-delete-row",onClick:t,"aria-label":"Delete row",title:"Delete row",children:a.jsx(Ve,{size:14})})})]})}function co(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=e.getBlock(o.parentId);return{table:r,row:o,rowIndex:r.contentIds.indexOf(o.id),colIndex:o.contentIds.indexOf(n)}}function rs(e,n,t){const{table:o,row:r,rowIndex:l,colIndex:s}=co(e,n);if(t==="left"||t==="right"){const d=t==="right"?1:-1,p=s+d;if(p>=0&&p<r.contentIds.length)return r.contentIds[p];const b=l+d;if(b<0||b>=o.contentIds.length)return null;const m=e.getBlock(o.contentIds[b]),h=t==="right"?0:m.contentIds.length-1;return m.contentIds[h]}const i=l+(t==="down"?1:-1);if(i<0||i>=o.contentIds.length)return null;const u=e.getBlock(o.contentIds[i]);return u.contentIds[s]??u.contentIds[u.contentIds.length-1]??null}function ls(e,n){const t=At(e,n,"down");if(t){G(t);return}ye(e,n,P("paragraph"))}function _e(e,n,t){var r;const o=rs(e,n,t);if(o){const l=e.getBlock(o),s=(r=l==null?void 0:l.contentIds)==null?void 0:r[0];s&&G(s);return}if(t==="right"){const{table:l}=co(e,n);ls(e,l.id)}}function ss({id:e}){const n=D(),t=te(e),o=f.useCallback(()=>_e(n,e,"right"),[n,e]),r=f.useCallback(()=>_e(n,e,"left"),[n,e]),l=f.useCallback(()=>_e(n,e,"up"),[n,e]),s=f.useCallback(()=>_e(n,e,"down"),[n,e]),c=f.useCallback(()=>_e(n,e,"down"),[n,e]);return t?a.jsx("td",{className:"be-table-cell","data-block-id":e,children:a.jsx(me,{blockId:e,runIds:t.contentIds,onTab:o,onShiftTab:r,onArrowUp:l,onArrowDown:s,onEnter:c})}):null}function as(e,n){const t=R(),o=[],r=[],l=[];for(const s of n){const c=hn(t,s);o.push(c.block),r.push(c.run),l.push(c.block.id)}return{block:{id:t,type:"tableRow",parentId:e,contentIds:l,props:{}},blocks:o,runs:r}}function cs({rows:e=2,cols:n=2}={}){return function(o){const r=R(),l=Wn(n),s=[],c=[],i=[];for(let d=0;d<e;d+=1){const p=as(r,l);s.push(p.block,...p.blocks),c.push(...p.runs),i.push(p.block.id)}return{block:{id:r,type:"table",parentId:o,contentIds:i,props:{columns:l}},runs:c,subtreeBlocks:s}}}function is(e,n){return`<td>${e.contentIds.map(o=>n.store.getRun(o)).map(o=>ve(o,n)).join("")}</td>`}function us(e,n){return e.contentIds.map(t=>Ie(n.store.getRun(t),n)).join("")}function ds(e,n){if(e.tagName!=="TD"&&e.tagName!=="TH")return null;const t=ue(e,n);return{block:{id:R(),type:"tableCell",parentId:null,contentIds:t.map(r=>r.id),props:{}},runs:t}}function ps(e,n){return`<tr>${e.contentIds.map(o=>{const r=n.store.getBlock(o);return n.registry.get(r.type).toHTML(r,n)}).join("")}</tr>`}function fs(e,n){return e.contentIds.map(t=>{const o=n.store.getBlock(t);return n.registry.get(o.type).toPlainText(o,n)}).join(" ")}function bs(e,n){if(e.tagName!=="TR")return null;const t=[...e.children].filter(i=>i.tagName==="TD"||i.tagName==="TH"),o=R(),r=[],l=[],s=[];for(const i of t){const u=n.registry.get("tableCell").fromHTML(i,n);u&&(u.block.parentId=o,r.push(u.block),l.push(...u.runs),s.push(u.block.id))}return{block:{id:o,type:"tableRow",parentId:null,contentIds:s,props:{}},runs:l,subtreeBlocks:r}}function hs(e,n){var s;const t=e.contentIds[0]&&n.store.getBlock(e.contentIds[0]),o=ce(e,((s=t==null?void 0:t.contentIds)==null?void 0:s.length)??0),r=o.length?`<thead><tr>${o.map(c=>`<th>${je(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>${r}<tbody>${l}</tbody></table>`}function ms(e,n){return e.contentIds.map(t=>{const o=n.store.getBlock(t);return n.registry.get(o.type).toPlainText(o,n)}).join(`
|
|
1815
|
-
`)}function
|
|
1816
|
-
`)}const ho={component:
|
|
1817
|
-
`);return`${t} ${o}`}const
|
|
1818
|
-
`),[n,e]),r=f.useCallback(()=>
|
|
1880
|
+
`,ot="noteloom-default-styles";function It(){if(typeof document>"u"||document.getElementById(ot))return;const e=document.createElement("style");e.id=ot,e.textContent=kr,document.head.appendChild(e)}const wt=f.createContext(null);function yr({store:e,registry:n,inlineRegistry:t=null,history:o=null,className:r,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:o,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,o,u,d,R,S,h,g,k,I,y,c]),w=r||l?a.jsx("div",{className:r?`be-root ${r}`:"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(),o=n&&t?t(n):void 0;return o?`${e} ${o}`:e}function An(){const{fieldTypeEditorTarget:e,openCreateFieldType:n,openEditFieldType:t,closeFieldTypeEditor:o}=pe();return{target:e,openCreate:n,openEdit:t,close:o}}function Q(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>n.getBlock(e),[n,e]);return f.useSyncExternalStore(t,o)}function ye(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>n.getRun(e),[n,e]);return f.useSyncExternalStore(t,o)}function T(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const Ct="",vr=//g;function me(e){return(e??"").replace(vr,"")}function rt(e){return me(e.textContent)}function Ir(e,n){var c;const t=new Map(n.map(i=>[i.id,i])),o=new Set,r=[];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)){o.add(u);const d=t.get(u);if(d.type!=="text"){r.push(d);continue}const b=rt(i);r.push(b===d.value?d:{...d,value:b});continue}l=!1;const p=rt(i);p&&r.push({id:T(),type:"text",value:p,marks:{}})}if(n.some(i=>!o.has(i.id))&&(l=!1),r.length!==n.length&&(l=!1),l){for(let i=0;i<r.length;i+=1)if(r[i].id!==n[i].id){l=!1;break}}const s=!l||r.some((i,u)=>i!==n[u]);return{runs:r,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 r,l;if(!n)return!1;const t=n.contentIds.length>0,o=(((l=(r=n.props)==null?void 0:r.titleRunIds)==null?void 0:l.length)??0)>0;return!t&&!o}function Rt(e,n){requestAnimationFrame(()=>{const t=document.querySelector(`[data-run-id="${e}"]`);if(!t)return;t.focus();const o=document.createRange();o.selectNodeContents(t),o.collapse(n);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(o)})}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 o=t.firstChild,r=document.createRange();if(o&&o.nodeType===3){const s=Math.max(0,Math.min(n,o.length));r.setStart(o,s),r.setEnd(o,s)}else r.selectNodeContents(t),r.collapse(n<=0);const l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(r)})}function Ye({isOpen:e,onClose:n,title:t,size:o="default",children:r}){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${o==="large"?" be-modal-large":""}`,role:"dialog","aria-modal":"true","aria-label":t,children:[t&&a.jsx("div",{className:"be-modal-title",children:t}),r]})}):null}function Tt({isOpen:e,initialHref:n,initialTarget:t,hasExistingLink:o,onSave:r,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&&r(d,u)},[d,u,r]);return a.jsx(Ye,{isOpen:e,onClose:s,title:o?"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:[o&&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,...o}){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",...o,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 wr(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 Cr(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 Br(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 Rr(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 Tr(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 jr(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 Sr(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 Er(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 Or(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 Lr(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 Nr(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 Mr(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 Ar(e){return a.jsx(Pn,{level:1,...e})}function Dr(e){return a.jsx(Pn,{level:2,...e})}function _r(e){return a.jsx(Pn,{level:3,...e})}function $r(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 Pr(e){return a.jsx(A,{...e,children:a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function Hr(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 zr(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 Fr(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 Ur(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 Kr(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 qr(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 Wr(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 Vr(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 Yr(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 Gr(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 Xr(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 Jr({containerRef:e,store:n}){var x;const[t,o]=f.useState(null),[r,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(()=>{o(k=>r?k:null)},250)},[i,r]);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(),o(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),o(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&&!r?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(Rr,{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:r,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 Qr(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 Zr({id:e,host:n,onValueSynced:t}){const o=ye(e);return f.useLayoutEffect(()=>{var u;if(!n||!o)return;const r=o.value??"";(me(n.textContent)!==r||r===""&&n.textContent==="")&&(n.textContent=r===""?Ct:r);const c=Qr(o.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=o.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,o,t]),null}function st(e,n,t,o){var d,b,h;const r=(d=window.getSelection)==null?void 0:d.call(window);if(!r||!r.isCollapsed||r.rangeCount===0)return null;const{anchorNode:l,anchorOffset:s}=r;if(!l||!e.contains(l))return null;const c=m=>{const g=n.indexOf(m);if(g===-1)return null;const x=o?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=o?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)||!(o?s===0:s===(l.textContent??"").length)?null:c(u.getAttribute("data-run-id"))}function at(e,n,t){var i,u;const o=(i=window.getSelection)==null?void 0:i.call(window);if(!o||o.isCollapsed||o.rangeCount===0)return null;const r=o.getRangeAt(0);if(r.startContainer!==r.endContainer||!e.contains(r.startContainer)||r.endOffset!==r.startOffset+1)return null;const l=r.startContainer.childNodes[r.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 o=n.nodeType===1?n:n.parentElement,r=(c=o==null?void 0:o.closest)==null?void 0:c.call(o,"[data-run-id]");if(!r||!e.contains(r))return null;const l=Array.prototype.indexOf.call(e.childNodes,r),s=n===r?t===0?0:(r.textContent??"").length:t;return{childIndex:l,charOffset:s}}function el(e,n,t,o){const r=ct(e,o.startContainer,o.startOffset),l=ct(e,o.endContainer,o.endOffset);if(!r||!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<r.childIndex,g=l.charOffset===null?d>=l.childIndex:d>l.childIndex;if(m||g){i.push(h);return}const x=r.charOffset!==null&&d===r.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,r.charOffset)+I.slice(l.charOffset);y&&i.push({...h,value:y}),u=i.length}else if(x){const y=I.slice(0,r.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 o=t;for(;o&&o.firstChild;)o=o.firstChild;if(n.anchorNode!==o&&n.anchorNode!==t)return!1;const r=o.nodeType===3&&o.textContent===Ct?1:0;return n.anchorOffset<=r}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 o=t;for(;o&&o.lastChild;)o=o.lastChild;if(n.anchorNode!==o&&n.anchorNode!==t)return!1;const r=o.nodeType===3?(o.textContent??"").length:0;return n.anchorOffset>=r}function it(e,n,t){const o=e.getBlock(n),r=e.getBlock(o==null?void 0:o.parentId);if(!r)return null;const l=r.contentIds.indexOf(n),s=t==="backward"?l-1:l+1;if(s<0||s>=r.contentIds.length)return null;const c=r.contentIds[s];return Ve(e,e.getBlock(c))?c:null}function ol({id:e,blockId:n,host:t,inlineRegistry:o,onValueSynced:r}){const l=ye(e);if(!l)return null;if(l.type==="text")return a.jsx(Zr,{id:e,host:t,onValueSynced:r});const s=o==null?void 0:o.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 rl(e,n,t){let o=e.get(t);if(!o){o=document.createElement("span"),o.dataset.runId=t;const r=n.getRun(t);r&&r.type!=="text"&&o.setAttribute("contenteditable","false"),e.set(t,o)}return o}function xe({blockId:e,runIds:n,onEnter:t,onBackspaceAtStart:o,onDeleteAtEnd:r,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}=Ir(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,re=!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,re=!1}else W>0?(K=(Y=P[W-1])==null?void 0:Y.id,re=!1):P.length>0&&(K=P[0].id,re=!0);const Re=P.length?P:[{id:T(),type:"text",value:"",marks:{}}];p.applyOperation(se(e,Re));const Z=K??Re[0].id;re?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(),o&&o(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}r&&r(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,o,r,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=rl(x.current,p,v);return Le.createPortal(a.jsx(ol,{id:v,blockId:e,host:j,inlineRegistry:d,onValueSynced:I},v),j)})}),a.jsx(Jr,{containerRef:m,store:p})]})}function ll(e,n,t){const o=e.getBlock(n),r=o&&e.getBlock(o.parentId);if(!r)return null;const l=r.contentIds.indexOf(n),s=t==="up"?l-1:l+1;return s<0||s>=r.contentIds.length?null:r.contentIds[s]}function _t(e,n,t){let o=n;for(;;){const r=ll(e,o,t);if(!r)return null;const l=t==="up"?fn(e,r):Hn(e,r);if(l)return l;o=r}}function te(e,n,t){const o=_t(e,n,t);o&&X(o)}function Hn(e,n){var l;const t=e.getBlock(n);if(!t)return null;const o=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!o||o.length===0)return null;const r=o[0];return e.getRun(r)?r:Hn(e,r)}function oe(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 o=((l=t.props)==null?void 0:l.titleRunIds)??t.contentIds;if(!o||o.length===0)return null;const r=o[o.length-1];return e.getRun(r)?r:fn(e,r)}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,o=t.nodeType===1?t:t.parentElement,r=(i=o==null?void 0:o.closest)==null?void 0:i.call(o,"[data-run-id]");if(!r)return null;const l=r.closest("[data-block-id]");if(!l)return null;const s=t.textContent??"";return{runId:r.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 o=n>=t.length,r=t[o?t.length-1:Math.max(0,n)],l=(r==null?void 0:r.nodeType)===1?(i=r.dataset)==null?void 0:i.runId:void 0;if(!l)return null;const s=r.closest("[data-block-id]");return s?{runId:l,blockId:s.getAttribute("data-block-id"),offset:o?me(r.textContent??"").length:0}:null}function Fe(e,n){var c;const t=al(e,n);if(t)return t;let o=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;const r=(c=o==null?void 0:o.closest)==null?void 0:c.call(o,"[data-run-id]");if(!r)return null;const l=r.closest("[data-block-id]");if(!l)return null;let s=me((e.textContent??"").slice(0,n)).length;if(e===r){s=0;for(let i=0;i<n&&i<r.childNodes.length;i+=1)s+=me(r.childNodes[i].textContent??"").length}return{runId:r.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:Fe(e.anchorNode,e.anchorOffset)}function Je(){var o;const e=(o=window.getSelection)==null?void 0:o.call(window);if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=Fe(e.anchorNode,e.anchorOffset),t=Fe(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 Ue(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=Fe(n.anchorNode,n.anchorOffset),o=Fe(n.focusNode,n.focusOffset);if(!t||!o||t.blockId===o.blockId)return null;const r=e.getBlock(t.blockId),l=r&&e.getBlock(r.parentId);if(!l)return null;const s=l.contentIds,c=s.indexOf(t.blockId),i=s.indexOf(o.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:o.blockId,endRunId:o.runId,endOffset:o.offset}}function zn(e,n,t){const r=e.getBlock(n).parentId,s=e.getBlock(r).contentIds.indexOf(n)+1,{block:c,runs:i=[],subtreeBlocks:u=[]}=t(r);return e.applyOperation(G(c,r,s,{blocks:[c,...u],runs:i})),c.id}function ve(e,n,t){const o=zn(e,n,t);return oe(e,o),o}function cl(e,n,t){const{block:o,runs:r=[],subtreeBlocks:l=[]}=t(n);return e.applyOperation(G(o,n,0,{blocks:[o,...l],runs:r})),oe(e,o.id),o.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 o=e.findIndex(u=>u.id===n);if(o===-1)return null;const r=e[o],l=e.slice(0,o),s=e.slice(o+1);if(r.type==="text"){const u=r.value??"",p=u.slice(0,t),d=u.slice(t);p&&d?(l.push({...r,value:p}),s.unshift({...r,id:T(),value:d})):d?s.unshift(r):l.push(r)}else t>0?l.push(r):s.unshift(r);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,o){const r=e.getBlock(n),l=e.getBlock(r.parentId),s=l.contentIds.indexOf(n)+1;return Ht(e,n,t,o,{insertParentId:l.id,insertIndex:s,fallback:()=>ve(e,n,o)})}function Pt(e,n,t,o){return Ht(e,n,t,o,{insertParentId:n,insertIndex:0,fallback:()=>cl(e,n,o)})}function Ht(e,n,t,o,{insertParentId:r,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=[]}=o(r,d),g=p.length?p:[{id:T(),type:"text",value:"",marks:{}}];return $t(e,[se(n,g),G(b,r,l,{blocks:[b,...m],runs:h})]),oe(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 r=e.getBlock(n).parentId,s=e.getBlock(r).contentIds.indexOf(n),{block:c,runs:i=[],subtreeBlocks:u=[]}=t(r);return $t(e,[_(n),G(c,r,s,{blocks:[c,...u],runs:i})]),oe(e,c.id),c.id}function ne(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,o)+c.slice(r),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(o,r){const l=T(),s=r!=null&&r.length?r:[{id:T(),type:"text",value:"",marks:{}}];return{block:{id:l,type:e,parentId:o,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:o,runs:r}=$("paragraph")(n);return e.applyOperation(G(o,n,0,{blocks:[o],runs:r})),o.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 o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=t.contentIds.length===0||t.contentIds.length===1&&bl(e,t.contentIds[0]);if(r<=0){if(!l)return null;if(o.contentIds.length>1)return Te(e,[_(n)]),e.getBlock(o.id).contentIds[0];if(fl.has(o.type))return ml(e,o);if(t.type==="paragraph")return null;const{block:u,runs:p}=$("paragraph")(o.id);return Te(e,[G(u,o.id,r,{blocks:[u],runs:p}),_(n)]),u.id}const s=o.contentIds[r-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 o=t.contentIds.indexOf(n.id),r=o>0?t.contentIds[o-1]:null,l=o!==-1&&o<t.contentIds.length-1?t.contentIds[o+1]:null;Te(e,[_(n.id)]);const s=Ae(e);return r??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,o){if(!n||n===t)return;const r=fn(e,n);if(r){X(r);return}o(n),requestAnimationFrame(()=>{var l;(l=document.querySelector(`[data-block-id="${n}"]`))==null||l.focus()})}function hl(e,n,t,o,r){const l=e.getBlock(n),c=e.getBlock(l.parentId).contentIds.indexOf(n),i="titleRunIds"in o,u="titleRunIds"in(l.props??{}),p={id:T(),type:t,parentId:l.parentId,contentIds:[],props:o},d=i?z(p.id,{titleRunIds:r}):je(p.id,r),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 o=t[0].value??"";for(const r of xl){const l=r.re.exec(o);if(!l)continue;const s=o.slice(l[0].length),{ops:c}=hl(e,n,r.type,r.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:o}=ge(),r=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,o)},[n,e,t,o]),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:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c,onAutoformat:i})})}function Se(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ce(e){return Se(e).replace(/"/g,""")}function Ie(e,n){var r,l;if(!e)return"";if(e.type!=="text"){const s=(r=n==null?void 0:n.inlineRegistry)==null?void 0:r.get(e.type);return s?s.toHTML(e,n):Se(e.value??"")}const t=e.marks??{};let o=Se(e.value??"");if(t.code&&(o=`<code>${o}</code>`),t.bold&&(o=`<strong>${o}</strong>`),t.italic&&(o=`<em>${o}</em>`),t.underline&&(o=`<u>${o}</u>`),t.strike&&(o=`<s>${o}</s>`),t.subscript&&(o=`<sub>${o}</sub>`),t.superscript&&(o=`<sup>${o}</sup>`),t.color&&(o=`<span style="color:${ce(t.color)}">${o}</span>`),t.highlight&&(o=`<span style="background-color:${ce(t.highlight)}">${o}</span>`),(l=t.link)!=null&&l.href){const s=t.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";o=`<a href="${ce(t.link.href)}"${s}>${o}</a>`}return o}function we(e,n){var t;if(!e)return"";if(e.type!=="text"){const o=(t=n==null?void 0:n.inlineRegistry)==null?void 0:t.get(e.type);return o?o.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 o=[],r=(l,s)=>{var u,p;if(l.nodeType===3){const d=l.textContent;d&&o.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){o.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)r(d,c)};return r(e,t),o.length?o:[{id:T(),type:"text",value:"",marks:{}}]}function wl(e,n){return`<p>${e.contentIds.map(o=>n.store.getRun(o)).map(o=>Ie(o,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(r=>r.id),props:{}},runs:t}}const Ft={component:vl,isLeaf:!0,defaultProps:{},toHTML:wl,toPlainText:Cl,fromHTML:Bl,slashCommand:{label:"Text",icon:Mr,keywords:["paragraph","text","p"],run:(e,n)=>ne(e,n,$("paragraph"))}};function Rl({id:e}){var b;const n=D(),t=Q(e),{setSelectedBlockId:o}=ge(),r=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,o)},[n,e,o]),s=f.useCallback(()=>te(n,e,"up"),[n,e]),c=f.useCallback(()=>te(n,e,"down"),[n,e]),i=ee("be-heading",t);if(!t)return null;const u=((b=t.props)==null?void 0:b.level)??3,p=`h${u}`,d=ae(n,t.contentIds);return a.jsx(p,{className:i,"data-block-id":e,"data-empty":d?"":void 0,"data-placeholder":`Heading ${u}`,children:a.jsx(xe,{blockId:e,runIds:t.contentIds,onEnter:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})}const yn={1:Ar,2:Dr,3:_r},Tl={H1:1,H2:2,H3:3};function jl(e,n){var r;const t=((r=e.props)==null?void 0:r.level)??3,o=e.contentIds.map(l=>n.store.getRun(l));return`<h${t}>${o.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 o=de(e,n);return{block:{id:T(),type:"heading",parentId:null,contentIds:o.map(l=>l.id),props:{level:t}},runs:o}}const Ut={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 Fn(e){const n=D(),t=f.useCallback(r=>n.subscribe(e,r),[n,e]),o=f.useCallback(()=>{const r=n.getBlock(e);return r?r.contentIds:Ol},[n,e]);return f.useSyncExternalStore(t,o)}class Kt extends f.Component{constructor(){super(...arguments);tt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,o){var r,l;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",t,o),(l=(r=this.props).onError)==null||l.call(r,t,o),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 Un=f.memo(function({id:n}){const t=Q(n),o=Ne();if(!t)return null;const r=o.get(t.type);if(!r)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${t.type}" (id: ${n})`),null;const l=r.component;return a.jsx(Kt,{children:a.jsx(l,{id:n})})});function bn(e,n,t){f.useEffect(()=>{if(!n)return;const o=Array.isArray(e)?e:[e],r=s=>{o.some(i=>i.current&&i.current.contains(s.target))||t()},l=s=>{s.key==="Escape"&&t()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",l)}},[n,t,e])}function Ze(e,n,t,o){const r={store:e,registry:n,inlineRegistry:o};return{html:Ll(e,n,t,r),text:t.map(l=>{const s=e.getBlock(l);return n.get(s.type).toPlainText(s,r)}).join(`
|
|
1881
|
+
`),json:JSON.stringify({version:1,blocks:t.map(l=>Kn(e,l))})}}function Ll(e,n,t,o){let r="",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,o),u+=1}const p=c?"ol":"ul";r+=`<${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,o),i+=1}r+=`<blockquote>${c}</blockquote>`,l=i}else r+=n.get(s.type).toHTML(s,o),l+=1}return r}function Kn(e,n){const t=[],o=[],r=l=>{var i;const s=e.getRun(l);if(s){o.push(s);return}const c=e.getBlock(l);if(c){t.push(c);for(const u of c.contentIds)r(u);for(const u of((i=c.props)==null?void 0:i.titleRunIds)??[])r(u)}};return r(n),{rootId:n,blocks:t,runs:o}}function qn({rootId:e,blocks:n,runs:t}){const o=new Map;for(const i of n)o.set(i.id,T());for(const i of t)o.set(i.id,T());const r=i=>o.get(i)??i,l=n.map(i=>{var u;return{...i,id:r(i.id),parentId:i.parentId?r(i.parentId):i.parentId,contentIds:i.contentIds.map(r),props:{...i.props,...(u=i.props)!=null&&u.titleRunIds?{titleRunIds:i.props.titleRunIds.map(r)}:{}}}}),s=t.map(i=>({...i,id:r(i.id)})),c=r(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 o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=Kn(e,n),{block:s,runs:c,subtreeBlocks:i}=qn(l);return e.applyOperation(G(s,o.id,r+1,{blocks:[s,...i],runs:c})),oe(e,s.id),s.id}function Wt(e,n){const t=e.getBlock(n),o=t&&e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n);return r<=0?!1:(e.applyOperation(ke(n,o.id,r-1)),!0)}function Vt(e,n){const t=e.getBlock(n),o=t&&e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n);return r===-1||r>=o.contentIds.length-1?!1:(e.applyOperation(ke(n,o.id,r+1)),!0)}function Wn(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=r>0?o.contentIds[r-1]:null,s=r!==-1&&r<o.contentIds.length-1?o.contentIds[r+1]:null;e.applyOperation(_(n));const c=Ae(e),i=l??s??c;return i&&oe(e,i),i??null}function Yt({id:e}){var R;const n=D(),t=Q(e),[o,r]=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(()=>r(!1),[]);bn(u,o,b);const h=f.useCallback(()=>{var S;s(((S=c.current)==null?void 0:S.getBoundingClientRect())??null),r(!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${o?" 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":o,onClick:()=>o?b():h(),children:a.jsx(Lr,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(Un,{id:e})}),o&&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=Fn(e),o=D(),[r]=Mn(),l=r?t.filter(s=>{var c,i;return!((i=(c=o.getBlock(s))==null?void 0:c.props)!=null&&i.hidden)}):t;return n&&!r?l.map(s=>a.jsx(Yt,{id:s},s)):l.map(s=>a.jsx(Un,{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[o,r]of Ml)for(;t>=o;)n+=r,t-=o;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,o=n;for(;o;){const r=e.getBlock(o.parentId);if(!r||r.type!=="listItem")break;t+=1,o=r}return t}function $l(e,n,t){const o=t.indexOf(n.id);let r=1;for(let l=o-1;l>=0;l-=1){const s=e.getBlock(t[l]);if(!_l(s)||!s.props.ordered)break;r+=1}return r}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(r,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:r,contentIds:u,props:i},runs:d,subtreeBlocks:p}}}function Fl(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=r>0?o.contentIds[r-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)),oe(e,n)}function wn(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId);if(!o||o.type!=="listItem")return;const r=o.parentId,s=e.getBlock(r).contentIds.indexOf(o.id);e.applyOperation(ke(n,r,s+1)),oe(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 Ul(e,n){const t=n.contentIds??[];if(t.length===0)return!0;if(t.length>1)return!1;const o=e.getBlock(t[0]);return!!o&&o.type==="paragraph"&&ae(e,o.contentIds)}function Kl(e,n){const t=e.getBlock(n);if(!t)return null;const o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=t.props.titleRunIds??[],c=Gt(e,l)&&Ul(e,t);if(r>0){const p=o.contentIds[r-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(o.type==="listItem")return wn(e,n),{focusBlockId:n,needsRefocus:!0};if(!c)return null;if(o.contentIds.length>1)return $e(e,[_(n)]),{focusBlockId:e.getBlock(o.id).contentIds[0],needsRefocus:!0};const{block:i,runs:u}=$("paragraph")(o.id);return $e(e,[G(i,o.id,r,{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 o=e.getBlock(n).parentId,l=e.getBlock(o).contentIds.indexOf(n),{block:s,runs:c}=$("paragraph")(o);return ql(e,[G(s,o,l,{blocks:[s],runs:c}),z(n,{titleRunIds:[]}),_(n)]),oe(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:o}=ge(),r=Fn(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(()=>Fl(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,o)},[n,e,o]),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,r)):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:o}=e.props,r=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?`<${o?"ol":"ul"}>${l}</${o?"ol":"ul"}>`:"";return`<li>${r}${s}</li>`}function Xl(e,n){const{titleRunIds:t=[]}=e.props;return t.map(o=>we(n.store.getRun(o),n)).join("")}function Xt(e,n){const t=[],o=[];for(const d of e.childNodes)d.nodeType===1&&(d.tagName==="UL"||d.tagName==="OL")?o.push(d):t.push(d);const r=e.ownerDocument.createElement("span");for(const d of t)r.appendChild(d.cloneNode(!0));const l=de(r,n),s=T(),c=[...l],i=[],u=[];for(const d of o){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:o,childBlocks:r}=Xt(e,n);return{block:t,runs:o,subtreeBlocks:r}}const Jt={component:Yl,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:Gl,toPlainText:Xl,fromHTML:Jl,slashCommands:[{label:"Bulleted list",icon:Kr,keywords:["list","bullet","ul"],run:(e,n)=>ne(e,n,He({ordered:!1}))},{label:"Numbered list",icon:qr,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 o;const t=(o=e.props)==null?void 0:o.columns;return!Array.isArray(t)||t.length!==n?Vn(n):t.map(r=>{const l=r.type??mn,s=r.width??hn;return l===r.type&&s===r.width?r:{...r,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 eo(e,n,t){if(e.type===n)return e;let o;if(e.type==="text")o=e.value??"";else{const r=t==null?void 0:t.get(e.type);o=r!=null&&r.toPlainText?r.toPlainText(e):""}if(n==="date"){const r=o?new Date(o):null,l=r&&!Number.isNaN(r.getTime())?r.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:o}}:{id:T(),type:"text",value:o,marks:{}}}function Be(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function no(e,n){const o=e.getBlock(n.parentId).contentIds.indexOf(n.id);Be(e,[_(n.id)]);const r=Ae(e);if(r)return oe(e,r),null;const l=e.getBlock(n.parentId),s=l.contentIds[o]??l.contentIds[o-1];return s&&oe(e,s),null}function to(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=ie(o,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:o.id,contentIds:u,props:{}};return e.applyOperation(G(p,o.id,r+1,{blocks:[p,...c],runs:i})),oe(e,s),s}function oo(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId);if(o.contentIds.length<=1)return no(e,o);const r=o.contentIds.indexOf(n);Be(e,[_(n)]);const l=e.getBlock(o.id),s=Math.min(r,l.contentIds.length-1),c=l.contentIds[s];return c&&oe(e,c),c??null}function Cn(e,n,t){const o=e.getBlock(n),r=ie(o,o.contentIds[0]?e.getBlock(o.contentIds[0]).contentIds.length:0),l={id:T(),label:"New Column",type:mn,width:hn},s=[];let c=null;for(const u of o.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=[...r];return i.splice(t+1,0,l),s.push(z(n,{columns:i})),Be(e,s),c&&oe(e,c),c}function ro(e,n,t){const o=e.getBlock(n),r=e.getBlock(o.contentIds[0]);if(!r||r.contentIds.length<=1)return no(e,o);const l=ie(o,r.contentIds.length),s=o.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(o.contentIds[0]),u=Math.min(t,i.contentIds.length-1),p=i.contentIds[u];return p&&oe(e,p),p??null}function lo(e,n,t,o){const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),s=ie(r,l?l.contentIds.length:0);if(!s[t])return;const c=[...s];c[t]={...s[t],width:Math.max(an,Math.round(o))},e.applyOperation(z(n,{columns:c}))}function so(e,n,t,o){const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),c=[...ie(r,l?l.contentIds.length:0)];c[t]&&(c[t]={...c[t],label:o},e.applyOperation(z(n,{columns:c})))}function Yn(e,n,t){return n.contentIds.map(o=>{const l=e.getBlock(o).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,o){const r=Yn(e,n,t),l=[],s=new Map;for(const{run:i}of r){const u=ft(i,o).trim();if(!u||s.has(u))continue;const p={value:T(),label:u};s.set(u,p),l.push(p)}const c=r.map(({cellId:i,run:u})=>{const p=ft(u,o).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 ao(e,n,t,o,r){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===o)return;const u=[...c];if(o==="select"){const{options:d,newRuns:b}=Zl(e,l,t,r);u[t]={...i,type:o,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:o};const p=[z(n,{columns:u})];for(const{cellId:d,run:b}of Yn(e,l,t)){if(!b)continue;const h=eo(b,o,r);p.push(se(d,[h]))}Be(e,p)}function ln(e,n,t,o){var d,b;const r=e.getBlock(n),l=e.getBlock(r.contentIds[0]),s=ie(r,l?l.contentIds.length:0),c=s[t];if(!c)return;const i=[...s];i[t]={...c,options:o};const u=[z(n,{columns:i})],p=new Map(o.map(h=>[h.value,h]));for(const{run:h}of Yn(e,r,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:o="Select…",ariaLabel:r,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 U=setTimeout(()=>{Promise.resolve(n(m)).then(ue=>{L||(R(ue??[]),C(!1))}).catch(()=>{L||(R([]),C(!1),v(!0))})},250);return()=>{L=!0,clearTimeout(U)}},[H,b,n,m]);const re=f.useCallback(()=>h(!1),[]);bn(q,b,re);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,U;(U=(L=M.current)==null?void 0:L.scrollIntoView)==null||U.call(L,{block:"nearest"})},[x]);const Z=f.useCallback(L=>{var U;t(L.value,L),re(),(U=B.current)==null||U.focus()},[t,re]),le=f.useCallback(L=>{var U;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(),re(),(U=B.current)==null||U.focus())},[K,x,Z,re]);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":r,onClick:()=>b?re():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:o}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"be-select-value",children:W?W.label:o}),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":r?`Search ${r}`:"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,U)=>{var ue,nt;return a.jsx("div",{ref:U===x?M:void 0,role:"option","aria-selected":L.value===e,className:`be-select-option${U===x?" be-select-option-active":""}${L.value===e?" be-select-option-selected":""}`,onMouseDown:dr=>{dr.preventDefault(),Z(L)},onMouseEnter:()=>k(U),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(),re(),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 os({tableId:e,colIndex:n,options:t}){const o=D(),[r,l]=f.useState(""),s=f.useCallback((u,p)=>{ln(o,e,n,t.map(d=>d.value===u?{...d,label:p}:d))},[o,e,n,t]),c=f.useCallback(u=>ln(o,e,n,t.filter(p=>p.value!==u)),[o,e,n,t]),i=f.useCallback(()=>{const u=r.trim();l(""),u&&ln(o,e,n,[...t,{value:T(),label:u,color:Ke(t.length)}])},[o,e,n,t,r]);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:r,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 rs({tableId:e,column:n,colIndex:t,colCount:o}){const r=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=>so(r,e,t,w.target.value),[r,e,t]),y=f.useCallback(()=>{Cn(r,e,t-1),x()},[r,e,t,x]),E=f.useCallback(()=>{Cn(r,e,t),x()},[r,e,t,x]),R=f.useCallback(()=>{ro(r,e,t),x()},[r,e,t,x]),S=f.useCallback(w=>ao(r,e,t,w,l),[r,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),lo(r,e,t,N(H)),d(null)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",q)},[r,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(os,{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:o<=1,children:"Delete column"})]}),document.body)]})}function co({tableId:e,columns:n}){return a.jsx("thead",{children:a.jsxs("tr",{className:"be-table-header-row",children:[n.map((t,o)=>a.jsx(rs,{tableId:e,column:t,colIndex:o,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),o=f.useCallback(()=>{var u;const i=(u=t==null?void 0:t.contentIds)==null?void 0:u[t.contentIds.length-1];i&&to(n,i)},[n,t]),r=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:r,"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(co,{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:o,children:[a.jsx(St,{size:14})," Add row"]})]})})}function ss({id:e}){const n=D(),t=Q(e),o=ee("be-table-row",t),r=f.useCallback(()=>oo(n,e),[n,e]);return a.jsxs("tr",{className:o,"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:r,"aria-label":"Delete row",title:"Delete row",children:a.jsx(Ge,{size:14})})})]})}function io(e,n){const t=e.getBlock(n),o=e.getBlock(t.parentId),r=e.getBlock(o.parentId);return{table:r,row:o,rowIndex:r.contentIds.indexOf(o.id),colIndex:o.contentIds.indexOf(n)}}function as(e,n,t){const{table:o,row:r,rowIndex:l,colIndex:s}=io(e,n);if(t==="left"||t==="right"){const p=t==="right"?1:-1,d=s+p;if(d>=0&&d<r.contentIds.length)return r.contentIds[d];const b=l+p;if(b<0||b>=o.contentIds.length)return null;const h=e.getBlock(o.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>=o.contentIds.length)return null;const u=e.getBlock(o.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 r;const o=as(e,n,t);if(o){const l=e.getBlock(o),s=(r=l==null?void 0:l.contentIds)==null?void 0:r[0];s&&X(s);return}if(t==="right"){const{table:l}=io(e,n);cs(e,l.id)}}function is({id:e}){const n=D(),t=Q(e),o=f.useCallback(()=>Pe(n,e,"right"),[n,e]),r=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:o,onShiftTab:r,onArrowUp:l,onArrowDown:s,onEnter:c})}):null}function us(e,n){const t=T(),o=[],r=[],l=[];for(const s of n){const c=gn(t,s);o.push(c.block),r.push(c.run),l.push(c.block.id)}return{block:{id:t,type:"tableRow",parentId:e,contentIds:l,props:{}},blocks:o,runs:r}}function ds({rows:e=2,cols:n=2}={}){return function(o){const r=T(),l=Vn(n),s=[],c=[],i=[];for(let p=0;p<e;p+=1){const d=us(r,l);s.push(d.block,...d.blocks),c.push(...d.runs),i.push(d.block.id)}return{block:{id:r,type:"table",parentId:o,contentIds:i,props:{columns:l}},runs:c,subtreeBlocks:s}}}function ps(e,n){return`<td>${e.contentIds.map(o=>n.store.getRun(o)).map(o=>Ie(o,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(r=>r.id),props:{}},runs:t}}function ms(e,n){return`<tr>${e.contentIds.map(o=>{const r=n.store.getBlock(o);return n.registry.get(r.type).toHTML(r,n)}).join("")}</tr>`}function hs(e,n){return e.contentIds.map(t=>{const o=n.store.getBlock(t);return n.registry.get(o.type).toPlainText(o,n)}).join(" ")}function gs(e,n){if(e.tagName!=="TR")return null;const t=[...e.children].filter(i=>i.tagName==="TD"||i.tagName==="TH"),o=T(),r=[],l=[],s=[];for(const i of t){const u=n.registry.get("tableCell").fromHTML(i,n);u&&(u.block.parentId=o,r.push(u.block),l.push(...u.runs),s.push(u.block.id))}return{block:{id:o,type:"tableRow",parentId:null,contentIds:s,props:{}},runs:l,subtreeBlocks:r}}function xs(e,n){var s;const t=e.contentIds[0]&&n.store.getBlock(e.contentIds[0]),o=ie(e,((s=t==null?void 0:t.contentIds)==null?void 0:s.length)??0),r=o.length?`<thead><tr>${o.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>${r}<tbody>${l}</tbody></table>`}function ks(e,n){return e.contentIds.map(t=>{const o=n.store.getBlock(t);return n.registry.get(o.type).toPlainText(o,n)}).join(`
|
|
1882
|
+
`)}function ys(e,n){if(e.tagName!=="TABLE")return null;const t=e.querySelector("thead tr"),o=e.querySelector("tbody")?[...e.querySelectorAll("tbody tr")]:[...e.querySelectorAll("tr")].filter(p=>p!==t),r=T(),l=[],s=[],c=[];for(const p of o){const d=n.registry.get("tableRow").fromHTML(p,n);if(d){d.block.parentId=r;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:r,type:"table",parentId:null,contentIds:c,props:i},runs:s,subtreeBlocks:l}}const uo={component:is,isLeaf:!0,defaultProps:{},toHTML:ps,toPlainText:fs,fromHTML:bs},po={component:ss,isLeaf:!1,defaultProps:{},toHTML:ms,toPlainText:hs,fromHTML:gs},fo={component:ls,isLeaf:!1,defaultProps:{},toHTML:xs,toPlainText:ks,fromHTML:ys,slashCommand:{label:"Table",icon:Fr,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 o=T(),r=[],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:o,contentIds:[p.id],props:{}};r.push(b,p),l.push(...d),s.push(u)}return{block:{id:o,type:"layout",parentId:t,contentIds:s,props:{}},runs:l,subtreeBlocks:r}}}function bo(e,n){return(t,o)=>`${e}${t.contentIds.map(r=>{const l=o.store.getBlock(r);return o.registry.get(l.type).toHTML(l,o)}).join("")}${n}`}function mo(e,n){return e.contentIds.map(t=>{const o=n.store.getBlock(t);return n.registry.get(o.type).toPlainText(o,n)}).join(`
|
|
1883
|
+
`)}const ho={component:Is,isLeaf:!1,defaultProps:{},toHTML:bo("<div>","</div>"),toPlainText:mo},go={component:vs,isLeaf:!1,defaultProps:{},toHTML:bo('<div style="display:flex;gap:1em">',"</div>"),toPlainText:mo,slashCommands:[2,3,4,5].map(e=>({label:`${e} columns`,icon:Ur,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 xo={component:Cs,isLeaf:!0,defaultProps:{},toHTML:Rs,toPlainText:Ts,fromHTML:js,slashCommand:{label:"Divider",icon:Pr,keywords:["divider","hr","separator","line"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>{const l=e.getRun(t),s=(l==null?void 0:l.value)??"";e.applyOperation(J(t,{value:s.slice(0,o)+s.slice(r)}));const c=zn(e,n,Bs());return ve(e,c,$("paragraph")),c}}},en="💡",ko="gray";function Ss({icon:e=en,color:n=ko}={}){return function(o){const r=T(),{block:l,runs:s}=$("paragraph")(r);return{block:{id:r,type:"callout",parentId:o,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),[o,r]=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)??ko,h=f.useCallback(y=>{const E=y.target.value.trim();E&&n.applyOperation(z(e,{icon:E})),r(!1)},[n,e]),m=f.useCallback(y=>{y.key==="Enter"&&y.currentTarget.blur(),y.key==="Escape"&&r(!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:o?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:()=>r(!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 o=n.store.getBlock(t);return n.registry.get(o.type).toHTML(o,n)}).join("")}function Ns(e,n){var o;const t=((o=e.props)==null?void 0:o.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 r;const t=((r=e.props)==null?void 0:r.icon)??en,o=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
|
|
1884
|
+
`);return`${t} ${o}`}const yo={component:Os,isLeaf:!1,defaultProps:{icon:en},toHTML:Ns,toPlainText:Ms,slashCommand:{label:"Callout",icon:Hr,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:o}=ge(),r=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,o)},[n,e,o]),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:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})}function Ds(e,n){return`<p>${e.contentIds.map(o=>n.store.getRun(o)).map(o=>Ie(o,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(r=>r.id),props:{}},runs:t}}const vo={component:As,isLeaf:!0,defaultProps:{},toHTML:Ds,toPlainText:_s,fromHTML:$s,slashCommand:{label:"Quote",icon:$r,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 o=Xe();if(!o||o.blockId!==n)return;const r=e.getRun(o.runId);if(!r||r.type!=="text")return;const l=r.value??"",s=l.slice(0,o.offset)+t+l.slice(o.offset);e.applyOperation(J(r.id,{value:s})),be(r.id,o.offset+t.length)}function zs({id:e}){var h;const n=D(),t=Q(e),o=f.useCallback(()=>bt(n,e,`
|
|
1885
|
+
`),[n,e]),r=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:o,onTab:r,onBackspaceAtStart:l,onArrowUp:s,onArrowDown:c})})})]})}function Fs(e,n){var l;const t=e.contentIds.map(s=>n.store.getRun(s)),o=(l=e.props)==null?void 0:l.language;return`<pre><code${o&&o!=="plaintext"?` data-language="${Se(o)}"`:""}>${t.map(s=>Ie(s,n)).join("")}</code></pre>`}function Us(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,o=(s=t.getAttribute)==null?void 0:s.call(t,"data-language"),r=T();return{block:{id:T(),type:"code",parentId:null,contentIds:[r],props:o?{language:o}:{}},runs:[{id:r,type:"text",value:t.textContent??"",marks:{}}]}}const Io={component:zs,isLeaf:!0,defaultProps:{language:"plaintext"},toHTML:Fs,toPlainText:Us,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 o=e.getBlock(t[0]);return!!o&&o.type==="paragraph"&&ae(e,o.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 o=e.getBlock(t.parentId),r=o.contentIds.indexOf(n),l=t.props.titleRunIds??[],s=qs(e,l)&&Ws(e,t);if(r<=0){if(!s)return null;if(o.contentIds.length>1)return tn(e,[_(n)]),{focusBlockId:e.getBlock(o.id).contentIds[0],needsRefocus:!0};const{block:u,runs:p}=$("paragraph")(o.id);return tn(e,[G(u,o.id,r,{blocks:[u],runs:p}),_(n)]),{focusBlockId:u.id,needsRefocus:!0}}const c=o.contentIds[r-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:o}=ge(),r=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,o)},[n,e,o]),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-toggle-heading-title","data-empty":ae(n,b)?"":void 0,"data-placeholder":`Toggle heading ${p}`,children:a.jsx(xe,{blockId:e,runIds:b,onEnter:r,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(o,r){const l=T(),s=r!=null&&r.length?r:[{id:T(),type:"text",value:"",marks:{}}],{block:c,runs:i}=$("paragraph")(l);return{block:{id:l,type:"toggleHeading",parentId:o,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:o=2,collapsed:r}=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${r?"":" open"}><summary><h${o}>${l}</h${o}></summary>${s}</details>`}function Qs(e,n){const{titleRunIds:t=[]}=e.props,o=t.map(l=>we(n.store.getRun(l),n)).join(""),r=e.contentIds.map(l=>{const s=n.store.getBlock(l);return n.registry.get(s.type).toPlainText(s,n)}).join(`
|
|
1819
1886
|
`);return r?`${o}
|
|
1820
|
-
${r}`:o}function Xs(e,n){if(e.tagName!=="DETAILS")return null;const t=[...e.children].find(p=>p.tagName==="SUMMARY"),o=t==null?void 0:t.querySelector("h1,h2,h3,h4,h5,h6"),r=o?Math.min(6,Math.max(1,Number(o.tagName[1]))):2,l=o?ue(o,n):[{id:R(),type:"text",value:"",marks:{}}],s=R(),c=[],i=[],u=[];for(const p of e.children){if(p===t||p.tagName!=="P")continue;const b=ue(p,n),m={id:R(),type:"paragraph",parentId:s,contentIds:b.map(h=>h.id),props:{}};c.push(m),i.push(...b),u.push(m.id)}if(u.length===0){const{block:p,runs:b}=P("paragraph")(s);c.push(p),i.push(...b),u.push(p.id)}return{block:{id:s,type:"toggleHeading",parentId:null,contentIds:u,props:{level:r,collapsed:!e.hasAttribute("open"),titleRunIds:l.map(p=>p.id)}},runs:[...l,...i],subtreeBlocks:c}}const Io={component:Ws,isLeaf:!1,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:Ys,toPlainText:Gs,fromHTML:Xs,slashCommands:[1,2,3].map(e=>({label:`Toggle heading ${e}`,icon:un,keywords:["toggle","heading","collapse","section"],run:(n,t)=>Z(n,t,Vs({level:e}))}))},xn=[{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 Js(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Qs({isOpen:e,onClose:n,store:t,blockId:o}){const[r,l]=f.useState(""),[s,c]=f.useState(""),[i,u]=f.useState(xn[0].value),[d,p]=f.useState([{key:"",value:""}]);f.useEffect(()=>{var y,I,E;if(!e)return;const g=t.getBlock(o);if(!g)return;const k=g.contentIds.map(T=>{var S;return((S=t.getRun(T))==null?void 0:S.value)??""}).join(""),x=((y=g.props)==null?void 0:y.customAttrs)??[];l(k),c(((I=g.props)==null?void 0:I.href)??""),u(((E=g.props)==null?void 0:E.color)??xn[0].value),p([...x,{key:"",value:""}])},[e,o,t]);const b=f.useCallback((g,k)=>{p(x=>{const y=x.map((E,T)=>T===g?{...E,...k}:E),I=y[y.length-1];return(I.key.trim()||I.value.trim())&&y.push({key:"",value:""}),y})},[]),m=f.useCallback(g=>{p(k=>k.filter((x,y)=>y!==g))},[]),h=f.useCallback(()=>{const g={id:R(),type:"text",value:r,marks:{}},k=d.filter(x=>x.key.trim());Js(t,[le(o,[g]),z(o,{href:s.trim(),color:i,customAttrs:k})]),n()},[t,o,r,s,i,d,n]);return a.jsxs(cn,{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:r,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:xn.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"}),d.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:()=>m(k),"aria-label":"Remove attribute",children:a.jsx(Ve,{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:h,children:"Save"})]})]})}const Zs="#2b6fd6";function ea({id:e}){var k,x,y,I;const n=D(),t=te(e),{setSelectedBlockId:o}=he(),[r,l]=f.useState(!1),s=f.useCallback(()=>{Le(n,e,(t==null?void 0:t.contentIds)??[],P("paragraph"))},[n,e,t]),c=f.useCallback(()=>{const E=Xe(n,e);Me(n,E,e,o)},[n,e,o]),i=f.useCallback(()=>ee(n,e,"up"),[n,e]),u=f.useCallback(()=>ee(n,e,"down"),[n,e]),d=f.useCallback(()=>{var T;const E=(T=t==null?void 0:t.props)==null?void 0:T.href;E&&window.open(E,"_blank","noopener,noreferrer")},[(k=t==null?void 0:t.props)==null?void 0:k.href]);if(!t)return null;const p=((x=t.props)==null?void 0:x.href)??"",b=((y=t.props)==null?void 0:y.color)??Zs,m=((I=t.props)==null?void 0:I.customAttrs)??[],h=se(n,t.contentIds),g={};for(const{key:E,value:T}of m)E.trim()&&(g[`data-${E.trim()}`]=T);return a.jsxs("div",{className:"be-button-block","data-block-id":e,children:[a.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:b},...g,children:[a.jsx("span",{className:"be-button-block-label","data-empty":h?"":void 0,"data-placeholder":"Button",children:a.jsx(me,{blockId:e,runIds:t.contentIds,onEnter:s,onBackspaceAtStart:c,onArrowUp:i,onArrowDown:u})}),a.jsx("button",{type:"button",className:"be-button-block-open",onClick:d,disabled:!p,title:p||"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(Qs,{isOpen:r,onClose:()=>l(!1),store:n,blockId:e})]})}function na({href:e="",label:n="Button",color:t="",customAttrs:o=[]}={}){return function(l,s){const c=R(),i=s!=null&&s.length?s:[{id:R(),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:o}},runs:i}}}const wo="be-button-block-link";function ta(e,n){var i,u,d;const t=e.contentIds.map(p=>n.store.getRun(p)),o=((i=e.props)==null?void 0:i.href)??"",r=(u=e.props)==null?void 0:u.color,l=r?` style="background-color:${ae(r)}"`:"",c=(((d=e.props)==null?void 0:d.customAttrs)??[]).filter(p=>{var b;return(b=p.key)==null?void 0:b.trim()}).map(p=>` data-${ae(p.key.trim())}="${ae(p.value??"")}"`).join("");return`<a class="${wo}" href="${ae(o)}"${l}${c}>${t.map(p=>ve(p,n)).join("")}</a>`}function oa(e,n){return e.contentIds.map(t=>Ie(n.store.getRun(t),n)).join("")}function ra(e,n){var l;if(e.tagName!=="A"||!e.classList.contains(wo))return null;const t=ue(e,n),o=[];for(const s of e.attributes)s.name.startsWith("data-")&&o.push({key:s.name.slice(5),value:s.value});return{block:{id:R(),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:o}},runs:t}}const Co={component:ea,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:ta,toPlainText:oa,fromHTML:ra,slashCommand:{label:"Button",icon:Pr,keywords:["button","link","cta","action"],run:(e,n)=>Z(e,n,na())}};function bt(e){return new Promise((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>t(o.error),o.readAsDataURL(e)})}const en={image:"image",video:"video",audio:"audio",file:"file"},la={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},Bo=20,Ro=100,sa=[{value:"left",Icon:Br,label:"Align left"},{value:"center",Icon:Rr,label:"Align center"},{value:"right",Icon:Tr,label:"Align right"}];function aa(e){return Math.min(Ro,Math.max(Bo,Math.round(e)))}function ca({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(Tt,{size:14})," ",t||n]})}function ia({id:e}){const n=D(),t=te(e),[o,r]=f.useState(""),[l,s]=f.useState(!1),[c,i]=f.useState(null),u=f.useRef(null),d=f.useRef(null),p=f.useCallback(C=>n.applyOperation(z(e,C)),[n,e]),b=f.useCallback(async C=>{var N;const j=(N=C.target.files)==null?void 0:N[0];if(!j)return;const L=await bt(j);p({src:L,name:j.name,mimeType:j.type})},[p]),m=f.useCallback(async C=>{var N;C.preventDefault(),s(!1);const j=(N=C.dataTransfer.files)==null?void 0:N[0];if(!j)return;const L=await bt(j);p({src:L,name:j.name,mimeType:j.type})},[p]),h=f.useCallback(C=>{C.preventDefault(),s(!0)},[]),g=f.useCallback(()=>s(!1),[]),k=f.useCallback(()=>{const C=o.trim();C&&(p({src:C,name:C}),r(""))},[o,p]),x=f.useCallback(()=>p({src:"",name:"",mimeType:""}),[p]),y=f.useCallback(C=>{C.preventDefault();const j=u.current,L=d.current;if(!j||!L)return;const N=j.getBoundingClientRect().width,A=L.getBoundingClientRect().width,K=C.clientX,q=W=>aa((A+(W.clientX-K))/N*100),H=W=>i(q(W)),$=W=>{document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",$),p({width:q(W)}),i(null)};document.addEventListener("mousemove",H),document.addEventListener("mouseup",$)},[p]);if(!t)return null;const{kind:I="file",src:E,name:T,align:S="left",width:w=100}=t.props,B=I==="image"||I==="video",v=c??w;return a.jsx("div",{className:"be-embed","data-block-id":e,"data-kind":I,contentEditable:!1,tabIndex:-1,children:E?a.jsx("div",{ref:u,className:`be-embed-preview be-embed-align-${S}`,children:a.jsxs("div",{ref:d,className:"be-embed-frame",style:B?{width:`${v}%`}:void 0,children:[a.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[sa.map(({value:C,Icon:j,label:L})=>a.jsx("button",{type:"button",className:`be-embed-toolbar-btn${S===C?" be-embed-toolbar-btn-active":""}`,title:L,"aria-label":L,"aria-pressed":S===C,onClick:()=>p({align:C}),children:a.jsx(j,{size:14})},C)),a.jsx("button",{type:"button",className:"be-embed-remove",onClick:x,"aria-label":`Remove ${en[I]}`,children:"Remove"})]}),a.jsx(ca,{kind:I,src:E,name:T}),B&&a.jsx("div",{className:"be-embed-resize-handle",onMouseDown:y,role:"slider","aria-label":`Resize ${en[I]}`,"aria-valuemin":Bo,"aria-valuemax":Ro,"aria-valuenow":v})]})}):a.jsxs("div",{className:`be-embed-dropzone${l?" be-embed-dropzone-active":""}`,onDrop:m,onDragOver:h,onDragLeave:g,children:[a.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",en[I],a.jsx("input",{type:"file",accept:la[I],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://... ${en[I]} URL`,value:o,onChange:C=>r(C.target.value),onKeyDown:C=>C.key==="Enter"&&k()}),a.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:k,children:"Embed"})]})]})})}function ua({kind:e="file",src:n="",name:t="",mimeType:o="",align:r="left",width:l=100}={}){return function(c){return{block:{id:R(),type:"embed",parentId:c,contentIds:[],props:{kind:e,src:n,name:t,mimeType:o,align:r,width:l}},runs:[]}}}const da={image:qr,video:Wr,audio:Vr,file:Tt},To="be-embed-file-link";function pa(e,n,t){if(e!=="image"&&e!=="video")return"";const o=[];return t!==100&&o.push(`width:${t}%`),n==="center"?o.push("display:block","margin-left:auto","margin-right:auto"):n==="right"&&o.push("display:block","margin-left:auto"),o.length?` style="${o.join(";")}"`:""}function ht(e){var r,l,s,c;const n=(r=e.style)==null?void 0:r.width,t=n&&n.endsWith("%")?parseInt(n,10):100;let o="left";return((l=e.style)==null?void 0:l.marginLeft)==="auto"&&((s=e.style)==null?void 0:s.marginRight)==="auto"?o="center":((c=e.style)==null?void 0:c.marginLeft)==="auto"&&(o="right"),{align:o,width:Number.isFinite(t)?t:100}}function fa(e){const{kind:n,src:t,name:o,align:r="left",width:l=100}=e.props;if(!t)return"<p></p>";const s=pa(n,r,l);return n==="image"?`<img src="${ae(t)}" alt="${ae(o||"")}"${s}>`:n==="video"?`<video src="${ae(t)}" controls${s}></video>`:n==="audio"?`<audio src="${ae(t)}" controls></audio>`:`<a class="${To}" href="${ae(t)}">${je(o||t)}</a>`}function ba(e){const{kind:n,src:t,name:o}=e.props;return t?`[${n}: ${o||t}]`:""}function ha(e){return e.tagName==="IMG"?nn("image",e.getAttribute("src")??"",e.getAttribute("alt")??"",ht(e)):e.tagName==="VIDEO"?nn("video",e.getAttribute("src")??"","",ht(e)):e.tagName==="AUDIO"?nn("audio",e.getAttribute("src")??"",""):e.tagName==="A"&&e.classList.contains(To)?nn("file",e.getAttribute("href")??"",e.textContent??""):null}function nn(e,n,t,{align:o="left",width:r=100}={}){return{block:{id:R(),type:"embed",parentId:null,contentIds:[],props:{kind:e,src:n,name:t,align:o,width:r}},runs:[]}}function ma(e){return(n,{blockId:t,runId:o,sliceStart:r,sliceEnd:l})=>{const s=n.getRun(o),c=(s==null?void 0:s.value)??"";n.applyOperation(X(o,{value:c.slice(0,r)+c.slice(l)}));const i=Hn(n,t,ua({kind:e}));return ye(n,i,P("paragraph")),i}}const jo={component:ia,isLeaf:!0,defaultProps:{kind:"file",src:"",name:"",mimeType:"",align:"left",width:100},toHTML:fa,toPlainText:ba,fromHTML:ha,slashCommands:["image","video","audio","file"].map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),icon:da[e],keywords:["embed","upload","insert",e],run:ma(e)}))};function ga(e){So(e,{paragraph:Ht,heading:zt,listItem:Xt,...Eo,...Oo,divider:go,callout:xo,blockquote:yo,code:vo,toggleHeading:Io,button:Co,embed:jo})}function So(e,n){for(const[t,o]of Object.entries(n))e.register(t,o)}const Eo={table:po,tableRow:uo,tableCell:io},Oo={layout:mo,layoutColumn:ho};function ka({id:e}){const n=D(),t=xe(e),o=f.useCallback(c=>{n.applyOperation(X(e,{data:{...t==null?void 0:t.data,selectedValue:c}}))},[n,e,t==null?void 0:t.data]);if(!t)return null;const{options:r=[],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(Ae,{value:l,options:r,onChange:o,placeholder:s,ariaLabel:"Select an option"})})}function mn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,o),u=c.slice(r),d=l(),p={...s,value:i},b={id:R(),type:"text",value:u,marks:{...s==null?void 0:s.marks}};e.applyOperation(Fe(n,[t],[p,d,b])),G(b.id)}function xa(e){return String(e).replace(/&/g,"&").replace(/"/g,""")}function Lo(e){var o;const{options:n=[],selectedValue:t=""}=e.data??{};return((o=n.find(r=>r.value===t))==null?void 0:o.label)??""}function ya(e){var t,o;const n=Lo(e)||((t=e.data)==null?void 0:t.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${xa(((o=e.data)==null?void 0:o.selectedValue)??"")}">${n}</span>`}function va(e){return Lo(e)}function Ia(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="select"?null:{id:R(),type:"select",value:"",marks:{},data:{options:[],selectedValue:e.getAttribute("data-selected-value")??""}}}const No={component:ka,isAtomic:!0,toHTML:ya,toPlainText:va,fromHTML:Ia,slashCommand:{label:"Select",icon:Kr,keywords:["select","dropdown","choice","picker"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>mn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:R(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}))}};function wa({id:e}){const n=D(),t=xe(e),o=f.useCallback(l=>{n.applyOperation(X(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:r=""}=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:r,onChange:o})})}function Ca(e){return String(e).replace(/&/g,"&").replace(/"/g,""")}function Mo(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 Ba(e){var t;const n=((t=e.data)==null?void 0:t.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${Ca(n)}">${Mo(n)}</span>`}function Ra(e){var n;return Mo(((n=e.data)==null?void 0:n.isoDate)??"")}function Ta(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="date"?null:{id:R(),type:"date",value:"",marks:{},data:{isoDate:e.getAttribute("data-iso-date")??""}}}function ja(){return new Date().toISOString().slice(0,10)}const Ao={component:wa,isAtomic:!0,toHTML:Ba,toPlainText:Ra,fromHTML:Ta,slashCommand:{label:"Date",icon:Fr,keywords:["date","when","schedule","calendar"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>mn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:R(),type:"date",value:"",marks:{},data:{isoDate:ja()}}))}};function Sa({id:e}){const n=D(),t=xe(e),o=f.useCallback(c=>{n.applyOperation(X(e,{data:{...t==null?void 0:t.data,checked:c.target.checked}}))},[n,e,t==null?void 0:t.data]),r=f.useCallback(c=>{n.applyOperation(X(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:o}),a.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:s,onChange:r,placeholder:"Label…"})]})}function Ea(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Oa(e){const{checked:n=!1,label:t=""}=e.data??{};return`<span data-inline-type="checkbox" data-checked="${n}">${n?"☑":"☐"} ${Ea(t)}</span>`}function La(e){const{checked:n=!1,label:t=""}=e.data??{};return`${n?"[x]":"[ ]"} ${t}`.trim()}function Na(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="checkbox"?null:{id:R(),type:"checkbox",value:"",marks:{},data:{checked:e.getAttribute("data-checked")==="true",label:(e.textContent??"").replace(/^[☑☐]\s*/,"")}}}const Do={component:Sa,isAtomic:!0,toHTML:Oa,toPlainText:La,fromHTML:Na,slashCommand:{label:"Checkbox",icon:Lt,keywords:["checkbox","todo","check","toggle"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>mn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:R(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function Ma({id:e,blockId:n}){var m;const t=D(),o=xe(e),r=n?t.getBlock(n):null,l=r?t.getBlock(r.parentId):null,s=(l==null?void 0:l.parentId)??null,c=te(s),i=l?l.contentIds.indexOf(n):-1,d=(((m=(c&&l?ce(c,l.contentIds.length):[])[i])==null?void 0:m.options)??[]).map((h,g)=>({...h,color:h.color??Ue(g)})),p=f.useCallback((h,g)=>{t.applyOperation(X(e,{data:{selectedValue:h,selectedLabel:(g==null?void 0:g.label)??""}}))},[t,e]);if(!o)return null;const{selectedValue:b=""}=o.data??{};return a.jsx("span",{className:"be-inline-table-select",onMouseDown:h=>{h.preventDefault(),h.stopPropagation()},onKeyDown:h=>h.stopPropagation(),children:a.jsx(Ae,{value:b,options:d,onChange:p,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function _o(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Aa(e){return _o(e).replace(/"/g,""")}function Da(e){const{selectedValue:n="",selectedLabel:t=""}=e.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${Aa(n)}">${_o(t)}</span>`}function _a(e){var n;return((n=e.data)==null?void 0:n.selectedLabel)??""}function Pa(e){var n;return((n=e.getAttribute)==null?void 0:n.call(e,"data-inline-type"))!=="tableSelect"?null:{id:R(),type:"tableSelect",value:"",marks:{},data:{selectedValue:e.getAttribute("data-selected-value")??"",selectedLabel:e.textContent??""}}}const Po={component:Ma,isAtomic:!0,toHTML:Da,toPlainText:_a,fromHTML:Pa},$o={};function $a(e){Ho(e,{select:No,date:Ao,checkbox:Do,...zo,emoji:$o})}function Ho(e,n){for(const[t,o]of Object.entries(n))e.register(t,o)}const zo={tableSelect:Po},Ha="$fieldTypes";function Uo(){const e=D(),n=f.useCallback(o=>e.subscribe(Ha,o),[e]),t=f.useCallback(()=>e.getFieldTypes(),[e]);return f.useSyncExternalStore(n,t)}const za={canUndo:!1,canRedo:!1};function Ua(){const{history:e}=be(),n=f.useCallback(r=>e?e.subscribeToHistory(r):()=>{},[e]),t=f.useCallback(()=>e?e.getUndoRedoSnapshot():za,[e]),o=f.useSyncExternalStore(n,t);return e?{...o,undo:()=>e.undo(),redo:()=>e.redo(),getHistoryLog:()=>e.getHistoryLog()}:null}const ln="application/x-block-editor-blocks+json";function Yn(e){return e.split(/\r\n|\r|\n/).filter(n=>n.length>0).map(n=>{const t=R();return{block:{id:R(),type:"paragraph",parentId:null,contentIds:[t],props:{}},runs:[{id:t,type:"text",value:n,marks:{}}]}})}function Fo(e,n,t){const o=new DOMParser().parseFromString(e,"text/html"),r={registry:n,inlineRegistry:t},l=n.listHtmlMatchers(),s=[],c=u=>{var b;const d=u.tagName==="OL",p=[];for(const m of u.children){if(m.tagName!=="LI")continue;const h=(b=n.get("listItem"))==null?void 0:b.fromHTML(m,r);h&&(h.block.props.ordered=d,p.push(h))}return p},i=u=>{var p;const d=Array.from(u.children).filter(b=>b.tagName==="P");if(d.length===0){const b=(p=n.get("blockquote"))==null?void 0:p.fromHTML(u,r);return b?[b]:[]}return d.map(b=>{const m=ue(b,r);return{block:{id:R(),type:"blockquote",parentId:null,contentIds:m.map(h=>h.id),props:{}},runs:m}})};for(const u of o.body.childNodes){if(u.nodeType===3){const p=u.textContent.trim();p&&s.push(...Yn(p));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 d=null;for(const p of l){const b=p.fromHTML(u,r);if(b){d=b;break}}if(d)s.push(d);else if(u.textContent.trim()){const p=ue(u,r);s.push({block:{id:R(),type:"paragraph",parentId:null,contentIds:p.map(b=>b.id),props:{}},runs:p})}}return s}function Ko(e,n,t){const o=e.types??[];if(o.includes(ln)){const l=e.getData(ln);if(l)return Fa(l)}if(o.includes("text/html")){const l=e.getData("text/html");if(l)return Fo(l,n,t)}const r=e.getData("text/plain")??"";return Yn(r)}function Fa(e){return JSON.parse(e).blocks.map(t=>Kn(t))}function wn(e,n){var o;const t=e.getBlock(n);return((o=t.props)==null?void 0:o.titleRunIds)??t.contentIds}function on(){return{id:R(),type:"text",value:"",marks:{}}}function Cn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Gn(e,n,t){const{startRunId:o,startOffset:r,endRunId:l,endOffset:s}=t,c=wn(e,n),i=c.indexOf(o),u=c.indexOf(l);if(i===-1||u===-1)return null;const[d,p]=i<=u?[i,u]:[u,i],b=i<=u?r:s,m=i<=u?s:r,h=c.slice(0,d).map(T=>e.getRun(T)),g=c.slice(p+1).map(T=>e.getRun(T)),k=c.slice(d,p+1).map(T=>e.getRun(T)),x=[];let y=null,I=0;if(d===p){const T=k[0];if(T.type==="text"){const S=Math.max(0,Math.min(b,m)),w=Math.min(T.value.length,Math.max(b,m)),B={...T,value:T.value.slice(0,S)+T.value.slice(w)};x.push(B),y=B.id,I=S}}else k.forEach((T,S)=>{if(T.type!=="text")return;const w=S===0,B=S===k.length-1,v=w?T.value.slice(0,b):"";if(w&&v){const C={...T,value:v};x.push(C),y=C.id,I=v.length}if(B&&!w){const C=T.value.slice(m);if(C){const j={id:R(),type:"text",value:C,marks:T.marks};x.push(j),y===null&&(y=j.id,I=0)}}});let E=[...h,...x,...g];if(E.length===0){const T=on();E=[T],y=T.id,I=0}else if(y===null){const T=h[h.length-1];T?(y=T.id,I=T.type==="text"?T.value.length:0):g[0]&&(y=g[0].id,I=0)}return e.applyOperation(le(n,E)),{blockId:n,runId:y,offset:I}}function Xn(e,n){const{blockIds:t,startBlockId:o,startRunId:r,startOffset:l,endBlockId:s,endRunId:c,endOffset:i}=n;if(!t||t.length===0)return null;const u=t.indexOf(o),d=t.indexOf(s);if(u===-1||d===-1)return null;const[p,b]=u<=d?[u,d]:[d,u],m=u<=d,h=m?r:c,g=m?l:i,k=m?c:r,x=m?i:l;if(p===b)return Gn(e,t[p],{startRunId:h,startOffset:g,endRunId:k,endOffset:x});const y=t[p],I=t[b],E=e.getBlock(y),T=e.getBlock(I),S=wn(e,y),w=S.indexOf(h),B=S.slice(0,w).map(V=>e.getRun(V)),v=e.getRun(h),C=v.type==="text"&&g>0?{...v,value:v.value.slice(0,g)}:null,j=wn(e,I),L=j.indexOf(k),N=j.slice(L+1).map(V=>e.getRun(V)),A=e.getRun(k),K=A.type==="text"&&x<A.value.length?{id:R(),type:"text",value:A.value.slice(x),marks:A.marks}:null,q=[...B,...C?[C]:[]],H=[...K?[K]:[],...N],$=[];for(let V=p+1;V<b;V+=1)$.push(_(t[V]));const W=$t(E.type,T.type),J=e.getBlock(E.parentId),oe=b-p-1+(W?1:0),Be=J&&J.contentIds.length-oe===1;let Q,re,de;if(W){const V=[...q,...H];if(V.length===0&&Be&&E.type!=="paragraph"){const{block:F,runs:ie}=P("paragraph")(J.id);return $.push({type:"insertBlock",block:F,parentId:J.id,index:0,subtree:{blocks:[F],runs:ie}}),$.push(_(y)),$.push(_(I)),Cn(e,$),{blockId:F.id,runId:F.contentIds[0],offset:0}}const O=V.length?V:[on()];if($.push(le(y,O)),$.push(_(I)),de=y,C)Q=C.id,re=C.value.length;else if(B.length){const F=B[B.length-1];Q=F.id,re=F.type==="text"?F.value.length:0}else K?(Q=K.id,re=0):N.length?(Q=N[0].id,re=0):(Q=O[0].id,re=0)}else{const V=q.length?q:[on()];if($.push(le(y,V)),$.push(le(I,H.length?H:[on()])),de=y,C)Q=C.id,re=C.value.length;else if(B.length){const O=B[B.length-1];Q=O.id,re=O.type==="text"?O.value.length:0}else Q=V[0].id,re=0}return Cn(e,$),{blockId:de,runId:Q,offset:re}}function sn(e,n=""){var c;const t=e.getRootId(),o=((c=e.getBlock(t))==null?void 0:c.contentIds)??[];if(o.length===0)return null;const r=o.map(i=>_(i)),{block:l,runs:s}=P("paragraph")(t);return n&&(s[0].value=n),r.push(Y(l,t,0,{blocks:[l],runs:s})),Cn(e,r),{blockId:l.id,runId:l.contentIds[0],offset:n.length}}function qo(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function $e(e,n){n.length!==0&&qo(e,n.map(t=>_(t)))}function Wo(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const o=e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n[0]),l=o.contentIds.indexOf(n[n.length-1]);if(r<=0)return!1;const s=o.contentIds[r-1];return e.applyOperation(ge(s,t.parentId,l)),!0}function Vo(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const o=e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n[0]),l=o.contentIds.indexOf(n[n.length-1]);if(l===-1||l>=o.contentIds.length-1)return!1;const s=o.contentIds[l+1];return e.applyOperation(ge(s,t.parentId,r)),!0}function Yo(e,n){return n.length>0&&n.every(t=>{var o,r;return!!((r=(o=e.getBlock(t))==null?void 0:o.props)!=null&&r.hidden)})}function Go(e,n,t){n.length!==0&&qo(e,n.map(o=>z(o,{hidden:t})))}function Bn(e,n){if(n.length===0)return[];const t=e.getBlock(n[0]),o=t&&e.getBlock(t.parentId);if(!o)return n;const r=new Set(n);return o.contentIds.filter(l=>r.has(l))}function Rn(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 Ka(e){var p;const n=(p=window.getSelection)==null?void 0:p.call(window);if(!n||n.rangeCount===0)return[];const t=Rn(n.anchorNode),o=Rn(n.focusNode);if(!t)return[];if(!o||t===o)return[t];const r=e.getBlock(t),l=r&&e.getBlock(r.parentId);if(!l)return[t];const s=l.contentIds,c=s.indexOf(t),i=s.indexOf(o);if(c===-1||i===-1)return[t];const[u,d]=c<=i?[c,i]:[i,c];return s.slice(u,d+1)}function mt(e){const n=Ge();if(n)return Gn(e,n.blockId,n);const t=ze(e);return t?Xn(e,t):null}function qa(e,n,t){const o=e.getRun(n.runId);if(!o||o.type!=="text")return null;const r=o.value??"",l=r.slice(0,n.offset)+t+r.slice(n.offset);return e.applyOperation(X(o.id,{value:l})),{blockId:n.blockId,runId:o.id,offset:n.offset+t.length}}function yn(e,n){if(typeof e.performBatch=="function")e.performBatch(n);else for(const t of n)e.applyOperation(t)}function Wa(){const e=D(),n=Ke(),t=ke(),[o,r]=Ln(),[l,s]=qe(),c=f.useCallback(d=>{var g;const p=o?((g=e.getBlock(e.getRootId()))==null?void 0:g.contentIds)??[]:l.length>0?l:Ka(e);if(p.length===0)return;const{html:b,text:m,json:h}=Fn(e,n,p,t);d.clipboardData.setData("text/plain",m),d.clipboardData.setData("text/html",b),d.clipboardData.setData(ln,h),d.preventDefault()},[e,n,t,o,l]),i=f.useCallback(d=>{if(c(d),o){const b=sn(e);r(!1),b!=null&&b.runId&&pe(b.runId,b.offset);return}if(l.length>0){$e(e,l),s([]);return}const p=mt(e);p!=null&&p.runId&&pe(p.runId,p.offset)},[c,e,o,r,l,s]),u=f.useCallback(d=>{var I,E,T;const p=Ko(d.clipboardData,n,t);if(p.length===0)return;if(o){const S=e.getRootId(),B=(((I=e.getBlock(S))==null?void 0:I.contentIds)??[]).map(C=>_(C));let v=0;for(const{block:C,runs:j,subtreeBlocks:L=[]}of p)C.parentId=S,B.push(Y(C,S,v,{blocks:[C,...L],runs:j})),v+=1;yn(e,B),r(!1),d.preventDefault();return}if(l.length>0){const S=e.getBlock(l[0]),w=(S==null?void 0:S.parentId)??null,B=w&&e.getBlock(w);let v=B?B.contentIds.indexOf(l[0]):0;const C=l.map(j=>_(j));for(const{block:j,runs:L,subtreeBlocks:N=[]}of p)j.parentId=w,C.push(Y(j,w,v,{blocks:[j,...N],runs:L})),v+=1;yn(e,C),s([]),d.preventDefault();return}const b=mt(e);if(p.length===1&&p[0].runs.every(S=>S.type==="text")&&(p[0].subtreeBlocks??[]).length===0){const S=b?{blockId:b.blockId,runId:b.runId,offset:b.offset}:Ye();if(S){const w=p[0].runs.map(v=>v.value).join(""),B=qa(e,S,w);if(B){pe(B.runId,B.offset),d.preventDefault();return}}}const h=(b==null?void 0:b.blockId)??Rn((T=(E=window.getSelection)==null?void 0:E.call(window))==null?void 0:T.anchorNode);if(!h)return;const g=e.getBlock(h);if(!g)return;let x=e.getBlock(g.parentId).contentIds.indexOf(h)+1;const y=[];for(const{block:S,runs:w,subtreeBlocks:B=[]}of p)S.parentId=g.parentId,y.push(Y(S,g.parentId,x,{blocks:[S,...B],runs:w})),x+=1;yn(e,y),d.preventDefault()},[e,n,t,o,r,l,s]);return{onCopy:c,onCut:i,onPaste:u}}const Va=["bold","italic","underline","strike","subscript","superscript","code"],Ya=["color","highlight","link"];function Se(e,n){var o;const t=e.getBlock(n);return((o=t.props)==null?void 0:o.titleRunIds)??t.contentIds}function Ga(e,n){return e===n?!0:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function Xo(e){var t;const n={};if(e.length===0)return n;for(const o of Va)n[o]=e.every(r=>{var l;return(l=r.marks)==null?void 0:l[o]});for(const o of Ya){const r=((t=e[0].marks)==null?void 0:t[o])??null;n[o]=e.every(l=>{var s;return Ga(((s=l.marks)==null?void 0:s[o])??null,r)})?r:null}return n}function Jo(e,n,t){const{startRunId:o,startOffset:r,endRunId:l,endOffset:s}=t,c=Se(e,n),i=c.indexOf(o),u=c.indexOf(l);if(i===-1||u===-1)return{};const[d,p]=i<=u?[i,u]:[u,i],b=c.slice(d,p+1).map(m=>e.getRun(m)).filter(m=>m&&m.type==="text");return Xo(b)}function Qo(e,n){const{blockIds:t,startBlockId:o,endBlockId:r}=n,l=t.indexOf(o),s=t.indexOf(r);if(l===-1||s===-1)return{};const[c,i]=l<=s?[l,s]:[s,l],u=[];for(let d=c;d<=i;d+=1)for(const p of Se(e,t[d])){const b=e.getRun(p);b&&b.type==="text"&&u.push(b)}return Xo(u)}function Zo(e,n){const t={...e};for(const[o,r]of Object.entries(n))r!=null?t[o]=r:delete t[o];return t}function er(e,n,t,o,r,l){const s=Zo(t.marks,l);if(o===0&&r===t.value.length)return e.applyOperation({type:"updateRun",id:t.id,patch:{marks:s}}),t.id;const c=t.value.slice(0,o),i=t.value.slice(o,r),u=t.value.slice(r),d=[];c&&d.push({id:R(),type:"text",value:c,marks:{...t.marks}});const p={id:R(),type:"text",value:i,marks:s};return d.push(p),u&&d.push({id:R(),type:"text",value:u,marks:{...t.marks}}),e.applyOperation(Fe(n,[t.id],d)),p.id}function Xa(e,n,t,o){const{startRunId:r,startOffset:l,endRunId:s,endOffset:c}=t,i=Se(e,n),u=i.indexOf(r),d=i.indexOf(s);if(u===-1||d===-1)return null;const[p,b]=u<=d?[u,d]:[d,u],m=u<=d?l:c,h=u<=d?c:l,g=i.slice(p,b+1),k=g.map(I=>e.getRun(I));if(p===b){const I=k[0];if(I.type!=="text")return I.id;const E=Math.max(0,Math.min(m,h)),T=Math.min(I.value.length,Math.max(m,h));return E===T?I.id:er(e,n,I,E,T,o)}const x=[];let y=null;return k.forEach((I,E)=>{if(I.type!=="text"){x.push(I),y=I.id;return}const T=E===0,S=E===k.length-1,w=T?m:0,B=S?h:I.value.length,v=I.value.slice(0,w),C=I.value.slice(w,B),j=I.value.slice(B);v&&x.push({id:R(),type:"text",value:v,marks:{...I.marks}});const L={id:R(),type:"text",value:C,marks:Zo(I.marks,o)};x.push(L),y=L.id,j&&x.push({id:R(),type:"text",value:j,marks:{...I.marks}})}),e.applyOperation(Fe(n,g,x)),y}function Ja(e,n,t,o){var h;const{startRunId:r,startOffset:l,endRunId:s,endOffset:c}=t,i=Se(e,n),u=i.indexOf(r),d=i.indexOf(s);if(u===-1||d===-1)return!0;const[p,b]=u<=d?[u,d]:[d,u],m=i.slice(p,b+1).map(g=>e.getRun(g)).filter(g=>g.type==="text");if(m.length===0)return!0;if(p===b){const g=Math.max(0,Math.min(l,c)),k=Math.min(m[0].value.length,Math.max(l,c));if(g===k)return!((h=m[0].marks)!=null&&h[o])}return!m.every(g=>{var k;return(k=g.marks)==null?void 0:k[o]})}function Qa(e,n,t,o,r,l){var p;const s=e.getRun(t),c=s.value??"",i=Math.max(0,Math.min(o,r)),u=Math.min(c.length,Math.max(o,r));if(i===u)return t;const d=!((p=s.marks)!=null&&p[l]);return er(e,n,s,i,u,{[l]:d?!0:null})}function Ee(e,n,t,o){return Xa(e,n,t,o)}function Jn(e,n,t,o){const r=Ja(e,n,t,o);return Ee(e,n,t,{[o]:r?!0:null})}function Qn(e,n,t){return an(e,n,o=>({[t]:o?null:!0}),t)}function an(e,n,t,o){var S;const{blockIds:r,startBlockId:l,startRunId:s,startOffset:c,endBlockId:i,endRunId:u,endOffset:d}=n;if(!r||r.length===0)return null;const p=r.indexOf(l),b=r.indexOf(i);if(p===-1||b===-1)return null;const[m,h]=p<=b?[p,b]:[b,p],g=p<=b,k=g?s:u,x=g?c:d,y=g?u:s,I=g?d:c;let E=t;if(typeof t=="function"){let w=!1,B=!0;for(let v=m;v<=h;v+=1){const C=Se(e,r[v]).map(j=>e.getRun(j)).filter(j=>j.type==="text");C.length!==0&&(w=!0,C.every(j=>{var L;return(L=j.marks)==null?void 0:L[o]})||(B=!1))}E=t(w&&B)}if(m===h)return Ee(e,r[m],{startRunId:k,startOffset:x,endRunId:y,endOffset:I},E);let T=null;for(let w=m;w<=h;w+=1){const B=r[w],v=Se(e,B),C=v[0],j=v[v.length-1],L=e.getRun(j),N=((S=L==null?void 0:L.value)==null?void 0:S.length)??0;let A;w===m&&w===h?A={startRunId:k,startOffset:x,endRunId:y,endOffset:I}:w===m?A={startRunId:k,startOffset:x,endRunId:j,endOffset:N}:w===h?A={startRunId:C,startOffset:0,endRunId:y,endOffset:I}:A={startRunId:C,startOffset:0,endRunId:j,endOffset:N},T=Ee(e,B,A,E)}return T}function nr(e,n){var o;const t=e.getBlock(n);return((o=t==null?void 0:t.props)==null?void 0:o.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function tr(e){const n=Ge();if(!n)return!1;const{blockId:t,startRunId:o,startOffset:r,endRunId:l,endOffset:s}=n,c=nr(e,t);if(c.length===0)return!1;const i=c.indexOf(o),u=c.indexOf(l);if(i===-1||u===-1)return!1;const[d,p]=i<=u?[i,u]:[u,i],b=i<=u?r:s,m=i<=u?s:r;if(d!==0||p!==c.length-1||b!==0)return!1;const h=e.getRun(c[c.length-1]),g=(h==null?void 0:h.type)==="text"?(h.value??"").length:1;return m===g}function Za(e){const n=Ye();return n?se(e,nr(e,n.blockId)):!1}function ec(e,n,t){var m,h;const o=e.getBlock(n);if(!o){t(null);return}const r=e.getBlock(o.parentId),l=r?r.contentIds.indexOf(n):-1,s=l>0?r.contentIds[l-1]:null,c=l!==-1&&l<r.contentIds.length-1?r.contentIds[l+1]:null;e.applyOperation(_(n)),t(null);const i=Ne(e),u=s??c??i;if(!u)return;const d=e.getBlock(u);if(We(e,d)){t(u),requestAnimationFrame(()=>{var g;return(g=document.querySelector(`[data-block-id="${u}"]`))==null?void 0:g.focus()});return}const p=(m=d==null?void 0:d.props)==null?void 0:m.titleRunIds,b=((h=d==null?void 0:d.contentIds)==null?void 0:h[d.contentIds.length-1])??(p==null?void 0:p[p.length-1]);b&&G(b)}const gt={b:"bold",i:"italic",u:"underline"};function nc(e){const n=D(),[t,o]=Ln(),{getSelectedBlockId:r,setSelectedBlockId:l}=he();f.useEffect(()=>{const s=e.current;if(!s)return;const c=u=>{var p,b;if(r()&&(u.key==="Backspace"||u.key==="Delete")&&!u.defaultPrevented){u.preventDefault(),u.stopPropagation(),ec(n,r(),l);return}if(r()&&u.key!=="Backspace"&&u.key!=="Delete"&&l(null),u.metaKey||u.ctrlKey){const m=u.key.toLowerCase();if(m==="z"&&!u.shiftKey){u.preventDefault(),(p=n.undo)==null||p.call(n);return}if(m==="z"&&u.shiftKey||m==="y"){u.preventDefault(),(b=n.redo)==null||b.call(n);return}if(m==="a"){if(t)return;(tr(n)||Za(n))&&(u.preventDefault(),o(!0));return}if(gt[m]){if(t)return;u.preventDefault();const h=gt[m],g=Ge();if(g){const x=Jn(n,g.blockId,g,h);x&&G(x);return}const k=ze(n);if(k){const x=Qn(n,k,h);x&&G(x)}}return}if(t){if(u.key==="Backspace"||u.key==="Delete"){u.preventDefault(),u.stopPropagation();const m=sn(n);o(!1),m!=null&&m.runId&&pe(m.runId,m.offset);return}if(u.key.length===1){u.preventDefault(),u.stopPropagation();const m=sn(n,u.key);o(!1),m!=null&&m.runId&&pe(m.runId,m.offset);return}if(o(!1),u.key==="Escape")return}if(u.key==="Backspace"||u.key==="Delete"){const m=ze(n);if(!m)return;u.preventDefault(),u.stopPropagation();const h=Xn(n,m);h!=null&&h.runId&&pe(h.runId,h.offset)}},i=()=>{t&&o(!1),r()&&l(null)};return s.addEventListener("keydown",c),s.addEventListener("mousedown",i),()=>{s.removeEventListener("keydown",c),s.removeEventListener("mousedown",i)}},[e,n,t,o,r,l])}async function Tn(e,n,t,o){var s,c,i;const{html:r,text:l}=Fn(e,n,o,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([r],{type:"text/html"})})]);return}await((i=(c=navigator.clipboard)==null?void 0:c.writeText)==null?void 0:i.call(c,l))}function tc(){const e=D(),n=Ke(),t=ke(),[o,r]=qe(),[l,s]=f.useState(null),c=f.useRef(null),i=o.length>0,u=f.useCallback(()=>r([]),[r]);f.useEffect(()=>{if(!i){s(null);return}const x=o[o.length-1],y=document.querySelector(`[data-block-row-id="${x}"]`);s((y==null?void 0:y.getBoundingClientRect())??null)},[i,o]),f.useEffect(()=>{if(!i)return;const x=I=>{var E,T,S;(E=c.current)!=null&&E.contains(I.target)||(S=(T=I.target).closest)!=null&&S.call(T,".be-block-gutter")||u()},y=I=>{I.key==="Escape"?u():(I.key==="Delete"||I.key==="Backspace")&&(I.preventDefault(),$e(e,o),u())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y)}},[i,e,o,u]);const d=f.useCallback(()=>{Tn(e,n,t,o)},[e,n,t,o]),p=f.useCallback(async()=>{await Tn(e,n,t,o),$e(e,o),u()},[e,n,t,o,u]),b=f.useCallback(()=>{$e(e,o),u()},[e,o,u]),m=f.useCallback(()=>{Wo(e,o)&&r(Bn(e,o))},[e,o,r]),h=f.useCallback(()=>{Vo(e,o)&&r(Bn(e,o))},[e,o,r]),g=Yo(e,o),k=f.useCallback(()=>{Go(e,o,!g),r(x=>[...x])},[e,o,g,r]);return!i||!l?null:Oe.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:d,children:[a.jsx(St,{size:15})," Copy"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:p,children:[a.jsx(Sr,{size:15})," Cut"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[a.jsx(Et,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:h,children:[a.jsx(Ot,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:k,children:[g?a.jsx(Nt,{size:15}):a.jsx(Mt,{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 oc=4;function rc(e,n,t){const o=e.getBlock(n);if(!o)return[];const r=e.getBlock(o.parentId);if(!r)return[n];const l=r.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 lc(){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 sc(e){const n=D(),[,t]=qe(),o=f.useRef(null),r=f.useRef(!1),l=f.useRef(null),s=f.useCallback(d=>{var m,h,g,k,x;if(!o.current)return;if(!r.current){const{x:y,y:I}=l.current??{x:d.clientX,y:d.clientY};if(Math.hypot(d.clientX-y,d.clientY-I)<oc)return;r.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(h=(m=window.getSelection)==null?void 0:m.call(window))==null||h.removeAllRanges()}(k=(g=window.getSelection)==null?void 0:g.call(window))==null||k.removeAllRanges(),d.preventDefault();const p=(x=document.elementFromPoint(d.clientX,d.clientY))==null?void 0:x.closest("[data-block-row-id]"),b=(p==null?void 0:p.getAttribute("data-block-row-id"))??null;t(rc(n,o.current,b))},[n,t]),c=f.useCallback(()=>{o.current=null,r.current=!1,l.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),i=f.useCallback((d,p)=>{o.current=d,r.current=!1,l.current={x:p.clientX,y:p.clientY}},[]),u=f.useCallback(d=>{var g,k;if(d.button!==0||lc()||(k=(g=d.target).closest)!=null&&k.call(g,"button, input, textarea, select"))return;const p=d.target.closest("[data-block-row-id]");if(p){if(d.target.closest(".be-block-row-content"))return;i(p.getAttribute("data-block-row-id"),d);return}const b=e==null?void 0:e.current;if(!b)return;const h=[...b.querySelectorAll("[data-block-row-id]")].find(x=>{const y=x.getBoundingClientRect();return d.clientY>=y.top&&d.clientY<=y.bottom});h&&i(h.getAttribute("data-block-row-id"),d)},[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 ac({minHeight:e=180,className:n="be-trailing-space"}){const t=D(),[o]=Nn(),r=f.useCallback(()=>{var u;if(o)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 d=Ne(t);d&&it(t,d);return}const i=t.getBlock(c);(i==null?void 0:i.type)==="paragraph"?it(t,c):ye(t,c,P("paragraph"))},[t,o]);return a.jsx("div",{className:n,style:{minHeight:e},onClick:r})}function cc(e,n,t,o){f.useEffect(()=>{if(!e||!n)return;const r=document.querySelector(`[data-run-id="${n}"]`);if(r)return r.setAttribute("aria-expanded","true"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-controls",o),t&&r.setAttribute("aria-activedescendant",t),()=>{r.removeAttribute("aria-expanded"),r.removeAttribute("aria-haspopup"),r.removeAttribute("aria-controls"),r.removeAttribute("aria-activedescendant")}},[e,n,t,o])}function ic({isOpen:e,rect:n,commands:t,runId:o,onSelect:r,onClose:l,menuId:s="be-slash-menu",ariaLabel:c="Slash commands"}){const[i,u]=f.useState(0),d=f.useRef(null);f.useEffect(()=>{u(0)},[t.length]),f.useEffect(()=>{var m,h;(h=(m=d.current)==null?void 0:m.scrollIntoView)==null||h.call(m,{block:"nearest"})},[i]),f.useEffect(()=>{if(!e)return;const m=h=>{h.key==="ArrowDown"?(h.preventDefault(),h.stopPropagation(),u(g=>Math.min(g+1,Math.max(t.length-1,0)))):h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),u(g=>Math.max(g-1,0))):h.key==="Enter"?(h.preventDefault(),h.stopPropagation(),t[i]&&r(t[i])):h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),l())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[e,t,i,r,l]);const b=t[i]?`${s}-option-${i}`:null;return cc(e,o,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((m,h)=>{const g=m.icon;return a.jsxs("div",{ref:h===i?d:void 0,id:`${s}-option-${h}`,role:"option","aria-selected":h===i,className:`be-slash-menu-item${h===i?" be-slash-menu-item-active":""}`,onMouseDown:k=>{k.preventDefault(),r(m)},onMouseEnter:()=>u(h),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:m.label})]},m.label)})})}function uc(e,n){var o;if(!n)return!0;const t=n.toLowerCase();return e.label.toLowerCase().includes(t)||((o=e.keywords)==null?void 0:o.some(r=>r.toLowerCase().includes(t)))}function dc(e,n){const t=n.anchorNode,o=n.anchorOffset;let r;if(t===e){r="";for(let l=0;l<o&&l<e.childNodes.length;l+=1)r+=e.childNodes[l].textContent??""}else t&&t.parentElement===e?r=(t.textContent??"").slice(0,o):r=e.textContent??"";return fe(r).length}function Zn(e,n,t){const o=D(),[r,l]=f.useState(null);f.useEffect(()=>{const u=e.current;if(!u)return;const d=()=>{var T,S,w,B;const b=(T=window.getSelection)==null?void 0:T.call(window),m=b==null?void 0:b.anchorNode;let h=(m==null?void 0:m.nodeType)===1?m:m==null?void 0:m.parentElement;for(;h&&typeof h.hasAttribute=="function"&&!h.hasAttribute("data-run-id");)h=h.parentElement;const g=(S=h==null?void 0:h.getAttribute)==null?void 0:S.call(h,"data-run-id");if(!g||!b){l(null);return}const k=dc(h,b),x=fe(h.textContent).slice(0,k),y=n.exec(x);if(!y){l(null);return}const I=(B=(w=h.closest)==null?void 0:w.call(h,"[data-block-id]"))==null?void 0:B.getAttribute("data-block-id");if(!I){l(null);return}const E=y.index+y[1].length;l({query:y[2],blockId:I,runId:g,sliceStart:E,sliceEnd:k,rect:h.getBoundingClientRect()})},p=b=>{b.key==="Escape"&&l(null)};return u.addEventListener("input",d),u.addEventListener("keydown",p),()=>{u.removeEventListener("input",d),u.removeEventListener("keydown",p)}},[e,n]);const s=r?t().filter(u=>uc(u,r.query)):[],c=f.useCallback(u=>{r&&(u.run(o,{blockId:r.blockId,runId:r.runId,sliceStart:r.sliceStart,sliceEnd:r.sliceEnd}),l(null))},[r,o]),i=f.useCallback(()=>l(null),[]);return{isOpen:!!r,query:(r==null?void 0:r.query)??"",rect:(r==null?void 0:r.rect)??null,runId:(r==null?void 0:r.runId)??null,commands:s,selectCommand:c,close:i}}const pc=/(^|\s)\/(\w*)$/;function fc(e){const n=Ke(),t=ke(),o=f.useCallback(()=>[...n.listSlashCommands(),...(t==null?void 0:t.listSlashCommands())??[]],[n,t]);return Zn(e,pc,o)}const bc=[{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 hc(e,{runId:n,sliceStart:t,sliceEnd:o},r){const l=e.getRun(n),s=(l==null?void 0:l.value)??"",c=s.slice(0,t)+r+s.slice(o);e.applyOperation(X(n,{value:c})),pe(n,t+r.length)}const mc=bc.map(({char:e,name:n,keywords:t})=>({label:`${e} ${n}`,keywords:t,run:(o,r)=>hc(o,r,e)})),gc=/(^|\s):(\w*)$/,kc=()=>mc;function xc(e){return Zn(e,gc,kc)}const yc=/(^|\s)@(\w*)$/;function vc(e){const n=ke(),t=f.useCallback(()=>(n==null?void 0:n.listAtCommands())??[],[n]);return Zn(e,yc,t)}const Ic=[{markName:"bold",Icon:xr,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:yr,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:vr,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:Cr,title:"Strikethrough"}],wc=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Cc=[{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 Bc({isOpen:e,rect:n,kind:t,selection:o,crossSelection:r,marks:l,store:s}){var T,S;const[c,i]=f.useState(null),[u,d]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{if(!c)return;const w=v=>{p.current&&!p.current.contains(v.target)&&i(null)},B=v=>{v.key==="Escape"&&i(null)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",B)}},[c]),f.useEffect(()=>{i(null)},[n,t]);const b=f.useCallback(w=>{const B=t==="same-block"?Ee(s,o.blockId,o,w):an(s,r,w);B&&G(B),i(null)},[s,t,o,r]),m=f.useCallback(w=>{const B=t==="same-block"?Jn(s,o.blockId,o,w):Qn(s,r,w);B&&G(B)},[s,t,o,r]),h=f.useCallback(w=>{const B=w==="subscript"?"superscript":"subscript",v=!l[w];b({[w]:v?!0:null,[B]:null})},[l,b]),g=f.useRef(null),k=f.useCallback(()=>{g.current={kind:t,selection:o,crossSelection:r},d(!0)},[t,o,r]),x=f.useCallback(()=>d(!1),[]),y=f.useCallback(w=>{const B=g.current;if(!B)return;const v=B.kind==="same-block"?Ee(s,B.selection.blockId,B.selection,w):an(s,B.crossSelection,w);v&&G(v),d(!1)},[s]),I=f.useCallback((w,B)=>y({link:{href:w,target:B}}),[y]),E=f.useCallback(()=>y({link:null}),[y]);return(!e||!n)&&!u?null:a.jsxs(a.Fragment,{children:[e&&n&&a.jsxs("div",{ref:p,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:w=>w.preventDefault(),children:[Ic.map(({markName:w,Icon:B,title:v})=>a.jsx("button",{type:"button",className:`be-floating-toolbar-btn${l[w]?" be-floating-toolbar-btn-active":""}`,title:v,"aria-label":v,"aria-pressed":!!l[w],onClick:()=>m(w),children:a.jsx(B,{})},w)),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:()=>i(w=>w==="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:wc.map(w=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:w.label,onClick:()=>b({color:w.value}),children:a.jsx("span",{style:{color:w.value||"#1a1a1a",fontWeight:700},children:"A"})},w.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(w=>w==="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:Cc.map(w=>a.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:w.value||"transparent"},title:w.label,onClick:()=>b({highlight:w.value})},w.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:k,children:a.jsx(wr,{})})]}),a.jsx(Rt,{isOpen:u,initialHref:((T=l.link)==null?void 0:T.href)??"",initialTarget:((S=l.link)==null?void 0:S.target)??"_self",hasExistingLink:!!l.link,onSave:I,onRemove:E,onClose:x})]})}function Rc(e){const n=D(),[t,o]=f.useState(null);return f.useEffect(()=>{const r=e.current;if(!r)return;const l=()=>{var d,p,b;const s=(d=window.getSelection)==null?void 0:d.call(window);if(!s||s.rangeCount===0||s.isCollapsed){o(null);return}if(!r.contains(s.anchorNode)||!r.contains(s.focusNode)){o(null);return}const c=((b=(p=s.getRangeAt(0)).getBoundingClientRect)==null?void 0:b.call(p))??{top:0,left:0,right:0,bottom:0,width:0,height:0},i=Ge();if(i){o({kind:"same-block",rect:c,selection:i,marks:Jo(n,i.blockId,i)});return}const u=ze(n);if(u){o({kind:"cross-block",rect:c,crossSelection:u,marks:Qo(n,u)});return}o(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:()=>o(null)}}function Tc({id:e,label:n,placeholder:t,variant:o,options:r,onManage:l,mention:s=!1}){const c=D(),i=xe(e),u=f.useCallback((m,h)=>{c.applyOperation(X(e,{data:{selectedValue:m,selectedLabel:(h==null?void 0:h.label)??"",selectedColor:h==null?void 0:h.color}}))},[c,e]);if(!i)return null;const{selectedValue:d="",selectedLabel:p="",selectedColor:b}=i.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onKeyDown:m=>m.stopPropagation(),children:a.jsx(Ae,{value:d,selectedLabel:p,selectedColor:b,options:r,onChange:u,placeholder:t,variant:o,ariaLabel:n,onManageOptions:l,mention:s})})}function or(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function kt(e){return or(e).replace(/"/g,""")}function rr({type:e,label:n,placeholder:t="Select…",variant:o="default",icon:r,options:l,onManage:s,triggers:c=["slash"],mention:i=c.includes("at")}){function u(h){var x,y;const g=((x=h.data)==null?void 0:x.selectedLabel)||"",k=i&&g?`@${g}`:g;return`<span data-inline-type="${kt(e)}" data-selected-value="${kt(((y=h.data)==null?void 0:y.selectedValue)??"")}">${or(k)}</span>`}function d(h){var k;const g=((k=h.data)==null?void 0:k.selectedLabel)??"";return i&&g?`@${g}`:g}function p(h){var x;if(((x=h.getAttribute)==null?void 0:x.call(h,"data-inline-type"))!==e)return null;const g=h.textContent??"",k=i&&g.startsWith("@")?g.slice(1):g;return{id:R(),type:e,value:"",marks:{},data:{selectedValue:h.getAttribute("data-selected-value")??"",selectedLabel:k}}}function b({id:h}){return a.jsx(Tc,{id:h,label:n,placeholder:t,variant:o,options:l,onManage:s,mention:i})}const m={label:n,icon:r,keywords:[n.toLowerCase(),"select","field"],run:(h,{blockId:g,runId:k,sliceStart:x,sliceEnd:y})=>mn(h,{blockId:g,runId:k,sliceStart:x,sliceEnd:y},()=>({id:R(),type:e,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}))};return{component:b,isAtomic:!0,toHTML:u,toPlainText:d,fromHTML:p,slashCommand:c.includes("slash")?m:void 0,atCommand:c.includes("at")?m:void 0}}function lr(e,n,{onManage:t}={}){for(const o of e.getFieldTypes())n.register(o.id,rr({type:o.id,label:o.label,placeholder:o.placeholder,variant:o.variant,options:o.options??[],onManage:t?()=>t(o.id):void 0}))}function sr(){const e=D(),n=ke(),t=Uo(),{openEdit:o}=Mn(),r=f.useRef([]);f.useEffect(()=>{if(!n)return;const l=new Set(t.map(s=>s.id));for(const s of r.current)l.has(s)||n.unregister(s);lr(e,n,{onManage:o}),r.current=[...l]},[e,n,t,o])}function jc(){sr();const e=D(),{target:n,close:t}=Mn(),o=n!==null,r=o&&n!=="new",[l,s]=f.useState(""),[c,i]=f.useState([]),[u,d]=f.useState("");f.useEffect(()=>{if(o){if(r){const k=e.getFieldType(n);s((k==null?void 0:k.label)??""),i((k==null?void 0:k.options)??[])}else s(""),i([]);d("")}},[o,r,n,e]);const p=f.useCallback((k,x)=>{i(y=>y.map(I=>I.value===k?{...I,label:x}:I))},[]),b=f.useCallback(k=>{i(x=>x.filter(y=>y.value!==k))},[]),m=f.useCallback(()=>{const k=u.trim();d(""),k&&i(x=>[...x,{value:R(),label:k,color:Ue(x.length)}])},[u]),h=f.useCallback(()=>{const k=l.trim();k&&(r?e.applyOperation(Sn(n,{label:k,options:c})):e.applyOperation(jn({id:R(),label:k,placeholder:"Select…",variant:"tag",options:c})),t())},[e,r,n,l,c,t]),g=f.useCallback(()=>{r&&e.applyOperation(En(n)),t()},[e,r,n,t]);return a.jsxs(cn,{isOpen:o,onClose:t,title:r?"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"}),c.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??Ue(x)).bg},"aria-hidden":"true"}),a.jsx("input",{className:"be-table-header-menu-option-input",value:k.label,onChange:y=>p(k.value,y.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(Ve,{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=>d(k.target.value),placeholder:"New option…",onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),m())}}),a.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:m,"aria-label":"Add option",children:"+"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[r&&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:h,children:"Save"})]})]})}exports.APP_MIME=ln;exports.BlockChildren=we;exports.BlockErrorBoundary=Ut;exports.BlockGutterRow=Vt;exports.BlockRangeActionMenu=tc;exports.BlockRegistry=xt;exports.BlockRenderer=Un;exports.COLUMN_TYPES=Jt;exports.DEFAULT_COLUMN_TYPE=fn;exports.DEFAULT_COLUMN_WIDTH=bn;exports.EditableBlockContent=me;exports.EditorProvider=mr;exports.EditorStore=On;exports.EditorTrailingSpace=ac;exports.FieldTypeEditorModal=jc;exports.FloatingToolbar=Bc;exports.History=pr;exports.InlineRegistry=yt;exports.LAYOUT_BLOCKS=Oo;exports.MIN_COLUMN_WIDTH=rn;exports.Modal=cn;exports.Select=Ae;exports.SlashMenu=ic;exports.TABLE_BLOCKS=Eo;exports.TABLE_SELECT_INLINE_TYPES=zo;exports.TableHeaderRow=ao;exports.blankRunForType=Qt;exports.blockquoteBlockType=yo;exports.buttonBlockType=Co;exports.calloutBlockType=xo;exports.checkboxInlineType=Do;exports.codeBlockType=vo;exports.convertRunToType=Zt;exports.copyBlockRangeToClipboard=Tn;exports.createBlockRegistry=fr;exports.createCellForColumn=hn;exports.createDefaultColumns=Wn;exports.createInlineRegistry=br;exports.createSelectFieldType=rr;exports.dateInlineType=Ao;exports.deleteBlockAndFocusSibling=qn;exports.deleteBlockRange=$e;exports.deleteColumn=oo;exports.deleteEntireDocument=sn;exports.deleteOverBlockRange=Xn;exports.deleteRow=to;exports.deleteRunRangeInBlock=Gn;exports.deserializeClipboard=Ko;exports.dividerBlockType=go;exports.duplicateBlock=Kt;exports.embedBlockType=jo;exports.emojiInlineType=$o;exports.ensureRootNonEmpty=Ne;exports.focusRunAtOffset=pe;exports.focusRunEnd=G;exports.focusRunStart=An;exports.getMarksSummaryOverBlockRange=Qo;exports.getMarksSummaryOverSelection=Jo;exports.headingBlockType=zt;exports.injectDefaultStyles=vt;exports.insertColumnAfter=In;exports.insertRowAfter=no;exports.isEntireBlockRangeHidden=Yo;exports.isEntireBlockSelected=tr;exports.layoutBlockType=mo;exports.layoutColumnBlockType=ho;exports.listItemBlockType=Xt;exports.moveBlockDown=Wt;exports.moveBlockRangeDown=Vo;exports.moveBlockRangeUp=Wo;exports.moveBlockUp=qt;exports.operations=ur;exports.paragraphBlockType=Ht;exports.registerBlocks=So;exports.registerBuiltInBlocks=ga;exports.registerBuiltInInlineTypes=$a;exports.registerInlineTypes=Ho;exports.registerStoredFieldTypes=lr;exports.remapSubtreeIds=Kn;exports.renameColumn=lo;exports.reorderBlockRangeFromStore=Bn;exports.resolveCollapsedCaret=Ye;exports.resolveColumns=ce;exports.resolveCrossBlockSelection=ze;exports.resolveMultiRunSelection=Ge;exports.resolveRunSelection=ol;exports.selectInlineType=No;exports.serializeBlockRange=Fn;exports.setBlockRangeHidden=Go;exports.setColumnOptions=tn;exports.setColumnType=so;exports.setColumnWidth=ro;exports.setMarksOverBlockRange=an;exports.setMarksOverSelection=Ee;exports.tableBlockType=po;exports.tableCellBlockType=io;exports.tableRowBlockType=uo;exports.tableSelectInlineType=Po;exports.textToParagraphs=Yn;exports.toggleHeadingBlockType=Io;exports.toggleMarkOnRunRange=Qa;exports.toggleMarkOverBlockRange=Qn;exports.toggleMarkOverSelection=Jn;exports.useAtMenuTrigger=vc;exports.useBlock=te;exports.useBlockChildren=zn;exports.useBlockRangeDrag=sc;exports.useBlockRangeSelection=qe;exports.useBlockRegistry=Ke;exports.useClipboardHandlers=Wa;exports.useEditorKeyboardShortcuts=nc;exports.useEditorStore=D;exports.useEmojiMenuTrigger=xc;exports.useFieldTypeEditor=Mn;exports.useFieldTypes=Uo;exports.useFloatingToolbarTrigger=Rc;exports.useHistory=Ua;exports.useInlineRegistry=ke;exports.usePreviewMode=Nn;exports.useRegisterFieldTypes=sr;exports.useRun=xe;exports.useSelectedBlock=he;exports.useSlashMenuTrigger=fc;exports.useWholeDocumentSelection=Ln;exports.walkDomToBlocks=Fo;
|
|
1887
|
+
${r}`:o}function Zs(e,n){if(e.tagName!=="DETAILS")return null;const t=[...e.children].find(d=>d.tagName==="SUMMARY"),o=t==null?void 0:t.querySelector("h1,h2,h3,h4,h5,h6"),r=o?Math.min(6,Math.max(1,Number(o.tagName[1]))):2,l=o?de(o,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:r,collapsed:!e.hasAttribute("open"),titleRunIds:l.map(d=>d.id)}},runs:[...l,...i],subtreeBlocks:c}}const wo={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:o}){const[r,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(o);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,o,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:r,marks:{}},x=p.filter(k=>k.key.trim());ea(t,[se(o,[g]),z(o,{href:s.trim(),color:i,customAttrs:x})]),n()},[t,o,r,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:r,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 oa({id:e}){var k,I,y,E;const n=D(),t=Q(e),{setSelectedBlockId:o}=ge(),[r,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,o)},[n,e,o]),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:r,onClose:()=>l(!1),store:n,blockId:e})]})}function ra({href:e="",label:n="Button",color:t="",customAttrs:o=[]}={}){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:o}},runs:i}}}const Co="be-button-block-link";function la(e,n){var i,u,p;const t=e.contentIds.map(d=>n.store.getRun(d)),o=((i=e.props)==null?void 0:i.href)??"",r=(u=e.props)==null?void 0:u.color,l=r?` style="background-color:${ce(r)}"`:"",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="${Co}" href="${ce(o)}"${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(Co))return null;const t=de(e,n),o=[];for(const s of e.attributes)s.name.startsWith("data-")&&o.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:o}},runs:t}}const Bo={component:oa,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:la,toPlainText:sa,fromHTML:aa,slashCommand:{label:"Button",icon:zr,keywords:["button","link","cta","action"],run:(e,n)=>ne(e,n,ra())}};function mt(e){return new Promise((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>t(o.error),o.readAsDataURL(e)})}const on={image:"image",video:"video",audio:"audio",file:"file"},ca={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},Ro=20,To=100,ia=[{value:"left",Icon:Sr,label:"Align left"},{value:"center",Icon:Er,label:"Align center"},{value:"right",Icon:Or,label:"Align right"}];function ua(e){return Math.min(To,Math.max(Ro,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),[o,r]=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=o.trim();B&&(d({src:B,name:B}),r(""))},[o,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 ${on[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 ${on[E]}`,"aria-valuemin":Ro,"aria-valuemax":To,"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 ",on[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://... ${on[E]} URL`,value:o,onChange:B=>r(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:o="",align:r="left",width:l=100}={}){return function(c){return{block:{id:T(),type:"embed",parentId:c,contentIds:[],props:{kind:e,src:n,name:t,mimeType:o,align:r,width:l}},runs:[]}}}const ba={image:Yr,video:Gr,audio:Xr,file:jt},jo="be-embed-file-link";function ma(e,n,t){if(e!=="image"&&e!=="video")return"";const o=[];return t!==100&&o.push(`width:${t}%`),n==="center"?o.push("display:block","margin-left:auto","margin-right:auto"):n==="right"&&o.push("display:block","margin-left:auto"),o.length?` style="${o.join(";")}"`:""}function ht(e){var r,l,s,c;const n=(r=e.style)==null?void 0:r.width,t=n&&n.endsWith("%")?parseInt(n,10):100;let o="left";return((l=e.style)==null?void 0:l.marginLeft)==="auto"&&((s=e.style)==null?void 0:s.marginRight)==="auto"?o="center":((c=e.style)==null?void 0:c.marginLeft)==="auto"&&(o="right"),{align:o,width:Number.isFinite(t)?t:100}}function ha(e){const{kind:n,src:t,name:o,align:r="left",width:l=100}=e.props;if(!t)return"<p></p>";const s=ma(n,r,l);return n==="image"?`<img src="${ce(t)}" alt="${ce(o||"")}"${s}>`:n==="video"?`<video src="${ce(t)}" controls${s}></video>`:n==="audio"?`<audio src="${ce(t)}" controls></audio>`:`<a class="${jo}" href="${ce(t)}">${Se(o||t)}</a>`}function ga(e){const{kind:n,src:t,name:o}=e.props;return t?`[${n}: ${o||t}]`:""}function xa(e){return e.tagName==="IMG"?rn("image",e.getAttribute("src")??"",e.getAttribute("alt")??"",ht(e)):e.tagName==="VIDEO"?rn("video",e.getAttribute("src")??"","",ht(e)):e.tagName==="AUDIO"?rn("audio",e.getAttribute("src")??"",""):e.tagName==="A"&&e.classList.contains(jo)?rn("file",e.getAttribute("href")??"",e.textContent??""):null}function rn(e,n,t,{align:o="left",width:r=100}={}){return{block:{id:T(),type:"embed",parentId:null,contentIds:[],props:{kind:e,src:n,name:t,align:o,width:r}},runs:[]}}function ka(e){return(n,{blockId:t,runId:o,sliceStart:r,sliceEnd:l})=>{const s=n.getRun(o),c=(s==null?void 0:s.value)??"";n.applyOperation(J(o,{value:c.slice(0,r)+c.slice(l)}));const i=zn(n,t,fa({kind:e}));return ve(n,i,$("paragraph")),i}}const So={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){Eo(e,{paragraph:Ft,heading:Ut,listItem:Jt,...Oo,...Lo,divider:xo,callout:yo,blockquote:vo,code:Io,toggleHeading:wo,button:Bo,embed:So})}function Eo(e,n){for(const[t,o]of Object.entries(n))e.register(t,o)}const Oo={table:fo,tableRow:po,tableCell:uo},Lo={layout:go,layoutColumn:ho};function va({id:e}){const n=D(),t=ye(e),o=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:r=[],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:r,onChange:o,placeholder:s,ariaLabel:"Select an option"})})}function xn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},l){const s=e.getRun(t),c=(s==null?void 0:s.value)??"",i=c.slice(0,o),u=c.slice(r),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,"&").replace(/"/g,""")}function No(e){var o;const{options:n=[],selectedValue:t=""}=e.data??{};return((o=n.find(r=>r.value===t))==null?void 0:o.label)??""}function wa(e){var t,o;const n=No(e)||((t=e.data)==null?void 0:t.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${Ia(((o=e.data)==null?void 0:o.selectedValue)??"")}">${n}</span>`}function Ca(e){return No(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 Mo={component:va,isAtomic:!0,toHTML:wa,toPlainText:Ca,fromHTML:Ba,slashCommand:{label:"Select",icon:Vr,keywords:["select","dropdown","choice","picker"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>xn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:T(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}))}};function Ra({id:e}){const n=D(),t=ye(e),o=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:r=""}=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:r,onChange:o})})}function Ta(e){return String(e).replace(/&/g,"&").replace(/"/g,""")}function Ao(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)}">${Ao(n)}</span>`}function Sa(e){var n;return Ao(((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 Do={component:Ra,isAtomic:!0,toHTML:ja,toPlainText:Sa,fromHTML:Ea,slashCommand:{label:"Date",icon:Wr,keywords:["date","when","schedule","calendar"],run:(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r})=>xn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:T(),type:"date",value:"",marks:{},data:{isoDate:Oa()}}))}};function La({id:e}){const n=D(),t=ye(e),o=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]),r=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:o}),a.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:s,onChange:r,placeholder:"Label…"})]})}function Na(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}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 _o={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:o,sliceEnd:r})=>xn(e,{blockId:n,runId:t,sliceStart:o,sliceEnd:r},()=>({id:T(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function _a({id:e,blockId:n}){var h;const t=D(),o=ye(e),r=n?t.getBlock(n):null,l=r?t.getBlock(r.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(!o)return null;const{selectedValue:b=""}=o.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 $o(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function $a(e){return $o(e).replace(/"/g,""")}function Pa(e){const{selectedValue:n="",selectedLabel:t=""}=e.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${$a(n)}">${$o(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 Po={component:_a,isAtomic:!0,toHTML:Pa,toPlainText:Ha,fromHTML:za},Ho={};function Fa(e){zo(e,{select:Mo,date:Do,checkbox:_o,...Fo,emoji:Ho})}function zo(e,n){for(const[t,o]of Object.entries(n))e.register(t,o)}const Fo={tableSelect:Po},Ua="$fieldTypes";function Uo(){const e=D(),n=f.useCallback(o=>e.subscribe(Ua,o),[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(r=>e?e.subscribeToHistory(r):()=>{},[e]),t=f.useCallback(()=>e?e.getUndoRedoSnapshot():Ka,[e]),o=f.useSyncExternalStore(n,t);return e?{...o,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 Ko(e,n,t){const o=new DOMParser().parseFromString(e,"text/html"),r={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,r);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,r);return b?[b]:[]}return p.map(b=>{const h=de(b,r);return{block:{id:T(),type:"blockquote",parentId:null,contentIds:h.map(m=>m.id),props:{}},runs:h}})};for(const u of o.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,r);if(b){p=b;break}}if(p)s.push(p);else if(u.textContent.trim()){const d=de(u,r);s.push({block:{id:T(),type:"paragraph",parentId:null,contentIds:d.map(b=>b.id),props:{}},runs:d})}}return s}function qo(e,n,t){const o=e.types??[];if(o.includes(cn)){const l=e.getData(cn);if(l)return Wa(l)}if(o.includes("text/html")){const l=e.getData("text/html");if(l)return Ko(l,n,t)}const r=e.getData("text/plain")??"";return Gn(r)}function Wa(e){return JSON.parse(e).blocks.map(t=>qn(t))}function Bn(e,n){var o;const t=e.getBlock(n);return((o=t.props)==null?void 0:o.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:o,startOffset:r,endRunId:l,endOffset:s}=t,c=Bn(e,n),i=c.indexOf(o),u=c.indexOf(l);if(i===-1||u===-1)return null;const[p,d]=i<=u?[i,u]:[u,i],b=i<=u?r:s,h=i<=u?s:r,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:o,startRunId:r,startOffset:l,endBlockId:s,endRunId:c,endOffset:i}=n;if(!t||t.length===0)return null;const u=t.indexOf(o),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?r:c,g=h?l:i,x=h?c:r,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),re=b-d-1+(W?1:0),Re=K&&K.contentIds.length-re===1;let Z,le,fe;if(W){const Y=[...V,...H];if(Y.length===0&&Re&&E.type!=="paragraph"){const{block:U,runs:ue}=$("paragraph")(K.id);return P.push({type:"insertBlock",block:U,parentId:K.id,index:0,subtree:{blocks:[U],runs:ue}}),P.push(_(I)),P.push(_(y)),Rn(e,P),{blockId:U.id,runId:U.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 U=w[w.length-1];Z=U.id,le=U.type==="text"?U.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(),o=((c=e.getBlock(t))==null?void 0:c.contentIds)??[];if(o.length===0)return null;const r=o.map(i=>_(i)),{block:l,runs:s}=$("paragraph")(t);return n&&(s[0].value=n),r.push(G(l,t,0,{blocks:[l],runs:s})),Rn(e,r),{blockId:l.id,runId:l.contentIds[0],offset:n.length}}function Wo(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&&Wo(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 o=e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n[0]),l=o.contentIds.indexOf(n[n.length-1]);if(r<=0)return!1;const s=o.contentIds[r-1];return e.applyOperation(ke(s,t.parentId,l)),!0}function Yo(e,n){if(n.length===0)return!1;const t=e.getBlock(n[0]);if(!t)return!1;const o=e.getBlock(t.parentId);if(!o)return!1;const r=o.contentIds.indexOf(n[0]),l=o.contentIds.indexOf(n[n.length-1]);if(l===-1||l>=o.contentIds.length-1)return!1;const s=o.contentIds[l+1];return e.applyOperation(ke(s,t.parentId,r)),!0}function Go(e,n){return n.length>0&&n.every(t=>{var o,r;return!!((r=(o=e.getBlock(t))==null?void 0:o.props)!=null&&r.hidden)})}function Xo(e,n,t){n.length!==0&&Wo(e,n.map(o=>z(o,{hidden:t})))}function Va(e,n){if(n.length===0)return[];const t=e.getBlock(n[0]),o=t&&e.getBlock(t.parentId);if(!o)return n;const r=new Set(n);return o.contentIds.filter(l=>r.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),o=Tn(n.focusNode);if(!t)return[];if(!o||t===o)return[t];const r=e.getBlock(t),l=r&&e.getBlock(r.parentId);if(!l)return[t];const s=l.contentIds,c=s.indexOf(t),i=s.indexOf(o);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=Ue(e);return t?Jn(e,t):null}function Ga(e,n,t){const o=e.getRun(n.runId);if(!o||o.type!=="text")return null;const r=o.value??"",l=r.slice(0,n.offset)+t+r.slice(n.offset);return e.applyOperation(J(o.id,{value:l})),{blockId:n.blockId,runId:o.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(),[o,r]=Nn(),[l,s]=We(),c=f.useCallback(p=>{var g;const d=o?((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,o,l]),i=f.useCallback(p=>{if(c(p),o){const b=un(e);r(!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,o,r,l,s]),u=f.useCallback(p=>{var y,E,R;const d=qo(p.clipboardData,n,t);if(d.length===0)return;if(o){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),r(!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,o,r,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 o;const t=e.getBlock(n);return((o=t.props)==null?void 0:o.titleRunIds)??t.contentIds}function Za(e,n){return e===n?!0:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function Jo(e){var t;const n={};if(e.length===0)return n;for(const o of Ja)n[o]=e.every(r=>{var l;return(l=r.marks)==null?void 0:l[o]});for(const o of Qa){const r=((t=e[0].marks)==null?void 0:t[o])??null;n[o]=e.every(l=>{var s;return Za(((s=l.marks)==null?void 0:s[o])??null,r)})?r:null}return n}function Qo(e,n,t){const{startRunId:o,startOffset:r,endRunId:l,endOffset:s}=t,c=Ee(e,n),i=c.indexOf(o),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 Jo(b)}function Zo(e,n){const{blockIds:t,startBlockId:o,endBlockId:r}=n,l=t.indexOf(o),s=t.indexOf(r);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 Jo(u)}function er(e,n){const t={...e};for(const[o,r]of Object.entries(n))r!=null?t[o]=r:delete t[o];return t}function nr(e,n,t,o,r,l){const s=er(t.marks,l);if(o===0&&r===t.value.length)return e.applyOperation({type:"updateRun",id:t.id,patch:{marks:s}}),t.id;const c=t.value.slice(0,o),i=t.value.slice(o,r),u=t.value.slice(r),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,o){const{startRunId:r,startOffset:l,endRunId:s,endOffset:c}=t,i=Ee(e,n),u=i.indexOf(r),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:nr(e,n,y,E,R,o)}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:er(y.marks,o)};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,o){var m;const{startRunId:r,startOffset:l,endRunId:s,endOffset:c}=t,i=Ee(e,n),u=i.indexOf(r),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[o])}return!h.every(g=>{var x;return(x=g.marks)==null?void 0:x[o]})}function tc(e,n,t,o,r,l){var d;const s=e.getRun(t),c=s.value??"",i=Math.max(0,Math.min(o,r)),u=Math.min(c.length,Math.max(o,r));if(i===u)return t;const p=!((d=s.marks)!=null&&d[l]);return nr(e,n,s,i,u,{[l]:p?!0:null})}function Oe(e,n,t,o){return ec(e,n,t,o)}function Qn(e,n,t,o){const r=nc(e,n,t,o);return Oe(e,n,t,{[o]:r?!0:null})}function Zn(e,n,t){return dn(e,n,o=>({[t]:o?null:!0}),t)}function dn(e,n,t,o){var S;const{blockIds:r,startBlockId:l,startRunId:s,startOffset:c,endBlockId:i,endRunId:u,endOffset:p}=n;if(!r||r.length===0)return null;const d=r.indexOf(l),b=r.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,r[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[o]})||(w=!1))}E=t(C&&w)}if(h===m)return Oe(e,r[h],{startRunId:x,startOffset:k,endRunId:I,endOffset:y},E);let R=null;for(let C=h;C<=m;C+=1){const w=r[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 tr(e,n){var o;const t=e.getBlock(n);return((o=t==null?void 0:t.props)==null?void 0:o.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function or(e){const n=Je();if(!n)return!1;const{blockId:t,startRunId:o,startOffset:r,endRunId:l,endOffset:s}=n,c=tr(e,t);if(c.length===0)return!1;const i=c.indexOf(o),u=c.indexOf(l);if(i===-1||u===-1)return!1;const[p,d]=i<=u?[i,u]:[u,i],b=i<=u?r:s,h=i<=u?s:r;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 oc(e){const n=Xe();return n?ae(e,tr(e,n.blockId)):!1}function rc(e,n,t){var h,m;const o=e.getBlock(n);if(!o){t(null);return}const r=e.getBlock(o.parentId),l=r?r.contentIds.indexOf(n):-1,s=l>0?r.contentIds[l-1]:null,c=l!==-1&&l<r.contentIds.length-1?r.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,o]=Nn(),{getSelectedBlockId:r,setSelectedBlockId:l}=ge();f.useEffect(()=>{const s=e.current;if(!s)return;const c=u=>{var d,b;if(r()&&(u.key==="Backspace"||u.key==="Delete")&&!u.defaultPrevented){u.preventDefault(),u.stopPropagation(),rc(n,r(),l);return}if(r()&&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;(or(n)||oc(n))&&(u.preventDefault(),o(!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=Ue(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);o(!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);o(!1),h!=null&&h.runId&&be(h.runId,h.offset);return}if(o(!1),u.key==="Escape")return}if(u.key==="Backspace"||u.key==="Delete"){const h=Ue(n);if(!h)return;u.preventDefault(),u.stopPropagation();const m=Jn(n,h);m!=null&&m.runId&&be(m.runId,m.offset)}},i=()=>{t&&o(!1),r()&&l(null)};return s.addEventListener("keydown",c),s.addEventListener("mousedown",i),()=>{s.removeEventListener("keydown",c),s.removeEventListener("mousedown",i)}},[e,n,t,o,r,l])}async function jn(e,n,t,o){var s,c,i;const{html:r,text:l}=Ze(e,n,o,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([r],{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(),[o,r]=We(),[l,s]=f.useState(null),c=f.useRef(null),i=o.length>0,u=f.useCallback(()=>r([]),[r]);f.useEffect(()=>{if(!i){s(null);return}const k=()=>{const I=o[o.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,o]),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,o),u())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",I)}},[i,e,o,u]);const p=f.useCallback(()=>{jn(e,n,t,o),u()},[e,n,t,o,u]),d=f.useCallback(async()=>{await jn(e,n,t,o),ze(e,o),u()},[e,n,t,o,u]),b=f.useCallback(()=>{ze(e,o),u()},[e,o,u]),h=f.useCallback(()=>{Vo(e,o),u()},[e,o,u]),m=f.useCallback(()=>{Yo(e,o),u()},[e,o,u]),g=Go(e,o),x=f.useCallback(()=>{Xo(e,o,!g),u()},[e,o,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(Nr,{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 o=e.getBlock(n);if(!o)return[];const r=e.getBlock(o.parentId);if(!r)return[n];const l=r.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(),o=f.useRef(null),r=f.useRef(!1),l=f.useRef(null),s=f.useCallback(p=>{var h,m,g,x,k;if(!o.current)return;if(!r.current){const{x:I,y}=l.current??{x:p.clientX,y:p.clientY};if(Math.hypot(p.clientX-I,p.clientY-y)<ac)return;r.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,o.current,b))},[n,t]),c=f.useCallback(()=>{o.current=null,r.current=!1,l.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),i=f.useCallback((p,d)=>{o.current=p,r.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(),[o]=Mn(),r=f.useCallback(()=>{var u;if(o)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,o]);return a.jsx("div",{className:n,style:{minHeight:e},onClick:r})}function rr(e,{pretty:n=!0}={}){const t=e.getRootId(),{blocks:o,runs:r}=Kn(e,t);return JSON.stringify({version:1,rootId:t,blocks:o,runs:r},null,n?2:0)}function lr(e,n,t){const o=e.getBlock(e.getRootId());return o?Ze(e,n,o.contentIds,t).html:""}function sr(e,n,t){const o=e.getBlock(e.getRootId());return o?Ze(e,n,o.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(),o=Ne(),r=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"?rr(t):c==="html"?lr(t,o,r):sr(t,o,r):"",[l,c,t,o,r]),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,o){f.useEffect(()=>{if(!e||!n)return;const r=document.querySelector(`[data-run-id="${n}"]`);if(r)return r.setAttribute("aria-expanded","true"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-controls",o),t&&r.setAttribute("aria-activedescendant",t),()=>{r.removeAttribute("aria-expanded"),r.removeAttribute("aria-haspopup"),r.removeAttribute("aria-controls"),r.removeAttribute("aria-activedescendant")}},[e,n,t,o])}function mc({isOpen:e,rect:n,commands:t,runId:o,onSelect:r,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]&&r(t[i])):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l())};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[e,t,i,r,l]);const b=t[i]?`${s}-option-${i}`:null;return bc(e,o,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(),r(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 o;if(!n)return!0;const t=n.toLowerCase();return e.label.toLowerCase().includes(t)||((o=e.keywords)==null?void 0:o.some(r=>r.toLowerCase().includes(t)))}function gc(e,n){const t=n.anchorNode,o=n.anchorOffset;let r;if(t===e){r="";for(let l=0;l<o&&l<e.childNodes.length;l+=1)r+=e.childNodes[l].textContent??""}else t&&t.parentElement===e?r=(t.textContent??"").slice(0,o):r=e.textContent??"";return me(r).length}function et(e,n,t){const o=D(),[r,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=r?t().filter(u=>hc(u,r.query)):[],c=f.useCallback(u=>{r&&(u.run(o,{blockId:r.blockId,runId:r.runId,sliceStart:r.sliceStart,sliceEnd:r.sliceEnd}),l(null))},[r,o]),i=f.useCallback(()=>l(null),[]);return{isOpen:!!r,query:(r==null?void 0:r.query)??"",rect:(r==null?void 0:r.rect)??null,runId:(r==null?void 0:r.runId)??null,commands:s,selectCommand:c,close:i}}const xc=/(^|\s)\/(\w*)$/;function kc(e){const n=Ne(),t=he(),o=f.useCallback(()=>[...n.listSlashCommands(),...(t==null?void 0:t.listSlashCommands())??[]],[n,t]);return et(e,xc,o)}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:o},r){const l=e.getRun(n),s=(l==null?void 0:l.value)??"",c=s.slice(0,t)+r+s.slice(o);e.applyOperation(J(n,{value:c})),be(n,t+r.length)}const Ic=yc.map(({char:e,name:n,keywords:t})=>({label:`${e} ${n}`,keywords:t,run:(o,r)=>vc(o,r,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:wr,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:Cr,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:Br,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:jr,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:o,crossSelection:r,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,o.blockId,o,C):dn(s,r,C);w&&X(w),i(null)},[s,t,o,r]),h=f.useCallback(C=>{const w=t==="same-block"?Qn(s,o.blockId,o,C):Zn(s,r,C);w&&X(w)},[s,t,o,r]),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:o,crossSelection:r},p(!0)},[t,o,r]),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(Tr,{})})]}),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,o]=f.useState(null);return f.useEffect(()=>{const r=e.current;if(!r)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){o(null);return}if(!r.contains(s.anchorNode)||!r.contains(s.focusNode)){o(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){o({kind:"same-block",rect:c,selection:i,marks:Qo(n,i.blockId,i)});return}const u=Ue(n);if(u){o({kind:"cross-block",rect:c,crossSelection:u,marks:Zo(n,u)});return}o(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:()=>o(null)}}function Nc({id:e,label:n,placeholder:t,variant:o,options:r,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:r,onChange:u,placeholder:t,variant:o,ariaLabel:n,onManageOptions:l,mention:s})})}function ar(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function kt(e){return ar(e).replace(/"/g,""")}function cr({type:e,label:n,placeholder:t="Select…",variant:o="default",icon:r,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)??"")}">${ar(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:o,options:l,onManage:s,mention:i})}const h={label:n,icon:r,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 ir(e,n,{onManage:t}={}){for(const o of e.getFieldTypes())n.register(o.id,cr({type:o.id,label:o.label,placeholder:o.placeholder,variant:o.variant,options:o.options??[],onManage:t?()=>t(o.id):void 0}))}function ur(){const e=D(),n=he(),t=Uo(),{openEdit:o}=An(),r=f.useRef([]);f.useEffect(()=>{if(!n)return;const l=new Set(t.map(s=>s.id));for(const s of r.current)l.has(s)||n.unregister(s);ir(e,n,{onManage:o}),r.current=[...l]},[e,n,t,o])}function Mc(){ur();const e=D(),{target:n,close:t}=An(),o=n!==null,r=o&&n!=="new",[l,s]=f.useState(""),[c,i]=f.useState([]),[u,p]=f.useState("");f.useEffect(()=>{if(o){if(r){const x=e.getFieldType(n);s((x==null?void 0:x.label)??""),i((x==null?void 0:x.options)??[])}else s(""),i([]);p("")}},[o,r,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&&(r?e.applyOperation(En(n,{label:x,options:c})):e.applyOperation(Sn({id:T(),label:x,placeholder:"Select…",variant:"tag",options:c})),t())},[e,r,n,l,c,t]),g=f.useCallback(()=>{r&&e.applyOperation(On(n)),t()},[e,r,n,t]);return a.jsxs(Ye,{isOpen:o,onClose:t,title:r?"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:[r&&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=Un;exports.COLUMN_TYPES=Qt;exports.DEFAULT_COLUMN_TYPE=mn;exports.DEFAULT_COLUMN_WIDTH=hn;exports.DocumentExportButton=fc;exports.EditableBlockContent=xe;exports.EditorProvider=yr;exports.EditorStore=Ln;exports.EditorTrailingSpace=dc;exports.FieldTypeEditorModal=Mc;exports.FloatingToolbar=Oc;exports.History=hr;exports.InlineRegistry=vt;exports.LAYOUT_BLOCKS=Lo;exports.MIN_COLUMN_WIDTH=an;exports.Modal=Ye;exports.Select=_e;exports.SlashMenu=mc;exports.TABLE_BLOCKS=Oo;exports.TABLE_SELECT_INLINE_TYPES=Fo;exports.TableHeaderRow=co;exports.blankRunForType=Zt;exports.blockquoteBlockType=vo;exports.buttonBlockType=Bo;exports.calloutBlockType=yo;exports.checkboxInlineType=_o;exports.codeBlockType=Io;exports.convertRunToType=eo;exports.copyBlockRangeToClipboard=jn;exports.createBlockRegistry=gr;exports.createCellForColumn=gn;exports.createDefaultColumns=Vn;exports.createInlineRegistry=xr;exports.createSelectFieldType=cr;exports.dateInlineType=Do;exports.deleteBlockAndFocusSibling=Wn;exports.deleteBlockRange=ze;exports.deleteColumn=ro;exports.deleteEntireDocument=un;exports.deleteOverBlockRange=Jn;exports.deleteRow=oo;exports.deleteRunRangeInBlock=Xn;exports.deserializeClipboard=qo;exports.dividerBlockType=xo;exports.duplicateBlock=qt;exports.embedBlockType=So;exports.emojiInlineType=Ho;exports.ensureRootNonEmpty=Ae;exports.exportDocumentHTML=lr;exports.exportDocumentJSON=rr;exports.exportDocumentText=sr;exports.focusRunAtOffset=be;exports.focusRunEnd=X;exports.focusRunStart=Dn;exports.getMarksSummaryOverBlockRange=Zo;exports.getMarksSummaryOverSelection=Qo;exports.headingBlockType=Ut;exports.injectDefaultStyles=It;exports.insertColumnAfter=Cn;exports.insertRowAfter=to;exports.isEntireBlockRangeHidden=Go;exports.isEntireBlockSelected=or;exports.layoutBlockType=go;exports.layoutColumnBlockType=ho;exports.listItemBlockType=Jt;exports.moveBlockDown=Vt;exports.moveBlockRangeDown=Yo;exports.moveBlockRangeUp=Vo;exports.moveBlockUp=Wt;exports.operations=br;exports.paragraphBlockType=Ft;exports.registerBlocks=Eo;exports.registerBuiltInBlocks=ya;exports.registerBuiltInInlineTypes=Fa;exports.registerInlineTypes=zo;exports.registerStoredFieldTypes=ir;exports.remapSubtreeIds=qn;exports.renameColumn=so;exports.reorderBlockRangeFromStore=Va;exports.resolveCollapsedCaret=Xe;exports.resolveColumns=ie;exports.resolveCrossBlockSelection=Ue;exports.resolveMultiRunSelection=Je;exports.resolveRunSelection=sl;exports.selectInlineType=Mo;exports.serializeBlockRange=Ze;exports.setBlockRangeHidden=Xo;exports.setColumnOptions=ln;exports.setColumnType=ao;exports.setColumnWidth=lo;exports.setMarksOverBlockRange=dn;exports.setMarksOverSelection=Oe;exports.tableBlockType=fo;exports.tableCellBlockType=uo;exports.tableRowBlockType=po;exports.tableSelectInlineType=Po;exports.textToParagraphs=Gn;exports.toggleHeadingBlockType=wo;exports.toggleMarkOnRunRange=tc;exports.toggleMarkOverBlockRange=Zn;exports.toggleMarkOverSelection=Qn;exports.useAtMenuTrigger=Tc;exports.useBlock=Q;exports.useBlockChildren=Fn;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=Uo;exports.useFloatingToolbarTrigger=Lc;exports.useHistory=qa;exports.useInlineRegistry=he;exports.usePreviewMode=Mn;exports.useRegisterFieldTypes=ur;exports.useRun=ye;exports.useSelectedBlock=ge;exports.useSlashMenuTrigger=kc;exports.useWholeDocumentSelection=Nn;exports.walkDomToBlocks=Ko;
|
|
1821
1888
|
//# sourceMappingURL=noteloom.cjs.map
|