@pubwave/editor 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";var Wo=Object.create;var pn=Object.defineProperty;var Vo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Yo=Object.getPrototypeOf,Ko=Object.prototype.hasOwnProperty;var Xo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Go(t))!Ko.call(e,r)&&r!==n&&pn(e,r,{get:()=>t[r],enumerable:!(o=Vo(t,r))||o.enumerable});return e};var Jo=(e,t,n)=>(n=e!=null?Wo(Yo(e)):{},Xo(t||!e||!e.__esModule?pn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("@tiptap/core"),Zo=require("@tiptap/extension-placeholder"),Qo=require("@tiptap/extension-history"),er=require("@tiptap/extension-dropcursor"),tr=require("@tiptap/extension-gapcursor"),nr=require("@tiptap/extension-document"),or=require("@tiptap/extension-paragraph"),rr=require("@tiptap/extension-text"),ar=require("@tiptap/extension-heading"),ir=require("@tiptap/extension-bullet-list"),sr=require("@tiptap/extension-ordered-list"),lr=require("@tiptap/extension-list-item"),cr=require("@tiptap/extension-task-list"),ur=require("@tiptap/extension-task-item"),dr=require("@tiptap/extension-table"),pr=require("@tiptap/extension-table-row"),fr=require("@tiptap/extension-table-header"),hr=require("@tiptap/extension-table-cell"),br=require("@tiptap/extension-blockquote"),vr=require("@tiptap/extension-code-block"),gr=require("@tiptap/extension-horizontal-rule"),mr=require("@tiptap/extension-hard-break"),Ae=require("@tiptap/react"),i=require("react/jsx-runtime"),x=require("react"),xr=require("react-dom"),yr=require("@tiptap/extension-image"),je=require("@tiptap/pm/state"),wr=require("@tiptap/extension-bold"),kr=require("@tiptap/extension-italic"),Cr=require("@tiptap/extension-underline"),Tr=require("@tiptap/extension-strike"),Lr=require("@tiptap/extension-code"),Br=require("@tiptap/extension-link"),Ar=require("@tiptap/suggestion"),jr=[{value:"bar",label:"bar"},{value:"line",label:"line"},{value:"pie",label:"pie"},{value:"doughnut",label:"doughnut"},{value:"radar",label:"radar"},{value:"polarArea",label:"polarArea"}];function Sr(e){return{backgroundColor:`rgba(59, 130, 246, ${.5+e%3*.2})`,borderColor:"rgba(59, 130, 246, 1)"}}function Mr({initialData:e,onSave:t,onCancel:n,locale:o}){var B,_,b,L,M,E,$,q,H;const[r,a]=x.useState(e.type),[s,l]=x.useState(((b=(_=(B=e.options)==null?void 0:B.plugins)==null?void 0:_.title)==null?void 0:b.text)??""),[c,f]=x.useState(((E=(M=(L=e.options)==null?void 0:L.plugins)==null?void 0:M.legend)==null?void 0:E.display)??!0),[u,m]=x.useState(((H=(q=($=e.options)==null?void 0:$.plugins)==null?void 0:q.legend)==null?void 0:H.position)??"bottom"),[h,v]=x.useState(e.data.labels),[p,g]=x.useState(e.data.datasets),C=x.useRef(null),y=(o==null?void 0:o.chart)||{modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Label",datasetLabelPlaceholder:"Dataset label...",data:"Data",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}};x.useEffect(()=>{const P=R=>{R.key==="Escape"&&n()};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[n]),x.useEffect(()=>{const P=W=>{C.current&&C.current.contains(W.target)},R=setTimeout(()=>{document.addEventListener("mousedown",P)},100);return()=>{clearTimeout(R),document.removeEventListener("mousedown",P)}},[]);const S=x.useCallback((P,R)=>{g(W=>W.map((V,J)=>J===P?{...V,label:R}:V))},[]),T=x.useCallback((P,R)=>{g(W=>W.map((V,J)=>J===P?{...V,data:R.split(",").map(Z=>parseFloat(Z.trim())||0)}:V))},[]),d=x.useCallback(()=>{const P=Sr(p.length);g(R=>[...R,{label:`${y.modal.fields.datasets.title} ${R.length+1}`,data:h.map(()=>Math.floor(Math.random()*100)),backgroundColor:P.backgroundColor,borderColor:P.borderColor,borderWidth:2}])},[p.length,h,y]),A=x.useCallback(P=>{g(R=>R.filter((W,V)=>V!==P))},[]),k=x.useCallback(P=>{v(P.split(",").map(R=>R.trim()).filter(Boolean))},[]),j=x.useCallback(()=>{const P={type:r,data:{labels:h,datasets:p},options:{...e.options,responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!!s,text:s,color:"var(--pubwave-text, #37352f)",font:{size:16,weight:"bold"}},legend:{display:c,position:u}}}};t(P)},[r,s,c,u,h,p,e.options,t]),I=x.useCallback(P=>{P.target===P.currentTarget&&n()},[n]),N=i.jsx("div",{className:"pubwave-modal__overlay",onClick:I,children:i.jsxs("div",{ref:C,className:"pubwave-modal__container",role:"dialog","aria-modal":"true","aria-labelledby":"chart-modal-title",children:[i.jsxs("div",{className:"pubwave-modal__header",children:[i.jsx("h2",{id:"chart-modal-title",className:"pubwave-modal__title",children:y.modal.title}),i.jsx("button",{type:"button",className:"pubwave-modal__close",onClick:n,"aria-label":y.modal.close,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsxs("div",{className:"pubwave-modal__body",children:[i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-type",className:"pubwave-form__label",children:y.modal.fields.chartType}),i.jsx("select",{id:"chart-type",className:"pubwave-form__select",value:r,onChange:P=>a(P.target.value),children:jr.map(P=>i.jsx("option",{value:P.value,children:y.chartTypes[P.value]},P.value))})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-title",className:"pubwave-form__label",children:y.modal.fields.title}),i.jsx("input",{id:"chart-title",type:"text",className:"pubwave-form__input",value:s,onChange:P=>l(P.target.value),placeholder:y.modal.fields.titlePlaceholder})]}),i.jsxs("div",{className:"pubwave-form__row",children:[i.jsx("div",{className:"pubwave-form__field",children:i.jsxs("label",{className:"pubwave-form__checkbox-label",children:[i.jsx("input",{type:"checkbox",className:"pubwave-form__checkbox",checked:c,onChange:P=>f(P.target.checked)}),y.modal.fields.showLegend]})}),c&&i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"legend-position",className:"pubwave-form__label",children:y.modal.fields.legendPosition}),i.jsxs("select",{id:"legend-position",className:"pubwave-form__select",value:u,onChange:P=>m(P.target.value),children:[i.jsx("option",{value:"top",children:y.modal.fields.position.top}),i.jsx("option",{value:"bottom",children:y.modal.fields.position.bottom}),i.jsx("option",{value:"left",children:y.modal.fields.position.left}),i.jsx("option",{value:"right",children:y.modal.fields.position.right})]})]})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-labels",className:"pubwave-form__label",children:y.modal.fields.labels}),i.jsx("input",{id:"chart-labels",type:"text",className:"pubwave-form__input",value:h.join(", "),onChange:P=>k(P.target.value),placeholder:y.modal.fields.labelsPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__section",children:[i.jsxs("div",{className:"pubwave-form__section-header",children:[i.jsx("h3",{className:"pubwave-form__section-title",children:y.modal.fields.datasets.title}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary pubwave-button--small",onClick:d,children:y.modal.fields.datasets.add})]}),p.map((P,R)=>i.jsxs("div",{className:"pubwave-form__dataset",children:[i.jsxs("div",{className:"pubwave-form__dataset-header",children:[i.jsxs("span",{className:"pubwave-form__dataset-title",children:[y.modal.fields.datasets.datasetLabel," ",R+1]}),p.length>1&&i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--danger pubwave-button--small",onClick:()=>A(R),"aria-label":`${y.modal.fields.datasets.remove} ${R+1}`,children:y.modal.fields.datasets.remove})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-label-${R}`,className:"pubwave-form__label",children:y.modal.fields.datasets.datasetLabel}),i.jsx("input",{id:`dataset-label-${R}`,type:"text",className:"pubwave-form__input",value:P.label??"",onChange:W=>S(R,W.target.value),placeholder:y.modal.fields.datasets.datasetLabelPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-data-${R}`,className:"pubwave-form__label",children:y.modal.fields.datasets.data}),i.jsx("input",{id:`dataset-data-${R}`,type:"text",className:"pubwave-form__input",value:P.data.join(", "),onChange:W=>T(R,W.target.value),placeholder:y.modal.fields.datasets.dataPlaceholder})]})]},R))]})]}),i.jsxs("div",{className:"pubwave-modal__footer",children:[i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary",onClick:n,children:y.modal.cancel}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--primary",onClick:j,children:y.modal.save})]})]})});return xr.createPortal(N,document.body)}const Pr={groups:{basic:"Basic",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},table:{title:"Table",description:"Insert a table"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}},Dr={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline Code",link:"Link",turnInto:"Turn Into",colorPicker:"Text and background color",textColor:"Text color",backgroundColor:"Background color",recentlyUsed:"Recently used",openLink:"Open link",removeLink:"Remove link",confirmLink:"Confirm link",clearLink:"Clear link",blockTypes:{text:"Text",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",bulletedList:"Bulleted list",numberedList:"Numbered list"}},Ir={editor:"Rich text editor",editorContent:"Editor content area",toolbar:"Text formatting toolbar",boldButton:"Toggle bold formatting",italicButton:"Toggle italic formatting",underlineButton:"Toggle underline formatting",strikeButton:"Toggle strikethrough formatting",codeButton:"Toggle inline code formatting",linkButton:"Add or edit link",turnIntoButton:"Turn into",colorPickerButton:"Text and background color",headingButton:"Set heading level",paragraphButton:"Convert to paragraph",dragHandle:"Drag to reorder block",dropIndicator:"Drop here to move block",blockMenu:"Block options menu",addBlock:"Add new block",deleteBlock:"Delete this block",linkDialog:"Link editor dialog",linkUrlInput:"Link URL input",linkSaveButton:"Save link",linkRemoveButton:"Remove link",linkCancelButton:"Cancel link editing",addBlockBelow:"Add block below",dragToMove:"Drag to reorder block",openLinkInNewTab:"Open link in new tab",linkConfirmButton:"Confirm link",linkOpenButton:"Open link in new tab",linkClearButton:"Clear link input"},Rr='Write, type "/" for commands...',Er="Paste a link...",Or={modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels (comma-separated)",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Dataset",datasetLabelPlaceholder:"Dataset label...",data:"Data (comma-separated numbers)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}},qn={slashMenu:Pr,toolbar:Dr,aria:Ir,placeholder:Rr,linkPlaceholder:Er,chart:Or},_r={groups:{basic:"基礎",list:"列表",media:"媒體",advanced:"高級",layout:"版面配置"},commands:{paragraph:{title:"文本",description:"普通文本塊"},heading1:{title:"標題 1",description:"大標題"},heading2:{title:"標題 2",description:"中標題"},heading3:{title:"標題 3",description:"小標題"},bulletList:{title:"無序列表",description:"創建無序列表"},orderedList:{title:"有序列表",description:"創建有序列表"},taskList:{title:"待辦清單",description:"創建帶複選框的待辦清單"},image:{title:"圖片",description:"上傳或粘貼圖片"},blockquote:{title:"引用",description:"創建引用塊"},codeBlock:{title:"代碼",description:"創建代碼片段"},horizontalRule:{title:"分割線",description:"創建水平分割線"},table:{title:"表格",description:"插入表格"},layoutTwoColumn:{title:"兩欄版面配置",description:"將內容分成兩個並排的欄"},layoutThreeColumn:{title:"三欄版面配置",description:"將內容分成三個並排的欄"}}},Nr={bold:"粗體",italic:"斜體",underline:"下劃線",strike:"刪除線",code:"行內代碼",link:"鏈接",turnInto:"轉換為",colorPicker:"文字和背景顏色",textColor:"文字顏色",backgroundColor:"背景顏色",recentlyUsed:"最近使用",openLink:"打開鏈接",removeLink:"移除鏈接",confirmLink:"確認鏈接",clearLink:"清空鏈接",blockTypes:{text:"文本",heading1:"標題 1",heading2:"標題 2",heading3:"標題 3",bulletedList:"無序列表",numberedList:"有序列表"}},Hr={editor:"富文本編輯器",editorContent:"編輯器內容區域",toolbar:"文本格式化工具欄",boldButton:"切換粗體格式",italicButton:"切換斜體格式",underlineButton:"切換下劃線格式",strikeButton:"切換刪除線格式",codeButton:"切換行內代碼格式",linkButton:"添加或編輯鏈接",turnIntoButton:"轉換為",colorPickerButton:"文字和背景顏色",headingButton:"設置標題級別",paragraphButton:"轉換為段落",dragHandle:"拖拽以重新排序塊",dropIndicator:"放置此處以移動塊",blockMenu:"塊選項菜單",addBlock:"添加新塊",deleteBlock:"刪除此塊",linkDialog:"鏈接編輯對話框",linkUrlInput:"鏈接 URL 輸入",linkSaveButton:"保存鏈接",linkRemoveButton:"移除鏈接",linkCancelButton:"取消鏈接編輯",addBlockBelow:"在下方添加塊",dragToMove:"拖拽以重新排序塊",openLinkInNewTab:"在新標籤頁中打開鏈接",linkConfirmButton:"確認鏈接",linkOpenButton:"在新標籤頁中打開鏈接",linkClearButton:"清空鏈接輸入"},$r='開始寫作,輸入 "/" 顯示命令...',zr="粘貼鏈接...",qr={modal:{title:"編輯圖表",close:"關閉",save:"保存",cancel:"取消",fields:{chartType:"圖表類型",title:"標題",titlePlaceholder:"圖表標題...",showLegend:"顯示圖例",legendPosition:"位置",position:{top:"頂部",bottom:"底部",left:"左側",right:"右側"},labels:"標籤(逗號分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"數據集",add:"+ 添加數據集",remove:"移除",datasetLabel:"標籤",datasetLabelPlaceholder:"數據集標籤...",data:"數據(逗號分隔的數字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱狀圖",line:"折線圖",pie:"餅圖",doughnut:"環形圖",radar:"雷達圖",polarArea:"極地圖"}},Ur={slashMenu:_r,toolbar:Nr,aria:Hr,placeholder:$r,linkPlaceholder:zr,chart:qr},Fr={groups:{basic:"基础",list:"列表",media:"媒体",advanced:"高级",layout:"版面布局"},commands:{paragraph:{title:"文本",description:"普通文本块"},heading1:{title:"标题 1",description:"大标题"},heading2:{title:"标题 2",description:"中标题"},heading3:{title:"标题 3",description:"小标题"},bulletList:{title:"无序列表",description:"创建无序列表"},orderedList:{title:"有序列表",description:"创建有序列表"},taskList:{title:"待办清单",description:"创建带复选框的待办清单"},image:{title:"图片",description:"上传或粘贴图片"},blockquote:{title:"引用",description:"创建引用块"},codeBlock:{title:"代码",description:"创建代码片段"},horizontalRule:{title:"分割线",description:"创建水平分割线"},table:{title:"表格",description:"插入表格"},layoutTwoColumn:{title:"两栏布局",description:"将内容分成两个并排的栏"},layoutThreeColumn:{title:"三栏布局",description:"将内容分成三个并排的栏"}}},Wr={bold:"粗体",italic:"斜体",underline:"下划线",strike:"删除线",code:"行内代码",link:"链接",turnInto:"转换为",colorPicker:"文字和背景颜色",textColor:"文字颜色",backgroundColor:"背景颜色",recentlyUsed:"最近使用",openLink:"打开链接",removeLink:"移除链接",confirmLink:"确认链接",clearLink:"清空链接",blockTypes:{text:"文本",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",bulletedList:"无序列表",numberedList:"有序列表"}},Vr={editor:"富文本编辑器",editorContent:"编辑器内容区域",toolbar:"文本格式化工具栏",boldButton:"切换粗体格式",italicButton:"切换斜体格式",underlineButton:"切换下划线格式",strikeButton:"切换删除线格式",codeButton:"切换行内代码格式",linkButton:"添加或编辑链接",turnIntoButton:"转换为",colorPickerButton:"文字和背景颜色",headingButton:"设置标题级别",paragraphButton:"转换为段落",dragHandle:"拖拽以重新排序块",dropIndicator:"放置此处以移动块",blockMenu:"块选项菜单",addBlock:"添加新块",deleteBlock:"删除此块",linkDialog:"链接编辑对话框",linkUrlInput:"链接 URL 输入",linkSaveButton:"保存链接",linkRemoveButton:"移除链接",linkCancelButton:"取消链接编辑",addBlockBelow:"在下方添加块",dragToMove:"拖拽以重新排序块",openLinkInNewTab:"在新标签页中打开链接",linkConfirmButton:"确认链接",linkOpenButton:"在新标签页中打开链接",linkClearButton:"清空链接输入"},Gr='开始写作,输入 "/" 显示命令...',Yr="粘贴链接...",Kr={modal:{title:"编辑图表",close:"关闭",save:"保存",cancel:"取消",fields:{chartType:"图表类型",title:"标题",titlePlaceholder:"图表标题...",showLegend:"显示图例",legendPosition:"位置",position:{top:"顶部",bottom:"底部",left:"左侧",right:"右侧"},labels:"标签(逗号分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"数据集",add:"+ 添加数据集",remove:"移除",datasetLabel:"标签",datasetLabelPlaceholder:"数据集标签...",data:"数据(逗号分隔的数字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱状图",line:"折线图",pie:"饼图",doughnut:"环形图",radar:"雷达图",polarArea:"极地图"}},Xr={slashMenu:Fr,toolbar:Wr,aria:Vr,placeholder:Gr,linkPlaceholder:Yr,chart:Kr},Jr={groups:{basic:"基本",list:"リスト",media:"メディア",advanced:"高度",layout:"レイアウト"},commands:{paragraph:{title:"テキスト",description:"プレーンテキストブロック"},heading1:{title:"見出し1",description:"大きなセクション見出し"},heading2:{title:"見出し2",description:"中サイズのセクション見出し"},heading3:{title:"見出し3",description:"小さなセクション見出し"},bulletList:{title:"箇条書きリスト",description:"箇条書きリストを作成"},orderedList:{title:"番号付きリスト",description:"番号付きリストを作成"},taskList:{title:"To-doリスト",description:"チェックボックス付きのTo-doリストを作成"},image:{title:"画像",description:"画像をアップロードまたは貼り付け"},blockquote:{title:"引用",description:"引用ブロックを作成"},codeBlock:{title:"コード",description:"コードスニペットを作成"},horizontalRule:{title:"区切り線",description:"水平線を作成"},table:{title:"テーブル",description:"テーブルを挿入"},layoutTwoColumn:{title:"2カラムレイアウト",description:"コンテンツを2つの横並びカラムに分割"},layoutThreeColumn:{title:"3カラムレイアウト",description:"コンテンツを3つの横並びカラムに分割"}}},Zr={bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",code:"インラインコード",link:"リンク",turnInto:"変換",colorPicker:"テキストと背景色",textColor:"文字色",backgroundColor:"背景色",recentlyUsed:"最近使用",openLink:"リンクを開く",removeLink:"リンクを削除",confirmLink:"リンクを確認",clearLink:"リンクをクリア",blockTypes:{text:"テキスト",heading1:"見出し1",heading2:"見出し2",heading3:"見出し3",bulletedList:"箇条書きリスト",numberedList:"番号付きリスト"}},Qr={editor:"リッチテキストエディタ",editorContent:"エディタコンテンツ領域",toolbar:"テキスト書式設定ツールバー",boldButton:"太字書式を切り替え",italicButton:"斜体書式を切り替え",underlineButton:"下線書式を切り替え",strikeButton:"取り消し線書式を切り替え",codeButton:"インラインコード書式を切り替え",linkButton:"リンクを追加または編集",turnIntoButton:"変換",colorPickerButton:"テキストと背景色",headingButton:"見出しレベルを設定",paragraphButton:"段落に変換",dragHandle:"ブロックを並び替えるためにドラッグ",dropIndicator:"ブロックを移動するためにここにドロップ",blockMenu:"ブロックオプションメニュー",addBlock:"新しいブロックを追加",deleteBlock:"このブロックを削除",linkDialog:"リンク編集ダイアログ",linkUrlInput:"リンクURL入力",linkSaveButton:"リンクを保存",linkRemoveButton:"リンクを削除",linkCancelButton:"リンク編集をキャンセル",addBlockBelow:"下にブロックを追加",dragToMove:"ブロックを並び替えるためにドラッグ",openLinkInNewTab:"新しいタブでリンクを開く",linkConfirmButton:"リンクを確認",linkOpenButton:"新しいタブでリンクを開く",linkClearButton:"リンク入力をクリア"},ea='書き始めましょう、コマンドを表示するには "/" を入力...',ta="リンクを貼り付け...",na={modal:{title:"チャート編集",close:"閉じる",save:"保存",cancel:"キャンセル",fields:{chartType:"チャートタイプ",title:"タイトル",titlePlaceholder:"チャートタイトル...",showLegend:"凡例を表示",legendPosition:"位置",position:{top:"上",bottom:"下",left:"左",right:"右"},labels:"ラベル(カンマ区切り)",labelsPlaceholder:"1月, 2月, 3月, 4月...",datasets:{title:"データセット",add:"+ データセットを追加",remove:"削除",datasetLabel:"ラベル",datasetLabelPlaceholder:"データセットラベル...",data:"データ(カンマ区切りの数値)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"棒グラフ",line:"折れ線グラフ",pie:"円グラフ",doughnut:"ドーナツグラフ",radar:"レーダーチャート",polarArea:"極座標グラフ"}},oa={slashMenu:Jr,toolbar:Zr,aria:Qr,placeholder:ea,linkPlaceholder:ta,chart:na},ra={groups:{basic:"기본",list:"목록",media:"미디어",advanced:"고급",layout:"레이아웃"},commands:{paragraph:{title:"텍스트",description:"일반 텍스트 블록"},heading1:{title:"제목 1",description:"큰 섹션 제목"},heading2:{title:"제목 2",description:"중간 섹션 제목"},heading3:{title:"제목 3",description:"작은 섹션 제목"},bulletList:{title:"글머리 기호 목록",description:"글머리 기호 목록 만들기"},orderedList:{title:"번호 매기기 목록",description:"번호 매기기 목록 만들기"},taskList:{title:"할 일 목록",description:"확인란 있는 할 일 목록 만들기"},image:{title:"이미지",description:"이미지 업로드 또는 붙여넣기"},blockquote:{title:"인용",description:"인용 블록 만들기"},codeBlock:{title:"코드",description:"코드 스니펫 만들기"},horizontalRule:{title:"구분선",description:"수평선 만들기"},table:{title:"표",description:"표를 삽입"},layoutTwoColumn:{title:"2열 레이아웃",description:"콘텐츠를 두 개의 나란히 있는 열로 분할"},layoutThreeColumn:{title:"3열 레이아웃",description:"콘텐츠를 세 개의 나란히 있는 열로 분할"}}},aa={bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",code:"인라인 코드",link:"링크",turnInto:"변환",colorPicker:"텍스트 및 배경색",textColor:"텍스트 색상",backgroundColor:"배경 색상",recentlyUsed:"최근 사용",openLink:"링크 열기",removeLink:"링크 제거",confirmLink:"링크 확인",clearLink:"링크 지우기",blockTypes:{text:"텍스트",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록"}},ia={editor:"리치 텍스트 에디터",editorContent:"에디터 내용 영역",toolbar:"텍스트 서식 도구 모음",boldButton:"굵게 서식 전환",italicButton:"기울임 서식 전환",underlineButton:"밑줄 서식 전환",strikeButton:"취소선 서식 전환",codeButton:"인라인 코드 서식 전환",linkButton:"링크 추가 또는 편집",turnIntoButton:"변환",colorPickerButton:"텍스트 및 배경색",headingButton:"제목 수준 설정",paragraphButton:"단락으로 변환",dragHandle:"블록 재정렬을 위해 드래그",dropIndicator:"블록 이동을 위해 여기에 놓기",blockMenu:"블록 옵션 메뉴",addBlock:"새 블록 추가",deleteBlock:"이 블록 삭제",linkDialog:"링크 편집 대화 상자",linkUrlInput:"링크 URL 입력",linkSaveButton:"링크 저장",linkRemoveButton:"링크 제거",linkCancelButton:"링크 편집 취소",addBlockBelow:"아래에 블록 추가",dragToMove:"블록 재정렬을 위해 드래그",openLinkInNewTab:"새 탭에서 링크 열기",linkConfirmButton:"링크 확인",linkOpenButton:"새 탭에서 링크 열기",linkClearButton:"링크 입력 지우기"},sa='작성 시작, 명령을 표시하려면 "/" 입력...',la="링크 붙여넣기...",ca={modal:{title:"차트 편집",close:"닫기",save:"저장",cancel:"취소",fields:{chartType:"차트 유형",title:"제목",titlePlaceholder:"차트 제목...",showLegend:"범례 표시",legendPosition:"위치",position:{top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"},labels:"레이블(쉼표로 구분)",labelsPlaceholder:"1월, 2월, 3월, 4월...",datasets:{title:"데이터 세트",add:"+ 데이터 세트 추가",remove:"제거",datasetLabel:"레이블",datasetLabelPlaceholder:"데이터 세트 레이블...",data:"데이터(쉼표로 구분된 숫자)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"막대형 차트",line:"선형 차트",pie:"원형 차트",doughnut:"도넛형 차트",radar:"레이더 차트",polarArea:"극좌표형 차트"}},ua={slashMenu:ra,toolbar:aa,aria:ia,placeholder:sa,linkPlaceholder:la,chart:ca},da={groups:{basic:"De base",list:"Listes",media:"Médias",advanced:"Avancé",layout:"Mise en page"},commands:{paragraph:{title:"Texte",description:"Bloc de texte simple"},heading1:{title:"Titre 1",description:"Grand titre de section"},heading2:{title:"Titre 2",description:"Titre de section moyen"},heading3:{title:"Titre 3",description:"Petit titre de section"},bulletList:{title:"Liste à puces",description:"Créer une liste à puces"},orderedList:{title:"Liste numérotée",description:"Créer une liste numérotée"},taskList:{title:"Liste de tâches",description:"Créer une liste de tâches avec cases à cocher"},image:{title:"Image",description:"Télécharger ou coller une image"},blockquote:{title:"Citation",description:"Créer un bloc de citation"},codeBlock:{title:"Code",description:"Créer un extrait de code"},horizontalRule:{title:"Séparateur",description:"Créer une ligne horizontale"},table:{title:"Tableau",description:"Insérer un tableau"},layoutTwoColumn:{title:"Mise en page à deux colonnes",description:"Diviser le contenu en deux colonnes côte à côte"},layoutThreeColumn:{title:"Mise en page à trois colonnes",description:"Diviser le contenu en trois colonnes côte à côte"}}},pa={bold:"Gras",italic:"Italique",underline:"Souligné",strike:"Barré",code:"Code en ligne",link:"Lien",turnInto:"Convertir en",colorPicker:"Couleur du texte et du fond",textColor:"Couleur du texte",backgroundColor:"Couleur de fond",recentlyUsed:"Récemment utilisés",openLink:"Ouvrir le lien",removeLink:"Supprimer le lien",confirmLink:"Confirmer le lien",clearLink:"Effacer le lien",blockTypes:{text:"Texte",heading1:"Titre 1",heading2:"Titre 2",heading3:"Titre 3",bulletedList:"Liste à puces",numberedList:"Liste numérotée"}},fa={editor:"Éditeur de texte riche",editorContent:"Zone de contenu de l'éditeur",toolbar:"Barre d'outils de formatage de texte",boldButton:"Activer/désactiver le formatage en gras",italicButton:"Activer/désactiver le formatage en italique",underlineButton:"Activer/désactiver le soulignement",strikeButton:"Activer/désactiver le texte barré",codeButton:"Activer/désactiver le code en ligne",linkButton:"Ajouter ou modifier un lien",turnIntoButton:"Convertir en",colorPickerButton:"Couleur du texte et du fond",headingButton:"Définir le niveau de titre",paragraphButton:"Convertir en paragraphe",dragHandle:"Glisser pour réorganiser le bloc",dropIndicator:"Déposer ici pour déplacer le bloc",blockMenu:"Menu des options de bloc",addBlock:"Ajouter un nouveau bloc",deleteBlock:"Supprimer ce bloc",linkDialog:"Boîte de dialogue d'édition de lien",linkUrlInput:"Entrée d'URL de lien",linkSaveButton:"Enregistrer le lien",linkRemoveButton:"Supprimer le lien",linkCancelButton:"Annuler l'édition du lien",addBlockBelow:"Ajouter un bloc en dessous",dragToMove:"Glisser pour réorganiser le bloc",openLinkInNewTab:"Ouvrir le lien dans un nouvel onglet",linkConfirmButton:"Confirmer le lien",linkOpenButton:"Ouvrir le lien dans un nouvel onglet",linkClearButton:"Effacer la saisie du lien"},ha='Écrivez, tapez "/" pour afficher les commandes...',ba="Collez un lien...",va={modal:{title:"Modifier le graphique",close:"Fermer",save:"Enregistrer",cancel:"Annuler",fields:{chartType:"Type de graphique",title:"Titre",titlePlaceholder:"Titre du graphique...",showLegend:"Afficher la légende",legendPosition:"Position",position:{top:"Haut",bottom:"Bas",left:"Gauche",right:"Droite"},labels:"Étiquettes (séparées par des virgules)",labelsPlaceholder:"Jan, Fév, Mar, Avr...",datasets:{title:"Jeux de données",add:"+ Ajouter un jeu de données",remove:"Supprimer",datasetLabel:"Étiquette",datasetLabelPlaceholder:"Étiquette du jeu de données...",data:"Données (nombres séparés par des virgules)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Graphique à barres",line:"Graphique linéaire",pie:"Graphique circulaire",doughnut:"Graphique en anneau",radar:"Graphique radar",polarArea:"Graphique en coordonnées polaires"}},ga={slashMenu:da,toolbar:pa,aria:fa,placeholder:ha,linkPlaceholder:ba,chart:va},ma={groups:{basic:"Basis",list:"Listen",media:"Medien",advanced:"Erweitert",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Einfacher Textblock"},heading1:{title:"Überschrift 1",description:"Große Abschnittsüberschrift"},heading2:{title:"Überschrift 2",description:"Mittlere Abschnittsüberschrift"},heading3:{title:"Überschrift 3",description:"Kleine Abschnittsüberschrift"},bulletList:{title:"Aufzählungsliste",description:"Aufzählungsliste erstellen"},orderedList:{title:"Nummerierte Liste",description:"Nummerierte Liste erstellen"},taskList:{title:"To-do-Liste",description:"To-do-Liste mit Kontrollkästchen erstellen"},image:{title:"Bild",description:"Bild hochladen oder einfügen"},blockquote:{title:"Zitat",description:"Zitatblock erstellen"},codeBlock:{title:"Code",description:"Codeausschnitt erstellen"},horizontalRule:{title:"Trennlinie",description:"Horizontale Linie erstellen"},table:{title:"Tabelle",description:"Eine Tabelle einfügen"},layoutTwoColumn:{title:"Zweispaltiges Layout",description:"Inhalt in zwei nebeneinander liegende Spalten aufteilen"},layoutThreeColumn:{title:"Dreispaltiges Layout",description:"Inhalt in drei nebeneinander liegende Spalten aufteilen"}}},xa={bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",strike:"Durchgestrichen",code:"Inline-Code",link:"Link",turnInto:"Umwandeln in",colorPicker:"Text- und Hintergrundfarbe",textColor:"Textfarbe",backgroundColor:"Hintergrundfarbe",recentlyUsed:"Zuletzt verwendet",openLink:"Link öffnen",removeLink:"Link entfernen",confirmLink:"Link bestätigen",clearLink:"Link löschen",blockTypes:{text:"Text",heading1:"Überschrift 1",heading2:"Überschrift 2",heading3:"Überschrift 3",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste"}},ya={editor:"Rich-Text-Editor",editorContent:"Editor-Inhaltsbereich",toolbar:"Textformatierungs-Symbolleiste",boldButton:"Fettformatierung ein/aus",italicButton:"Kursivformatierung ein/aus",underlineButton:"Unterstreichung ein/aus",strikeButton:"Durchstreichung ein/aus",codeButton:"Inline-Code-Formatierung ein/aus",linkButton:"Link hinzufügen oder bearbeiten",turnIntoButton:"Umwandeln in",colorPickerButton:"Text- und Hintergrundfarbe",headingButton:"Überschriftsebene festlegen",paragraphButton:"In Absatz umwandeln",dragHandle:"Zum Neuordnen des Blocks ziehen",dropIndicator:"Hier ablegen, um Block zu verschieben",blockMenu:"Block-Optionsmenü",addBlock:"Neuen Block hinzufügen",deleteBlock:"Diesen Block löschen",linkDialog:"Link-Bearbeitungsdialog",linkUrlInput:"Link-URL-Eingabe",linkSaveButton:"Link speichern",linkRemoveButton:"Link entfernen",linkCancelButton:"Link-Bearbeitung abbrechen",addBlockBelow:"Block darunter hinzufügen",dragToMove:"Zum Neuordnen des Blocks ziehen",openLinkInNewTab:"Link in neuem Tab öffnen",linkConfirmButton:"Link bestätigen",linkOpenButton:"Link in neuem Tab öffnen",linkClearButton:"Link-Eingabe löschen"},wa='Schreiben, tippen Sie "/" für Befehle...',ka="Link einfügen...",Ca={modal:{title:"Chart bearbeiten",close:"Schließen",save:"Speichern",cancel:"Abbrechen",fields:{chartType:"Chart-Typ",title:"Titel",titlePlaceholder:"Chart-Titel...",showLegend:"Legende anzeigen",legendPosition:"Position",position:{top:"Oben",bottom:"Unten",left:"Links",right:"Rechts"},labels:"Beschriftungen (kommagetrennt)",labelsPlaceholder:"Jan, Feb, Mär, Apr...",datasets:{title:"Datensätze",add:"+ Datensatz hinzufügen",remove:"Entfernen",datasetLabel:"Datensatz",datasetLabelPlaceholder:"Datensatz-Beschriftung...",data:"Daten (kommagetrennte Zahlen)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Balkendiagramm",line:"Liniendiagramm",pie:"Kreisdiagramm",doughnut:"Ringdiagramm",radar:"Netzdiagramm",polarArea:"Polärfächen-Diagramm"}},Ta={slashMenu:ma,toolbar:xa,aria:ya,placeholder:wa,linkPlaceholder:ka,chart:Ca},La={groups:{basic:"Básico",list:"Listas",media:"Medios",advanced:"Avanzado",layout:"Diseño"},commands:{paragraph:{title:"Texto",description:"Bloque de texto plano"},heading1:{title:"Título 1",description:"Título de sección grande"},heading2:{title:"Título 2",description:"Título de sección mediano"},heading3:{title:"Título 3",description:"Título de sección pequeño"},bulletList:{title:"Lista con viñetas",description:"Crear una lista con viñetas"},orderedList:{title:"Lista numerada",description:"Crear una lista numerada"},taskList:{title:"Lista de tareas",description:"Crear una lista de tareas con casillas"},image:{title:"Imagen",description:"Subir o pegar una imagen"},blockquote:{title:"Cita",description:"Crear un bloque de cita"},codeBlock:{title:"Código",description:"Crear un fragmento de código"},horizontalRule:{title:"Divisor",description:"Crear una línea horizontal"},table:{title:"Tabla",description:"Insertar una tabla"},layoutTwoColumn:{title:"Diseño de dos columnas",description:"Dividir el contenido en dos columnas una al lado de la otra"},layoutThreeColumn:{title:"Diseño de tres columnas",description:"Dividir el contenido en tres columnas una al lado de la otra"}}},Ba={bold:"Negrita",italic:"Cursiva",underline:"Subrayado",strike:"Tachado",code:"Código en línea",link:"Enlace",turnInto:"Convertir en",colorPicker:"Color de texto y fondo",textColor:"Color del texto",backgroundColor:"Color de fondo",recentlyUsed:"Recientemente usados",openLink:"Abrir enlace",removeLink:"Eliminar enlace",confirmLink:"Confirmar enlace",clearLink:"Limpiar enlace",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista con viñetas",numberedList:"Lista numerada"}},Aa={editor:"Editor de texto enriquecido",editorContent:"Área de contenido del editor",toolbar:"Barra de herramientas de formato de texto",boldButton:"Activar/desactivar formato en negrita",italicButton:"Activar/desactivar formato en cursiva",underlineButton:"Activar/desactivar subrayado",strikeButton:"Activar/desactivar tachado",codeButton:"Activar/desactivar código en línea",linkButton:"Añadir o editar enlace",turnIntoButton:"Convertir en",colorPickerButton:"Color de texto y fondo",headingButton:"Establecer nivel de título",paragraphButton:"Convertir a párrafo",dragHandle:"Arrastrar para reorganizar el bloque",dropIndicator:"Soltar aquí para mover el bloque",blockMenu:"Menú de opciones del bloque",addBlock:"Añadir nuevo bloque",deleteBlock:"Eliminar este bloque",linkDialog:"Diálogo de edición de enlace",linkUrlInput:"Entrada de URL del enlace",linkSaveButton:"Guardar enlace",linkRemoveButton:"Eliminar enlace",linkCancelButton:"Cancelar edición de enlace",addBlockBelow:"Añadir bloque debajo",dragToMove:"Arrastrar para reorganizar el bloque",openLinkInNewTab:"Abrir enlace en nueva pestaña",linkConfirmButton:"Confirmar enlace",linkOpenButton:"Abrir enlace en nueva pestaña",linkClearButton:"Limpiar entrada de enlace"},ja='Escribe, escribe "/" para comandos...',Sa="Pegue un enlace...",Ma={modal:{title:"Editar gráfico",close:"Cerrar",save:"Guardar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título del gráfico...",showLegend:"Mostrar leyenda",legendPosition:"Posición",position:{top:"Arriba",bottom:"Abajo",left:"Izquierda",right:"Derecha"},labels:"Etiquetas (separadas por comas)",labelsPlaceholder:"Ene, Feb, Mar, Abr...",datasets:{title:"Conjuntos de datos",add:"+ Añadir conjunto de datos",remove:"Eliminar",datasetLabel:"Etiqueta",datasetLabelPlaceholder:"Etiqueta del conjunto de datos...",data:"Datos (números separados por comas)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de líneas",pie:"Gráfico circular",doughnut:"Gráfico de anillo",radar:"Gráfico radar",polarArea:"Gráfico de área polar"}},Pa={slashMenu:La,toolbar:Ba,aria:Aa,placeholder:ja,linkPlaceholder:Sa,chart:Ma},Da={groups:{basic:"Básico",list:"Listas",media:"Mídia",advanced:"Avançado",layout:"Layout"},commands:{paragraph:{title:"Texto",description:"Bloco de texto simples"},heading1:{title:"Título 1",description:"Título de seção grande"},heading2:{title:"Título 2",description:"Título de seção médio"},heading3:{title:"Título 3",description:"Título de seção pequeno"},bulletList:{title:"Lista com marcadores",description:"Criar uma lista com marcadores"},orderedList:{title:"Lista numerada",description:"Criar uma lista numerada"},taskList:{title:"Lista de tarefas",description:"Criar uma lista de tarefas com caixas de seleção"},image:{title:"Imagem",description:"Enviar ou colar uma imagem"},blockquote:{title:"Citação",description:"Criar um bloco de citação"},codeBlock:{title:"Código",description:"Criar um trecho de código"},horizontalRule:{title:"Divisor",description:"Criar uma linha horizontal"},table:{title:"Tabela",description:"Inserir uma tabela"},layoutTwoColumn:{title:"Layout de duas colunas",description:"Dividir o conteúdo em duas colunas lado a lado"},layoutThreeColumn:{title:"Layout de três colunas",description:"Dividir o conteúdo em três colunas lado a lado"}}},Ia={bold:"Negrito",italic:"Itálico",underline:"Sublinhado",strike:"Tachado",code:"Código inline",link:"Link",turnInto:"Converter em",colorPicker:"Cor do texto e fundo",textColor:"Cor do texto",backgroundColor:"Cor de fundo",recentlyUsed:"Usados recentemente",openLink:"Abrir link",removeLink:"Remover link",confirmLink:"Confirmar link",clearLink:"Limpar link",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista com marcadores",numberedList:"Lista numerada"}},Ra={editor:"Editor de texto rico",editorContent:"Área de conteúdo do editor",toolbar:"Barra de ferramentas de formatação de texto",boldButton:"Alternar formatação em negrito",italicButton:"Alternar formatação em itálico",underlineButton:"Alternar sublinhado",strikeButton:"Alternar tachado",codeButton:"Alternar código inline",linkButton:"Adicionar ou editar link",turnIntoButton:"Converter em",colorPickerButton:"Cor do texto e fundo",headingButton:"Definir nível de título",paragraphButton:"Converter em parágrafo",dragHandle:"Arrastar para reorganizar o bloco",dropIndicator:"Soltar aqui para mover o bloco",blockMenu:"Menu de opções do bloco",addBlock:"Adicionar novo bloco",deleteBlock:"Excluir este bloco",linkDialog:"Diálogo de edição de link",linkUrlInput:"Entrada de URL do link",linkSaveButton:"Salvar link",linkRemoveButton:"Remover link",linkCancelButton:"Cancelar edição de link",addBlockBelow:"Adicionar bloco abaixo",dragToMove:"Arrastar para reorganizar o bloco",openLinkInNewTab:"Abrir link em nova aba",linkConfirmButton:"Confirmar link",linkOpenButton:"Abrir link em nova aba",linkClearButton:"Limpar entrada de link"},Ea='Escreva, digite "/" para comandos...',Oa="Cole um link...",_a={modal:{title:"Editar gráfico",close:"Fechar",save:"Salvar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título do gráfico...",showLegend:"Mostrar legenda",legendPosition:"Posição",position:{top:"Superior",bottom:"Inferior",left:"Esquerda",right:"Direita"},labels:"Rótulos (separados por vírgula)",labelsPlaceholder:"Jan, Fev, Mar, Abr...",datasets:{title:"Conjuntos de dados",add:"+ Adicionar conjunto de dados",remove:"Remover",datasetLabel:"Rótulo",datasetLabelPlaceholder:"Rótulo do conjunto de dados...",data:"Dados (números separados por vírgula)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de linhas",pie:"Gráfico de pizza",doughnut:"Gráfico de rosca",radar:"Gráfico de radar",polarArea:"Gráfico de área polar"}},Na={slashMenu:Da,toolbar:Ia,aria:Ra,placeholder:Ea,linkPlaceholder:Oa,chart:_a},Ft=qn,Ha={en:qn,zh:Ur,"zh-CN":Xr,ja:oa,ko:ua,fr:ga,de:Ta,es:Pa,pt:Na};function jt(e){return e&&Ha[e]||Ft}const Un=x.createContext({locale:Ft}),fn=Un.Provider;function We(){return x.useContext(Un).locale}const $a=async()=>import("chart.js/auto");function Xe(e,t,n){const o=getComputedStyle(e),r=t.replace(/^var\(/,"").replace(/\)$/,"");return o.getPropertyValue(r).trim()||n}function za(e){var B,_,b;const{node:t,updateAttributes:n,editor:o,selected:r}=e,a=t.attrs.data,[s,l]=x.useState(!1),[c,f]=x.useState(!1),[u,m]=x.useState(null),h=x.useRef(null),v=x.useRef(null),p=x.useRef(null),g=We(),C=((B=o==null?void 0:o.options)==null?void 0:B.editable)??!0,y=C?r:!1,S=x.useCallback(()=>{if(!u||!p.current||!v.current)return;const L=v.current,M=Xe(L,"--pubwave-text","#37352f"),E=Xe(L,"--pubwave-text-muted","#9b9a97"),$=Xe(L,"--pubwave-border","#e3e2e0"),q=u.options.plugins||{},H=u.options.scales;if(q.legend){const P=q.legend;P.labels?P.labels.color=M:q.legend.labels={color:M},P.onHover=()=>{const R=h.current;R&&(R.style.cursor="pointer")},P.onLeave=()=>{const R=h.current;R&&(R.style.cursor="default")}}q.title&&(q.title.color=M),H&&(H.x&&(H.x.ticks&&(H.x.ticks.color=E),H.x.grid&&(H.x.grid.color=$)),H.y&&(H.y.ticks&&(H.y.ticks.color=E),H.y.grid&&(H.y.grid.color=$))),u.update("none")},[u]);x.useEffect(()=>!h.current||!a?void 0:((async()=>{var M,E,$,q,H,P,R,W,V,J,Z,Q,ae,ye,ie,we,de,ke;try{const Ce=(await $a()).default;if(p.current=Ce,h.current){const G=Ce.getChart(h.current);G&&G.destroy()}u&&u.destroy();const Oe=(M=h.current)==null?void 0:M.getContext("2d");if(!Oe){console.warn("Failed to get 2D context for chart");return}const pe=v.current,Te=pe?Xe(pe,"--pubwave-text","#37352f"):"#37352f",Me=pe?Xe(pe,"--pubwave-text-muted","#9b9a97"):"#9b9a97",_e=pe?Xe(pe,"--pubwave-border","#e3e2e0"):"#e3e2e0",fe=((E=a.options)==null?void 0:E.scales)??{},he=T(a.type)?{x:{...fe.x??{},ticks:{...(($=fe.x)==null?void 0:$.ticks)??{},color:Me},grid:{...((q=fe.x)==null?void 0:q.grid)??{},color:_e}},y:{...fe.y??{},ticks:{...((H=fe.y)==null?void 0:H.ticks)??{},color:Me},grid:{...((P=fe.y)==null?void 0:P.grid)??{},color:_e}}}:void 0,be={...a.options,responsive:!0,maintainAspectRatio:!1,plugins:{...(R=a.options)==null?void 0:R.plugins,legend:{display:((J=(V=(W=a.options)==null?void 0:W.plugins)==null?void 0:V.legend)==null?void 0:J.display)??!0,position:((ae=(Q=(Z=a.options)==null?void 0:Z.plugins)==null?void 0:Q.legend)==null?void 0:ae.position)??"top",...(we=(ie=(ye=a.options)==null?void 0:ye.plugins)==null?void 0:ie.legend)!=null&&we.labels?{labels:{...a.options.plugins.legend.labels,color:Te}}:{labels:{color:Te}},onHover:()=>{const G=h.current;G&&(G.style.cursor="pointer")},onLeave:()=>{const G=h.current;G&&(G.style.cursor="default")}},title:(ke=(de=a.options)==null?void 0:de.plugins)!=null&&ke.title?{...a.options.plugins.title,color:Te,...a.options.plugins.title.font?{font:{...a.options.plugins.title.font}}:{}}:void 0},scales:he},Ne=new Ce(Oe,{type:a.type,data:a.data,options:be});m(Ne)}catch(Ee){console.error("Failed to load Chart.js:",Ee)}})(),()=>{u&&u.destroy()}),[a,C]),x.useEffect(()=>{if(!u||!v.current)return;const L=()=>{setTimeout(()=>{S()},0)},M=new MutationObserver($=>{$.forEach(q=>{(q.attributeName==="style"||q.attributeName==="class")&&L()})});let E=v.current;for(;E&&(M.observe(E,{attributes:!0}),!(E.classList.contains("pubwave-editor")||E===document.body));)E=E.parentElement;return M.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>{M.disconnect()}},[u,S]);function T(L){return["bar","line","radar"].includes(L)}const d=x.useCallback(L=>{n({data:L}),l(!1)},[n]),A=x.useCallback(()=>{l(!1)},[]),k=x.useCallback(()=>{l(!0)},[]);if(!a)return i.jsx(Ae.NodeViewWrapper,{className:"pubwave-editor__chart",children:i.jsx("div",{className:"pubwave-chart__placeholder",children:"Invalid chart data"})});const j=(_=a.options)==null?void 0:_.height,I=(b=a.options)==null?void 0:b.minHeight,N=j||I?{height:j?`${j}px`:void 0,minHeight:I?`${I}px`:void 0}:void 0;return i.jsxs(Ae.NodeViewWrapper,{ref:v,className:"pubwave-editor__chart","data-selected":y,"data-chart-type":a.type,children:[i.jsxs("div",{className:"pubwave-chart__container",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[i.jsx("div",{className:"pubwave-chart__canvas-wrapper",style:N,children:i.jsx("canvas",{ref:h,className:"pubwave-chart__canvas"})}),C&&(c||y)&&i.jsx("button",{type:"button",className:"pubwave-chart__edit-button",onClick:k,"aria-label":"Edit chart",title:"Edit chart",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),s&&a&&i.jsx(Mr,{initialData:a,onSave:d,onCancel:A,locale:g})]})}const qa=ne.Node.create({name:"chart",priority:1e3,group:"block",atom:!0,draggable:!0,addAttributes(){return{data:{default:null,parseHTML:e=>{const t=e.getAttribute("data-chart-data");if(t)try{return JSON.parse(t)}catch{return null}return null},renderHTML:e=>e.data?{"data-chart-data":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:'div[data-type="chart"]'}]},renderHTML({HTMLAttributes:e}){return["div",ne.mergeAttributes({"data-type":"chart"},e)]},addNodeView(){return Ae.ReactNodeViewRenderer(za)}});function Ua(e){return i.jsx(Ae.NodeViewWrapper,{className:"pubwave-layout__column","data-type":"layoutColumn",children:i.jsx(Ae.NodeViewContent,{as:"div",className:"pubwave-layout__column-content"})})}const Fa=ne.Node.create({name:"layout",priority:1e3,group:"block",draggable:!0,content:"layoutColumn+",addAttributes(){return{columns:{default:2,parseHTML:e=>{const t=e.getAttribute("data-layout-columns");return t?parseInt(t,10):2},renderHTML:e=>({"data-layout-columns":String(e.columns)})}}},parseHTML(){return[{tag:'div[data-type="layout"]',getAttrs:e=>{const t=e.getAttribute("data-layout-columns"),n=t?parseInt(t,10):2;return n!==2&&n!==3?!1:{columns:n}}}]},renderHTML({node:e,HTMLAttributes:t}){const n=e.attrs.columns,o=["pubwave-editor__layout",`pubwave-layout--${n}-cols`];return["div",ne.mergeAttributes({"data-type":"layout","data-layout-columns":String(n),class:o.join(" ")},t),0]}}),Wa=ne.Node.create({name:"layoutColumn",priority:1e3,group:"block",isolating:!0,content:"block+",parseHTML(){return[{tag:'div[data-type="layoutColumn"]'},{tag:"div.pubwave-layout__column"}]},renderHTML({HTMLAttributes:e}){return["div",ne.mergeAttributes({"data-type":"layoutColumn",class:"pubwave-layout__column"},e),0]},addNodeView(){return Ae.ReactNodeViewRenderer(Ua)}});async function Va(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var c;const l=(c=s.target)==null?void 0:c.result;l?o(l):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Ga(e){return yr.extend({addProseMirrorPlugins(){return[new je.Plugin({key:new je.PluginKey("imagePasteHandler"),props:{handlePaste:(t,n)=>{var r;const o=Array.from(((r=n.clipboardData)==null?void 0:r.items)||[]);for(const a of o)if(a.type.indexOf("image")===0){n.preventDefault();const s=a.getAsFile();if(s)return Va(s,e).then(l=>{const{state:c,dispatch:f}=t,u=c.schema.nodes.image;if(u){const m=u.create({src:l}),h=c.tr.replaceSelectionWith(m);f(h)}}).catch(l=>{console.error("Failed to upload image:",l)}),!0}return!1}}})]}}).configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"pubwave-editor__image"}})}function Ya(e={}){const{headingLevels:t=[1,2,3],imageUpload:n,enableChart:o=!0,enableLayout:r=!0}=e,a=[nr,or.configure({HTMLAttributes:{class:"pubwave-editor__paragraph"}}),rr,mr,ar.configure({levels:t,HTMLAttributes:{class:"pubwave-editor__heading"}}),ir.configure({HTMLAttributes:{class:"pubwave-editor__bullet-list"}}),sr.configure({HTMLAttributes:{class:"pubwave-editor__ordered-list"}}),lr.configure({HTMLAttributes:{class:"pubwave-editor__list-item"}}),cr.configure({HTMLAttributes:{class:"pubwave-editor__task-list"}}),ur.configure({nested:!0,HTMLAttributes:{class:"pubwave-editor__task-item"}}),dr.configure({resizable:!0,HTMLAttributes:{class:"pubwave-editor__table"}}),pr.configure({HTMLAttributes:{class:"pubwave-editor__table-row"}}),fr.configure({HTMLAttributes:{class:"pubwave-editor__table-header"}}),hr.configure({HTMLAttributes:{class:"pubwave-editor__table-cell"}}),br.configure({HTMLAttributes:{class:"pubwave-editor__blockquote"}}),vr.configure({HTMLAttributes:{class:"pubwave-editor__code-block"}}),gr.configure({HTMLAttributes:{class:"pubwave-editor__divider"}}),Ga(n)];return o&&a.push(qa.configure({HTMLAttributes:{class:"pubwave-editor__chart"}})),r&&a.push(Fa.configure({HTMLAttributes:{class:"pubwave-editor__layout"}}),Wa.configure({HTMLAttributes:{class:"pubwave-editor__layout-column"}})),a}const Ka=ne.Mark.create({name:"textColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{color:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.color||t.getAttribute("data-color")||null},renderHTML:e=>e.color?{style:`color: ${e.color}`,"data-color":e.color}:{}}}},parseHTML(){return[{tag:'span[style*="color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.color||t.getAttribute("data-color");return n?{color:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",ne.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(l=>l.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(l=>l.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.color)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run()},unsetColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}}),Xa=ne.Mark.create({name:"backgroundColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.backgroundColor||t.getAttribute("data-background-color")||null},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`,"data-background-color":e.backgroundColor}:{}}}},parseHTML(){return[{tag:'span[style*="background-color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.backgroundColor||t.getAttribute("data-background-color");return n?{backgroundColor:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",ne.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBackgroundColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(l=>l.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(l=>l.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.backgroundColor)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run()},unsetBackgroundColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}});function Ja(e={}){const{linkOpenInNewTab:t=!0,linkOpenOnClick:n=!0}=e;return[wr.configure({HTMLAttributes:{class:"pubwave-editor__mark--bold"}}),kr.configure({HTMLAttributes:{class:"pubwave-editor__mark--italic"}}),Cr.configure({HTMLAttributes:{class:"pubwave-editor__mark--underline"}}),Tr.configure({HTMLAttributes:{class:"pubwave-editor__mark--strike"}}),Lr.configure({HTMLAttributes:{class:"pubwave-editor__mark--code"}}),Br.configure({openOnClick:n,HTMLAttributes:{class:"pubwave-editor__mark--link",rel:t?"noopener noreferrer":void 0,target:t?"_blank":void 0},validate:o=>{try{return new URL(o),!0}catch{return o.startsWith("/")||o.startsWith("#")}}}),Ka.configure({HTMLAttributes:{class:"pubwave-editor__mark--text-color"}}),Xa.configure({HTMLAttributes:{class:"pubwave-editor__mark--background-color"}})]}function Za(e,t,n){x.useEffect(()=>{if(e>=0&&n.current&&t.current){const o=t.current,r=n.current,a=o.scrollTop,s=o.clientHeight,l=o.scrollHeight,c=r.offsetTop,f=r.offsetHeight,u=o.querySelector(".pubwave-slash-menu__group"),m=o.querySelector(".pubwave-slash-menu__item"),h=Array.from(o.querySelectorAll(".pubwave-slash-menu__item")).pop(),v=c-a,p=v+f;let g=a;if(v<0)g=c-4,u&&g>u.offsetTop&&(g=Math.max(0,u.offsetTop)),m&&g>m.offsetTop-2&&(g=Math.max(0,m.offsetTop-2));else if(p>s){if(g=c-s+f+4,h){const y=h.offsetTop+h.offsetHeight-s+2;g>y&&(g=y)}g=Math.min(l-s,g)}Math.abs(g-a)>.5&&(o.scrollTop=g)}},[e,t,n])}const Qa={backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",maxHeight:"280px",overflowY:"auto",minWidth:"240px",maxWidth:"300px",padding:"var(--pubwave-spacing-1, 4px)",display:"flex",flexDirection:"column"},ei={marginBottom:"0"},ti={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted, #6b7280)",textTransform:"uppercase",letterSpacing:"0.5px"},ni={display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-3, 12px)",width:"100%",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",background:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--pubwave-radius-md, 6px)",transition:"background-color 0.1s ease",fontSize:"var(--pubwave-font-size-base, 14px)",color:"var(--pubwave-text, #1a1a1a)"},oi={display:"flex",alignItems:"center",justifyContent:"center",width:"var(--pubwave-icon-size, 20px)",height:"var(--pubwave-icon-size, 20px)",color:"var(--pubwave-text-tertiary, #4b5563)",flexShrink:0},ri={fontSize:"var(--pubwave-font-size-base, 14px)",fontWeight:400,color:"var(--pubwave-text, #1a1a1a)"},ai=typeof window>"u",Ot=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement=="function";function Y(e){return Ot?window.requestAnimationFrame(e):0}function vt(){if(!Ot)return!1;const e="ontouchstart"in window||navigator.maxTouchPoints>0,t=window.matchMedia("(pointer: coarse)").matches,n=window.matchMedia("(hover: hover)").matches;return e&&t||e&&!n}function Fn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 7V4h16v3M9 20h6M12 4v16"})})}function Wn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 10l3-2v12"})})}function Vn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M21 18h-5c0-2.5 5-2.5 5-5 0-1.5-1-3-3-3s-3 1.5-3 3"})})}function Gn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 12h3M17 18c2.5 0 4-1 4-3s-1.5-3-4-3"})})}function Yn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),i.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),i.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),i.jsx("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"})]})}function Kn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),i.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),i.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),i.jsx("text",{x:"3",y:"8",fontSize:"8",fill:"currentColor",stroke:"none",children:"1"}),i.jsx("text",{x:"3",y:"14",fontSize:"8",fill:"currentColor",stroke:"none",children:"2"}),i.jsx("text",{x:"3",y:"20",fontSize:"8",fill:"currentColor",stroke:"none",children:"3"})]})}function ii(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"6,9 12,15 18,9"})})}function si(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2h5a3 3 0 0 1 0 6H4V2z"}),i.jsx("path",{d:"M4 8h6a3 3 0 0 1 0 6H4V8z"})]})}function li(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"11",y1:"2",x2:"5",y2:"14"}),i.jsx("line",{x1:"6",y1:"2",x2:"12",y2:"2"}),i.jsx("line",{x1:"4",y1:"14",x2:"10",y2:"14"})]})}function ci(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2v6a4 4 0 0 0 8 0V2"}),i.jsx("line",{x1:"2",y1:"14",x2:"14",y2:"14"})]})}function ui(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),i.jsx("path",{d:"M5 4c0-1 1.5-2 3-2s3 .5 3 2c0 1-1 2-3 2"}),i.jsx("path",{d:"M5 12c0 1 1.5 2 3 2s3-.5 3-2c0-1-1-2-3-2"})]})}function di(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"5 4 1 8 5 12"}),i.jsx("polyline",{points:"11 4 15 8 11 12"})]})}function pi(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"1.87 0 12.19 16",fill:"currentColor",children:[i.jsx("path",{d:"M12.848 2.8a3.145 3.145 0 0 0-4.448 0L6.918 4.283a.625.625 0 0 0 .884.883l1.482-1.482c.74-.74 1.94-.74 2.68 0l.294.294c.74.74.74 1.94 0 2.68l-1.482 1.483a.625.625 0 1 0 .884.884l1.482-1.482a3.145 3.145 0 0 0 0-4.449z"}),i.jsx("path",{d:"M10.472 5.47a.625.625 0 0 0-.884 0L5.229 9.83a.625.625 0 1 0 .884.883l4.359-4.359a.625.625 0 0 0 0-.883"}),i.jsx("path",{d:"M5.167 6.918a.625.625 0 0 0-.884 0L2.8 8.4a3.146 3.146 0 0 0 0 4.448l.294.294a3.145 3.145 0 0 0 4.449 0l1.482-1.482a.625.625 0 0 0-.884-.884L6.66 12.258c-.74.74-1.94.74-2.68 0l-.295-.294c-.74-.74-.74-1.94 0-2.68L5.167 7.8a.625.625 0 0 0 0-.883"})]})}function fi(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M10 3h4v4M14 3l-7 7M14 11v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3"})})}function hi(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M13 4L6 11l-3-3"})})}function bi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}function vi({textColor:e,backgroundColor:t}){const n=t||"transparent",o=!t;return i.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:n,border:o?"1px solid var(--pubwave-border)":"none",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:e,lineHeight:1},children:"A"})})}function gi(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"5",width:"4",height:"4",rx:"0.5"}),i.jsx("rect",{x:"3",y:"14",width:"4",height:"4",rx:"0.5"}),i.jsx("path",{d:"M4 16l1.5 1.5L7 15"}),i.jsx("line",{x1:"10",y1:"7",x2:"21",y2:"7"}),i.jsx("line",{x1:"10",y1:"16",x2:"21",y2:"16"})]})}function mi(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2H4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"}),i.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2h-4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"})]})}function xi(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"16,18 22,12 16,6"}),i.jsx("polyline",{points:"8,6 2,12 8,18"})]})}function yi(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}function wi(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),i.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),i.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),i.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function ki(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21,15 16,10 5,21"})]})}function Ci(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function Ti(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"21"}),i.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"21"})]})}async function Li(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var c;const l=(c=s.target)==null?void 0:c.result;l?o(l):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Bi(e,t,n){if(!((n==null?void 0:n.accept)??["image/*"]).some(a=>a==="image/*"?t.type.startsWith("image/"):t.type===a)){console.warn("Selected file is not an image");return}Li(t,n).then(a=>{e.chain().focus().setImage({src:a}).run()}).catch(a=>{console.error("Failed to upload image:",a)})}function hn(e,t){const{state:n,dispatch:o}=e.view,r=n.schema.nodes.layout,a=n.schema.nodes.layoutColumn;if(!r||!a){console.warn("Layout node type not found in schema");return}const s=n.schema.nodes.paragraph;if(!s){console.warn("Paragraph node type not found in schema");return}const l=Array.from({length:t},()=>a.create(null,s.create())),c=r.create({columns:t},l),f=n.tr.replaceSelectionWith(c);o(f);const u=f.selection.$from.before();e.chain().focus().setTextSelection(u+2).run()}function Jt(e,t){var r,a,s,l,c,f;const o=(t||{slashMenu:{commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},table:{title:"Table",description:"Insert a table"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}}}).slashMenu.commands;return[{id:"paragraph",title:o.paragraph.title,description:o.paragraph.description,icon:i.jsx(Fn,{}),aliases:["p","text","paragraph"],group:"basic",action:u=>u.chain().focus().setParagraph().run()},{id:"heading1",title:o.heading1.title,description:o.heading1.description,icon:i.jsx(Wn,{}),aliases:["h1","title"],group:"basic",action:u=>u.chain().focus().toggleHeading({level:1}).run()},{id:"heading2",title:o.heading2.title,description:o.heading2.description,icon:i.jsx(Vn,{}),aliases:["h2","subtitle"],group:"basic",action:u=>u.chain().focus().toggleHeading({level:2}).run()},{id:"heading3",title:o.heading3.title,description:o.heading3.description,icon:i.jsx(Gn,{}),aliases:["h3"],group:"basic",action:u=>u.chain().focus().toggleHeading({level:3}).run()},{id:"bulletList",title:o.bulletList.title,description:o.bulletList.description,icon:i.jsx(Yn,{}),aliases:["ul","bullet","unordered","-"],group:"list",action:u=>u.chain().focus().toggleBulletList().run()},{id:"orderedList",title:o.orderedList.title,description:o.orderedList.description,icon:i.jsx(Kn,{}),aliases:["ol","numbered","ordered","1."],group:"list",action:u=>u.chain().focus().toggleOrderedList().run()},{id:"taskList",title:o.taskList.title,description:o.taskList.description,icon:i.jsx(gi,{}),aliases:["todo","task","checkbox","[]"],group:"list",action:u=>u.chain().focus().toggleTaskList().run()},{id:"image",title:o.image.title,description:o.image.description,icon:i.jsx(ki,{}),aliases:["img","picture","photo","pic"],group:"media",action:u=>{const m=document.createElement("input");m.type="file";const h=(e==null?void 0:e.accept)??["image/*"];m.accept=h.join(","),m.style.display="none",m.onchange=v=>{var g;const p=(g=v.target.files)==null?void 0:g[0];p&&Bi(u,p,e),document.body.removeChild(m)},document.body.appendChild(m),m.click()}},{id:"blockquote",title:o.blockquote.title,description:o.blockquote.description,icon:i.jsx(mi,{}),aliases:["quote","blockquote",">"],group:"advanced",action:u=>u.chain().focus().toggleBlockquote().run()},{id:"codeBlock",title:o.codeBlock.title,description:o.codeBlock.description,icon:i.jsx(xi,{}),aliases:["code","pre","snippet","```"],group:"advanced",action:u=>u.chain().focus().toggleCodeBlock().run()},{id:"horizontalRule",title:o.horizontalRule.title,description:o.horizontalRule.description,icon:i.jsx(yi,{}),aliases:["hr","divider","line","---"],group:"advanced",action:u=>{u.chain().focus().setHorizontalRule().run(),Y(()=>{const{state:m}=u.view,{$from:h}=m.selection;let v=-1;const p=h.pos;if(m.doc.descendants((g,C)=>{if(g.type.name==="horizontalRule"){const y=Math.abs(C-p);(v===-1||Math.abs(v-p)>y)&&(v=C)}}),v!==-1){const g=m.doc.nodeAt(v);if(g){const C=v+g.nodeSize;u.chain().setTextSelection(C).insertContent({type:"paragraph"}).focus().run()}}else u.chain().focus().createParagraphNear().run()})}},{id:"table",title:((r=o.table)==null?void 0:r.title)??"Table",description:((a=o.table)==null?void 0:a.description)??"Insert a table",icon:i.jsx(wi,{}),aliases:["table","grid","tbl"],group:"advanced",action:u=>u.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{id:"layoutTwoColumn",title:((s=o.layoutTwoColumn)==null?void 0:s.title)??"Two Column Layout",description:((l=o.layoutTwoColumn)==null?void 0:l.description)??"Split content into two side-by-side columns",icon:i.jsx(Ci,{}),aliases:["layout2","two columns","2 col","columns"],group:"layout",action:u=>hn(u,2)},{id:"layoutThreeColumn",title:((c=o.layoutThreeColumn)==null?void 0:c.title)??"Three Column Layout",description:((f=o.layoutThreeColumn)==null?void 0:f.description)??"Split content into three side-by-side columns",icon:i.jsx(Ti,{}),aliases:["layout3","three columns","3 col"],group:"layout",action:u=>hn(u,3)}]}const Xn=Jt();function Ai(e,t){if(!t)return e;const n=t.toLowerCase();return e.filter(o=>{var l;const r=o.title.toLowerCase(),a=r.startsWith(n)||r.includes(` ${n}`),s=((l=o.aliases)==null?void 0:l.some(c=>c.toLowerCase().startsWith(n)))??!1;return a||s})}var ee="top",ce="bottom",ue="right",te="left",Zt="auto",gt=[ee,ce,ue,te],Qe="start",dt="end",ji="clippingParents",Jn="viewport",rt="popper",Si="reference",bn=gt.reduce(function(e,t){return e.concat([t+"-"+Qe,t+"-"+dt])},[]),Zn=[].concat(gt,[Zt]).reduce(function(e,t){return e.concat([t,t+"-"+Qe,t+"-"+dt])},[]),Mi="beforeRead",Pi="read",Di="afterRead",Ii="beforeMain",Ri="main",Ei="afterMain",Oi="beforeWrite",_i="write",Ni="afterWrite",Hi=[Mi,Pi,Di,Ii,Ri,Ei,Oi,_i,Ni];function me(e){return e?(e.nodeName||"").toLowerCase():null}function re(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Fe(e){var t=re(e).Element;return e instanceof t||e instanceof Element}function le(e){var t=re(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Qt(e){if(typeof ShadowRoot>"u")return!1;var t=re(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function $i(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var o=t.styles[n]||{},r=t.attributes[n]||{},a=t.elements[n];!le(a)||!me(a)||(Object.assign(a.style,o),Object.keys(r).forEach(function(s){var l=r[s];l===!1?a.removeAttribute(s):a.setAttribute(s,l===!0?"":l)}))})}function zi(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(o){var r=t.elements[o],a=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:n[o]),l=s.reduce(function(c,f){return c[f]="",c},{});!le(r)||!me(r)||(Object.assign(r.style,l),Object.keys(a).forEach(function(c){r.removeAttribute(c)}))})}}const Qn={name:"applyStyles",enabled:!0,phase:"write",fn:$i,effect:zi,requires:["computeStyles"]};function ge(e){return e.split("-")[0]}var Ue=Math.max,Dt=Math.min,et=Math.round;function Wt(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function eo(){return!/^((?!chrome|android).)*safari/i.test(Wt())}function tt(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var o=e.getBoundingClientRect(),r=1,a=1;t&&le(e)&&(r=e.offsetWidth>0&&et(o.width)/e.offsetWidth||1,a=e.offsetHeight>0&&et(o.height)/e.offsetHeight||1);var s=Fe(e)?re(e):window,l=s.visualViewport,c=!eo()&&n,f=(o.left+(c&&l?l.offsetLeft:0))/r,u=(o.top+(c&&l?l.offsetTop:0))/a,m=o.width/r,h=o.height/a;return{width:m,height:h,top:u,right:f+m,bottom:u+h,left:f,x:f,y:u}}function en(e){var t=tt(e),n=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:o}}function to(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Qt(n)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function Se(e){return re(e).getComputedStyle(e)}function qi(e){return["table","td","th"].indexOf(me(e))>=0}function De(e){return((Fe(e)?e.ownerDocument:e.document)||window.document).documentElement}function _t(e){return me(e)==="html"?e:e.assignedSlot||e.parentNode||(Qt(e)?e.host:null)||De(e)}function vn(e){return!le(e)||Se(e).position==="fixed"?null:e.offsetParent}function Ui(e){var t=/firefox/i.test(Wt()),n=/Trident/i.test(Wt());if(n&&le(e)){var o=Se(e);if(o.position==="fixed")return null}var r=_t(e);for(Qt(r)&&(r=r.host);le(r)&&["html","body"].indexOf(me(r))<0;){var a=Se(r);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||t&&a.willChange==="filter"||t&&a.filter&&a.filter!=="none")return r;r=r.parentNode}return null}function mt(e){for(var t=re(e),n=vn(e);n&&qi(n)&&Se(n).position==="static";)n=vn(n);return n&&(me(n)==="html"||me(n)==="body"&&Se(n).position==="static")?t:n||Ui(e)||t}function tn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function lt(e,t,n){return Ue(e,Dt(t,n))}function Fi(e,t,n){var o=lt(e,t,n);return o>n?n:o}function no(){return{top:0,right:0,bottom:0,left:0}}function oo(e){return Object.assign({},no(),e)}function ro(e,t){return t.reduce(function(n,o){return n[o]=e,n},{})}var Wi=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,oo(typeof t!="number"?t:ro(t,gt))};function Vi(e){var t,n=e.state,o=e.name,r=e.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,l=ge(n.placement),c=tn(l),f=[te,ue].indexOf(l)>=0,u=f?"height":"width";if(!(!a||!s)){var m=Wi(r.padding,n),h=en(a),v=c==="y"?ee:te,p=c==="y"?ce:ue,g=n.rects.reference[u]+n.rects.reference[c]-s[c]-n.rects.popper[u],C=s[c]-n.rects.reference[c],y=mt(a),S=y?c==="y"?y.clientHeight||0:y.clientWidth||0:0,T=g/2-C/2,d=m[v],A=S-h[u]-m[p],k=S/2-h[u]/2+T,j=lt(d,k,A),I=c;n.modifiersData[o]=(t={},t[I]=j,t.centerOffset=j-k,t)}}function Gi(e){var t=e.state,n=e.options,o=n.element,r=o===void 0?"[data-popper-arrow]":o;r!=null&&(typeof r=="string"&&(r=t.elements.popper.querySelector(r),!r)||to(t.elements.popper,r)&&(t.elements.arrow=r))}const Yi={name:"arrow",enabled:!0,phase:"main",fn:Vi,effect:Gi,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function nt(e){return e.split("-")[1]}var Ki={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Xi(e,t){var n=e.x,o=e.y,r=t.devicePixelRatio||1;return{x:et(n*r)/r||0,y:et(o*r)/r||0}}function gn(e){var t,n=e.popper,o=e.popperRect,r=e.placement,a=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,f=e.adaptive,u=e.roundOffsets,m=e.isFixed,h=s.x,v=h===void 0?0:h,p=s.y,g=p===void 0?0:p,C=typeof u=="function"?u({x:v,y:g}):{x:v,y:g};v=C.x,g=C.y;var y=s.hasOwnProperty("x"),S=s.hasOwnProperty("y"),T=te,d=ee,A=window;if(f){var k=mt(n),j="clientHeight",I="clientWidth";if(k===re(n)&&(k=De(n),Se(k).position!=="static"&&l==="absolute"&&(j="scrollHeight",I="scrollWidth")),k=k,r===ee||(r===te||r===ue)&&a===dt){d=ce;var N=m&&k===A&&A.visualViewport?A.visualViewport.height:k[j];g-=N-o.height,g*=c?1:-1}if(r===te||(r===ee||r===ce)&&a===dt){T=ue;var B=m&&k===A&&A.visualViewport?A.visualViewport.width:k[I];v-=B-o.width,v*=c?1:-1}}var _=Object.assign({position:l},f&&Ki),b=u===!0?Xi({x:v,y:g},re(n)):{x:v,y:g};if(v=b.x,g=b.y,c){var L;return Object.assign({},_,(L={},L[d]=S?"0":"",L[T]=y?"0":"",L.transform=(A.devicePixelRatio||1)<=1?"translate("+v+"px, "+g+"px)":"translate3d("+v+"px, "+g+"px, 0)",L))}return Object.assign({},_,(t={},t[d]=S?g+"px":"",t[T]=y?v+"px":"",t.transform="",t))}function Ji(e){var t=e.state,n=e.options,o=n.gpuAcceleration,r=o===void 0?!0:o,a=n.adaptive,s=a===void 0?!0:a,l=n.roundOffsets,c=l===void 0?!0:l,f={placement:ge(t.placement),variation:nt(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,gn(Object.assign({},f,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,gn(Object.assign({},f,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Zi={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Ji,data:{}};var Bt={passive:!0};function Qi(e){var t=e.state,n=e.instance,o=e.options,r=o.scroll,a=r===void 0?!0:r,s=o.resize,l=s===void 0?!0:s,c=re(t.elements.popper),f=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&f.forEach(function(u){u.addEventListener("scroll",n.update,Bt)}),l&&c.addEventListener("resize",n.update,Bt),function(){a&&f.forEach(function(u){u.removeEventListener("scroll",n.update,Bt)}),l&&c.removeEventListener("resize",n.update,Bt)}}const es={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Qi,data:{}};var ts={left:"right",right:"left",bottom:"top",top:"bottom"};function St(e){return e.replace(/left|right|bottom|top/g,function(t){return ts[t]})}var ns={start:"end",end:"start"};function mn(e){return e.replace(/start|end/g,function(t){return ns[t]})}function nn(e){var t=re(e),n=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:n,scrollTop:o}}function on(e){return tt(De(e)).left+nn(e).scrollLeft}function os(e,t){var n=re(e),o=De(e),r=n.visualViewport,a=o.clientWidth,s=o.clientHeight,l=0,c=0;if(r){a=r.width,s=r.height;var f=eo();(f||!f&&t==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}return{width:a,height:s,x:l+on(e),y:c}}function rs(e){var t,n=De(e),o=nn(e),r=(t=e.ownerDocument)==null?void 0:t.body,a=Ue(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=Ue(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),l=-o.scrollLeft+on(e),c=-o.scrollTop;return Se(r||n).direction==="rtl"&&(l+=Ue(n.clientWidth,r?r.clientWidth:0)-a),{width:a,height:s,x:l,y:c}}function rn(e){var t=Se(e),n=t.overflow,o=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+o)}function ao(e){return["html","body","#document"].indexOf(me(e))>=0?e.ownerDocument.body:le(e)&&rn(e)?e:ao(_t(e))}function ct(e,t){var n;t===void 0&&(t=[]);var o=ao(e),r=o===((n=e.ownerDocument)==null?void 0:n.body),a=re(o),s=r?[a].concat(a.visualViewport||[],rn(o)?o:[]):o,l=t.concat(s);return r?l:l.concat(ct(_t(s)))}function Vt(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function as(e,t){var n=tt(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function xn(e,t,n){return t===Jn?Vt(os(e,n)):Fe(t)?as(t,n):Vt(rs(De(e)))}function is(e){var t=ct(_t(e)),n=["absolute","fixed"].indexOf(Se(e).position)>=0,o=n&&le(e)?mt(e):e;return Fe(o)?t.filter(function(r){return Fe(r)&&to(r,o)&&me(r)!=="body"}):[]}function ss(e,t,n,o){var r=t==="clippingParents"?is(e):[].concat(t),a=[].concat(r,[n]),s=a[0],l=a.reduce(function(c,f){var u=xn(e,f,o);return c.top=Ue(u.top,c.top),c.right=Dt(u.right,c.right),c.bottom=Dt(u.bottom,c.bottom),c.left=Ue(u.left,c.left),c},xn(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function io(e){var t=e.reference,n=e.element,o=e.placement,r=o?ge(o):null,a=o?nt(o):null,s=t.x+t.width/2-n.width/2,l=t.y+t.height/2-n.height/2,c;switch(r){case ee:c={x:s,y:t.y-n.height};break;case ce:c={x:s,y:t.y+t.height};break;case ue:c={x:t.x+t.width,y:l};break;case te:c={x:t.x-n.width,y:l};break;default:c={x:t.x,y:t.y}}var f=r?tn(r):null;if(f!=null){var u=f==="y"?"height":"width";switch(a){case Qe:c[f]=c[f]-(t[u]/2-n[u]/2);break;case dt:c[f]=c[f]+(t[u]/2-n[u]/2);break}}return c}function pt(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=o===void 0?e.placement:o,a=n.strategy,s=a===void 0?e.strategy:a,l=n.boundary,c=l===void 0?ji:l,f=n.rootBoundary,u=f===void 0?Jn:f,m=n.elementContext,h=m===void 0?rt:m,v=n.altBoundary,p=v===void 0?!1:v,g=n.padding,C=g===void 0?0:g,y=oo(typeof C!="number"?C:ro(C,gt)),S=h===rt?Si:rt,T=e.rects.popper,d=e.elements[p?S:h],A=ss(Fe(d)?d:d.contextElement||De(e.elements.popper),c,u,s),k=tt(e.elements.reference),j=io({reference:k,element:T,placement:r}),I=Vt(Object.assign({},T,j)),N=h===rt?I:k,B={top:A.top-N.top+y.top,bottom:N.bottom-A.bottom+y.bottom,left:A.left-N.left+y.left,right:N.right-A.right+y.right},_=e.modifiersData.offset;if(h===rt&&_){var b=_[r];Object.keys(B).forEach(function(L){var M=[ue,ce].indexOf(L)>=0?1:-1,E=[ee,ce].indexOf(L)>=0?"y":"x";B[L]+=b[E]*M})}return B}function ls(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=n.boundary,a=n.rootBoundary,s=n.padding,l=n.flipVariations,c=n.allowedAutoPlacements,f=c===void 0?Zn:c,u=nt(o),m=u?l?bn:bn.filter(function(p){return nt(p)===u}):gt,h=m.filter(function(p){return f.indexOf(p)>=0});h.length===0&&(h=m);var v=h.reduce(function(p,g){return p[g]=pt(e,{placement:g,boundary:r,rootBoundary:a,padding:s})[ge(g)],p},{});return Object.keys(v).sort(function(p,g){return v[p]-v[g]})}function cs(e){if(ge(e)===Zt)return[];var t=St(e);return[mn(e),t,mn(t)]}function us(e){var t=e.state,n=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,l=s===void 0?!0:s,c=n.fallbackPlacements,f=n.padding,u=n.boundary,m=n.rootBoundary,h=n.altBoundary,v=n.flipVariations,p=v===void 0?!0:v,g=n.allowedAutoPlacements,C=t.options.placement,y=ge(C),S=y===C,T=c||(S||!p?[St(C)]:cs(C)),d=[C].concat(T).reduce(function(Z,Q){return Z.concat(ge(Q)===Zt?ls(t,{placement:Q,boundary:u,rootBoundary:m,padding:f,flipVariations:p,allowedAutoPlacements:g}):Q)},[]),A=t.rects.reference,k=t.rects.popper,j=new Map,I=!0,N=d[0],B=0;B<d.length;B++){var _=d[B],b=ge(_),L=nt(_)===Qe,M=[ee,ce].indexOf(b)>=0,E=M?"width":"height",$=pt(t,{placement:_,boundary:u,rootBoundary:m,altBoundary:h,padding:f}),q=M?L?ue:te:L?ce:ee;A[E]>k[E]&&(q=St(q));var H=St(q),P=[];if(a&&P.push($[b]<=0),l&&P.push($[q]<=0,$[H]<=0),P.every(function(Z){return Z})){N=_,I=!1;break}j.set(_,P)}if(I)for(var R=p?3:1,W=function(Q){var ae=d.find(function(ye){var ie=j.get(ye);if(ie)return ie.slice(0,Q).every(function(we){return we})});if(ae)return N=ae,"break"},V=R;V>0;V--){var J=W(V);if(J==="break")break}t.placement!==N&&(t.modifiersData[o]._skip=!0,t.placement=N,t.reset=!0)}}const ds={name:"flip",enabled:!0,phase:"main",fn:us,requiresIfExists:["offset"],data:{_skip:!1}};function yn(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function wn(e){return[ee,ue,ce,te].some(function(t){return e[t]>=0})}function ps(e){var t=e.state,n=e.name,o=t.rects.reference,r=t.rects.popper,a=t.modifiersData.preventOverflow,s=pt(t,{elementContext:"reference"}),l=pt(t,{altBoundary:!0}),c=yn(s,o),f=yn(l,r,a),u=wn(c),m=wn(f);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:f,isReferenceHidden:u,hasPopperEscaped:m},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":m})}const fs={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:ps};function hs(e,t,n){var o=ge(e),r=[te,ee].indexOf(o)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=a[0],l=a[1];return s=s||0,l=(l||0)*r,[te,ue].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}function bs(e){var t=e.state,n=e.options,o=e.name,r=n.offset,a=r===void 0?[0,0]:r,s=Zn.reduce(function(u,m){return u[m]=hs(m,t.rects,a),u},{}),l=s[t.placement],c=l.x,f=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=f),t.modifiersData[o]=s}const vs={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:bs};function gs(e){var t=e.state,n=e.name;t.modifiersData[n]=io({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const ms={name:"popperOffsets",enabled:!0,phase:"read",fn:gs,data:{}};function xs(e){return e==="x"?"y":"x"}function ys(e){var t=e.state,n=e.options,o=e.name,r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,l=s===void 0?!1:s,c=n.boundary,f=n.rootBoundary,u=n.altBoundary,m=n.padding,h=n.tether,v=h===void 0?!0:h,p=n.tetherOffset,g=p===void 0?0:p,C=pt(t,{boundary:c,rootBoundary:f,padding:m,altBoundary:u}),y=ge(t.placement),S=nt(t.placement),T=!S,d=tn(y),A=xs(d),k=t.modifiersData.popperOffsets,j=t.rects.reference,I=t.rects.popper,N=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,B=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),_=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,b={x:0,y:0};if(k){if(a){var L,M=d==="y"?ee:te,E=d==="y"?ce:ue,$=d==="y"?"height":"width",q=k[d],H=q+C[M],P=q-C[E],R=v?-I[$]/2:0,W=S===Qe?j[$]:I[$],V=S===Qe?-I[$]:-j[$],J=t.elements.arrow,Z=v&&J?en(J):{width:0,height:0},Q=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:no(),ae=Q[M],ye=Q[E],ie=lt(0,j[$],Z[$]),we=T?j[$]/2-R-ie-ae-B.mainAxis:W-ie-ae-B.mainAxis,de=T?-j[$]/2+R+ie+ye+B.mainAxis:V+ie+ye+B.mainAxis,ke=t.elements.arrow&&mt(t.elements.arrow),Ee=ke?d==="y"?ke.clientTop||0:ke.clientLeft||0:0,Ce=(L=_==null?void 0:_[d])!=null?L:0,Oe=q+we-Ce-Ee,pe=q+de-Ce,Te=lt(v?Dt(H,Oe):H,q,v?Ue(P,pe):P);k[d]=Te,b[d]=Te-q}if(l){var Me,_e=d==="x"?ee:te,fe=d==="x"?ce:ue,he=k[A],be=A==="y"?"height":"width",Ne=he+C[_e],G=he-C[fe],ot=[ee,te].indexOf(y)!==-1,yt=(Me=_==null?void 0:_[A])!=null?Me:0,wt=ot?Ne:he-j[be]-I[be]-yt+B.altAxis,kt=ot?he+j[be]+I[be]-yt-B.altAxis:G,Ct=v&&ot?Fi(wt,he,kt):lt(v?wt:Ne,he,v?kt:G);k[A]=Ct,b[A]=Ct-he}t.modifiersData[o]=b}}const ws={name:"preventOverflow",enabled:!0,phase:"main",fn:ys,requiresIfExists:["offset"]};function ks(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Cs(e){return e===re(e)||!le(e)?nn(e):ks(e)}function Ts(e){var t=e.getBoundingClientRect(),n=et(t.width)/e.offsetWidth||1,o=et(t.height)/e.offsetHeight||1;return n!==1||o!==1}function Ls(e,t,n){n===void 0&&(n=!1);var o=le(t),r=le(t)&&Ts(t),a=De(t),s=tt(e,r,n),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!n)&&((me(t)!=="body"||rn(a))&&(l=Cs(t)),le(t)?(c=tt(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=on(a))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}function Bs(e){var t=new Map,n=new Set,o=[];e.forEach(function(a){t.set(a.name,a)});function r(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(l){if(!n.has(l)){var c=t.get(l);c&&r(c)}}),o.push(a)}return e.forEach(function(a){n.has(a.name)||r(a)}),o}function As(e){var t=Bs(e);return Hi.reduce(function(n,o){return n.concat(t.filter(function(r){return r.phase===o}))},[])}function js(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function Ss(e){var t=e.reduce(function(n,o){var r=n[o.name];return n[o.name]=r?Object.assign({},r,o,{options:Object.assign({},r.options,o.options),data:Object.assign({},r.data,o.data)}):o,n},{});return Object.keys(t).map(function(n){return t[n]})}var kn={placement:"bottom",modifiers:[],strategy:"absolute"};function Cn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}function Ms(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,o=n===void 0?[]:n,r=t.defaultOptions,a=r===void 0?kn:r;return function(l,c,f){f===void 0&&(f=a);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},kn,a),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},m=[],h=!1,v={state:u,setOptions:function(y){var S=typeof y=="function"?y(u.options):y;g(),u.options=Object.assign({},a,u.options,S),u.scrollParents={reference:Fe(l)?ct(l):l.contextElement?ct(l.contextElement):[],popper:ct(c)};var T=As(Ss([].concat(o,u.options.modifiers)));return u.orderedModifiers=T.filter(function(d){return d.enabled}),p(),v.update()},forceUpdate:function(){if(!h){var y=u.elements,S=y.reference,T=y.popper;if(Cn(S,T)){u.rects={reference:Ls(S,mt(T),u.options.strategy==="fixed"),popper:en(T)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(B){return u.modifiersData[B.name]=Object.assign({},B.data)});for(var d=0;d<u.orderedModifiers.length;d++){if(u.reset===!0){u.reset=!1,d=-1;continue}var A=u.orderedModifiers[d],k=A.fn,j=A.options,I=j===void 0?{}:j,N=A.name;typeof k=="function"&&(u=k({state:u,options:I,name:N,instance:v})||u)}}}},update:js(function(){return new Promise(function(C){v.forceUpdate(),C(u)})}),destroy:function(){g(),h=!0}};if(!Cn(l,c))return v;v.setOptions(f).then(function(C){!h&&f.onFirstUpdate&&f.onFirstUpdate(C)});function p(){u.orderedModifiers.forEach(function(C){var y=C.name,S=C.options,T=S===void 0?{}:S,d=C.effect;if(typeof d=="function"){var A=d({state:u,name:y,instance:v,options:T}),k=function(){};m.push(A||k)}})}function g(){m.forEach(function(C){return C()}),m=[]}return v}}var Ps=[es,ms,Zi,Qn,vs,ds,ws,Yi,fs],Ds=Ms({defaultModifiers:Ps}),Is="tippy-box",so="tippy-content",Rs="tippy-backdrop",lo="tippy-arrow",co="tippy-svg-arrow",ze={passive:!0,capture:!0},uo=function(){return document.body};function Es(e,t){return{}.hasOwnProperty.call(e,t)}function $t(e,t,n){if(Array.isArray(e)){var o=e[t];return o??(Array.isArray(n)?n[t]:n)}return e}function an(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function po(e,t){return typeof e=="function"?e.apply(void 0,t):e}function Tn(e,t){if(t===0)return e;var n;return function(o){clearTimeout(n),n=setTimeout(function(){e(o)},t)}}function Os(e,t){var n=Object.assign({},e);return t.forEach(function(o){delete n[o]}),n}function _s(e){return e.split(/\s+/).filter(Boolean)}function Ze(e){return[].concat(e)}function Ln(e,t){e.indexOf(t)===-1&&e.push(t)}function Ns(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function Hs(e){return e.split("-")[0]}function It(e){return[].slice.call(e)}function Bn(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function ut(){return document.createElement("div")}function ft(e){return["Element","Fragment"].some(function(t){return an(e,t)})}function $s(e){return an(e,"NodeList")}function zs(e){return an(e,"MouseEvent")}function qs(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Us(e){return ft(e)?[e]:$s(e)?It(e):Array.isArray(e)?e:It(document.querySelectorAll(e))}function zt(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function An(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function Fs(e){var t,n=Ze(e),o=n[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}function Ws(e,t){var n=t.clientX,o=t.clientY;return e.every(function(r){var a=r.popperRect,s=r.popperState,l=r.props,c=l.interactiveBorder,f=Hs(s.placement),u=s.modifiersData.offset;if(!u)return!0;var m=f==="bottom"?u.top.y:0,h=f==="top"?u.bottom.y:0,v=f==="right"?u.left.x:0,p=f==="left"?u.right.x:0,g=a.top-o+m>c,C=o-a.bottom-h>c,y=a.left-n+v>c,S=n-a.right-p>c;return g||C||y||S})}function qt(e,t,n){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){e[o](r,n)})}function jn(e,t){for(var n=t;n;){var o;if(e.contains(n))return!0;n=n.getRootNode==null||(o=n.getRootNode())==null?void 0:o.host}return!1}var ve={isTouch:!1},Sn=0;function Vs(){ve.isTouch||(ve.isTouch=!0,window.performance&&document.addEventListener("mousemove",fo))}function fo(){var e=performance.now();e-Sn<20&&(ve.isTouch=!1,document.removeEventListener("mousemove",fo)),Sn=e}function Gs(){var e=document.activeElement;if(qs(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function Ys(){document.addEventListener("touchstart",Vs,ze),window.addEventListener("blur",Gs)}var Ks=typeof window<"u"&&typeof document<"u",Xs=Ks?!!window.msCrypto:!1;function Je(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Mn(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function Js(e){return Mn(`
1
+ "use strict";var Yo=Object.create;var fn=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Ko=Object.getOwnPropertyNames;var Jo=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var Qo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ko(t))!Zo.call(e,r)&&r!==n&&fn(e,r,{get:()=>t[r],enumerable:!(o=Xo(t,r))||o.enumerable});return e};var er=(e,t,n)=>(n=e!=null?Yo(Jo(e)):{},Qo(t||!e||!e.__esModule?fn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("@tiptap/core"),tr=require("@tiptap/extension-placeholder"),nr=require("@tiptap/extension-history"),or=require("@tiptap/extension-dropcursor"),rr=require("@tiptap/extension-gapcursor"),ar=require("@tiptap/extension-document"),ir=require("@tiptap/extension-paragraph"),sr=require("@tiptap/extension-text"),lr=require("@tiptap/extension-heading"),cr=require("@tiptap/extension-bullet-list"),ur=require("@tiptap/extension-ordered-list"),dr=require("@tiptap/extension-list-item"),pr=require("@tiptap/extension-task-list"),fr=require("@tiptap/extension-task-item"),hr=require("@tiptap/extension-table"),br=require("@tiptap/extension-table-row"),vr=require("@tiptap/extension-table-header"),gr=require("@tiptap/extension-table-cell"),mr=require("@tiptap/extension-blockquote"),wr=require("@tiptap/extension-code-block"),yr=require("@tiptap/extension-horizontal-rule"),xr=require("@tiptap/extension-hard-break"),Pe=require("@tiptap/react"),i=require("react/jsx-runtime"),w=require("react"),kr=require("react-dom"),Cr=require("@tiptap/extension-image"),Ae=require("@tiptap/pm/state"),Tr=require("@tiptap/extension-bold"),Lr=require("@tiptap/extension-italic"),Br=require("@tiptap/extension-underline"),Ar=require("@tiptap/extension-strike"),jr=require("@tiptap/extension-code"),Sr=require("@tiptap/extension-link"),Rr=require("@tiptap/pm/schema-list"),Mr=require("@tiptap/suggestion"),Pr=[{value:"bar",label:"bar"},{value:"line",label:"line"},{value:"pie",label:"pie"},{value:"doughnut",label:"doughnut"},{value:"radar",label:"radar"},{value:"polarArea",label:"polarArea"}];function Dr(e){return{backgroundColor:`rgba(59, 130, 246, ${.5+e%3*.2})`,borderColor:"rgba(59, 130, 246, 1)"}}function Ir({initialData:e,onSave:t,onCancel:n,locale:o}){var S,K,g,j,I,F,X,W,z;const[r,a]=w.useState(e.type),[s,l]=w.useState(((g=(K=(S=e.options)==null?void 0:S.plugins)==null?void 0:K.title)==null?void 0:g.text)??""),[c,f]=w.useState(((F=(I=(j=e.options)==null?void 0:j.plugins)==null?void 0:I.legend)==null?void 0:F.display)??!0),[p,y]=w.useState(((z=(W=(X=e.options)==null?void 0:X.plugins)==null?void 0:W.legend)==null?void 0:z.position)??"bottom"),[d,b]=w.useState(e.data.labels),[h,v]=w.useState(e.data.datasets),C=w.useRef(null),m=(o==null?void 0:o.chart)||{modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Label",datasetLabelPlaceholder:"Dataset label...",data:"Data",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}};w.useEffect(()=>{const M=D=>{D.key==="Escape"&&n()};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n]),w.useEffect(()=>{const M=ne=>{C.current&&C.current.contains(ne.target)},D=setTimeout(()=>{document.addEventListener("mousedown",M)},100);return()=>{clearTimeout(D),document.removeEventListener("mousedown",M)}},[]);const B=w.useCallback((M,D)=>{v(ne=>ne.map((oe,se)=>se===M?{...oe,label:D}:oe))},[]),k=w.useCallback((M,D)=>{v(ne=>ne.map((oe,se)=>se===M?{...oe,data:D.split(",").map(L=>parseFloat(L.trim())||0)}:oe))},[]),u=w.useCallback(()=>{const M=Dr(h.length);v(D=>[...D,{label:`${m.modal.fields.datasets.title} ${D.length+1}`,data:d.map(()=>Math.floor(Math.random()*100)),backgroundColor:M.backgroundColor,borderColor:M.borderColor,borderWidth:2}])},[h.length,d,m]),T=w.useCallback(M=>{v(D=>D.filter((ne,oe)=>oe!==M))},[]),A=w.useCallback(M=>{b(M.split(",").map(D=>D.trim()).filter(Boolean))},[]),E=w.useCallback(()=>{const M={type:r,data:{labels:d,datasets:h},options:{...e.options,responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!!s,text:s,color:"var(--pubwave-text, #37352f)",font:{size:16,weight:"bold"}},legend:{display:c,position:p}}}};t(M)},[r,s,c,p,d,h,e.options,t]),H=w.useCallback(M=>{M.target===M.currentTarget&&n()},[n]),G=i.jsx("div",{className:"pubwave-modal__overlay",onClick:H,children:i.jsxs("div",{ref:C,className:"pubwave-modal__container",role:"dialog","aria-modal":"true","aria-labelledby":"chart-modal-title",children:[i.jsxs("div",{className:"pubwave-modal__header",children:[i.jsx("h2",{id:"chart-modal-title",className:"pubwave-modal__title",children:m.modal.title}),i.jsx("button",{type:"button",className:"pubwave-modal__close",onClick:n,"aria-label":m.modal.close,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsxs("div",{className:"pubwave-modal__body",children:[i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-type",className:"pubwave-form__label",children:m.modal.fields.chartType}),i.jsx("select",{id:"chart-type",className:"pubwave-form__select",value:r,onChange:M=>a(M.target.value),children:Pr.map(M=>i.jsx("option",{value:M.value,children:m.chartTypes[M.value]},M.value))})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-title",className:"pubwave-form__label",children:m.modal.fields.title}),i.jsx("input",{id:"chart-title",type:"text",className:"pubwave-form__input",value:s,onChange:M=>l(M.target.value),placeholder:m.modal.fields.titlePlaceholder})]}),i.jsxs("div",{className:"pubwave-form__row",children:[i.jsx("div",{className:"pubwave-form__field",children:i.jsxs("label",{className:"pubwave-form__checkbox-label",children:[i.jsx("input",{type:"checkbox",className:"pubwave-form__checkbox",checked:c,onChange:M=>f(M.target.checked)}),m.modal.fields.showLegend]})}),c&&i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"legend-position",className:"pubwave-form__label",children:m.modal.fields.legendPosition}),i.jsxs("select",{id:"legend-position",className:"pubwave-form__select",value:p,onChange:M=>y(M.target.value),children:[i.jsx("option",{value:"top",children:m.modal.fields.position.top}),i.jsx("option",{value:"bottom",children:m.modal.fields.position.bottom}),i.jsx("option",{value:"left",children:m.modal.fields.position.left}),i.jsx("option",{value:"right",children:m.modal.fields.position.right})]})]})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-labels",className:"pubwave-form__label",children:m.modal.fields.labels}),i.jsx("input",{id:"chart-labels",type:"text",className:"pubwave-form__input",value:d.join(", "),onChange:M=>A(M.target.value),placeholder:m.modal.fields.labelsPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__section",children:[i.jsxs("div",{className:"pubwave-form__section-header",children:[i.jsx("h3",{className:"pubwave-form__section-title",children:m.modal.fields.datasets.title}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary pubwave-button--small",onClick:u,children:m.modal.fields.datasets.add})]}),h.map((M,D)=>i.jsxs("div",{className:"pubwave-form__dataset",children:[i.jsxs("div",{className:"pubwave-form__dataset-header",children:[i.jsxs("span",{className:"pubwave-form__dataset-title",children:[m.modal.fields.datasets.datasetLabel," ",D+1]}),h.length>1&&i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--danger pubwave-button--small",onClick:()=>T(D),"aria-label":`${m.modal.fields.datasets.remove} ${D+1}`,children:m.modal.fields.datasets.remove})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-label-${D}`,className:"pubwave-form__label",children:m.modal.fields.datasets.datasetLabel}),i.jsx("input",{id:`dataset-label-${D}`,type:"text",className:"pubwave-form__input",value:M.label??"",onChange:ne=>B(D,ne.target.value),placeholder:m.modal.fields.datasets.datasetLabelPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-data-${D}`,className:"pubwave-form__label",children:m.modal.fields.datasets.data}),i.jsx("input",{id:`dataset-data-${D}`,type:"text",className:"pubwave-form__input",value:M.data.join(", "),onChange:ne=>k(D,ne.target.value),placeholder:m.modal.fields.datasets.dataPlaceholder})]})]},D))]})]}),i.jsxs("div",{className:"pubwave-modal__footer",children:[i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary",onClick:n,children:m.modal.cancel}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--primary",onClick:E,children:m.modal.save})]})]})});return kr.createPortal(G,document.body)}const Er={groups:{basic:"Basic",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},table:{title:"Table",description:"Insert a table"},chart:{title:"Chart",description:"Insert a chart"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}},Or={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline Code",link:"Link",turnInto:"Turn Into",colorPicker:"Text and background color",textColor:"Text color",backgroundColor:"Background color",recentlyUsed:"Recently used",openLink:"Open link",removeLink:"Remove link",confirmLink:"Confirm link",clearLink:"Clear link",blockTypes:{text:"Text",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",bulletedList:"Bulleted list",numberedList:"Numbered list"}},_r={editor:"Rich text editor",editorContent:"Editor content area",toolbar:"Text formatting toolbar",boldButton:"Toggle bold formatting",italicButton:"Toggle italic formatting",underlineButton:"Toggle underline formatting",strikeButton:"Toggle strikethrough formatting",codeButton:"Toggle inline code formatting",linkButton:"Add or edit link",turnIntoButton:"Turn into",colorPickerButton:"Text and background color",headingButton:"Set heading level",paragraphButton:"Convert to paragraph",dragHandle:"Drag to reorder block",dropIndicator:"Drop here to move block",blockMenu:"Block options menu",addBlock:"Add new block",deleteBlock:"Delete this block",linkDialog:"Link editor dialog",linkUrlInput:"Link URL input",linkSaveButton:"Save link",linkRemoveButton:"Remove link",linkCancelButton:"Cancel link editing",addBlockBelow:"Add block below",dragToMove:"Drag to reorder block",openLinkInNewTab:"Open link in new tab",linkConfirmButton:"Confirm link",linkOpenButton:"Open link in new tab",linkClearButton:"Clear link input"},Nr='Write, type "/" for commands...',Hr="Paste a link...",zr={modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels (comma-separated)",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Dataset",datasetLabelPlaceholder:"Dataset label...",data:"Data (comma-separated numbers)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}},Wn={slashMenu:Er,toolbar:Or,aria:_r,placeholder:Nr,linkPlaceholder:Hr,chart:zr},$r={groups:{basic:"基礎",list:"列表",media:"媒體",advanced:"高級",layout:"版面配置"},commands:{paragraph:{title:"文本",description:"普通文本塊"},heading1:{title:"標題 1",description:"大標題"},heading2:{title:"標題 2",description:"中標題"},heading3:{title:"標題 3",description:"小標題"},bulletList:{title:"無序列表",description:"創建無序列表"},orderedList:{title:"有序列表",description:"創建有序列表"},taskList:{title:"待辦清單",description:"創建帶複選框的待辦清單"},image:{title:"圖片",description:"上傳或粘貼圖片"},blockquote:{title:"引用",description:"創建引用塊"},codeBlock:{title:"代碼",description:"創建代碼片段"},horizontalRule:{title:"分割線",description:"創建水平分割線"},table:{title:"表格",description:"插入表格"},chart:{title:"圖表",description:"插入圖表"},layoutTwoColumn:{title:"兩欄版面配置",description:"將內容分成兩個並排的欄"},layoutThreeColumn:{title:"三欄版面配置",description:"將內容分成三個並排的欄"}}},qr={bold:"粗體",italic:"斜體",underline:"下劃線",strike:"刪除線",code:"行內代碼",link:"鏈接",turnInto:"轉換為",colorPicker:"文字和背景顏色",textColor:"文字顏色",backgroundColor:"背景顏色",recentlyUsed:"最近使用",openLink:"打開鏈接",removeLink:"移除鏈接",confirmLink:"確認鏈接",clearLink:"清空鏈接",blockTypes:{text:"文本",heading1:"標題 1",heading2:"標題 2",heading3:"標題 3",bulletedList:"無序列表",numberedList:"有序列表"}},Ur={editor:"富文本編輯器",editorContent:"編輯器內容區域",toolbar:"文本格式化工具欄",boldButton:"切換粗體格式",italicButton:"切換斜體格式",underlineButton:"切換下劃線格式",strikeButton:"切換刪除線格式",codeButton:"切換行內代碼格式",linkButton:"添加或編輯鏈接",turnIntoButton:"轉換為",colorPickerButton:"文字和背景顏色",headingButton:"設置標題級別",paragraphButton:"轉換為段落",dragHandle:"拖拽以重新排序塊",dropIndicator:"放置此處以移動塊",blockMenu:"塊選項菜單",addBlock:"添加新塊",deleteBlock:"刪除此塊",linkDialog:"鏈接編輯對話框",linkUrlInput:"鏈接 URL 輸入",linkSaveButton:"保存鏈接",linkRemoveButton:"移除鏈接",linkCancelButton:"取消鏈接編輯",addBlockBelow:"在下方添加塊",dragToMove:"拖拽以重新排序塊",openLinkInNewTab:"在新標籤頁中打開鏈接",linkConfirmButton:"確認鏈接",linkOpenButton:"在新標籤頁中打開鏈接",linkClearButton:"清空鏈接輸入"},Fr='開始寫作,輸入 "/" 顯示命令...',Wr="粘貼鏈接...",Vr={modal:{title:"編輯圖表",close:"關閉",save:"保存",cancel:"取消",fields:{chartType:"圖表類型",title:"標題",titlePlaceholder:"圖表標題...",showLegend:"顯示圖例",legendPosition:"位置",position:{top:"頂部",bottom:"底部",left:"左側",right:"右側"},labels:"標籤(逗號分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"數據集",add:"+ 添加數據集",remove:"移除",datasetLabel:"標籤",datasetLabelPlaceholder:"數據集標籤...",data:"數據(逗號分隔的數字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱狀圖",line:"折線圖",pie:"餅圖",doughnut:"環形圖",radar:"雷達圖",polarArea:"極地圖"}},Gr={slashMenu:$r,toolbar:qr,aria:Ur,placeholder:Fr,linkPlaceholder:Wr,chart:Vr},Yr={groups:{basic:"基础",list:"列表",media:"媒体",advanced:"高级",layout:"版面布局"},commands:{paragraph:{title:"文本",description:"普通文本块"},heading1:{title:"标题 1",description:"大标题"},heading2:{title:"标题 2",description:"中标题"},heading3:{title:"标题 3",description:"小标题"},bulletList:{title:"无序列表",description:"创建无序列表"},orderedList:{title:"有序列表",description:"创建有序列表"},taskList:{title:"待办清单",description:"创建带复选框的待办清单"},image:{title:"图片",description:"上传或粘贴图片"},blockquote:{title:"引用",description:"创建引用块"},codeBlock:{title:"代码",description:"创建代码片段"},horizontalRule:{title:"分割线",description:"创建水平分割线"},table:{title:"表格",description:"插入表格"},chart:{title:"图表",description:"插入图表"},layoutTwoColumn:{title:"两栏布局",description:"将内容分成两个并排的栏"},layoutThreeColumn:{title:"三栏布局",description:"将内容分成三个并排的栏"}}},Xr={bold:"粗体",italic:"斜体",underline:"下划线",strike:"删除线",code:"行内代码",link:"链接",turnInto:"转换为",colorPicker:"文字和背景颜色",textColor:"文字颜色",backgroundColor:"背景颜色",recentlyUsed:"最近使用",openLink:"打开链接",removeLink:"移除链接",confirmLink:"确认链接",clearLink:"清空链接",blockTypes:{text:"文本",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",bulletedList:"无序列表",numberedList:"有序列表"}},Kr={editor:"富文本编辑器",editorContent:"编辑器内容区域",toolbar:"文本格式化工具栏",boldButton:"切换粗体格式",italicButton:"切换斜体格式",underlineButton:"切换下划线格式",strikeButton:"切换删除线格式",codeButton:"切换行内代码格式",linkButton:"添加或编辑链接",turnIntoButton:"转换为",colorPickerButton:"文字和背景颜色",headingButton:"设置标题级别",paragraphButton:"转换为段落",dragHandle:"拖拽以重新排序块",dropIndicator:"放置此处以移动块",blockMenu:"块选项菜单",addBlock:"添加新块",deleteBlock:"删除此块",linkDialog:"链接编辑对话框",linkUrlInput:"链接 URL 输入",linkSaveButton:"保存链接",linkRemoveButton:"移除链接",linkCancelButton:"取消链接编辑",addBlockBelow:"在下方添加块",dragToMove:"拖拽以重新排序块",openLinkInNewTab:"在新标签页中打开链接",linkConfirmButton:"确认链接",linkOpenButton:"在新标签页中打开链接",linkClearButton:"清空链接输入"},Jr='开始写作,输入 "/" 显示命令...',Zr="粘贴链接...",Qr={modal:{title:"编辑图表",close:"关闭",save:"保存",cancel:"取消",fields:{chartType:"图表类型",title:"标题",titlePlaceholder:"图表标题...",showLegend:"显示图例",legendPosition:"位置",position:{top:"顶部",bottom:"底部",left:"左侧",right:"右侧"},labels:"标签(逗号分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"数据集",add:"+ 添加数据集",remove:"移除",datasetLabel:"标签",datasetLabelPlaceholder:"数据集标签...",data:"数据(逗号分隔的数字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱状图",line:"折线图",pie:"饼图",doughnut:"环形图",radar:"雷达图",polarArea:"极地图"}},ea={slashMenu:Yr,toolbar:Xr,aria:Kr,placeholder:Jr,linkPlaceholder:Zr,chart:Qr},ta={groups:{basic:"基本",list:"リスト",media:"メディア",advanced:"高度",layout:"レイアウト"},commands:{paragraph:{title:"テキスト",description:"プレーンテキストブロック"},heading1:{title:"見出し1",description:"大きなセクション見出し"},heading2:{title:"見出し2",description:"中サイズのセクション見出し"},heading3:{title:"見出し3",description:"小さなセクション見出し"},bulletList:{title:"箇条書きリスト",description:"箇条書きリストを作成"},orderedList:{title:"番号付きリスト",description:"番号付きリストを作成"},taskList:{title:"To-doリスト",description:"チェックボックス付きのTo-doリストを作成"},image:{title:"画像",description:"画像をアップロードまたは貼り付け"},blockquote:{title:"引用",description:"引用ブロックを作成"},codeBlock:{title:"コード",description:"コードスニペットを作成"},horizontalRule:{title:"区切り線",description:"水平線を作成"},table:{title:"テーブル",description:"テーブルを挿入"},chart:{title:"チャート",description:"チャートを挿入"},layoutTwoColumn:{title:"2カラムレイアウト",description:"コンテンツを2つの横並びカラムに分割"},layoutThreeColumn:{title:"3カラムレイアウト",description:"コンテンツを3つの横並びカラムに分割"}}},na={bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",code:"インラインコード",link:"リンク",turnInto:"変換",colorPicker:"テキストと背景色",textColor:"文字色",backgroundColor:"背景色",recentlyUsed:"最近使用",openLink:"リンクを開く",removeLink:"リンクを削除",confirmLink:"リンクを確認",clearLink:"リンクをクリア",blockTypes:{text:"テキスト",heading1:"見出し1",heading2:"見出し2",heading3:"見出し3",bulletedList:"箇条書きリスト",numberedList:"番号付きリスト"}},oa={editor:"リッチテキストエディタ",editorContent:"エディタコンテンツ領域",toolbar:"テキスト書式設定ツールバー",boldButton:"太字書式を切り替え",italicButton:"斜体書式を切り替え",underlineButton:"下線書式を切り替え",strikeButton:"取り消し線書式を切り替え",codeButton:"インラインコード書式を切り替え",linkButton:"リンクを追加または編集",turnIntoButton:"変換",colorPickerButton:"テキストと背景色",headingButton:"見出しレベルを設定",paragraphButton:"段落に変換",dragHandle:"ブロックを並び替えるためにドラッグ",dropIndicator:"ブロックを移動するためにここにドロップ",blockMenu:"ブロックオプションメニュー",addBlock:"新しいブロックを追加",deleteBlock:"このブロックを削除",linkDialog:"リンク編集ダイアログ",linkUrlInput:"リンクURL入力",linkSaveButton:"リンクを保存",linkRemoveButton:"リンクを削除",linkCancelButton:"リンク編集をキャンセル",addBlockBelow:"下にブロックを追加",dragToMove:"ブロックを並び替えるためにドラッグ",openLinkInNewTab:"新しいタブでリンクを開く",linkConfirmButton:"リンクを確認",linkOpenButton:"新しいタブでリンクを開く",linkClearButton:"リンク入力をクリア"},ra='書き始めましょう、コマンドを表示するには "/" を入力...',aa="リンクを貼り付け...",ia={modal:{title:"チャート編集",close:"閉じる",save:"保存",cancel:"キャンセル",fields:{chartType:"チャートタイプ",title:"タイトル",titlePlaceholder:"チャートタイトル...",showLegend:"凡例を表示",legendPosition:"位置",position:{top:"上",bottom:"下",left:"左",right:"右"},labels:"ラベル(カンマ区切り)",labelsPlaceholder:"1月, 2月, 3月, 4月...",datasets:{title:"データセット",add:"+ データセットを追加",remove:"削除",datasetLabel:"ラベル",datasetLabelPlaceholder:"データセットラベル...",data:"データ(カンマ区切りの数値)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"棒グラフ",line:"折れ線グラフ",pie:"円グラフ",doughnut:"ドーナツグラフ",radar:"レーダーチャート",polarArea:"極座標グラフ"}},sa={slashMenu:ta,toolbar:na,aria:oa,placeholder:ra,linkPlaceholder:aa,chart:ia},la={groups:{basic:"기본",list:"목록",media:"미디어",advanced:"고급",layout:"레이아웃"},commands:{paragraph:{title:"텍스트",description:"일반 텍스트 블록"},heading1:{title:"제목 1",description:"큰 섹션 제목"},heading2:{title:"제목 2",description:"중간 섹션 제목"},heading3:{title:"제목 3",description:"작은 섹션 제목"},bulletList:{title:"글머리 기호 목록",description:"글머리 기호 목록 만들기"},orderedList:{title:"번호 매기기 목록",description:"번호 매기기 목록 만들기"},taskList:{title:"할 일 목록",description:"확인란 있는 할 일 목록 만들기"},image:{title:"이미지",description:"이미지 업로드 또는 붙여넣기"},blockquote:{title:"인용",description:"인용 블록 만들기"},codeBlock:{title:"코드",description:"코드 스니펫 만들기"},horizontalRule:{title:"구분선",description:"수평선 만들기"},table:{title:"표",description:"표를 삽입"},chart:{title:"차트",description:"차트를 삽입"},layoutTwoColumn:{title:"2열 레이아웃",description:"콘텐츠를 두 개의 나란히 있는 열로 분할"},layoutThreeColumn:{title:"3열 레이아웃",description:"콘텐츠를 세 개의 나란히 있는 열로 분할"}}},ca={bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",code:"인라인 코드",link:"링크",turnInto:"변환",colorPicker:"텍스트 및 배경색",textColor:"텍스트 색상",backgroundColor:"배경 색상",recentlyUsed:"최근 사용",openLink:"링크 열기",removeLink:"링크 제거",confirmLink:"링크 확인",clearLink:"링크 지우기",blockTypes:{text:"텍스트",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록"}},ua={editor:"리치 텍스트 에디터",editorContent:"에디터 내용 영역",toolbar:"텍스트 서식 도구 모음",boldButton:"굵게 서식 전환",italicButton:"기울임 서식 전환",underlineButton:"밑줄 서식 전환",strikeButton:"취소선 서식 전환",codeButton:"인라인 코드 서식 전환",linkButton:"링크 추가 또는 편집",turnIntoButton:"변환",colorPickerButton:"텍스트 및 배경색",headingButton:"제목 수준 설정",paragraphButton:"단락으로 변환",dragHandle:"블록 재정렬을 위해 드래그",dropIndicator:"블록 이동을 위해 여기에 놓기",blockMenu:"블록 옵션 메뉴",addBlock:"새 블록 추가",deleteBlock:"이 블록 삭제",linkDialog:"링크 편집 대화 상자",linkUrlInput:"링크 URL 입력",linkSaveButton:"링크 저장",linkRemoveButton:"링크 제거",linkCancelButton:"링크 편집 취소",addBlockBelow:"아래에 블록 추가",dragToMove:"블록 재정렬을 위해 드래그",openLinkInNewTab:"새 탭에서 링크 열기",linkConfirmButton:"링크 확인",linkOpenButton:"새 탭에서 링크 열기",linkClearButton:"링크 입력 지우기"},da='작성 시작, 명령을 표시하려면 "/" 입력...',pa="링크 붙여넣기...",fa={modal:{title:"차트 편집",close:"닫기",save:"저장",cancel:"취소",fields:{chartType:"차트 유형",title:"제목",titlePlaceholder:"차트 제목...",showLegend:"범례 표시",legendPosition:"위치",position:{top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"},labels:"레이블(쉼표로 구분)",labelsPlaceholder:"1월, 2월, 3월, 4월...",datasets:{title:"데이터 세트",add:"+ 데이터 세트 추가",remove:"제거",datasetLabel:"레이블",datasetLabelPlaceholder:"데이터 세트 레이블...",data:"데이터(쉼표로 구분된 숫자)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"막대형 차트",line:"선형 차트",pie:"원형 차트",doughnut:"도넛형 차트",radar:"레이더 차트",polarArea:"극좌표형 차트"}},ha={slashMenu:la,toolbar:ca,aria:ua,placeholder:da,linkPlaceholder:pa,chart:fa},ba={groups:{basic:"De base",list:"Listes",media:"Médias",advanced:"Avancé",layout:"Mise en page"},commands:{paragraph:{title:"Texte",description:"Bloc de texte simple"},heading1:{title:"Titre 1",description:"Grand titre de section"},heading2:{title:"Titre 2",description:"Titre de section moyen"},heading3:{title:"Titre 3",description:"Petit titre de section"},bulletList:{title:"Liste à puces",description:"Créer une liste à puces"},orderedList:{title:"Liste numérotée",description:"Créer une liste numérotée"},taskList:{title:"Liste de tâches",description:"Créer une liste de tâches avec cases à cocher"},image:{title:"Image",description:"Télécharger ou coller une image"},blockquote:{title:"Citation",description:"Créer un bloc de citation"},codeBlock:{title:"Code",description:"Créer un extrait de code"},horizontalRule:{title:"Séparateur",description:"Créer une ligne horizontale"},table:{title:"Tableau",description:"Insérer un tableau"},chart:{title:"Graphique",description:"Insérer un graphique"},layoutTwoColumn:{title:"Mise en page à deux colonnes",description:"Diviser le contenu en deux colonnes côte à côte"},layoutThreeColumn:{title:"Mise en page à trois colonnes",description:"Diviser le contenu en trois colonnes côte à côte"}}},va={bold:"Gras",italic:"Italique",underline:"Souligné",strike:"Barré",code:"Code en ligne",link:"Lien",turnInto:"Convertir en",colorPicker:"Couleur du texte et du fond",textColor:"Couleur du texte",backgroundColor:"Couleur de fond",recentlyUsed:"Récemment utilisés",openLink:"Ouvrir le lien",removeLink:"Supprimer le lien",confirmLink:"Confirmer le lien",clearLink:"Effacer le lien",blockTypes:{text:"Texte",heading1:"Titre 1",heading2:"Titre 2",heading3:"Titre 3",bulletedList:"Liste à puces",numberedList:"Liste numérotée"}},ga={editor:"Éditeur de texte riche",editorContent:"Zone de contenu de l'éditeur",toolbar:"Barre d'outils de formatage de texte",boldButton:"Activer/désactiver le formatage en gras",italicButton:"Activer/désactiver le formatage en italique",underlineButton:"Activer/désactiver le soulignement",strikeButton:"Activer/désactiver le texte barré",codeButton:"Activer/désactiver le code en ligne",linkButton:"Ajouter ou modifier un lien",turnIntoButton:"Convertir en",colorPickerButton:"Couleur du texte et du fond",headingButton:"Définir le niveau de titre",paragraphButton:"Convertir en paragraphe",dragHandle:"Glisser pour réorganiser le bloc",dropIndicator:"Déposer ici pour déplacer le bloc",blockMenu:"Menu des options de bloc",addBlock:"Ajouter un nouveau bloc",deleteBlock:"Supprimer ce bloc",linkDialog:"Boîte de dialogue d'édition de lien",linkUrlInput:"Entrée d'URL de lien",linkSaveButton:"Enregistrer le lien",linkRemoveButton:"Supprimer le lien",linkCancelButton:"Annuler l'édition du lien",addBlockBelow:"Ajouter un bloc en dessous",dragToMove:"Glisser pour réorganiser le bloc",openLinkInNewTab:"Ouvrir le lien dans un nouvel onglet",linkConfirmButton:"Confirmer le lien",linkOpenButton:"Ouvrir le lien dans un nouvel onglet",linkClearButton:"Effacer la saisie du lien"},ma='Écrivez, tapez "/" pour afficher les commandes...',wa="Collez un lien...",ya={modal:{title:"Modifier le graphique",close:"Fermer",save:"Enregistrer",cancel:"Annuler",fields:{chartType:"Type de graphique",title:"Titre",titlePlaceholder:"Titre du graphique...",showLegend:"Afficher la légende",legendPosition:"Position",position:{top:"Haut",bottom:"Bas",left:"Gauche",right:"Droite"},labels:"Étiquettes (séparées par des virgules)",labelsPlaceholder:"Jan, Fév, Mar, Avr...",datasets:{title:"Jeux de données",add:"+ Ajouter un jeu de données",remove:"Supprimer",datasetLabel:"Étiquette",datasetLabelPlaceholder:"Étiquette du jeu de données...",data:"Données (nombres séparés par des virgules)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Graphique à barres",line:"Graphique linéaire",pie:"Graphique circulaire",doughnut:"Graphique en anneau",radar:"Graphique radar",polarArea:"Graphique en coordonnées polaires"}},xa={slashMenu:ba,toolbar:va,aria:ga,placeholder:ma,linkPlaceholder:wa,chart:ya},ka={groups:{basic:"Basis",list:"Listen",media:"Medien",advanced:"Erweitert",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Einfacher Textblock"},heading1:{title:"Überschrift 1",description:"Große Abschnittsüberschrift"},heading2:{title:"Überschrift 2",description:"Mittlere Abschnittsüberschrift"},heading3:{title:"Überschrift 3",description:"Kleine Abschnittsüberschrift"},bulletList:{title:"Aufzählungsliste",description:"Aufzählungsliste erstellen"},orderedList:{title:"Nummerierte Liste",description:"Nummerierte Liste erstellen"},taskList:{title:"To-do-Liste",description:"To-do-Liste mit Kontrollkästchen erstellen"},image:{title:"Bild",description:"Bild hochladen oder einfügen"},blockquote:{title:"Zitat",description:"Zitatblock erstellen"},codeBlock:{title:"Code",description:"Codeausschnitt erstellen"},horizontalRule:{title:"Trennlinie",description:"Horizontale Linie erstellen"},table:{title:"Tabelle",description:"Eine Tabelle einfügen"},chart:{title:"Diagramm",description:"Diagramm einfügen"},layoutTwoColumn:{title:"Zweispaltiges Layout",description:"Inhalt in zwei nebeneinander liegende Spalten aufteilen"},layoutThreeColumn:{title:"Dreispaltiges Layout",description:"Inhalt in drei nebeneinander liegende Spalten aufteilen"}}},Ca={bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",strike:"Durchgestrichen",code:"Inline-Code",link:"Link",turnInto:"Umwandeln in",colorPicker:"Text- und Hintergrundfarbe",textColor:"Textfarbe",backgroundColor:"Hintergrundfarbe",recentlyUsed:"Zuletzt verwendet",openLink:"Link öffnen",removeLink:"Link entfernen",confirmLink:"Link bestätigen",clearLink:"Link löschen",blockTypes:{text:"Text",heading1:"Überschrift 1",heading2:"Überschrift 2",heading3:"Überschrift 3",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste"}},Ta={editor:"Rich-Text-Editor",editorContent:"Editor-Inhaltsbereich",toolbar:"Textformatierungs-Symbolleiste",boldButton:"Fettformatierung ein/aus",italicButton:"Kursivformatierung ein/aus",underlineButton:"Unterstreichung ein/aus",strikeButton:"Durchstreichung ein/aus",codeButton:"Inline-Code-Formatierung ein/aus",linkButton:"Link hinzufügen oder bearbeiten",turnIntoButton:"Umwandeln in",colorPickerButton:"Text- und Hintergrundfarbe",headingButton:"Überschriftsebene festlegen",paragraphButton:"In Absatz umwandeln",dragHandle:"Zum Neuordnen des Blocks ziehen",dropIndicator:"Hier ablegen, um Block zu verschieben",blockMenu:"Block-Optionsmenü",addBlock:"Neuen Block hinzufügen",deleteBlock:"Diesen Block löschen",linkDialog:"Link-Bearbeitungsdialog",linkUrlInput:"Link-URL-Eingabe",linkSaveButton:"Link speichern",linkRemoveButton:"Link entfernen",linkCancelButton:"Link-Bearbeitung abbrechen",addBlockBelow:"Block darunter hinzufügen",dragToMove:"Zum Neuordnen des Blocks ziehen",openLinkInNewTab:"Link in neuem Tab öffnen",linkConfirmButton:"Link bestätigen",linkOpenButton:"Link in neuem Tab öffnen",linkClearButton:"Link-Eingabe löschen"},La='Schreiben, tippen Sie "/" für Befehle...',Ba="Link einfügen...",Aa={modal:{title:"Chart bearbeiten",close:"Schließen",save:"Speichern",cancel:"Abbrechen",fields:{chartType:"Chart-Typ",title:"Titel",titlePlaceholder:"Chart-Titel...",showLegend:"Legende anzeigen",legendPosition:"Position",position:{top:"Oben",bottom:"Unten",left:"Links",right:"Rechts"},labels:"Beschriftungen (kommagetrennt)",labelsPlaceholder:"Jan, Feb, Mär, Apr...",datasets:{title:"Datensätze",add:"+ Datensatz hinzufügen",remove:"Entfernen",datasetLabel:"Datensatz",datasetLabelPlaceholder:"Datensatz-Beschriftung...",data:"Daten (kommagetrennte Zahlen)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Balkendiagramm",line:"Liniendiagramm",pie:"Kreisdiagramm",doughnut:"Ringdiagramm",radar:"Netzdiagramm",polarArea:"Polärfächen-Diagramm"}},ja={slashMenu:ka,toolbar:Ca,aria:Ta,placeholder:La,linkPlaceholder:Ba,chart:Aa},Sa={groups:{basic:"Básico",list:"Listas",media:"Medios",advanced:"Avanzado",layout:"Diseño"},commands:{paragraph:{title:"Texto",description:"Bloque de texto plano"},heading1:{title:"Título 1",description:"Título de sección grande"},heading2:{title:"Título 2",description:"Título de sección mediano"},heading3:{title:"Título 3",description:"Título de sección pequeño"},bulletList:{title:"Lista con viñetas",description:"Crear una lista con viñetas"},orderedList:{title:"Lista numerada",description:"Crear una lista numerada"},taskList:{title:"Lista de tareas",description:"Crear una lista de tareas con casillas"},image:{title:"Imagen",description:"Subir o pegar una imagen"},blockquote:{title:"Cita",description:"Crear un bloque de cita"},codeBlock:{title:"Código",description:"Crear un fragmento de código"},horizontalRule:{title:"Divisor",description:"Crear una línea horizontal"},table:{title:"Tabla",description:"Insertar una tabla"},chart:{title:"Gráfico",description:"Insertar un gráfico"},layoutTwoColumn:{title:"Diseño de dos columnas",description:"Dividir el contenido en dos columnas una al lado de la otra"},layoutThreeColumn:{title:"Diseño de tres columnas",description:"Dividir el contenido en tres columnas una al lado de la otra"}}},Ra={bold:"Negrita",italic:"Cursiva",underline:"Subrayado",strike:"Tachado",code:"Código en línea",link:"Enlace",turnInto:"Convertir en",colorPicker:"Color de texto y fondo",textColor:"Color del texto",backgroundColor:"Color de fondo",recentlyUsed:"Recientemente usados",openLink:"Abrir enlace",removeLink:"Eliminar enlace",confirmLink:"Confirmar enlace",clearLink:"Limpiar enlace",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista con viñetas",numberedList:"Lista numerada"}},Ma={editor:"Editor de texto enriquecido",editorContent:"Área de contenido del editor",toolbar:"Barra de herramientas de formato de texto",boldButton:"Activar/desactivar formato en negrita",italicButton:"Activar/desactivar formato en cursiva",underlineButton:"Activar/desactivar subrayado",strikeButton:"Activar/desactivar tachado",codeButton:"Activar/desactivar código en línea",linkButton:"Añadir o editar enlace",turnIntoButton:"Convertir en",colorPickerButton:"Color de texto y fondo",headingButton:"Establecer nivel de título",paragraphButton:"Convertir a párrafo",dragHandle:"Arrastrar para reorganizar el bloque",dropIndicator:"Soltar aquí para mover el bloque",blockMenu:"Menú de opciones del bloque",addBlock:"Añadir nuevo bloque",deleteBlock:"Eliminar este bloque",linkDialog:"Diálogo de edición de enlace",linkUrlInput:"Entrada de URL del enlace",linkSaveButton:"Guardar enlace",linkRemoveButton:"Eliminar enlace",linkCancelButton:"Cancelar edición de enlace",addBlockBelow:"Añadir bloque debajo",dragToMove:"Arrastrar para reorganizar el bloque",openLinkInNewTab:"Abrir enlace en nueva pestaña",linkConfirmButton:"Confirmar enlace",linkOpenButton:"Abrir enlace en nueva pestaña",linkClearButton:"Limpiar entrada de enlace"},Pa='Escribe, escribe "/" para comandos...',Da="Pegue un enlace...",Ia={modal:{title:"Editar gráfico",close:"Cerrar",save:"Guardar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título del gráfico...",showLegend:"Mostrar leyenda",legendPosition:"Posición",position:{top:"Arriba",bottom:"Abajo",left:"Izquierda",right:"Derecha"},labels:"Etiquetas (separadas por comas)",labelsPlaceholder:"Ene, Feb, Mar, Abr...",datasets:{title:"Conjuntos de datos",add:"+ Añadir conjunto de datos",remove:"Eliminar",datasetLabel:"Etiqueta",datasetLabelPlaceholder:"Etiqueta del conjunto de datos...",data:"Datos (números separados por comas)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de líneas",pie:"Gráfico circular",doughnut:"Gráfico de anillo",radar:"Gráfico radar",polarArea:"Gráfico de área polar"}},Ea={slashMenu:Sa,toolbar:Ra,aria:Ma,placeholder:Pa,linkPlaceholder:Da,chart:Ia},Oa={groups:{basic:"Básico",list:"Listas",media:"Mídia",advanced:"Avançado",layout:"Layout"},commands:{paragraph:{title:"Texto",description:"Bloco de texto simples"},heading1:{title:"Título 1",description:"Título de seção grande"},heading2:{title:"Título 2",description:"Título de seção médio"},heading3:{title:"Título 3",description:"Título de seção pequeno"},bulletList:{title:"Lista com marcadores",description:"Criar uma lista com marcadores"},orderedList:{title:"Lista numerada",description:"Criar uma lista numerada"},taskList:{title:"Lista de tarefas",description:"Criar uma lista de tarefas com caixas de seleção"},image:{title:"Imagem",description:"Enviar ou colar uma imagem"},blockquote:{title:"Citação",description:"Criar um bloco de citação"},codeBlock:{title:"Código",description:"Criar um trecho de código"},horizontalRule:{title:"Divisor",description:"Criar uma linha horizontal"},table:{title:"Tabela",description:"Inserir uma tabela"},chart:{title:"Gráfico",description:"Inserir um gráfico"},layoutTwoColumn:{title:"Layout de duas colunas",description:"Dividir o conteúdo em duas colunas lado a lado"},layoutThreeColumn:{title:"Layout de três colunas",description:"Dividir o conteúdo em três colunas lado a lado"}}},_a={bold:"Negrito",italic:"Itálico",underline:"Sublinhado",strike:"Tachado",code:"Código inline",link:"Link",turnInto:"Converter em",colorPicker:"Cor do texto e fundo",textColor:"Cor do texto",backgroundColor:"Cor de fundo",recentlyUsed:"Usados recentemente",openLink:"Abrir link",removeLink:"Remover link",confirmLink:"Confirmar link",clearLink:"Limpar link",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista com marcadores",numberedList:"Lista numerada"}},Na={editor:"Editor de texto rico",editorContent:"Área de conteúdo do editor",toolbar:"Barra de ferramentas de formatação de texto",boldButton:"Alternar formatação em negrito",italicButton:"Alternar formatação em itálico",underlineButton:"Alternar sublinhado",strikeButton:"Alternar tachado",codeButton:"Alternar código inline",linkButton:"Adicionar ou editar link",turnIntoButton:"Converter em",colorPickerButton:"Cor do texto e fundo",headingButton:"Definir nível de título",paragraphButton:"Converter em parágrafo",dragHandle:"Arrastar para reorganizar o bloco",dropIndicator:"Soltar aqui para mover o bloco",blockMenu:"Menu de opções do bloco",addBlock:"Adicionar novo bloco",deleteBlock:"Excluir este bloco",linkDialog:"Diálogo de edição de link",linkUrlInput:"Entrada de URL do link",linkSaveButton:"Salvar link",linkRemoveButton:"Remover link",linkCancelButton:"Cancelar edição de link",addBlockBelow:"Adicionar bloco abaixo",dragToMove:"Arrastar para reorganizar o bloco",openLinkInNewTab:"Abrir link em nova aba",linkConfirmButton:"Confirmar link",linkOpenButton:"Abrir link em nova aba",linkClearButton:"Limpar entrada de link"},Ha='Escreva, digite "/" para comandos...',za="Cole um link...",$a={modal:{title:"Editar gráfico",close:"Fechar",save:"Salvar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título do gráfico...",showLegend:"Mostrar legenda",legendPosition:"Posição",position:{top:"Superior",bottom:"Inferior",left:"Esquerda",right:"Direita"},labels:"Rótulos (separados por vírgula)",labelsPlaceholder:"Jan, Fev, Mar, Abr...",datasets:{title:"Conjuntos de dados",add:"+ Adicionar conjunto de dados",remove:"Remover",datasetLabel:"Rótulo",datasetLabelPlaceholder:"Rótulo do conjunto de dados...",data:"Dados (números separados por vírgula)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de linhas",pie:"Gráfico de pizza",doughnut:"Gráfico de rosca",radar:"Gráfico de radar",polarArea:"Gráfico de área polar"}},qa={slashMenu:Oa,toolbar:_a,aria:Na,placeholder:Ha,linkPlaceholder:za,chart:$a},Ft=Wn,Ua={en:Wn,zh:Gr,"zh-CN":ea,ja:sa,ko:ha,fr:xa,de:ja,es:Ea,pt:qa};function jt(e){return e&&Ua[e]||Ft}const Vn=w.createContext({locale:Ft}),hn=Vn.Provider;function We(){return w.useContext(Vn).locale}const Fa=async()=>import("chart.js/auto");function Ke(e,t,n){const o=getComputedStyle(e),r=t.replace(/^var\(/,"").replace(/\)$/,"");return o.getPropertyValue(r).trim()||n}function Wa(e){var S,K,g;const{node:t,updateAttributes:n,editor:o,selected:r}=e,a=t.attrs.data,[s,l]=w.useState(!1),[c,f]=w.useState(!1),[p,y]=w.useState(null),d=w.useRef(null),b=w.useRef(null),h=w.useRef(null),v=We(),C=((S=o==null?void 0:o.options)==null?void 0:S.editable)??!0,m=C?r:!1,B=w.useCallback(()=>{if(!p||!h.current||!b.current)return;const j=b.current,I=Ke(j,"--pubwave-text","#37352f"),F=Ke(j,"--pubwave-text-muted","#9b9a97"),X=Ke(j,"--pubwave-border","#e3e2e0"),W=p.options.plugins||{},z=p.options.scales;if(W.legend){const M=W.legend;M.labels?M.labels.color=I:W.legend.labels={color:I},M.onHover=()=>{const D=d.current;D&&(D.style.cursor="pointer")},M.onLeave=()=>{const D=d.current;D&&(D.style.cursor="default")}}W.title&&(W.title.color=I),z&&(z.x&&(z.x.ticks&&(z.x.ticks.color=F),z.x.grid&&(z.x.grid.color=X)),z.y&&(z.y.ticks&&(z.y.ticks.color=F),z.y.grid&&(z.y.grid.color=X))),p.update("none")},[p]);w.useEffect(()=>!d.current||!a?void 0:((async()=>{var I,F,X,W,z,M,D,ne,oe,se,L,R,O,U,V,J,$,Y;try{const Z=(await Fa()).default;if(h.current=Z,d.current){const le=Z.getChart(d.current);le&&le.destroy()}p&&p.destroy();const re=(I=d.current)==null?void 0:I.getContext("2d");if(!re){console.warn("Failed to get 2D context for chart");return}const ie=b.current,ee=ie?Ke(ie,"--pubwave-text","#37352f"):"#37352f",ae=ie?Ke(ie,"--pubwave-text-muted","#9b9a97"):"#9b9a97",ue=ie?Ke(ie,"--pubwave-border","#e3e2e0"):"#e3e2e0",ve=((F=a.options)==null?void 0:F.scales)??{},ge=k(a.type)?{x:{...ve.x??{},ticks:{...((X=ve.x)==null?void 0:X.ticks)??{},color:ae},grid:{...((W=ve.x)==null?void 0:W.grid)??{},color:ue}},y:{...ve.y??{},ticks:{...((z=ve.y)==null?void 0:z.ticks)??{},color:ae},grid:{...((M=ve.y)==null?void 0:M.grid)??{},color:ue}}}:void 0,Te={...a.options,responsive:!0,maintainAspectRatio:!1,plugins:{...(D=a.options)==null?void 0:D.plugins,legend:{display:((se=(oe=(ne=a.options)==null?void 0:ne.plugins)==null?void 0:oe.legend)==null?void 0:se.display)??!0,position:((O=(R=(L=a.options)==null?void 0:L.plugins)==null?void 0:R.legend)==null?void 0:O.position)??"top",...(J=(V=(U=a.options)==null?void 0:U.plugins)==null?void 0:V.legend)!=null&&J.labels?{labels:{...a.options.plugins.legend.labels,color:ee}}:{labels:{color:ee}},onHover:()=>{const le=d.current;le&&(le.style.cursor="pointer")},onLeave:()=>{const le=d.current;le&&(le.style.cursor="default")}},title:(Y=($=a.options)==null?void 0:$.plugins)!=null&&Y.title?{...a.options.plugins.title,color:ee,...a.options.plugins.title.font?{font:{...a.options.plugins.title.font}}:{}}:void 0},scales:ge},Ne=new Z(re,{type:a.type,data:a.data,options:Te});y(Ne)}catch(q){console.error("Failed to load Chart.js:",q)}})(),()=>{p&&p.destroy()}),[a,C]),w.useEffect(()=>{if(!p||!b.current)return;const j=()=>{setTimeout(()=>{B()},0)},I=new MutationObserver(X=>{X.forEach(W=>{(W.attributeName==="style"||W.attributeName==="class")&&j()})});let F=b.current;for(;F&&(I.observe(F,{attributes:!0}),!(F.classList.contains("pubwave-editor")||F===document.body));)F=F.parentElement;return I.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>{I.disconnect()}},[p,B]);function k(j){return["bar","line","radar"].includes(j)}const u=w.useCallback(j=>{n({data:j}),l(!1)},[n]),T=w.useCallback(()=>{l(!1)},[]),A=w.useCallback(()=>{l(!0)},[]);if(!a)return i.jsx(Pe.NodeViewWrapper,{className:"pubwave-editor__chart",children:i.jsx("div",{className:"pubwave-chart__placeholder",children:"Invalid chart data"})});const E=(K=a.options)==null?void 0:K.height,H=(g=a.options)==null?void 0:g.minHeight,G=E||H?{height:E?`${E}px`:void 0,minHeight:H?`${H}px`:void 0}:void 0;return i.jsxs(Pe.NodeViewWrapper,{ref:b,className:"pubwave-editor__chart","data-selected":m,"data-chart-type":a.type,children:[i.jsxs("div",{className:"pubwave-chart__container",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[i.jsx("div",{className:"pubwave-chart__canvas-wrapper",style:G,children:i.jsx("canvas",{ref:d,className:"pubwave-chart__canvas"})}),C&&(c||m)&&i.jsx("button",{type:"button",className:"pubwave-chart__edit-button",onClick:A,"aria-label":"Edit chart",title:"Edit chart",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),s&&a&&i.jsx(Ir,{initialData:a,onSave:u,onCancel:T,locale:v})]})}const Va=be.Node.create({name:"chart",priority:1e3,group:"block",atom:!0,draggable:!0,addAttributes(){return{data:{default:null,parseHTML:e=>{const t=e.getAttribute("data-chart-data");if(t)try{return JSON.parse(t)}catch{return null}return null},renderHTML:e=>e.data?{"data-chart-data":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:'div[data-type="chart"]'}]},renderHTML({HTMLAttributes:e}){return["div",be.mergeAttributes({"data-type":"chart"},e)]},addNodeView(){return Pe.ReactNodeViewRenderer(Wa)}});function Ga(e){return i.jsx(Pe.NodeViewWrapper,{className:"pubwave-layout__column","data-type":"layoutColumn",children:i.jsx(Pe.NodeViewContent,{as:"div",className:"pubwave-layout__column-content"})})}const Ya=be.Node.create({name:"layout",priority:1e3,group:"block",draggable:!0,content:"layoutColumn+",addAttributes(){return{columns:{default:2,parseHTML:e=>{const t=e.getAttribute("data-layout-columns");return t?parseInt(t,10):2},renderHTML:e=>({"data-layout-columns":String(e.columns)})}}},parseHTML(){return[{tag:'div[data-type="layout"]',getAttrs:e=>{const t=e.getAttribute("data-layout-columns"),n=t?parseInt(t,10):2;return n!==2&&n!==3?!1:{columns:n}}}]},renderHTML({node:e,HTMLAttributes:t}){const n=e.attrs.columns,o=["pubwave-editor__layout",`pubwave-layout--${n}-cols`];return["div",be.mergeAttributes({"data-type":"layout","data-layout-columns":String(n),class:o.join(" ")},t),0]}}),Xa=be.Node.create({name:"layoutColumn",priority:1e3,group:"block",isolating:!0,content:"block+",parseHTML(){return[{tag:'div[data-type="layoutColumn"]'},{tag:"div.pubwave-layout__column"}]},renderHTML({HTMLAttributes:e}){return["div",be.mergeAttributes({"data-type":"layoutColumn",class:"pubwave-layout__column"},e),0]},addNodeView(){return Pe.ReactNodeViewRenderer(Ga)}});async function Ka(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var c;const l=(c=s.target)==null?void 0:c.result;l?o(l):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Ja(e){return Cr.extend({addProseMirrorPlugins(){return[new Ae.Plugin({key:new Ae.PluginKey("imagePasteHandler"),props:{handlePaste:(t,n)=>{var r;const o=Array.from(((r=n.clipboardData)==null?void 0:r.items)||[]);for(const a of o)if(a.type.indexOf("image")===0){n.preventDefault();const s=a.getAsFile();if(s)return Ka(s,e).then(l=>{const{state:c,dispatch:f}=t,p=c.schema.nodes.image;if(p){const y=p.create({src:l}),d=c.tr.replaceSelectionWith(y);f(d)}}).catch(l=>{console.error("Failed to upload image:",l)}),!0}return!1}}})]}}).configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"pubwave-editor__image"}})}function Za(e={}){const{headingLevels:t=[1,2,3],imageUpload:n,enableChart:o=!0,enableLayout:r=!0}=e,a=[ar,ir.configure({HTMLAttributes:{class:"pubwave-editor__paragraph"}}),sr,xr,lr.configure({levels:t,HTMLAttributes:{class:"pubwave-editor__heading"}}),cr.configure({HTMLAttributes:{class:"pubwave-editor__bullet-list"}}),ur.configure({HTMLAttributes:{class:"pubwave-editor__ordered-list"}}),dr.configure({HTMLAttributes:{class:"pubwave-editor__list-item"}}),pr.configure({HTMLAttributes:{class:"pubwave-editor__task-list"}}),fr.configure({nested:!0,HTMLAttributes:{class:"pubwave-editor__task-item"}}),hr.configure({resizable:!0,HTMLAttributes:{class:"pubwave-editor__table"}}),br.configure({HTMLAttributes:{class:"pubwave-editor__table-row"}}),vr.configure({HTMLAttributes:{class:"pubwave-editor__table-header"}}),gr.configure({HTMLAttributes:{class:"pubwave-editor__table-cell"}}),mr.configure({HTMLAttributes:{class:"pubwave-editor__blockquote"}}),wr.configure({HTMLAttributes:{class:"pubwave-editor__code-block"}}),yr.configure({HTMLAttributes:{class:"pubwave-editor__divider"}}),Ja(n)];return o&&a.push(Va.configure({HTMLAttributes:{class:"pubwave-editor__chart"}})),r&&a.push(Ya.configure({HTMLAttributes:{class:"pubwave-editor__layout"}}),Xa.configure({HTMLAttributes:{class:"pubwave-editor__layout-column"}})),a}const Qa=be.Mark.create({name:"textColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{color:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.color||t.getAttribute("data-color")||null},renderHTML:e=>e.color?{style:`color: ${e.color}`,"data-color":e.color}:{}}}},parseHTML(){return[{tag:'span[style*="color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.color||t.getAttribute("data-color");return n?{color:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",be.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(l=>l.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(l=>l.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.color)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run()},unsetColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}}),ei=be.Mark.create({name:"backgroundColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.backgroundColor||t.getAttribute("data-background-color")||null},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`,"data-background-color":e.backgroundColor}:{}}}},parseHTML(){return[{tag:'span[style*="background-color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.backgroundColor||t.getAttribute("data-background-color");return n?{backgroundColor:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",be.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBackgroundColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(l=>l.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(l=>l.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.backgroundColor)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run()},unsetBackgroundColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}});function ti(e={}){const{linkOpenInNewTab:t=!0,linkOpenOnClick:n=!0}=e;return[Tr.configure({HTMLAttributes:{class:"pubwave-editor__mark--bold"}}),Lr.configure({HTMLAttributes:{class:"pubwave-editor__mark--italic"}}),Br.configure({HTMLAttributes:{class:"pubwave-editor__mark--underline"}}),Ar.configure({HTMLAttributes:{class:"pubwave-editor__mark--strike"}}),jr.configure({HTMLAttributes:{class:"pubwave-editor__mark--code"}}),Sr.configure({openOnClick:n,HTMLAttributes:{class:"pubwave-editor__mark--link",rel:t?"noopener noreferrer":void 0,target:t?"_blank":void 0},validate:o=>{try{return new URL(o),!0}catch{return o.startsWith("/")||o.startsWith("#")}}}),Qa.configure({HTMLAttributes:{class:"pubwave-editor__mark--text-color"}}),ei.configure({HTMLAttributes:{class:"pubwave-editor__mark--background-color"}})]}function ni(e,t,n){w.useEffect(()=>{if(e>=0&&n.current&&t.current){const o=t.current,r=n.current,a=o.scrollTop,s=o.clientHeight,l=o.scrollHeight,c=r.offsetTop,f=r.offsetHeight,p=o.querySelector(".pubwave-slash-menu__group"),y=o.querySelector(".pubwave-slash-menu__item"),d=Array.from(o.querySelectorAll(".pubwave-slash-menu__item")).pop(),b=c-a,h=b+f;let v=a;if(b<0)v=c-4,p&&v>p.offsetTop&&(v=Math.max(0,p.offsetTop)),y&&v>y.offsetTop-2&&(v=Math.max(0,y.offsetTop-2));else if(h>s){if(v=c-s+f+4,d){const m=d.offsetTop+d.offsetHeight-s+2;v>m&&(v=m)}v=Math.min(l-s,v)}Math.abs(v-a)>.5&&(o.scrollTop=v)}},[e,t,n])}const oi={backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",maxHeight:"280px",overflowY:"auto",minWidth:"240px",maxWidth:"300px",padding:"var(--pubwave-spacing-1, 4px)",display:"flex",flexDirection:"column"},ri={marginBottom:"0"},ai={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted, #6b7280)",textTransform:"uppercase",letterSpacing:"0.5px"},ii={display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-3, 12px)",width:"100%",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",background:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--pubwave-radius-md, 6px)",transition:"background-color 0.1s ease",fontSize:"var(--pubwave-font-size-base, 14px)",color:"var(--pubwave-text, #1a1a1a)"},si={display:"flex",alignItems:"center",justifyContent:"center",width:"var(--pubwave-icon-size, 20px)",height:"var(--pubwave-icon-size, 20px)",color:"var(--pubwave-text-tertiary, #4b5563)",flexShrink:0},li={fontSize:"var(--pubwave-font-size-base, 14px)",fontWeight:400,color:"var(--pubwave-text, #1a1a1a)"},ci=typeof window>"u",Ot=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement=="function";function ce(e){return Ot?window.requestAnimationFrame(e):0}function vt(){if(!Ot)return!1;const e="ontouchstart"in window||navigator.maxTouchPoints>0,t=window.matchMedia("(pointer: coarse)").matches,n=window.matchMedia("(hover: hover)").matches;return e&&t||e&&!n}function Gn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 7V4h16v3M9 20h6M12 4v16"})})}function Yn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 10l3-2v12"})})}function Xn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M21 18h-5c0-2.5 5-2.5 5-5 0-1.5-1-3-3-3s-3 1.5-3 3"})})}function Kn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 12h3M17 18c2.5 0 4-1 4-3s-1.5-3-4-3"})})}function Jn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),i.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),i.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),i.jsx("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"})]})}function Zn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),i.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),i.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),i.jsx("text",{x:"3",y:"8",fontSize:"8",fill:"currentColor",stroke:"none",children:"1"}),i.jsx("text",{x:"3",y:"14",fontSize:"8",fill:"currentColor",stroke:"none",children:"2"}),i.jsx("text",{x:"3",y:"20",fontSize:"8",fill:"currentColor",stroke:"none",children:"3"})]})}function ui(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),i.jsx("line",{x1:"4",y1:"20",x2:"4",y2:"4"}),i.jsx("rect",{x:"7",y:"12",width:"3",height:"8"}),i.jsx("rect",{x:"12",y:"9",width:"3",height:"11"}),i.jsx("rect",{x:"17",y:"6",width:"3",height:"14"})]})}function di(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"6,9 12,15 18,9"})})}function pi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2h5a3 3 0 0 1 0 6H4V2z"}),i.jsx("path",{d:"M4 8h6a3 3 0 0 1 0 6H4V8z"})]})}function fi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"11",y1:"2",x2:"5",y2:"14"}),i.jsx("line",{x1:"6",y1:"2",x2:"12",y2:"2"}),i.jsx("line",{x1:"4",y1:"14",x2:"10",y2:"14"})]})}function hi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2v6a4 4 0 0 0 8 0V2"}),i.jsx("line",{x1:"2",y1:"14",x2:"14",y2:"14"})]})}function bi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),i.jsx("path",{d:"M5 4c0-1 1.5-2 3-2s3 .5 3 2c0 1-1 2-3 2"}),i.jsx("path",{d:"M5 12c0 1 1.5 2 3 2s3-.5 3-2c0-1-1-2-3-2"})]})}function vi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"5 4 1 8 5 12"}),i.jsx("polyline",{points:"11 4 15 8 11 12"})]})}function gi(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"1.87 0 12.19 16",fill:"currentColor",children:[i.jsx("path",{d:"M12.848 2.8a3.145 3.145 0 0 0-4.448 0L6.918 4.283a.625.625 0 0 0 .884.883l1.482-1.482c.74-.74 1.94-.74 2.68 0l.294.294c.74.74.74 1.94 0 2.68l-1.482 1.483a.625.625 0 1 0 .884.884l1.482-1.482a3.145 3.145 0 0 0 0-4.449z"}),i.jsx("path",{d:"M10.472 5.47a.625.625 0 0 0-.884 0L5.229 9.83a.625.625 0 1 0 .884.883l4.359-4.359a.625.625 0 0 0 0-.883"}),i.jsx("path",{d:"M5.167 6.918a.625.625 0 0 0-.884 0L2.8 8.4a3.146 3.146 0 0 0 0 4.448l.294.294a3.145 3.145 0 0 0 4.449 0l1.482-1.482a.625.625 0 0 0-.884-.884L6.66 12.258c-.74.74-1.94.74-2.68 0l-.295-.294c-.74-.74-.74-1.94 0-2.68L5.167 7.8a.625.625 0 0 0 0-.883"})]})}function mi(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M10 3h4v4M14 3l-7 7M14 11v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3"})})}function wi(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M13 4L6 11l-3-3"})})}function yi(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}function xi({textColor:e,backgroundColor:t}){const n=t||"transparent",o=!t;return i.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:n,border:o?"1px solid var(--pubwave-border)":"none",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:e,lineHeight:1},children:"A"})})}function ki(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"5",width:"4",height:"4",rx:"0.5"}),i.jsx("rect",{x:"3",y:"14",width:"4",height:"4",rx:"0.5"}),i.jsx("path",{d:"M4 16l1.5 1.5L7 15"}),i.jsx("line",{x1:"10",y1:"7",x2:"21",y2:"7"}),i.jsx("line",{x1:"10",y1:"16",x2:"21",y2:"16"})]})}function Ci(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2H4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"}),i.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2h-4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"})]})}function Ti(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"16,18 22,12 16,6"}),i.jsx("polyline",{points:"8,6 2,12 8,18"})]})}function Li(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}function Bi(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),i.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),i.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),i.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function Ai(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21,15 16,10 5,21"})]})}function ji(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function Si(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"21"}),i.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"21"})]})}const bn=["rgba(59, 130, 246, 0.7)","rgba(236, 72, 153, 0.7)","rgba(34, 197, 94, 0.7)","rgba(251, 146, 60, 0.7)","rgba(139, 92, 246, 0.7)","rgba(14, 165, 233, 0.7)","rgba(244, 63, 94, 0.7)","rgba(234, 179, 8, 0.7)"],Ri=["rgba(59, 130, 246, 1)","rgba(236, 72, 153, 1)","rgba(34, 197, 94, 1)","rgba(251, 146, 60, 1)","rgba(139, 92, 246, 1)","rgba(14, 165, 233, 1)","rgba(244, 63, 94, 1)","rgba(234, 179, 8, 1)"],Mi={responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!0,text:"Chart Title",color:"var(--pubwave-text, #37352f)",font:{size:16,weight:"bold"}},legend:{display:!0,position:"top"}}};function Pi(e,t,n){const o=n%bn.length;return{label:e,data:t,backgroundColor:bn[o],borderColor:Ri[o],borderWidth:2}}function Di(e){return{type:e,data:{labels:["Category 1","Category 2","Category 3","Category 4"],datasets:[Pi("Dataset 1",[12,19,3,5],0)]},options:{...Mi}}}async function Ii(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var c;const l=(c=s.target)==null?void 0:c.result;l?o(l):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Ei(e,t,n){if(!((n==null?void 0:n.accept)??["image/*"]).some(a=>a==="image/*"?t.type.startsWith("image/"):t.type===a)){console.warn("Selected file is not an image");return}Ii(t,n).then(a=>{e.chain().focus().setImage({src:a}).run()}).catch(a=>{console.error("Failed to upload image:",a)})}function vn(e,t){const{state:n,dispatch:o}=e.view,r=n.schema.nodes.layout,a=n.schema.nodes.layoutColumn;if(!r||!a){console.warn("Layout node type not found in schema");return}const s=n.schema.nodes.paragraph;if(!s){console.warn("Paragraph node type not found in schema");return}const l=Array.from({length:t},()=>a.create(null,s.create())),c=r.create({columns:t},l),{from:f}=n.selection,p=n.tr.replaceSelectionWith(c),y=p.mapping.map(f,-1),d=p.doc.nodeAt(y);if(d){let b=y,h=d;for(;h.childCount>0;){const v=h.child(0);if(b+=1,h=v,h.isTextblock){b+=1;break}}p.setSelection(Ae.TextSelection.create(p.doc,b))}o(p),e.view.focus()}function Zt(e,t){var r,a,s,l,c,f,p,y;const o=(t||{slashMenu:{commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},table:{title:"Table",description:"Insert a table"},chart:{title:"Chart",description:"Insert a chart"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}}}).slashMenu.commands;return[{id:"paragraph",title:o.paragraph.title,description:o.paragraph.description,icon:i.jsx(Gn,{}),aliases:["p","text","paragraph"],group:"basic",action:d=>d.chain().focus().setParagraph().run()},{id:"heading1",title:o.heading1.title,description:o.heading1.description,icon:i.jsx(Yn,{}),aliases:["h1","title"],group:"basic",action:d=>d.chain().focus().toggleHeading({level:1}).run()},{id:"heading2",title:o.heading2.title,description:o.heading2.description,icon:i.jsx(Xn,{}),aliases:["h2","subtitle"],group:"basic",action:d=>d.chain().focus().toggleHeading({level:2}).run()},{id:"heading3",title:o.heading3.title,description:o.heading3.description,icon:i.jsx(Kn,{}),aliases:["h3"],group:"basic",action:d=>d.chain().focus().toggleHeading({level:3}).run()},{id:"bulletList",title:o.bulletList.title,description:o.bulletList.description,icon:i.jsx(Jn,{}),aliases:["ul","bullet","unordered","-"],group:"list",action:d=>d.chain().focus().toggleBulletList().run()},{id:"orderedList",title:o.orderedList.title,description:o.orderedList.description,icon:i.jsx(Zn,{}),aliases:["ol","numbered","ordered","1."],group:"list",action:d=>d.chain().focus().toggleOrderedList().run()},{id:"taskList",title:o.taskList.title,description:o.taskList.description,icon:i.jsx(ki,{}),aliases:["todo","task","checkbox","[]"],group:"list",action:d=>d.chain().focus().toggleTaskList().run()},{id:"image",title:o.image.title,description:o.image.description,icon:i.jsx(Ai,{}),aliases:["img","picture","photo","pic"],group:"media",action:d=>{const b=document.createElement("input");b.type="file";const h=(e==null?void 0:e.accept)??["image/*"];b.accept=h.join(","),b.style.display="none",b.onchange=v=>{var m;const C=(m=v.target.files)==null?void 0:m[0];C&&Ei(d,C,e),document.body.removeChild(b)},document.body.appendChild(b),b.click()}},{id:"blockquote",title:o.blockquote.title,description:o.blockquote.description,icon:i.jsx(Ci,{}),aliases:["quote","blockquote",">"],group:"advanced",action:d=>d.chain().focus().toggleBlockquote().run()},{id:"codeBlock",title:o.codeBlock.title,description:o.codeBlock.description,icon:i.jsx(Ti,{}),aliases:["code","pre","snippet","```"],group:"advanced",action:d=>d.chain().focus().toggleCodeBlock().run()},{id:"horizontalRule",title:o.horizontalRule.title,description:o.horizontalRule.description,icon:i.jsx(Li,{}),aliases:["hr","divider","line","---"],group:"advanced",action:d=>{d.chain().focus().setHorizontalRule().run(),ce(()=>{const{state:b}=d.view,{$from:h}=b.selection;let v=-1;const C=h.pos;if(b.doc.descendants((m,B)=>{if(m.type.name==="horizontalRule"){const k=Math.abs(B-C);(v===-1||Math.abs(v-C)>k)&&(v=B)}}),v!==-1){const m=b.doc.nodeAt(v);if(m){const B=v+m.nodeSize;d.chain().setTextSelection(B).insertContent({type:"paragraph"}).focus().run()}}else d.chain().focus().createParagraphNear().run()})}},{id:"table",title:((r=o.table)==null?void 0:r.title)??"Table",description:((a=o.table)==null?void 0:a.description)??"Insert a table",icon:i.jsx(Bi,{}),aliases:["table","grid","tbl"],group:"advanced",action:d=>d.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{id:"chart",title:((s=o.chart)==null?void 0:s.title)??"Chart",description:((l=o.chart)==null?void 0:l.description)??"Insert a chart",icon:i.jsx(ui,{}),aliases:["chart","graph","plot"],group:"advanced",action:d=>{if(!d.schema.nodes.chart){console.warn("Chart node type not found in schema");return}d.chain().focus().insertContent({type:"chart",attrs:{data:Di("bar")}}).run()}},{id:"layoutTwoColumn",title:((c=o.layoutTwoColumn)==null?void 0:c.title)??"Two Column Layout",description:((f=o.layoutTwoColumn)==null?void 0:f.description)??"Split content into two side-by-side columns",icon:i.jsx(ji,{}),aliases:["layout2","two columns","2 col","columns"],group:"layout",action:d=>vn(d,2)},{id:"layoutThreeColumn",title:((p=o.layoutThreeColumn)==null?void 0:p.title)??"Three Column Layout",description:((y=o.layoutThreeColumn)==null?void 0:y.description)??"Split content into three side-by-side columns",icon:i.jsx(Si,{}),aliases:["layout3","three columns","3 col"],group:"layout",action:d=>vn(d,3)}]}const Qn=Zt();function Oi(e,t){if(!t)return e;const n=t.toLowerCase();return e.filter(o=>{var l;const r=o.title.toLowerCase(),a=r.startsWith(n)||r.includes(` ${n}`),s=((l=o.aliases)==null?void 0:l.some(c=>c.toLowerCase().startsWith(n)))??!1;return a||s})}var fe="top",ke="bottom",Ce="right",he="left",Qt="auto",gt=[fe,ke,Ce,he],Qe="start",pt="end",_i="clippingParents",eo="viewport",at="popper",Ni="reference",gn=gt.reduce(function(e,t){return e.concat([t+"-"+Qe,t+"-"+pt])},[]),to=[].concat(gt,[Qt]).reduce(function(e,t){return e.concat([t,t+"-"+Qe,t+"-"+pt])},[]),Hi="beforeRead",zi="read",$i="afterRead",qi="beforeMain",Ui="main",Fi="afterMain",Wi="beforeWrite",Vi="write",Gi="afterWrite",Yi=[Hi,zi,$i,qi,Ui,Fi,Wi,Vi,Gi];function je(e){return e?(e.nodeName||"").toLowerCase():null}function we(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Fe(e){var t=we(e).Element;return e instanceof t||e instanceof Element}function xe(e){var t=we(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function en(e){if(typeof ShadowRoot>"u")return!1;var t=we(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function Xi(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var o=t.styles[n]||{},r=t.attributes[n]||{},a=t.elements[n];!xe(a)||!je(a)||(Object.assign(a.style,o),Object.keys(r).forEach(function(s){var l=r[s];l===!1?a.removeAttribute(s):a.setAttribute(s,l===!0?"":l)}))})}function Ki(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(o){var r=t.elements[o],a=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:n[o]),l=s.reduce(function(c,f){return c[f]="",c},{});!xe(r)||!je(r)||(Object.assign(r.style,l),Object.keys(a).forEach(function(c){r.removeAttribute(c)}))})}}const no={name:"applyStyles",enabled:!0,phase:"write",fn:Xi,effect:Ki,requires:["computeStyles"]};function Be(e){return e.split("-")[0]}var Ue=Math.max,Pt=Math.min,et=Math.round;function Wt(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function oo(){return!/^((?!chrome|android).)*safari/i.test(Wt())}function tt(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var o=e.getBoundingClientRect(),r=1,a=1;t&&xe(e)&&(r=e.offsetWidth>0&&et(o.width)/e.offsetWidth||1,a=e.offsetHeight>0&&et(o.height)/e.offsetHeight||1);var s=Fe(e)?we(e):window,l=s.visualViewport,c=!oo()&&n,f=(o.left+(c&&l?l.offsetLeft:0))/r,p=(o.top+(c&&l?l.offsetTop:0))/a,y=o.width/r,d=o.height/a;return{width:y,height:d,top:p,right:f+y,bottom:p+d,left:f,x:f,y:p}}function tn(e){var t=tt(e),n=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:o}}function ro(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&en(n)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function De(e){return we(e).getComputedStyle(e)}function Ji(e){return["table","td","th"].indexOf(je(e))>=0}function Ee(e){return((Fe(e)?e.ownerDocument:e.document)||window.document).documentElement}function _t(e){return je(e)==="html"?e:e.assignedSlot||e.parentNode||(en(e)?e.host:null)||Ee(e)}function mn(e){return!xe(e)||De(e).position==="fixed"?null:e.offsetParent}function Zi(e){var t=/firefox/i.test(Wt()),n=/Trident/i.test(Wt());if(n&&xe(e)){var o=De(e);if(o.position==="fixed")return null}var r=_t(e);for(en(r)&&(r=r.host);xe(r)&&["html","body"].indexOf(je(r))<0;){var a=De(r);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||t&&a.willChange==="filter"||t&&a.filter&&a.filter!=="none")return r;r=r.parentNode}return null}function mt(e){for(var t=we(e),n=mn(e);n&&Ji(n)&&De(n).position==="static";)n=mn(n);return n&&(je(n)==="html"||je(n)==="body"&&De(n).position==="static")?t:n||Zi(e)||t}function nn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function ct(e,t,n){return Ue(e,Pt(t,n))}function Qi(e,t,n){var o=ct(e,t,n);return o>n?n:o}function ao(){return{top:0,right:0,bottom:0,left:0}}function io(e){return Object.assign({},ao(),e)}function so(e,t){return t.reduce(function(n,o){return n[o]=e,n},{})}var es=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,io(typeof t!="number"?t:so(t,gt))};function ts(e){var t,n=e.state,o=e.name,r=e.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,l=Be(n.placement),c=nn(l),f=[he,Ce].indexOf(l)>=0,p=f?"height":"width";if(!(!a||!s)){var y=es(r.padding,n),d=tn(a),b=c==="y"?fe:he,h=c==="y"?ke:Ce,v=n.rects.reference[p]+n.rects.reference[c]-s[c]-n.rects.popper[p],C=s[c]-n.rects.reference[c],m=mt(a),B=m?c==="y"?m.clientHeight||0:m.clientWidth||0:0,k=v/2-C/2,u=y[b],T=B-d[p]-y[h],A=B/2-d[p]/2+k,E=ct(u,A,T),H=c;n.modifiersData[o]=(t={},t[H]=E,t.centerOffset=E-A,t)}}function ns(e){var t=e.state,n=e.options,o=n.element,r=o===void 0?"[data-popper-arrow]":o;r!=null&&(typeof r=="string"&&(r=t.elements.popper.querySelector(r),!r)||ro(t.elements.popper,r)&&(t.elements.arrow=r))}const os={name:"arrow",enabled:!0,phase:"main",fn:ts,effect:ns,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function nt(e){return e.split("-")[1]}var rs={top:"auto",right:"auto",bottom:"auto",left:"auto"};function as(e,t){var n=e.x,o=e.y,r=t.devicePixelRatio||1;return{x:et(n*r)/r||0,y:et(o*r)/r||0}}function wn(e){var t,n=e.popper,o=e.popperRect,r=e.placement,a=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,f=e.adaptive,p=e.roundOffsets,y=e.isFixed,d=s.x,b=d===void 0?0:d,h=s.y,v=h===void 0?0:h,C=typeof p=="function"?p({x:b,y:v}):{x:b,y:v};b=C.x,v=C.y;var m=s.hasOwnProperty("x"),B=s.hasOwnProperty("y"),k=he,u=fe,T=window;if(f){var A=mt(n),E="clientHeight",H="clientWidth";if(A===we(n)&&(A=Ee(n),De(A).position!=="static"&&l==="absolute"&&(E="scrollHeight",H="scrollWidth")),A=A,r===fe||(r===he||r===Ce)&&a===pt){u=ke;var G=y&&A===T&&T.visualViewport?T.visualViewport.height:A[E];v-=G-o.height,v*=c?1:-1}if(r===he||(r===fe||r===ke)&&a===pt){k=Ce;var S=y&&A===T&&T.visualViewport?T.visualViewport.width:A[H];b-=S-o.width,b*=c?1:-1}}var K=Object.assign({position:l},f&&rs),g=p===!0?as({x:b,y:v},we(n)):{x:b,y:v};if(b=g.x,v=g.y,c){var j;return Object.assign({},K,(j={},j[u]=B?"0":"",j[k]=m?"0":"",j.transform=(T.devicePixelRatio||1)<=1?"translate("+b+"px, "+v+"px)":"translate3d("+b+"px, "+v+"px, 0)",j))}return Object.assign({},K,(t={},t[u]=B?v+"px":"",t[k]=m?b+"px":"",t.transform="",t))}function is(e){var t=e.state,n=e.options,o=n.gpuAcceleration,r=o===void 0?!0:o,a=n.adaptive,s=a===void 0?!0:a,l=n.roundOffsets,c=l===void 0?!0:l,f={placement:Be(t.placement),variation:nt(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,wn(Object.assign({},f,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,wn(Object.assign({},f,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const ss={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:is,data:{}};var Bt={passive:!0};function ls(e){var t=e.state,n=e.instance,o=e.options,r=o.scroll,a=r===void 0?!0:r,s=o.resize,l=s===void 0?!0:s,c=we(t.elements.popper),f=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&f.forEach(function(p){p.addEventListener("scroll",n.update,Bt)}),l&&c.addEventListener("resize",n.update,Bt),function(){a&&f.forEach(function(p){p.removeEventListener("scroll",n.update,Bt)}),l&&c.removeEventListener("resize",n.update,Bt)}}const cs={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:ls,data:{}};var us={left:"right",right:"left",bottom:"top",top:"bottom"};function St(e){return e.replace(/left|right|bottom|top/g,function(t){return us[t]})}var ds={start:"end",end:"start"};function yn(e){return e.replace(/start|end/g,function(t){return ds[t]})}function on(e){var t=we(e),n=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:n,scrollTop:o}}function rn(e){return tt(Ee(e)).left+on(e).scrollLeft}function ps(e,t){var n=we(e),o=Ee(e),r=n.visualViewport,a=o.clientWidth,s=o.clientHeight,l=0,c=0;if(r){a=r.width,s=r.height;var f=oo();(f||!f&&t==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}return{width:a,height:s,x:l+rn(e),y:c}}function fs(e){var t,n=Ee(e),o=on(e),r=(t=e.ownerDocument)==null?void 0:t.body,a=Ue(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=Ue(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),l=-o.scrollLeft+rn(e),c=-o.scrollTop;return De(r||n).direction==="rtl"&&(l+=Ue(n.clientWidth,r?r.clientWidth:0)-a),{width:a,height:s,x:l,y:c}}function an(e){var t=De(e),n=t.overflow,o=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+o)}function lo(e){return["html","body","#document"].indexOf(je(e))>=0?e.ownerDocument.body:xe(e)&&an(e)?e:lo(_t(e))}function ut(e,t){var n;t===void 0&&(t=[]);var o=lo(e),r=o===((n=e.ownerDocument)==null?void 0:n.body),a=we(o),s=r?[a].concat(a.visualViewport||[],an(o)?o:[]):o,l=t.concat(s);return r?l:l.concat(ut(_t(s)))}function Vt(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function hs(e,t){var n=tt(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function xn(e,t,n){return t===eo?Vt(ps(e,n)):Fe(t)?hs(t,n):Vt(fs(Ee(e)))}function bs(e){var t=ut(_t(e)),n=["absolute","fixed"].indexOf(De(e).position)>=0,o=n&&xe(e)?mt(e):e;return Fe(o)?t.filter(function(r){return Fe(r)&&ro(r,o)&&je(r)!=="body"}):[]}function vs(e,t,n,o){var r=t==="clippingParents"?bs(e):[].concat(t),a=[].concat(r,[n]),s=a[0],l=a.reduce(function(c,f){var p=xn(e,f,o);return c.top=Ue(p.top,c.top),c.right=Pt(p.right,c.right),c.bottom=Pt(p.bottom,c.bottom),c.left=Ue(p.left,c.left),c},xn(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function co(e){var t=e.reference,n=e.element,o=e.placement,r=o?Be(o):null,a=o?nt(o):null,s=t.x+t.width/2-n.width/2,l=t.y+t.height/2-n.height/2,c;switch(r){case fe:c={x:s,y:t.y-n.height};break;case ke:c={x:s,y:t.y+t.height};break;case Ce:c={x:t.x+t.width,y:l};break;case he:c={x:t.x-n.width,y:l};break;default:c={x:t.x,y:t.y}}var f=r?nn(r):null;if(f!=null){var p=f==="y"?"height":"width";switch(a){case Qe:c[f]=c[f]-(t[p]/2-n[p]/2);break;case pt:c[f]=c[f]+(t[p]/2-n[p]/2);break}}return c}function ft(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=o===void 0?e.placement:o,a=n.strategy,s=a===void 0?e.strategy:a,l=n.boundary,c=l===void 0?_i:l,f=n.rootBoundary,p=f===void 0?eo:f,y=n.elementContext,d=y===void 0?at:y,b=n.altBoundary,h=b===void 0?!1:b,v=n.padding,C=v===void 0?0:v,m=io(typeof C!="number"?C:so(C,gt)),B=d===at?Ni:at,k=e.rects.popper,u=e.elements[h?B:d],T=vs(Fe(u)?u:u.contextElement||Ee(e.elements.popper),c,p,s),A=tt(e.elements.reference),E=co({reference:A,element:k,placement:r}),H=Vt(Object.assign({},k,E)),G=d===at?H:A,S={top:T.top-G.top+m.top,bottom:G.bottom-T.bottom+m.bottom,left:T.left-G.left+m.left,right:G.right-T.right+m.right},K=e.modifiersData.offset;if(d===at&&K){var g=K[r];Object.keys(S).forEach(function(j){var I=[Ce,ke].indexOf(j)>=0?1:-1,F=[fe,ke].indexOf(j)>=0?"y":"x";S[j]+=g[F]*I})}return S}function gs(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=n.boundary,a=n.rootBoundary,s=n.padding,l=n.flipVariations,c=n.allowedAutoPlacements,f=c===void 0?to:c,p=nt(o),y=p?l?gn:gn.filter(function(h){return nt(h)===p}):gt,d=y.filter(function(h){return f.indexOf(h)>=0});d.length===0&&(d=y);var b=d.reduce(function(h,v){return h[v]=ft(e,{placement:v,boundary:r,rootBoundary:a,padding:s})[Be(v)],h},{});return Object.keys(b).sort(function(h,v){return b[h]-b[v]})}function ms(e){if(Be(e)===Qt)return[];var t=St(e);return[yn(e),t,yn(t)]}function ws(e){var t=e.state,n=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,l=s===void 0?!0:s,c=n.fallbackPlacements,f=n.padding,p=n.boundary,y=n.rootBoundary,d=n.altBoundary,b=n.flipVariations,h=b===void 0?!0:b,v=n.allowedAutoPlacements,C=t.options.placement,m=Be(C),B=m===C,k=c||(B||!h?[St(C)]:ms(C)),u=[C].concat(k).reduce(function(L,R){return L.concat(Be(R)===Qt?gs(t,{placement:R,boundary:p,rootBoundary:y,padding:f,flipVariations:h,allowedAutoPlacements:v}):R)},[]),T=t.rects.reference,A=t.rects.popper,E=new Map,H=!0,G=u[0],S=0;S<u.length;S++){var K=u[S],g=Be(K),j=nt(K)===Qe,I=[fe,ke].indexOf(g)>=0,F=I?"width":"height",X=ft(t,{placement:K,boundary:p,rootBoundary:y,altBoundary:d,padding:f}),W=I?j?Ce:he:j?ke:fe;T[F]>A[F]&&(W=St(W));var z=St(W),M=[];if(a&&M.push(X[g]<=0),l&&M.push(X[W]<=0,X[z]<=0),M.every(function(L){return L})){G=K,H=!1;break}E.set(K,M)}if(H)for(var D=h?3:1,ne=function(R){var O=u.find(function(U){var V=E.get(U);if(V)return V.slice(0,R).every(function(J){return J})});if(O)return G=O,"break"},oe=D;oe>0;oe--){var se=ne(oe);if(se==="break")break}t.placement!==G&&(t.modifiersData[o]._skip=!0,t.placement=G,t.reset=!0)}}const ys={name:"flip",enabled:!0,phase:"main",fn:ws,requiresIfExists:["offset"],data:{_skip:!1}};function kn(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Cn(e){return[fe,Ce,ke,he].some(function(t){return e[t]>=0})}function xs(e){var t=e.state,n=e.name,o=t.rects.reference,r=t.rects.popper,a=t.modifiersData.preventOverflow,s=ft(t,{elementContext:"reference"}),l=ft(t,{altBoundary:!0}),c=kn(s,o),f=kn(l,r,a),p=Cn(c),y=Cn(f);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:f,isReferenceHidden:p,hasPopperEscaped:y},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":y})}const ks={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:xs};function Cs(e,t,n){var o=Be(e),r=[he,fe].indexOf(o)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=a[0],l=a[1];return s=s||0,l=(l||0)*r,[he,Ce].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}function Ts(e){var t=e.state,n=e.options,o=e.name,r=n.offset,a=r===void 0?[0,0]:r,s=to.reduce(function(p,y){return p[y]=Cs(y,t.rects,a),p},{}),l=s[t.placement],c=l.x,f=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=f),t.modifiersData[o]=s}const Ls={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ts};function Bs(e){var t=e.state,n=e.name;t.modifiersData[n]=co({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const As={name:"popperOffsets",enabled:!0,phase:"read",fn:Bs,data:{}};function js(e){return e==="x"?"y":"x"}function Ss(e){var t=e.state,n=e.options,o=e.name,r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,l=s===void 0?!1:s,c=n.boundary,f=n.rootBoundary,p=n.altBoundary,y=n.padding,d=n.tether,b=d===void 0?!0:d,h=n.tetherOffset,v=h===void 0?0:h,C=ft(t,{boundary:c,rootBoundary:f,padding:y,altBoundary:p}),m=Be(t.placement),B=nt(t.placement),k=!B,u=nn(m),T=js(u),A=t.modifiersData.popperOffsets,E=t.rects.reference,H=t.rects.popper,G=typeof v=="function"?v(Object.assign({},t.rects,{placement:t.placement})):v,S=typeof G=="number"?{mainAxis:G,altAxis:G}:Object.assign({mainAxis:0,altAxis:0},G),K=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,g={x:0,y:0};if(A){if(a){var j,I=u==="y"?fe:he,F=u==="y"?ke:Ce,X=u==="y"?"height":"width",W=A[u],z=W+C[I],M=W-C[F],D=b?-H[X]/2:0,ne=B===Qe?E[X]:H[X],oe=B===Qe?-H[X]:-E[X],se=t.elements.arrow,L=b&&se?tn(se):{width:0,height:0},R=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:ao(),O=R[I],U=R[F],V=ct(0,E[X],L[X]),J=k?E[X]/2-D-V-O-S.mainAxis:ne-V-O-S.mainAxis,$=k?-E[X]/2+D+V+U+S.mainAxis:oe+V+U+S.mainAxis,Y=t.elements.arrow&&mt(t.elements.arrow),q=Y?u==="y"?Y.clientTop||0:Y.clientLeft||0:0,Z=(j=K==null?void 0:K[u])!=null?j:0,re=W+J-Z-q,ie=W+$-Z,ee=ct(b?Pt(z,re):z,W,b?Ue(M,ie):M);A[u]=ee,g[u]=ee-W}if(l){var ae,ue=u==="x"?fe:he,ve=u==="x"?ke:Ce,ge=A[T],Te=T==="y"?"height":"width",Ne=ge+C[ue],le=ge-C[ve],rt=[fe,he].indexOf(m)!==-1,yt=(ae=K==null?void 0:K[T])!=null?ae:0,xt=rt?Ne:ge-E[Te]-H[Te]-yt+S.altAxis,kt=rt?ge+E[Te]+H[Te]-yt-S.altAxis:le,Ct=b&&rt?Qi(xt,ge,kt):ct(b?xt:Ne,ge,b?kt:le);A[T]=Ct,g[T]=Ct-ge}t.modifiersData[o]=g}}const Rs={name:"preventOverflow",enabled:!0,phase:"main",fn:Ss,requiresIfExists:["offset"]};function Ms(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Ps(e){return e===we(e)||!xe(e)?on(e):Ms(e)}function Ds(e){var t=e.getBoundingClientRect(),n=et(t.width)/e.offsetWidth||1,o=et(t.height)/e.offsetHeight||1;return n!==1||o!==1}function Is(e,t,n){n===void 0&&(n=!1);var o=xe(t),r=xe(t)&&Ds(t),a=Ee(t),s=tt(e,r,n),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!n)&&((je(t)!=="body"||an(a))&&(l=Ps(t)),xe(t)?(c=tt(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=rn(a))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}function Es(e){var t=new Map,n=new Set,o=[];e.forEach(function(a){t.set(a.name,a)});function r(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(l){if(!n.has(l)){var c=t.get(l);c&&r(c)}}),o.push(a)}return e.forEach(function(a){n.has(a.name)||r(a)}),o}function Os(e){var t=Es(e);return Yi.reduce(function(n,o){return n.concat(t.filter(function(r){return r.phase===o}))},[])}function _s(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function Ns(e){var t=e.reduce(function(n,o){var r=n[o.name];return n[o.name]=r?Object.assign({},r,o,{options:Object.assign({},r.options,o.options),data:Object.assign({},r.data,o.data)}):o,n},{});return Object.keys(t).map(function(n){return t[n]})}var Tn={placement:"bottom",modifiers:[],strategy:"absolute"};function Ln(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}function Hs(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,o=n===void 0?[]:n,r=t.defaultOptions,a=r===void 0?Tn:r;return function(l,c,f){f===void 0&&(f=a);var p={placement:"bottom",orderedModifiers:[],options:Object.assign({},Tn,a),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},y=[],d=!1,b={state:p,setOptions:function(m){var B=typeof m=="function"?m(p.options):m;v(),p.options=Object.assign({},a,p.options,B),p.scrollParents={reference:Fe(l)?ut(l):l.contextElement?ut(l.contextElement):[],popper:ut(c)};var k=Os(Ns([].concat(o,p.options.modifiers)));return p.orderedModifiers=k.filter(function(u){return u.enabled}),h(),b.update()},forceUpdate:function(){if(!d){var m=p.elements,B=m.reference,k=m.popper;if(Ln(B,k)){p.rects={reference:Is(B,mt(k),p.options.strategy==="fixed"),popper:tn(k)},p.reset=!1,p.placement=p.options.placement,p.orderedModifiers.forEach(function(S){return p.modifiersData[S.name]=Object.assign({},S.data)});for(var u=0;u<p.orderedModifiers.length;u++){if(p.reset===!0){p.reset=!1,u=-1;continue}var T=p.orderedModifiers[u],A=T.fn,E=T.options,H=E===void 0?{}:E,G=T.name;typeof A=="function"&&(p=A({state:p,options:H,name:G,instance:b})||p)}}}},update:_s(function(){return new Promise(function(C){b.forceUpdate(),C(p)})}),destroy:function(){v(),d=!0}};if(!Ln(l,c))return b;b.setOptions(f).then(function(C){!d&&f.onFirstUpdate&&f.onFirstUpdate(C)});function h(){p.orderedModifiers.forEach(function(C){var m=C.name,B=C.options,k=B===void 0?{}:B,u=C.effect;if(typeof u=="function"){var T=u({state:p,name:m,instance:b,options:k}),A=function(){};y.push(T||A)}})}function v(){y.forEach(function(C){return C()}),y=[]}return b}}var zs=[cs,As,ss,no,Ls,ys,Rs,os,ks],$s=Hs({defaultModifiers:zs}),qs="tippy-box",uo="tippy-content",Us="tippy-backdrop",po="tippy-arrow",fo="tippy-svg-arrow",$e={passive:!0,capture:!0},ho=function(){return document.body};function Fs(e,t){return{}.hasOwnProperty.call(e,t)}function zt(e,t,n){if(Array.isArray(e)){var o=e[t];return o??(Array.isArray(n)?n[t]:n)}return e}function sn(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function bo(e,t){return typeof e=="function"?e.apply(void 0,t):e}function Bn(e,t){if(t===0)return e;var n;return function(o){clearTimeout(n),n=setTimeout(function(){e(o)},t)}}function Ws(e,t){var n=Object.assign({},e);return t.forEach(function(o){delete n[o]}),n}function Vs(e){return e.split(/\s+/).filter(Boolean)}function Ze(e){return[].concat(e)}function An(e,t){e.indexOf(t)===-1&&e.push(t)}function Gs(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function Ys(e){return e.split("-")[0]}function Dt(e){return[].slice.call(e)}function jn(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function dt(){return document.createElement("div")}function ht(e){return["Element","Fragment"].some(function(t){return sn(e,t)})}function Xs(e){return sn(e,"NodeList")}function Ks(e){return sn(e,"MouseEvent")}function Js(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Zs(e){return ht(e)?[e]:Xs(e)?Dt(e):Array.isArray(e)?e:Dt(document.querySelectorAll(e))}function $t(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function Sn(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function Qs(e){var t,n=Ze(e),o=n[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}function el(e,t){var n=t.clientX,o=t.clientY;return e.every(function(r){var a=r.popperRect,s=r.popperState,l=r.props,c=l.interactiveBorder,f=Ys(s.placement),p=s.modifiersData.offset;if(!p)return!0;var y=f==="bottom"?p.top.y:0,d=f==="top"?p.bottom.y:0,b=f==="right"?p.left.x:0,h=f==="left"?p.right.x:0,v=a.top-o+y>c,C=o-a.bottom-d>c,m=a.left-n+b>c,B=n-a.right-h>c;return v||C||m||B})}function qt(e,t,n){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){e[o](r,n)})}function Rn(e,t){for(var n=t;n;){var o;if(e.contains(n))return!0;n=n.getRootNode==null||(o=n.getRootNode())==null?void 0:o.host}return!1}var Le={isTouch:!1},Mn=0;function tl(){Le.isTouch||(Le.isTouch=!0,window.performance&&document.addEventListener("mousemove",vo))}function vo(){var e=performance.now();e-Mn<20&&(Le.isTouch=!1,document.removeEventListener("mousemove",vo)),Mn=e}function nl(){var e=document.activeElement;if(Js(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function ol(){document.addEventListener("touchstart",tl,$e),window.addEventListener("blur",nl)}var rl=typeof window<"u"&&typeof document<"u",al=rl?!!window.msCrypto:!1;function Je(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Pn(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function il(e){return Pn(`
2
2
  %ctippy.js
3
3
 
4
- %c`+Mn(e)+`
4
+ %c`+Pn(e)+`
5
5
 
6
6
  %c👷‍ This is a development-only message. It will be removed in production.
7
- `)}function ho(e){return[Js(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var ht;process.env.NODE_ENV!=="production"&&Zs();function Zs(){ht=new Set}function Le(e,t){if(e&&!ht.has(t)){var n;ht.add(t),(n=console).warn.apply(n,ho(t))}}function Gt(e,t){if(e&&!ht.has(t)){var n;ht.add(t),(n=console).error.apply(n,ho(t))}}function Qs(e){var t=!e,n=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;Gt(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),Gt(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var bo={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},el={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},oe=Object.assign({appendTo:uo,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},bo,el),tl=Object.keys(oe),nl=function(t){process.env.NODE_ENV!=="production"&&go(t,[]);var n=Object.keys(t);n.forEach(function(o){oe[o]=t[o]})};function vo(e){var t=e.plugins||[],n=t.reduce(function(o,r){var a=r.name,s=r.defaultValue;if(a){var l;o[a]=e[a]!==void 0?e[a]:(l=oe[a])!=null?l:s}return o},{});return Object.assign({},e,n)}function ol(e,t){var n=t?Object.keys(vo(Object.assign({},oe,{plugins:t}))):tl,o=n.reduce(function(r,a){var s=(e.getAttribute("data-tippy-"+a)||"").trim();if(!s)return r;if(a==="content")r[a]=s;else try{r[a]=JSON.parse(s)}catch{r[a]=s}return r},{});return o}function Pn(e,t){var n=Object.assign({},t,{content:po(t.content,[e])},t.ignoreAttributes?{}:ol(e,t.plugins));return n.aria=Object.assign({},oe.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?t.interactive:n.aria.expanded,content:n.aria.content==="auto"?t.interactive?null:"describedby":n.aria.content},n}function go(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var n=Object.keys(e);n.forEach(function(o){var r=Os(oe,Object.keys(bo)),a=!Es(r,o);a&&(a=t.filter(function(s){return s.name===o}).length===0),Le(a,["`"+o+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
7
+ `)}function go(e){return[il(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var bt;process.env.NODE_ENV!=="production"&&sl();function sl(){bt=new Set}function Re(e,t){if(e&&!bt.has(t)){var n;bt.add(t),(n=console).warn.apply(n,go(t))}}function Gt(e,t){if(e&&!bt.has(t)){var n;bt.add(t),(n=console).error.apply(n,go(t))}}function ll(e){var t=!e,n=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;Gt(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),Gt(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var mo={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},cl={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},me=Object.assign({appendTo:ho,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},mo,cl),ul=Object.keys(me),dl=function(t){process.env.NODE_ENV!=="production"&&yo(t,[]);var n=Object.keys(t);n.forEach(function(o){me[o]=t[o]})};function wo(e){var t=e.plugins||[],n=t.reduce(function(o,r){var a=r.name,s=r.defaultValue;if(a){var l;o[a]=e[a]!==void 0?e[a]:(l=me[a])!=null?l:s}return o},{});return Object.assign({},e,n)}function pl(e,t){var n=t?Object.keys(wo(Object.assign({},me,{plugins:t}))):ul,o=n.reduce(function(r,a){var s=(e.getAttribute("data-tippy-"+a)||"").trim();if(!s)return r;if(a==="content")r[a]=s;else try{r[a]=JSON.parse(s)}catch{r[a]=s}return r},{});return o}function Dn(e,t){var n=Object.assign({},t,{content:bo(t.content,[e])},t.ignoreAttributes?{}:pl(e,t.plugins));return n.aria=Object.assign({},me.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?t.interactive:n.aria.expanded,content:n.aria.content==="auto"?t.interactive?null:"describedby":n.aria.content},n}function yo(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var n=Object.keys(e);n.forEach(function(o){var r=Ws(me,Object.keys(mo)),a=!Fs(r,o);a&&(a=t.filter(function(s){return s.name===o}).length===0),Re(a,["`"+o+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
8
8
 
9
9
  `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
10
- `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var rl=function(){return"innerHTML"};function Yt(e,t){e[rl()]=t}function Dn(e){var t=ut();return e===!0?t.className=lo:(t.className=co,ft(e)?t.appendChild(e):Yt(t,e)),t}function In(e,t){ft(t.content)?(Yt(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Yt(e,t.content):e.textContent=t.content)}function Kt(e){var t=e.firstElementChild,n=It(t.children);return{box:t,content:n.find(function(o){return o.classList.contains(so)}),arrow:n.find(function(o){return o.classList.contains(lo)||o.classList.contains(co)}),backdrop:n.find(function(o){return o.classList.contains(Rs)})}}function mo(e){var t=ut(),n=ut();n.className=Is,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var o=ut();o.className=so,o.setAttribute("data-state","hidden"),In(o,e.props),t.appendChild(n),n.appendChild(o),r(e.props,e.props);function r(a,s){var l=Kt(t),c=l.box,f=l.content,u=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(a.content!==s.content||a.allowHTML!==s.allowHTML)&&In(f,e.props),s.arrow?u?a.arrow!==s.arrow&&(c.removeChild(u),c.appendChild(Dn(s.arrow))):c.appendChild(Dn(s.arrow)):u&&c.removeChild(u)}return{popper:t,onUpdate:r}}mo.$$tippy=!0;var al=1,At=[],Ut=[];function il(e,t){var n=Pn(e,Object.assign({},oe,vo(Bn(t)))),o,r,a,s=!1,l=!1,c=!1,f=!1,u,m,h,v=[],p=Tn(Oe,n.interactiveDebounce),g,C=al++,y=null,S=Ns(n.plugins),T={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},d={id:C,reference:e,popper:ut(),popperInstance:y,props:n,state:T,plugins:S,clearDelayTimeouts:wt,setProps:kt,setContent:Ct,show:Ho,hide:$o,hideWithInteractivity:zo,enable:ot,disable:yt,unmount:qo,destroy:Uo};if(!n.render)return process.env.NODE_ENV!=="production"&&Gt(!0,"render() function has not been supplied."),d;var A=n.render(d),k=A.popper,j=A.onUpdate;k.setAttribute("data-tippy-root",""),k.id="tippy-"+d.id,d.popper=k,e._tippy=d,k._tippy=d;var I=S.map(function(w){return w.fn(d)}),N=e.hasAttribute("aria-expanded");return ke(),R(),q(),H("onCreate",[d]),n.showOnCreate&&Ne(),k.addEventListener("mouseenter",function(){d.props.interactive&&d.state.isVisible&&d.clearDelayTimeouts()}),k.addEventListener("mouseleave",function(){d.props.interactive&&d.props.trigger.indexOf("mouseenter")>=0&&M().addEventListener("mousemove",p)}),d;function B(){var w=d.props.touch;return Array.isArray(w)?w:[w,0]}function _(){return B()[0]==="hold"}function b(){var w;return!!((w=d.props.render)!=null&&w.$$tippy)}function L(){return g||e}function M(){var w=L().parentNode;return w?Fs(w):document}function E(){return Kt(k)}function $(w){return d.state.isMounted&&!d.state.isVisible||ve.isTouch||u&&u.type==="focus"?0:$t(d.props.delay,w?0:1,oe.delay)}function q(w){w===void 0&&(w=!1),k.style.pointerEvents=d.props.interactive&&!w?"":"none",k.style.zIndex=""+d.props.zIndex}function H(w,D,O){if(O===void 0&&(O=!0),I.forEach(function(U){U[w]&&U[w].apply(U,D)}),O){var F;(F=d.props)[w].apply(F,D)}}function P(){var w=d.props.aria;if(w.content){var D="aria-"+w.content,O=k.id,F=Ze(d.props.triggerTarget||e);F.forEach(function(U){var K=U.getAttribute(D);if(d.state.isVisible)U.setAttribute(D,K?K+" "+O:O);else{var se=K&&K.replace(O,"").trim();se?U.setAttribute(D,se):U.removeAttribute(D)}})}}function R(){if(!(N||!d.props.aria.expanded)){var w=Ze(d.props.triggerTarget||e);w.forEach(function(D){d.props.interactive?D.setAttribute("aria-expanded",d.state.isVisible&&D===L()?"true":"false"):D.removeAttribute("aria-expanded")})}}function W(){M().removeEventListener("mousemove",p),At=At.filter(function(w){return w!==p})}function V(w){if(!(ve.isTouch&&(c||w.type==="mousedown"))){var D=w.composedPath&&w.composedPath()[0]||w.target;if(!(d.props.interactive&&jn(k,D))){if(Ze(d.props.triggerTarget||e).some(function(O){return jn(O,D)})){if(ve.isTouch||d.state.isVisible&&d.props.trigger.indexOf("click")>=0)return}else H("onClickOutside",[d,w]);d.props.hideOnClick===!0&&(d.clearDelayTimeouts(),d.hide(),l=!0,setTimeout(function(){l=!1}),d.state.isMounted||ae())}}}function J(){c=!0}function Z(){c=!1}function Q(){var w=M();w.addEventListener("mousedown",V,!0),w.addEventListener("touchend",V,ze),w.addEventListener("touchstart",Z,ze),w.addEventListener("touchmove",J,ze)}function ae(){var w=M();w.removeEventListener("mousedown",V,!0),w.removeEventListener("touchend",V,ze),w.removeEventListener("touchstart",Z,ze),w.removeEventListener("touchmove",J,ze)}function ye(w,D){we(w,function(){!d.state.isVisible&&k.parentNode&&k.parentNode.contains(k)&&D()})}function ie(w,D){we(w,D)}function we(w,D){var O=E().box;function F(U){U.target===O&&(qt(O,"remove",F),D())}if(w===0)return D();qt(O,"remove",m),qt(O,"add",F),m=F}function de(w,D,O){O===void 0&&(O=!1);var F=Ze(d.props.triggerTarget||e);F.forEach(function(U){U.addEventListener(w,D,O),v.push({node:U,eventType:w,handler:D,options:O})})}function ke(){_()&&(de("touchstart",Ce,{passive:!0}),de("touchend",pe,{passive:!0})),_s(d.props.trigger).forEach(function(w){if(w!=="manual")switch(de(w,Ce),w){case"mouseenter":de("mouseleave",pe);break;case"focus":de(Xs?"focusout":"blur",Te);break;case"focusin":de("focusout",Te);break}})}function Ee(){v.forEach(function(w){var D=w.node,O=w.eventType,F=w.handler,U=w.options;D.removeEventListener(O,F,U)}),v=[]}function Ce(w){var D,O=!1;if(!(!d.state.isEnabled||Me(w)||l)){var F=((D=u)==null?void 0:D.type)==="focus";u=w,g=w.currentTarget,R(),!d.state.isVisible&&zs(w)&&At.forEach(function(U){return U(w)}),w.type==="click"&&(d.props.trigger.indexOf("mouseenter")<0||s)&&d.props.hideOnClick!==!1&&d.state.isVisible?O=!0:Ne(w),w.type==="click"&&(s=!O),O&&!F&&G(w)}}function Oe(w){var D=w.target,O=L().contains(D)||k.contains(D);if(!(w.type==="mousemove"&&O)){var F=be().concat(k).map(function(U){var K,se=U._tippy,Ye=(K=se.popperInstance)==null?void 0:K.state;return Ye?{popperRect:U.getBoundingClientRect(),popperState:Ye,props:n}:null}).filter(Boolean);Ws(F,w)&&(W(),G(w))}}function pe(w){var D=Me(w)||d.props.trigger.indexOf("click")>=0&&s;if(!D){if(d.props.interactive){d.hideWithInteractivity(w);return}G(w)}}function Te(w){d.props.trigger.indexOf("focusin")<0&&w.target!==L()||d.props.interactive&&w.relatedTarget&&k.contains(w.relatedTarget)||G(w)}function Me(w){return ve.isTouch?_()!==w.type.indexOf("touch")>=0:!1}function _e(){fe();var w=d.props,D=w.popperOptions,O=w.placement,F=w.offset,U=w.getReferenceClientRect,K=w.moveTransition,se=b()?Kt(k).arrow:null,Ye=U?{getBoundingClientRect:U,contextElement:U.contextElement||L()}:e,dn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Tt){var Ke=Tt.state;if(b()){var Fo=E(),Ht=Fo.box;["placement","reference-hidden","escaped"].forEach(function(Lt){Lt==="placement"?Ht.setAttribute("data-placement",Ke.placement):Ke.attributes.popper["data-popper-"+Lt]?Ht.setAttribute("data-"+Lt,""):Ht.removeAttribute("data-"+Lt)}),Ke.attributes.popper={}}}},He=[{name:"offset",options:{offset:F}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!K}},dn];b()&&se&&He.push({name:"arrow",options:{element:se,padding:3}}),He.push.apply(He,(D==null?void 0:D.modifiers)||[]),d.popperInstance=Ds(Ye,k,Object.assign({},D,{placement:O,onFirstUpdate:h,modifiers:He}))}function fe(){d.popperInstance&&(d.popperInstance.destroy(),d.popperInstance=null)}function he(){var w=d.props.appendTo,D,O=L();d.props.interactive&&w===uo||w==="parent"?D=O.parentNode:D=po(w,[O]),D.contains(k)||D.appendChild(k),d.state.isMounted=!0,_e(),process.env.NODE_ENV!=="production"&&Le(d.props.interactive&&w===oe.appendTo&&O.nextElementSibling!==k,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
10
+ `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var fl=function(){return"innerHTML"};function Yt(e,t){e[fl()]=t}function In(e){var t=dt();return e===!0?t.className=po:(t.className=fo,ht(e)?t.appendChild(e):Yt(t,e)),t}function En(e,t){ht(t.content)?(Yt(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Yt(e,t.content):e.textContent=t.content)}function Xt(e){var t=e.firstElementChild,n=Dt(t.children);return{box:t,content:n.find(function(o){return o.classList.contains(uo)}),arrow:n.find(function(o){return o.classList.contains(po)||o.classList.contains(fo)}),backdrop:n.find(function(o){return o.classList.contains(Us)})}}function xo(e){var t=dt(),n=dt();n.className=qs,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var o=dt();o.className=uo,o.setAttribute("data-state","hidden"),En(o,e.props),t.appendChild(n),n.appendChild(o),r(e.props,e.props);function r(a,s){var l=Xt(t),c=l.box,f=l.content,p=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(a.content!==s.content||a.allowHTML!==s.allowHTML)&&En(f,e.props),s.arrow?p?a.arrow!==s.arrow&&(c.removeChild(p),c.appendChild(In(s.arrow))):c.appendChild(In(s.arrow)):p&&c.removeChild(p)}return{popper:t,onUpdate:r}}xo.$$tippy=!0;var hl=1,At=[],Ut=[];function bl(e,t){var n=Dn(e,Object.assign({},me,wo(jn(t)))),o,r,a,s=!1,l=!1,c=!1,f=!1,p,y,d,b=[],h=Bn(re,n.interactiveDebounce),v,C=hl++,m=null,B=Gs(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},u={id:C,reference:e,popper:dt(),popperInstance:m,props:n,state:k,plugins:B,clearDelayTimeouts:xt,setProps:kt,setContent:Ct,show:qo,hide:Uo,hideWithInteractivity:Fo,enable:rt,disable:yt,unmount:Wo,destroy:Vo};if(!n.render)return process.env.NODE_ENV!=="production"&&Gt(!0,"render() function has not been supplied."),u;var T=n.render(u),A=T.popper,E=T.onUpdate;A.setAttribute("data-tippy-root",""),A.id="tippy-"+u.id,u.popper=A,e._tippy=u,A._tippy=u;var H=B.map(function(x){return x.fn(u)}),G=e.hasAttribute("aria-expanded");return Y(),D(),W(),z("onCreate",[u]),n.showOnCreate&&Ne(),A.addEventListener("mouseenter",function(){u.props.interactive&&u.state.isVisible&&u.clearDelayTimeouts()}),A.addEventListener("mouseleave",function(){u.props.interactive&&u.props.trigger.indexOf("mouseenter")>=0&&I().addEventListener("mousemove",h)}),u;function S(){var x=u.props.touch;return Array.isArray(x)?x:[x,0]}function K(){return S()[0]==="hold"}function g(){var x;return!!((x=u.props.render)!=null&&x.$$tippy)}function j(){return v||e}function I(){var x=j().parentNode;return x?Qs(x):document}function F(){return Xt(A)}function X(x){return u.state.isMounted&&!u.state.isVisible||Le.isTouch||p&&p.type==="focus"?0:zt(u.props.delay,x?0:1,me.delay)}function W(x){x===void 0&&(x=!1),A.style.pointerEvents=u.props.interactive&&!x?"":"none",A.style.zIndex=""+u.props.zIndex}function z(x,P,N){if(N===void 0&&(N=!0),H.forEach(function(Q){Q[x]&&Q[x].apply(Q,P)}),N){var te;(te=u.props)[x].apply(te,P)}}function M(){var x=u.props.aria;if(x.content){var P="aria-"+x.content,N=A.id,te=Ze(u.props.triggerTarget||e);te.forEach(function(Q){var de=Q.getAttribute(P);if(u.state.isVisible)Q.setAttribute(P,de?de+" "+N:N);else{var ye=de&&de.replace(N,"").trim();ye?Q.setAttribute(P,ye):Q.removeAttribute(P)}})}}function D(){if(!(G||!u.props.aria.expanded)){var x=Ze(u.props.triggerTarget||e);x.forEach(function(P){u.props.interactive?P.setAttribute("aria-expanded",u.state.isVisible&&P===j()?"true":"false"):P.removeAttribute("aria-expanded")})}}function ne(){I().removeEventListener("mousemove",h),At=At.filter(function(x){return x!==h})}function oe(x){if(!(Le.isTouch&&(c||x.type==="mousedown"))){var P=x.composedPath&&x.composedPath()[0]||x.target;if(!(u.props.interactive&&Rn(A,P))){if(Ze(u.props.triggerTarget||e).some(function(N){return Rn(N,P)})){if(Le.isTouch||u.state.isVisible&&u.props.trigger.indexOf("click")>=0)return}else z("onClickOutside",[u,x]);u.props.hideOnClick===!0&&(u.clearDelayTimeouts(),u.hide(),l=!0,setTimeout(function(){l=!1}),u.state.isMounted||O())}}}function se(){c=!0}function L(){c=!1}function R(){var x=I();x.addEventListener("mousedown",oe,!0),x.addEventListener("touchend",oe,$e),x.addEventListener("touchstart",L,$e),x.addEventListener("touchmove",se,$e)}function O(){var x=I();x.removeEventListener("mousedown",oe,!0),x.removeEventListener("touchend",oe,$e),x.removeEventListener("touchstart",L,$e),x.removeEventListener("touchmove",se,$e)}function U(x,P){J(x,function(){!u.state.isVisible&&A.parentNode&&A.parentNode.contains(A)&&P()})}function V(x,P){J(x,P)}function J(x,P){var N=F().box;function te(Q){Q.target===N&&(qt(N,"remove",te),P())}if(x===0)return P();qt(N,"remove",y),qt(N,"add",te),y=te}function $(x,P,N){N===void 0&&(N=!1);var te=Ze(u.props.triggerTarget||e);te.forEach(function(Q){Q.addEventListener(x,P,N),b.push({node:Q,eventType:x,handler:P,options:N})})}function Y(){K()&&($("touchstart",Z,{passive:!0}),$("touchend",ie,{passive:!0})),Vs(u.props.trigger).forEach(function(x){if(x!=="manual")switch($(x,Z),x){case"mouseenter":$("mouseleave",ie);break;case"focus":$(al?"focusout":"blur",ee);break;case"focusin":$("focusout",ee);break}})}function q(){b.forEach(function(x){var P=x.node,N=x.eventType,te=x.handler,Q=x.options;P.removeEventListener(N,te,Q)}),b=[]}function Z(x){var P,N=!1;if(!(!u.state.isEnabled||ae(x)||l)){var te=((P=p)==null?void 0:P.type)==="focus";p=x,v=x.currentTarget,D(),!u.state.isVisible&&Ks(x)&&At.forEach(function(Q){return Q(x)}),x.type==="click"&&(u.props.trigger.indexOf("mouseenter")<0||s)&&u.props.hideOnClick!==!1&&u.state.isVisible?N=!0:Ne(x),x.type==="click"&&(s=!N),N&&!te&&le(x)}}function re(x){var P=x.target,N=j().contains(P)||A.contains(P);if(!(x.type==="mousemove"&&N)){var te=Te().concat(A).map(function(Q){var de,ye=Q._tippy,Ye=(de=ye.popperInstance)==null?void 0:de.state;return Ye?{popperRect:Q.getBoundingClientRect(),popperState:Ye,props:n}:null}).filter(Boolean);el(te,x)&&(ne(),le(x))}}function ie(x){var P=ae(x)||u.props.trigger.indexOf("click")>=0&&s;if(!P){if(u.props.interactive){u.hideWithInteractivity(x);return}le(x)}}function ee(x){u.props.trigger.indexOf("focusin")<0&&x.target!==j()||u.props.interactive&&x.relatedTarget&&A.contains(x.relatedTarget)||le(x)}function ae(x){return Le.isTouch?K()!==x.type.indexOf("touch")>=0:!1}function ue(){ve();var x=u.props,P=x.popperOptions,N=x.placement,te=x.offset,Q=x.getReferenceClientRect,de=x.moveTransition,ye=g()?Xt(A).arrow:null,Ye=Q?{getBoundingClientRect:Q,contextElement:Q.contextElement||j()}:e,pn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Tt){var Xe=Tt.state;if(g()){var Go=F(),Ht=Go.box;["placement","reference-hidden","escaped"].forEach(function(Lt){Lt==="placement"?Ht.setAttribute("data-placement",Xe.placement):Xe.attributes.popper["data-popper-"+Lt]?Ht.setAttribute("data-"+Lt,""):Ht.removeAttribute("data-"+Lt)}),Xe.attributes.popper={}}}},He=[{name:"offset",options:{offset:te}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!de}},pn];g()&&ye&&He.push({name:"arrow",options:{element:ye,padding:3}}),He.push.apply(He,(P==null?void 0:P.modifiers)||[]),u.popperInstance=$s(Ye,A,Object.assign({},P,{placement:N,onFirstUpdate:d,modifiers:He}))}function ve(){u.popperInstance&&(u.popperInstance.destroy(),u.popperInstance=null)}function ge(){var x=u.props.appendTo,P,N=j();u.props.interactive&&x===ho||x==="parent"?P=N.parentNode:P=bo(x,[N]),P.contains(A)||P.appendChild(A),u.state.isMounted=!0,ue(),process.env.NODE_ENV!=="production"&&Re(u.props.interactive&&x===me.appendTo&&N.nextElementSibling!==A,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
11
11
 
12
12
  `,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
13
13
 
14
14
  `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
15
15
 
16
- `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function be(){return It(k.querySelectorAll("[data-tippy-root]"))}function Ne(w){d.clearDelayTimeouts(),w&&H("onTrigger",[d,w]),Q();var D=$(!0),O=B(),F=O[0],U=O[1];ve.isTouch&&F==="hold"&&U&&(D=U),D?o=setTimeout(function(){d.show()},D):d.show()}function G(w){if(d.clearDelayTimeouts(),H("onUntrigger",[d,w]),!d.state.isVisible){ae();return}if(!(d.props.trigger.indexOf("mouseenter")>=0&&d.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(w.type)>=0&&s)){var D=$(!1);D?r=setTimeout(function(){d.state.isVisible&&d.hide()},D):a=requestAnimationFrame(function(){d.hide()})}}function ot(){d.state.isEnabled=!0}function yt(){d.hide(),d.state.isEnabled=!1}function wt(){clearTimeout(o),clearTimeout(r),cancelAnimationFrame(a)}function kt(w){if(process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("setProps")),!d.state.isDestroyed){H("onBeforeUpdate",[d,w]),Ee();var D=d.props,O=Pn(e,Object.assign({},D,Bn(w),{ignoreAttributes:!0}));d.props=O,ke(),D.interactiveDebounce!==O.interactiveDebounce&&(W(),p=Tn(Oe,O.interactiveDebounce)),D.triggerTarget&&!O.triggerTarget?Ze(D.triggerTarget).forEach(function(F){F.removeAttribute("aria-expanded")}):O.triggerTarget&&e.removeAttribute("aria-expanded"),R(),q(),j&&j(D,O),d.popperInstance&&(_e(),be().forEach(function(F){requestAnimationFrame(F._tippy.popperInstance.forceUpdate)})),H("onAfterUpdate",[d,w])}}function Ct(w){d.setProps({content:w})}function Ho(){process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("show"));var w=d.state.isVisible,D=d.state.isDestroyed,O=!d.state.isEnabled,F=ve.isTouch&&!d.props.touch,U=$t(d.props.duration,0,oe.duration);if(!(w||D||O||F)&&!L().hasAttribute("disabled")&&(H("onShow",[d],!1),d.props.onShow(d)!==!1)){if(d.state.isVisible=!0,b()&&(k.style.visibility="visible"),q(),Q(),d.state.isMounted||(k.style.transition="none"),b()){var K=E(),se=K.box,Ye=K.content;zt([se,Ye],0)}h=function(){var He;if(!(!d.state.isVisible||f)){if(f=!0,k.offsetHeight,k.style.transition=d.props.moveTransition,b()&&d.props.animation){var Nt=E(),Tt=Nt.box,Ke=Nt.content;zt([Tt,Ke],U),An([Tt,Ke],"visible")}P(),R(),Ln(Ut,d),(He=d.popperInstance)==null||He.forceUpdate(),H("onMount",[d]),d.props.animation&&b()&&ie(U,function(){d.state.isShown=!0,H("onShown",[d])})}},he()}}function $o(){process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("hide"));var w=!d.state.isVisible,D=d.state.isDestroyed,O=!d.state.isEnabled,F=$t(d.props.duration,1,oe.duration);if(!(w||D||O)&&(H("onHide",[d],!1),d.props.onHide(d)!==!1)){if(d.state.isVisible=!1,d.state.isShown=!1,f=!1,s=!1,b()&&(k.style.visibility="hidden"),W(),ae(),q(!0),b()){var U=E(),K=U.box,se=U.content;d.props.animation&&(zt([K,se],F),An([K,se],"hidden"))}P(),R(),d.props.animation?b()&&ye(F,d.unmount):d.unmount()}}function zo(w){process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("hideWithInteractivity")),M().addEventListener("mousemove",p),Ln(At,p),p(w)}function qo(){process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("unmount")),d.state.isVisible&&d.hide(),d.state.isMounted&&(fe(),be().forEach(function(w){w._tippy.unmount()}),k.parentNode&&k.parentNode.removeChild(k),Ut=Ut.filter(function(w){return w!==d}),d.state.isMounted=!1,H("onHidden",[d]))}function Uo(){process.env.NODE_ENV!=="production"&&Le(d.state.isDestroyed,Je("destroy")),!d.state.isDestroyed&&(d.clearDelayTimeouts(),d.unmount(),Ee(),delete e._tippy,d.state.isDestroyed=!0,H("onDestroy",[d]))}}function Ie(e,t){t===void 0&&(t={});var n=oe.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(Qs(e),go(t,n)),Ys();var o=Object.assign({},t,{plugins:n}),r=Us(e);if(process.env.NODE_ENV!=="production"){var a=ft(o.content),s=r.length>1;Le(a&&s,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
16
+ `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Te(){return Dt(A.querySelectorAll("[data-tippy-root]"))}function Ne(x){u.clearDelayTimeouts(),x&&z("onTrigger",[u,x]),R();var P=X(!0),N=S(),te=N[0],Q=N[1];Le.isTouch&&te==="hold"&&Q&&(P=Q),P?o=setTimeout(function(){u.show()},P):u.show()}function le(x){if(u.clearDelayTimeouts(),z("onUntrigger",[u,x]),!u.state.isVisible){O();return}if(!(u.props.trigger.indexOf("mouseenter")>=0&&u.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(x.type)>=0&&s)){var P=X(!1);P?r=setTimeout(function(){u.state.isVisible&&u.hide()},P):a=requestAnimationFrame(function(){u.hide()})}}function rt(){u.state.isEnabled=!0}function yt(){u.hide(),u.state.isEnabled=!1}function xt(){clearTimeout(o),clearTimeout(r),cancelAnimationFrame(a)}function kt(x){if(process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("setProps")),!u.state.isDestroyed){z("onBeforeUpdate",[u,x]),q();var P=u.props,N=Dn(e,Object.assign({},P,jn(x),{ignoreAttributes:!0}));u.props=N,Y(),P.interactiveDebounce!==N.interactiveDebounce&&(ne(),h=Bn(re,N.interactiveDebounce)),P.triggerTarget&&!N.triggerTarget?Ze(P.triggerTarget).forEach(function(te){te.removeAttribute("aria-expanded")}):N.triggerTarget&&e.removeAttribute("aria-expanded"),D(),W(),E&&E(P,N),u.popperInstance&&(ue(),Te().forEach(function(te){requestAnimationFrame(te._tippy.popperInstance.forceUpdate)})),z("onAfterUpdate",[u,x])}}function Ct(x){u.setProps({content:x})}function qo(){process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("show"));var x=u.state.isVisible,P=u.state.isDestroyed,N=!u.state.isEnabled,te=Le.isTouch&&!u.props.touch,Q=zt(u.props.duration,0,me.duration);if(!(x||P||N||te)&&!j().hasAttribute("disabled")&&(z("onShow",[u],!1),u.props.onShow(u)!==!1)){if(u.state.isVisible=!0,g()&&(A.style.visibility="visible"),W(),R(),u.state.isMounted||(A.style.transition="none"),g()){var de=F(),ye=de.box,Ye=de.content;$t([ye,Ye],0)}d=function(){var He;if(!(!u.state.isVisible||f)){if(f=!0,A.offsetHeight,A.style.transition=u.props.moveTransition,g()&&u.props.animation){var Nt=F(),Tt=Nt.box,Xe=Nt.content;$t([Tt,Xe],Q),Sn([Tt,Xe],"visible")}M(),D(),An(Ut,u),(He=u.popperInstance)==null||He.forceUpdate(),z("onMount",[u]),u.props.animation&&g()&&V(Q,function(){u.state.isShown=!0,z("onShown",[u])})}},ge()}}function Uo(){process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("hide"));var x=!u.state.isVisible,P=u.state.isDestroyed,N=!u.state.isEnabled,te=zt(u.props.duration,1,me.duration);if(!(x||P||N)&&(z("onHide",[u],!1),u.props.onHide(u)!==!1)){if(u.state.isVisible=!1,u.state.isShown=!1,f=!1,s=!1,g()&&(A.style.visibility="hidden"),ne(),O(),W(!0),g()){var Q=F(),de=Q.box,ye=Q.content;u.props.animation&&($t([de,ye],te),Sn([de,ye],"hidden"))}M(),D(),u.props.animation?g()&&U(te,u.unmount):u.unmount()}}function Fo(x){process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("hideWithInteractivity")),I().addEventListener("mousemove",h),An(At,h),h(x)}function Wo(){process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("unmount")),u.state.isVisible&&u.hide(),u.state.isMounted&&(ve(),Te().forEach(function(x){x._tippy.unmount()}),A.parentNode&&A.parentNode.removeChild(A),Ut=Ut.filter(function(x){return x!==u}),u.state.isMounted=!1,z("onHidden",[u]))}function Vo(){process.env.NODE_ENV!=="production"&&Re(u.state.isDestroyed,Je("destroy")),!u.state.isDestroyed&&(u.clearDelayTimeouts(),u.unmount(),q(),delete e._tippy,u.state.isDestroyed=!0,z("onDestroy",[u]))}}function Oe(e,t){t===void 0&&(t={});var n=me.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(ll(e),yo(t,n)),ol();var o=Object.assign({},t,{plugins:n}),r=Zs(e);if(process.env.NODE_ENV!=="production"){var a=ht(o.content),s=r.length>1;Re(a&&s,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
17
17
 
18
18
  `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
19
19
 
20
20
  `,`1) content: element.innerHTML
21
- `,"2) content: () => element.cloneNode(true)"].join(" "))}var l=r.reduce(function(c,f){var u=f&&il(f,o);return u&&c.push(u),c},[]);return ft(e)?l[0]:l}Ie.defaultProps=oe;Ie.setDefaultProps=nl;Ie.currentInput=ve;Object.assign({},Qn,{effect:function(t){var n=t.state,o={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,o.popper),n.styles=o,n.elements.arrow&&Object.assign(n.elements.arrow.style,o.arrow)}});Ie.setDefaultProps({render:mo});const z={colors:{background:"var(--pubwave-color-background)",surface:"var(--pubwave-color-surface)",text:"var(--pubwave-color-text)",textMuted:"var(--pubwave-color-text-muted)",border:"var(--pubwave-color-border)",borderLight:"var(--pubwave-color-border-light)",hover:"var(--pubwave-color-hover)",focus:"var(--pubwave-color-focus)",selection:"var(--pubwave-color-selection)",selectionBg:"var(--pubwave-color-selection-bg)",primary:"var(--pubwave-color-primary)",primaryFaded:"var(--pubwave-color-primary-faded)",dropIndicator:"var(--pubwave-color-drop-indicator)",dropTarget:"var(--pubwave-color-drop-target)",error:"var(--pubwave-color-error)"},spacing:{xs:"var(--pubwave-spacing-xs)",sm:"var(--pubwave-spacing-sm)",md:"var(--pubwave-spacing-md)",lg:"var(--pubwave-spacing-lg)",xl:"var(--pubwave-spacing-xl)",blockPaddingX:"var(--pubwave-block-padding-x)",blockPaddingY:"var(--pubwave-block-padding-y)",blockMarginY:"var(--pubwave-block-margin-y)",toolbarGap:"var(--pubwave-toolbar-gap)"},typography:{fontFamily:"var(--pubwave-font-family)",fontSizeBase:"var(--pubwave-font-size-base)",fontSizeSmall:"var(--pubwave-font-size-small)",lineHeightBase:"var(--pubwave-line-height-base)",lineHeightHeading:"var(--pubwave-line-height-heading)",fontWeightNormal:"var(--pubwave-font-weight-normal)",fontWeightMedium:"var(--pubwave-font-weight-medium)",fontWeightBold:"var(--pubwave-font-weight-bold)",fontWeightHeading:"var(--pubwave-font-weight-heading)"},borderRadius:{sm:"var(--pubwave-border-radius-sm)",md:"var(--pubwave-border-radius)",lg:"var(--pubwave-border-radius-large)"},shadow:{sm:"var(--pubwave-shadow-sm)",md:"var(--pubwave-shadow-md)",toolbar:"var(--pubwave-shadow-toolbar)",popup:"var(--pubwave-shadow-popup)"},transition:{fast:"var(--pubwave-transition-fast)",normal:"var(--pubwave-transition-normal)"},zIndex:{dragPreview:100,dragHandle:40,toolbar:50,dropdown:60}},sl=`
21
+ `,"2) content: () => element.cloneNode(true)"].join(" "))}var l=r.reduce(function(c,f){var p=f&&bl(f,o);return p&&c.push(p),c},[]);return ht(e)?l[0]:l}Oe.defaultProps=me;Oe.setDefaultProps=dl;Oe.currentInput=Le;Object.assign({},no,{effect:function(t){var n=t.state,o={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,o.popper),n.styles=o,n.elements.arrow&&Object.assign(n.elements.arrow.style,o.arrow)}});Oe.setDefaultProps({render:xo});const _={colors:{background:"var(--pubwave-color-background)",surface:"var(--pubwave-color-surface)",text:"var(--pubwave-color-text)",textMuted:"var(--pubwave-color-text-muted)",border:"var(--pubwave-color-border)",borderLight:"var(--pubwave-color-border-light)",hover:"var(--pubwave-color-hover)",focus:"var(--pubwave-color-focus)",selection:"var(--pubwave-color-selection)",selectionBg:"var(--pubwave-color-selection-bg)",primary:"var(--pubwave-color-primary)",primaryFaded:"var(--pubwave-color-primary-faded)",dropIndicator:"var(--pubwave-color-drop-indicator)",dropTarget:"var(--pubwave-color-drop-target)",error:"var(--pubwave-color-error)"},spacing:{xs:"var(--pubwave-spacing-xs)",sm:"var(--pubwave-spacing-sm)",md:"var(--pubwave-spacing-md)",lg:"var(--pubwave-spacing-lg)",xl:"var(--pubwave-spacing-xl)",blockPaddingX:"var(--pubwave-block-padding-x)",blockPaddingY:"var(--pubwave-block-padding-y)",blockMarginY:"var(--pubwave-block-margin-y)",toolbarGap:"var(--pubwave-toolbar-gap)"},typography:{fontFamily:"var(--pubwave-font-family)",fontSizeBase:"var(--pubwave-font-size-base)",fontSizeSmall:"var(--pubwave-font-size-small)",lineHeightBase:"var(--pubwave-line-height-base)",lineHeightHeading:"var(--pubwave-line-height-heading)",fontWeightNormal:"var(--pubwave-font-weight-normal)",fontWeightMedium:"var(--pubwave-font-weight-medium)",fontWeightBold:"var(--pubwave-font-weight-bold)",fontWeightHeading:"var(--pubwave-font-weight-heading)"},borderRadius:{sm:"var(--pubwave-border-radius-sm)",md:"var(--pubwave-border-radius)",lg:"var(--pubwave-border-radius-large)"},shadow:{sm:"var(--pubwave-shadow-sm)",md:"var(--pubwave-shadow-md)",toolbar:"var(--pubwave-shadow-toolbar)",popup:"var(--pubwave-shadow-popup)"},transition:{fast:"var(--pubwave-transition-fast)",normal:"var(--pubwave-transition-normal)"},zIndex:{dragPreview:100,dragHandle:40,toolbar:50,dropdown:60}},vl=`
22
22
  :root {
23
23
  /* Colors - Light theme */
24
24
  --pubwave-color-background: #ffffff;
@@ -100,4 +100,4 @@
100
100
  --pubwave-color-error: #f87171;
101
101
  }
102
102
  }
103
- `,ll=sl;function Ve(...e){return e.filter(Boolean).join(" ")}const Mt={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"};function xo(e,t,n){var a;const o=e??(t||n?Jt(t,n):Xn),r=((a=n==null?void 0:n.slashMenu)==null?void 0:a.groups)||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"};return ne.Extension.create({name:"slashCommands",addOptions(){return{suggestion:{char:"/",command:({editor:s,range:l,props:c})=>{if(c.id==="taskList"){s.chain().focus().deleteRange(l).toggleTaskList().run();return}s.chain().focus().deleteRange(l).run(),c.action(s)}}}},addProseMirrorPlugins(){const s=this.editor;return[Ar({editor:this.editor,...this.options.suggestion,allowed:({state:l,range:c})=>{try{if(s.isActive("codeBlock"))return!1;const f=l.doc.resolve(c.from);for(let u=f.depth;u>=1;u--)if(f.node(u).type.name==="codeBlock")return!1;return!0}catch{return!0}},items:({query:l,state:c})=>{let f=o;try{const u=c.doc.resolve(c.selection.from);for(let m=u.depth;m>=0;m--)if(u.node(m).type.name==="layoutColumn"){f=o.filter(v=>v.group!=="layout");break}}catch{}return Ai(f,l)},render:()=>{let l,c;return{onStart:f=>{this.editor.isActive("codeBlock")||(l=new Ae.ReactRenderer(yo,{props:{...f,query:f.query,editor:this.editor,groupLabels:r},editor:this.editor}),f.clientRect&&(c=Ie("body",{getReferenceClientRect:f.clientRect,appendTo:()=>document.body,content:l.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",offset:[0,8],zIndex:z.zIndex.dropdown,arrow:!1,duration:[0,0],animation:!1,popperOptions:{modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:8,altAxis:!0}},{name:"flip",options:{fallbackPlacements:["top-start","bottom-end","top"]}}]},onShow(u){const m=u.popper.querySelector(".tippy-box");m&&(m.style.zIndex=String(z.zIndex.dropdown),m.style.backgroundColor="transparent",m.style.background="transparent",m.style.border="none");const h=u.popper.querySelector(".pubwave-slash-menu");if(h){const v=document.querySelector(".ProseMirror");if(v){const p=h.getBoundingClientRect(),C=v.getBoundingClientRect().bottom-p.top-16,y=Math.max(200,Math.min(280,C));h.style.maxHeight=`${y}px`}}}})))},onUpdate(f){var u,m,h;if(l.updateProps({...f,query:f.query,editor:f.editor,groupLabels:r}),f.items.length===0){if(c[0]){c[0].hide();const v=c[0].popper.querySelector(".tippy-box");v&&(v.style.opacity="0",v.style.pointerEvents="none")}return}f.clientRect&&((u=c[0])==null||u.setProps({getReferenceClientRect:f.clientRect}),(m=c[0])!=null&&m.state.isVisible||(h=c[0])==null||h.show())},onKeyDown(f){var u,m;return f.event.key==="Escape"?((u=c[0])==null||u.hide(),!0):((m=l.ref)==null?void 0:m.onKeyDown(f))??!1},onExit(){var f;(f=c[0])==null||f.destroy(),l.destroy()}}}})]}})}const yo=x.forwardRef(function({items:t,command:n,query:o="",groupLabels:r},a){const[s,l]=x.useState(-1),c=x.useRef(null),f=x.useRef(null);x.useEffect(()=>{t.length>0&&o.length>0?l(0):(t.length,l(-1))},[t,o]),Za(s,c,f);const u=x.useMemo(()=>{const p={};for(const g of t){const C=p[g.group]??[];C.push(g),p[g.group]=C}return p},[t]),m=t,h=x.useCallback(p=>{const g=m[p];g&&n(g)},[m,n]);x.useImperativeHandle(a,()=>({onKeyDown:({event:p})=>m.length===0?!1:p.key==="ArrowUp"?(l(g=>g<0?m.length-1:g<=0?0:g-1),!0):p.key==="ArrowDown"?(l(g=>g<0?0:g>=m.length-1?m.length-1:g+1),!0):p.key==="Enter"&&s>=0&&s<m.length?(h(s),!0):!1}));const v=r||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced"};return t.length===0?null:i.jsx("div",{className:"pubwave-slash-menu",ref:c,style:Qa,"data-testid":"slash-menu",children:i.jsx("div",{style:{padding:"var(--pubwave-spacing-1, 4px) 0"},children:(()=>{let p=0;return["basic","list","media","advanced"].map(C=>{const y=u[C];return!y||y.length===0?null:i.jsxs("div",{className:"pubwave-slash-menu__group",style:ei,children:[i.jsx("div",{className:"pubwave-slash-menu__group-label",style:ti,children:v[C]||C}),y.map(S=>{const T=p++,d=T===s;return i.jsxs("button",{ref:d?f:null,className:`pubwave-slash-menu__item ${d?"pubwave-slash-menu__item--selected":""}`,style:{...ni,backgroundColor:d?"var(--pubwave-hover-bg, #f3f4f6)":"transparent"},onClick:()=>h(T),onMouseEnter:()=>l(T),children:[i.jsx("span",{className:"pubwave-slash-menu__item-icon",style:oi,children:S.icon}),i.jsx("span",{className:"pubwave-slash-menu__item-title",style:ri,children:S.title})]},S.id)})]},C)})})()})})}),X=new je.PluginKey("pubwave-dnd"),Rt={draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null,cancelled:!1};function qe(e,t){switch(t.type){case"START_DRAG":return{...e,draggingBlockId:t.blockId,draggingBlockPos:t.pos,dropTargetPos:null,dropPosition:null,cancelled:!1};case"UPDATE_DROP_TARGET":return{...e,dropTargetPos:t.pos,dropPosition:t.position};case"CANCEL_DRAG":return{...e,cancelled:!0,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"COMPLETE_DRAG":return{...e,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"RESET":return Rt;default:return e}}function bt(e,t){const n=Math.max(0,Math.min(t,e.content.size));try{const o=e.resolve(n);if(o.depth>=1){const r=o.node(1);if(["taskList","bulletList","orderedList","blockquote","table"].includes(r.type.name))return{node:r,pos:o.before(1)}}for(let r=o.depth;r>0;r--){const a=o.node(r);if(a.isBlock)return{node:a,pos:o.before(r)}}if(o.depth===0&&e.childCount>0){let r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r+s.nodeSize>n)return{node:s,pos:r};r+=s.nodeSize}return{node:e.lastChild,pos:e.content.size-e.lastChild.nodeSize}}return null}catch{let o=null,r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r<=n&&r+s.nodeSize>n){o={node:s,pos:r};break}r+=s.nodeSize}return o}}function wo(e,t,n,o){const{state:r}=e,{tr:a,doc:s}=r,l=bt(s,t);if(!l)return!1;const c=bt(s,n);if(!c)return!1;let f=c.pos;if(o==="after"&&(f=c.pos+c.node.nodeSize),l.pos===c.pos||f===l.pos||f===l.pos+l.node.nodeSize)return!1;const u=l.node,m=l.pos,h=l.pos+u.nodeSize,v=s.slice(m,h);let p=f;m<f&&(p=f-u.nodeSize),a.delete(m,h);const g=a.doc.content.size;if(p<0?p=0:p>g&&(p=g),p>=0&&p<=g)a.insert(p,v.content);else return!1;return a.setSelection(r.selection.map(a.doc,a.mapping)),e.view.dispatch(a),!0}function Rn(e,t){const n=e.state.doc;if(n.childCount===0)return null;const o=0,r=e.nodeDOM(o);let a=0;for(let f=0;f<n.childCount-1;f++)a+=n.child(f).nodeSize;const s=e.nodeDOM(a),l=t.clientY;if(r){const f=r.getBoundingClientRect();if(l<f.top+50)return{pos:o,position:"before"}}if(s){const f=s.getBoundingClientRect();if(l>f.bottom-50)return{pos:a,position:"after"}}const c=e.posAtCoords({left:t.clientX,top:t.clientY});if(c){const f=bt(n,c.pos);if(f){const u=e.nodeDOM(f.pos);if(u){const m=u.getBoundingClientRect(),h=m.top+m.height/2;return{pos:f.pos,position:l<h?"before":"after"}}}}return null}function ko(e){let t=Rt;return new je.Plugin({key:X,state:{init(){return Rt},apply(n,o){const r=n.getMeta(X);return r!==void 0?(t=r,r):(t=o,o)}},props:{handleKeyDown(n,o){return o.key==="Escape"&&t.draggingBlockId?(t=qe(t,{type:"CANCEL_DRAG"}),n.dispatch(n.state.tr.setMeta(X,t)),!0):!1},handleDOMEvents:{dragover(n,o){var s;if(!((s=o.dataTransfer)!=null&&s.types.includes("application/x-pubwave-block")))return!1;o.preventDefault(),o.dataTransfer.dropEffect="move",t=X.getState(n.state)??t;const a=Rn(n,o);return a?(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:a.pos,position:a.position}),n.dispatch(n.state.tr.setMeta(X,t))):t.dropTargetPos!==null&&(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(X,t))),!0},drop(n,o){var h;const r=(h=o.dataTransfer)==null?void 0:h.getData("application/x-pubwave-block");if(!r)return!1;o.preventDefault(),o.stopPropagation();let l=(X.getState(n.state)??t).draggingBlockPos;if(l===null&&r.startsWith("block-")){const v=parseInt(r.replace("block-",""),10);isNaN(v)||(l=v)}if(l===null)return!1;const c=Rn(n,o);if(!c)return!1;const{pos:f,position:u}=c;if(f===l||!e)return!1;const m=wo(e,l,f,u);return t=qe(t,{type:"COMPLETE_DRAG"}),n.dispatch(n.state.tr.setMeta(X,t)),m},dragleave(n,o){const r=o.relatedTarget;return r!=null&&r.closest(".pubwave-editor")||(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(X,t))),!1}}}})}function sn(e){return X.getState(e.state)??Rt}function Co(e,t,n){const{view:o}=e,r={type:"START_DRAG",blockId:t,pos:n},a=qe(sn(e),r);o.dispatch(o.state.tr.setMeta(X,a))}function cl(e){const{view:t}=e,n={type:"CANCEL_DRAG"},o=qe(sn(e),n);t.dispatch(t.state.tr.setMeta(X,o))}const ul=new je.PluginKey("editorBehaviors");function dl(e,t){const n=e.dom,o=n.getBoundingClientRect();if(t.clientX<o.left||t.clientX>o.right||t.clientY<o.top||t.clientY>o.bottom)return!1;const r=n.lastElementChild;if(!r)return!0;const a=r.getBoundingClientRect();return t.clientY>a.bottom+1}function pl(e,t){if(t.button!==0||t.defaultPrevented||!dl(e,t))return!1;const{state:n}=e,o=n.schema.nodes.paragraph;if(!o)return!1;const r=n.doc.content.size,a=n.doc.lastChild,s=n.tr;return a&&a.type===o&&a.content.size===0?(s.setSelection(je.TextSelection.create(n.doc,Math.max(1,r-1))),e.dispatch(s),e.focus(),!0):(s.insert(r,o.create()),s.setSelection(je.TextSelection.create(s.doc,r+1)),e.dispatch(s.scrollIntoView()),e.focus(),!0)}function fl(e,t){if(t.key!=="Enter"||t.defaultPrevented)return!1;const{state:n}=e,{selection:o}=n;if(!o.empty)return!1;const{$from:r}=o,a=n.schema.nodes.paragraph;if(!a||r.parent.type!==a||r.parent.content.size!==0)return!1;let s=-1,l=-1;for(let y=r.depth;y>0;y--){const S=r.node(y);S.type.name==="layoutColumn"&&s===-1&&(s=y),S.type.name==="layout"&&l===-1&&(l=y)}if(s===-1||l===-1)return!1;const c=r.node(s);if(r.index(s)!==c.childCount-1)return!1;t.preventDefault();const u=n.tr,m=r.before(r.depth),h=r.parent.nodeSize;c.childCount>1&&u.delete(m,m+h);const v=r.before(l),p=u.mapping.map(v),g=u.doc.nodeAt(p);if(!g)return!1;const C=p+g.nodeSize;return u.insert(C,a.create()),u.setSelection(je.TextSelection.create(u.doc,C+1)),e.dispatch(u.scrollIntoView()),e.focus(),!0}function hl(){return new je.Plugin({key:ul,props:{handleClick(e,t,n){return n instanceof MouseEvent?pl(e,n):!1},handleKeyDown(e,t){return fl(e,t)}}})}const bl=["paragraph","heading","bulletList","orderedList","taskList","table","blockquote","codeBlock","horizontalRule","image","chart","layout"],vl=["bold","italic","underline","strike","code","link"];function ln(e={}){const{placeholder:t,historyDepth:n=100,headingLevels:o,linkOpenInNewTab:r,linkOpenOnClick:a,enableChart:s,enableLayout:l,enableSlashCommands:c=!0,slashCommands:f,imageUpload:u,locale:m}=e,h=m?jt(m):null,v=t??(h==null?void 0:h.placeholder)??'Write,type "/" for commands...',p=[...Ya({headingLevels:o,imageUpload:u,enableChart:s,enableLayout:l}),...Ja({linkOpenInNewTab:r,linkOpenOnClick:a}),Zo.configure({placeholder:v,emptyEditorClass:"pubwave-editor--empty",emptyNodeClass:"pubwave-editor__node--empty"}),Qo.configure({depth:n}),er.configure({color:"var(--pubwave-dropcursor-color, #3b82f6)",width:2}),tr,ne.Extension.create({name:"dragAndDrop",addProseMirrorPlugins(){return[ko(this.editor)]}}),ne.Extension.create({name:"editorBehaviors",addProseMirrorPlugins(){return[hl()]}})];if(c){const g=jt(m||"en"),C=Jt(u,g);let y=f?[...C,...f]:C;l===!1&&(y=y.filter(S=>S.group!=="layout")),p.push(xo(y,u,g))}return p}function gl(e={}){if(!Ot)throw new Error("createEditor() cannot be called server-side. Ensure this function is only called in client-side code (e.g., useEffect, event handlers).");const{content:t,editable:n=!0,placeholder:o,autofocus:r=!1,imageUpload:a,enableChart:s,enableLayout:l,onUpdate:c,onSelectionUpdate:f,onFocus:u,onBlur:m,onCreate:h,onDestroy:v}=e,g={extensions:ln({placeholder:o,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:a,enableChart:s,enableLayout:l}),content:t,editable:n,autofocus:r,editorProps:{attributes:{class:"pubwave-editor__content","data-placeholder":o??'Write,type "/" for commands...'}},onUpdate:c?({editor:C})=>{c({editor:C})}:void 0,onSelectionUpdate:f?({editor:C})=>{f({editor:C})}:void 0,onFocus:u?({editor:C})=>{u({editor:C})}:void 0,onBlur:m?({editor:C})=>{m({editor:C})}:void 0,onCreate:h?({editor:C})=>{h({editor:C})}:void 0,onDestroy:v?()=>{v()}:void 0};return new ne.Editor(g)}function ml(e){e&&!e.isDestroyed&&e.destroy()}function xl(e){return e!==null&&!e.isDestroyed}function cn(e){const{state:t}=e,{selection:n}=t,{from:o,to:r,empty:a}=n,s=a?"":t.doc.textBetween(o,r," "),l=n instanceof Object&&"node"in n,c=s.length>0,f=e.isActive("bold"),u=e.isActive("italic"),m=e.isActive("underline"),h=e.isActive("strike"),v=e.isActive("code"),p=e.isActive("link"),g=p?e.getAttributes("link").href:null;return{hasSelection:!a||l,isEmpty:a&&!l,hasTextContent:c,isNodeSelection:l,selectedText:s,from:o,to:r,isBold:f,isItalic:u,isUnderline:m,isStrike:h,isCode:v,hasLink:p,linkHref:g}}function yl(e){return e.state.selection.empty}function Pt(e){const t=cn(e);return t.isEmpty?!1:!!t.hasTextContent}function wl(e){if(typeof window>"u")return null;const{view:t}=e,{from:n,to:o}=t.state.selection;if(n===o)return null;const r=t.coordsAtPos(n),a=t.coordsAtPos(o),s=Math.min(r.top,a.top),l=Math.max(r.bottom,a.bottom),c=Math.min(r.left,a.left),f=Math.max(r.right,a.right);return{top:s,left:c,right:f,bottom:l,width:f-c,height:l-s}}function kl(e){return e.chain().focus().toggleBold().run()}function Cl(e){return e.chain().focus().toggleItalic().run()}function Tl(e,t){return t?e.chain().focus().setLink({href:t}).run():e.chain().focus().unsetLink().run()}function Ll(e){return e.chain().focus().unsetLink().run()}function Bl(e){return e.chain().focus().setParagraph().run()}function Al(e,t){return e.chain().focus().setHeading({level:t}).run()}function jl(e,t){return e.chain().focus().toggleHeading({level:t}).run()}function Sl(e){return e.chain().focus().undo().run()}function Ml(e){return e.chain().focus().redo().run()}function Pl(e,t){return e.chain().focus(t).run()}function Dl(e){return e.chain().focus().selectAll().run()}function Il(e){return e.chain().focus().unsetAllMarks().run()}function Rl(e,t){return e.isActive(t)}function El(e,t,n){return e.isActive(t,n)}function Ol(e){const t=[];return e.isActive("bold")&&t.push("bold"),e.isActive("italic")&&t.push("italic"),e.isActive("link")&&t.push("link"),t}function _l(e){return e.getAttributes("link").href??null}function To(e){return e?!e.isEditable:!0}function xt(e){return e?e.isEditable:!1}function Nl(e){return xt(e)}function Hl(e){return xt(e)}function $l(e){return xt(e)}function zl(e){return xt(e)}function ql(e){return To(e)?"pubwave-editor--readonly":""}const Et={editor:"Rich text editor",toolbar:"Text formatting toolbar",dragHandle:"Drag to reorder block"},at={bold:"Cmd+B",italic:"Cmd+I",underline:"Cmd+U",strike:"Cmd+Shift+X",code:"Cmd+E"};function Pe(e,t){return t?`${e} (${t})`:e}const Be=x.forwardRef(({active:e=!1,disabled:t=!1,onClick:n,"data-tooltip":o,"data-testid":r,"aria-label":a,children:s,style:l},c)=>i.jsx("button",{ref:c,type:"button",className:Ve("pubwave-toolbar__button",e&&"pubwave-toolbar__button--active",t&&"pubwave-toolbar__button--disabled"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:(l==null?void 0:l.width)??"var(--pubwave-button-width, 28px)",height:(l==null?void 0:l.height)??"var(--pubwave-button-height, 28px)",minWidth:l==null?void 0:l.minWidth,padding:(l==null?void 0:l.padding)??0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:e?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"color 0.1s ease, background-color 0.1s ease",...l},onClick:f=>{f.preventDefault(),f.stopPropagation(),n()},disabled:t,"data-tooltip":o,"data-testid":r,"aria-label":a,"aria-pressed":e,onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},children:s}));Be.displayName="ToolbarButton";function En(){return i.jsx("div",{className:"pubwave-toolbar__divider",style:{width:"var(--pubwave-divider-width, 1px)",height:"var(--pubwave-divider-height, 20px)",backgroundColor:"var(--pubwave-border)",margin:"0 var(--pubwave-spacing-1, 4px)"},role:"separator","aria-orientation":"vertical"})}function Lo(e,t,n,o=8){const r=e,a=window.innerHeight-t,s=n+o;return r>=s?"top":a>=s?"bottom":r>=a?"top":"bottom"}function Ul(e,t,n=8){return Lo(e.top,e.bottom,t,n)}function Bo(e,t,n,o="left",r=8){const a=window.innerWidth,s=(e+t)/2,l=e,c=a-t,f=n+r,u=n+r,m=n/2+r;let h=o,v;return o==="left"?(v=e,(v<r||v+n>a-r)&&(c>=u&&t+n<=a-r?(h="right",v=t-n):l>=m&&s-n/2>=r?(h="center",v=s-n/2):(c>=l?(h="right",v=t-n):(h="left",v=e),v=Math.max(r,Math.min(v,a-n-r))))):o==="center"?(v=s-n/2,(v<r||v+n>a-r)&&(c>=u&&t+n<=a-r?(h="right",v=t-n):l>=f&&e+n<=a-r?(h="left",v=e):(c>=l?(h="right",v=t-n):(h="left",v=e),v=Math.max(r,Math.min(v,a-n-r))))):(v=t-n,(v<r||v+n>a-r)&&(l>=f&&e+n<=a-r?(h="left",v=e):l>=m&&s-n/2>=r?(h="center",v=s-n/2):(l>=c?(h="left",v=e):(h="right",v=t-n),v=Math.max(r,Math.min(v,a-n-r))))),v=Math.max(r,Math.min(v,a-n-r)),{align:h,left:v}}function Fl(e,t,n="left",o=8){return Bo(e.left,e.right,t,n,o)}function un({isOpen:e,buttonRef:t,children:n,className:o,style:r,align:a="left",margin:s=8,onClickOutside:l,onClick:c,"data-testid":f}){const[u,m]=x.useState("top"),[h,v]=x.useState(null),p=x.useRef(null);if(x.useEffect(()=>{if(!e||!t.current)return;const C=()=>{if(!p.current||!t.current)return;const S=t.current.getBoundingClientRect(),T=p.current.offsetHeight||300,d=p.current.offsetWidth||240,A=Ul(S,T,s);m(A);let k=t.current.parentElement;for(;k;){const I=window.getComputedStyle(k);if(I.position==="relative"||I.position==="absolute"||I.position==="fixed")break;k=k.parentElement}const j=Fl(S,d,a,s);if(k){const I=k.getBoundingClientRect(),N=j.left-I.left;v({align:j.align,left:N})}else v(j)};C();const y=requestAnimationFrame(()=>{C()});return()=>cancelAnimationFrame(y)},[e,t,s,a]),x.useEffect(()=>{if(!e||!l)return;const C=y=>{p.current&&!p.current.contains(y.target)&&t.current&&!t.current.contains(y.target)&&l(y)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[e,l,t]),!e)return null;const g=()=>{if(h)return{left:`${h.left}px`};switch(a){case"center":return{left:"50%",transform:"translateX(-50%)"};case"right":return{right:0};case"left":default:return{left:0}}};return i.jsx("div",{ref:p,className:o,"data-testid":f,style:{position:"absolute",...u==="top"?{bottom:"100%",marginBottom:`${s}px`}:{top:"100%",marginTop:`${s}px`},...g(),...r},onClick:C=>{C.stopPropagation(),c==null||c(C)},children:n})}function Wl({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=We(),a=x.useRef(null),s=x.useCallback(()=>e.isActive("heading",{level:1})?"heading1":e.isActive("heading",{level:2})?"heading2":e.isActive("heading",{level:3})?"heading3":e.isActive("bulletList")?"bulletList":e.isActive("orderedList")?"orderedList":e.isActive("taskList")?"taskList":e.isActive("blockquote")?"blockquote":e.isActive("codeBlock")?"codeBlock":"paragraph",[e]),l=x.useMemo(()=>[{id:"paragraph",label:r.toolbar.blockTypes.text,icon:i.jsx(Fn,{}),action:h=>h.chain().focus().setParagraph().run(),isActive:h=>h.isActive("paragraph")},{id:"heading1",label:r.toolbar.blockTypes.heading1,icon:i.jsx(Wn,{}),action:h=>h.chain().focus().setHeading({level:1}).run(),isActive:h=>h.isActive("heading",{level:1})},{id:"heading2",label:r.toolbar.blockTypes.heading2,icon:i.jsx(Vn,{}),action:h=>h.chain().focus().setHeading({level:2}).run(),isActive:h=>h.isActive("heading",{level:2})},{id:"heading3",label:r.toolbar.blockTypes.heading3,icon:i.jsx(Gn,{}),action:h=>h.chain().focus().setHeading({level:3}).run(),isActive:h=>h.isActive("heading",{level:3})},{id:"bulletList",label:r.toolbar.blockTypes.bulletedList,icon:i.jsx(Yn,{}),action:h=>h.chain().focus().toggleBulletList().run(),isActive:h=>h.isActive("bulletList")},{id:"orderedList",label:r.toolbar.blockTypes.numberedList,icon:i.jsx(Kn,{}),action:h=>h.chain().focus().toggleOrderedList().run(),isActive:h=>h.isActive("orderedList")}],[r]),c=s(),f=l.find(h=>h.id===c),u=x.useCallback(h=>{h.action(e),o(),setTimeout(()=>{e.chain().blur().run()},0)},[e,o]),m=h=>h===r.toolbar.blockTypes.heading1?r.toolbar.blockTypes.heading1:h===r.toolbar.blockTypes.heading2?r.toolbar.blockTypes.heading2:h===r.toolbar.blockTypes.heading3?r.toolbar.blockTypes.heading3:h===r.toolbar.blockTypes.bulletedList?r.toolbar.blockTypes.bulletedList:h===r.toolbar.blockTypes.numberedList?r.toolbar.blockTypes.numberedList:r.toolbar.blockTypes.text;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Be,{ref:a,active:t,onClick:n,"data-tooltip":Pe(r.toolbar.turnInto),"data-testid":"toolbar-turnInto","aria-label":r.aria.turnIntoButton,style:{width:"auto",minWidth:"auto",padding:"0 8px",height:"var(--pubwave-button-height, 28px)"},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:f?m(f.label):r.toolbar.blockTypes.text}),i.jsx(ii,{})]})}),i.jsxs(un,{isOpen:t,buttonRef:a,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-turn-into-dropdown","data-testid":"turn-into-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-1, 4px)",minWidth:"240px",zIndex:z.zIndex.dropdown+1},children:[i.jsx("div",{style:Mt,children:r.toolbar.turnInto}),l.map(h=>{const v=h.isActive(e);return i.jsxs("button",{type:"button",className:Ve("pubwave-toolbar__turn-into-option",v&&"pubwave-toolbar__turn-into-option--active"),onClick:()=>u(h),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-2, 8px)",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",backgroundColor:v?"var(--pubwave-primary-faded)":"transparent",color:v?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:"pointer",fontSize:"var(--pubwave-font-size-base, 14px)",textAlign:"left",borderRadius:"var(--pubwave-border-radius-sm, 0.25rem)",transition:"background-color 0.1s ease"},children:[i.jsx("span",{style:{display:"flex",alignItems:"center",width:"18px",height:"18px",flexShrink:0},children:h.icon}),i.jsx("span",{children:h.label})]},h.id)})]})]})}function xe(e){return!!(e&&!e.isDestroyed)}function Vl(e,t){xe(e)&&Y(()=>{if(xe(e))switch(t){case"start":e.commands.focus("start");break;case"end":e.commands.focus("end");break;case"preserve":e.commands.focus();break;default:typeof t=="number"&&(e.commands.setTextSelection(t),e.commands.focus())}})}function Re(e){xe(e)&&Y(()=>{xe(e)&&(e.isFocused||e.commands.focus())})}function Gl(e,t){xe(e)&&(t.preventDefault(),Y(()=>{xe(e)&&e.commands.focus()}))}function Yl(e){if(!xe(e))return function(){};const t=o=>{const r=o.relatedTarget;if(r){const a=e.view.dom.closest(".pubwave-editor");a&&!a.contains(r)&&r.closest(".pubwave-toolbar, .pubwave-menu, .pubwave-dialog")}},n=e.view.dom;return n.addEventListener("focusout",t),()=>{n.removeEventListener("focusout",t)}}function Ao(e){if(!xe(e))return null;const{from:t,to:n,empty:o}=e.state.selection;return{from:t,to:n,empty:o}}function st(e,t){if(!xe(e)||!t)return;const{from:n,to:o}=t,r=e.state.doc.content.size,a=Math.min(n,r),s=Math.min(o,r);e.commands.setTextSelection({from:a,to:s})}function Kl(e){if(!xe(e))return;const{selection:t}=e.state;if(t.$anchor.pos>0){e.commands.focus();return}e.commands.focus("end")}function Xl(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1],r=a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),o==null||o.focus()):document.activeElement===o&&(a.preventDefault(),n==null||n.focus()))};return{activate(){e.addEventListener("keydown",r),n==null||n.focus()},deactivate(){e.removeEventListener("keydown",r)}}}function Jl({editor:e,isOpen:t,onToggle:n,onClose:o,selectionState:r}){const a=We(),s=x.useRef(null),l=x.useRef(null),c=x.useRef(null),f=x.useRef([]),u=x.useRef(null),[m,h]=x.useState(""),v=(r==null?void 0:r.hasLink)??!1,p=(r==null?void 0:r.linkHref)??null;x.useEffect(()=>{t?(u.current=Ao(e),h(p||""),setTimeout(()=>{var T,d;(T=l.current)==null||T.focus(),(d=l.current)==null||d.select()},50)):u.current=null},[t,p,e]),x.useEffect(()=>{if(!vt()){if(!t){f.current.forEach(T=>T.destroy()),f.current=[];return}return f.current.forEach(T=>T.destroy()),f.current=[],Y(()=>{Y(()=>{if(!c.current)return;c.current.querySelectorAll("[data-tooltip]").forEach(d=>{const A=d.getAttribute("data-tooltip");if(A){const k=Ie(d,{content:A,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});f.current.push(k)}})})}),()=>{f.current.forEach(T=>T.destroy()),f.current=[]}}},[t,a,m,p]);const g=x.useCallback(T=>{if(T==null||T.preventDefault(),!m.trim()){u.current&&st(e,u.current),e.chain().focus().unsetLink().run(),u.current&&Y(()=>{Y(()=>{st(e,u.current)})}),o();return}let d=m.trim();!/^https?:\/\//i.test(d)&&!d.startsWith("/")&&!d.startsWith("#")&&(d=`https://${d}`),u.current&&st(e,u.current),e.chain().focus().setLink({href:d}).run(),u.current&&Y(()=>{Y(()=>{st(e,u.current)})}),o()},[e,m,o]),C=x.useCallback(()=>{const T=m.trim()||p;if(T){let d=T;!/^https?:\/\//i.test(d)&&!d.startsWith("/")&&!d.startsWith("#")&&(d=`https://${d}`),window.open(d,"_blank","noopener,noreferrer")}},[m,p]),y=x.useCallback(()=>{var T;h(""),(T=l.current)==null||T.focus()},[]),S=x.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),g()):T.key==="Escape"&&(T.preventDefault(),o(),e.chain().focus().run())},[g,o,e]);return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Be,{ref:s,active:v,onClick:n,"data-tooltip":Pe(a.toolbar.link),"data-testid":"toolbar-link","aria-label":a.aria.linkButton,children:i.jsx(pi,{})}),i.jsx(un,{isOpen:t,buttonRef:s,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-link-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-2, 8px)",minWidth:"280px",zIndex:z.zIndex.dropdown+1},children:i.jsx("div",{ref:c,children:i.jsx("form",{onSubmit:g,style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[i.jsx("input",{ref:l,type:"text",value:m,onChange:T=>h(T.target.value),onKeyDown:S,placeholder:a.linkPlaceholder,"data-testid":"link-input","aria-label":a.aria.linkUrlInput,style:{flex:1,padding:"6px 100px 6px 8px",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-sm, 4px)",fontSize:"var(--pubwave-font-size-base, 14px)",backgroundColor:"var(--pubwave-bg)",color:"var(--pubwave-text)",outline:"none"}}),i.jsxs("div",{style:{position:"absolute",right:"4px",display:"flex",alignItems:"center",gap:"2px"},children:[i.jsx("button",{type:"button",onClick:g,"data-tooltip":a.toolbar.confirmLink,"data-testid":"link-confirm-button","aria-label":a.aria.linkConfirmButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},children:i.jsx(hi,{})}),(m.trim()||p)&&i.jsx("button",{type:"button",onClick:C,"data-tooltip":a.toolbar.openLink,"data-testid":"link-open-button","aria-label":a.aria.linkOpenButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},children:i.jsx(fi,{})}),i.jsx("button",{type:"button",onClick:y,"data-tooltip":a.toolbar.clearLink,"data-testid":"link-clear-button","aria-label":a.aria.linkClearButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},children:i.jsx(bi,{})})]})]})})})})]})}const Zl=[{name:"Default",value:null,color:"#1f2937"},{name:"Gray",value:"#6b7280",color:"#6b7280"},{name:"Brown",value:"#92400e",color:"#92400e"},{name:"Orange",value:"#ea580c",color:"#ea580c"},{name:"Orange Dark",value:"#c2410c",color:"#c2410c"},{name:"Green",value:"#16a34a",color:"#16a34a"},{name:"Blue",value:"#2563eb",color:"#2563eb"},{name:"Purple",value:"#9333ea",color:"#9333ea"},{name:"Pink",value:"#ec4899",color:"#ec4899"},{name:"Red",value:"#dc2626",color:"#dc2626"}],Ql=[{name:"Default",value:null,color:"#ffffff"},{name:"Gray",value:"#f3f4f6",color:"#f3f4f6"},{name:"Peach",value:"#fed7aa",color:"#fed7aa"},{name:"Orange",value:"#fdba74",color:"#fdba74"},{name:"Yellow",value:"#fde047",color:"#fde047"},{name:"Green",value:"#86efac",color:"#86efac"},{name:"Blue",value:"#93c5fd",color:"#93c5fd"},{name:"Purple",value:"#c084fc",color:"#c084fc"},{name:"Pink",value:"#f9a8d4",color:"#f9a8d4"},{name:"Red",value:"#fca5a5",color:"#fca5a5"}],jo="pubwave-editor-recent-colors",On=5;function ec(){if(typeof window>"u")return[];try{const e=localStorage.getItem(jo);if(e)return JSON.parse(e)}catch{}return[]}function _n(e){if(!(typeof window>"u"))try{localStorage.setItem(jo,JSON.stringify(e))}catch{}}function tc({editor:e,onClose:t,buttonRef:n}){const o=We(),[r,a]=x.useState([]),s=x.useRef(null),l=x.useRef([]);x.useEffect(()=>{const p=ec();p.length>0&&a(p)},[]);const c=()=>{try{const p=e.getAttributes("textColor");return(p==null?void 0:p.color)||null}catch{return null}},f=()=>{try{const p=e.getAttributes("backgroundColor");return(p==null?void 0:p.backgroundColor)||null}catch{return null}},u=c(),m=f(),h=p=>{p===null?e.chain().focus().unsetColor().run():(e.chain().focus().setColor(p).run(),a(g=>{const y=[{type:"text",value:p},...g.filter(S=>!(S.type==="text"&&S.value===p))].slice(0,On);return _n(y),y}))},v=p=>{p===null?e.chain().focus().unsetBackgroundColor().run():(e.chain().focus().setBackgroundColor(p).run(),a(g=>{const y=[{type:"background",value:p},...g.filter(S=>!(S.type==="background"&&S.value===p))].slice(0,On);return _n(y),y}))};return x.useEffect(()=>{if(!vt()&&s.current)return l.current.forEach(p=>p.destroy()),l.current=[],requestAnimationFrame(()=>{if(!s.current)return;s.current.querySelectorAll("[data-tooltip]").forEach(g=>{const C=g.getAttribute("data-tooltip");if(C){const y=Ie(g,{content:C,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});l.current.push(y)}})}),()=>{l.current.forEach(p=>p.destroy()),l.current=[]}},[r,u,m,o]),i.jsx(un,{isOpen:!0,buttonRef:n,align:"center",margin:8,onClickOutside:()=>t==null?void 0:t(),className:"pubwave-color-picker","data-testid":"color-picker",style:{backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1))",padding:"12px",minWidth:"240px",zIndex:z.zIndex.dropdown+1},children:i.jsxs("div",{ref:s,children:[r.length>0&&i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...Mt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.recentlyUsed}),i.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:r.map((p,g)=>i.jsx("button",{type:"button",onClick:()=>{p.type==="text"?h(p.value):v(p.value)},style:{width:"24px",height:"24px",borderRadius:"4px",border:"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:p.type==="background"?p.value:"#ffffff",cursor:"pointer",padding:p.type==="text"?"4px":0,display:p.type==="text"?"flex":"block",alignItems:p.type==="text"?"center":"normal",justifyContent:p.type==="text"?"center":"normal"},"data-tooltip":p.type==="text"?`${p.value} text`:`${p.value} background`,children:p.type==="text"&&i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:p.value,lineHeight:1},children:"A"})},`${p.type}-${p.value}-${g}`))})]}),i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...Mt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.textColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Zl.map(p=>{const g=u===p.value;return i.jsx("button",{type:"button",onClick:()=>h(p.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:"#ffffff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center"},"data-tooltip":p.value?`${p.name} text`:"Default text",children:i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:p.color},children:"A"})},p.name)})})]}),i.jsxs("div",{children:[i.jsx("div",{style:{...Mt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.backgroundColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Ql.map(p=>{const g=m===p.value;return i.jsx("button",{type:"button",onClick:()=>v(p.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:p.color,cursor:"pointer",padding:0},"data-tooltip":p.value?`${p.name} background`:"Default background"},p.name)})})]})]})})}function nc({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=We(),a=x.useRef(null),s=()=>{try{const p=e.getAttributes("textColor");return(p==null?void 0:p.color)||null}catch{return null}},l=()=>{try{if(!e.isActive("backgroundColor"))return null;const p=e.getAttributes("backgroundColor");return(p==null?void 0:p.backgroundColor)||null}catch{return null}},c=s(),f=l(),u=c||f,h=c||(()=>{if(typeof window>"u")return"#1f2937";const p=document.querySelector(".pubwave-editor");return p&&window.getComputedStyle(p).getPropertyValue("--pubwave-text").trim()||"#1f2937"})(),v=f;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Be,{ref:a,active:!!u,onClick:n,"data-tooltip":Pe(r.toolbar.textColor),"data-testid":"toolbar-colorPicker","aria-label":r.aria.colorPickerButton,children:i.jsx(vi,{textColor:h,backgroundColor:v})}),t&&i.jsx(tc,{editor:e,onClose:o,buttonRef:a})]})}function oc({editor:e,selectionState:t}){const n=We(),[o,r]=x.useState(null),a=x.useCallback(()=>{r(null),e.chain().focus().toggleBold().run()},[e]),s=x.useCallback(()=>{r(null),e.chain().focus().toggleItalic().run()},[e]),l=x.useCallback(()=>{r(null),e.chain().focus().toggleUnderline().run()},[e]),c=x.useCallback(()=>{r(null),e.chain().focus().toggleStrike().run()},[e]),f=x.useCallback(()=>{r(null),e.chain().focus().toggleCode().run()},[e]),u=x.useCallback(()=>{r(S=>S==="turnInto"?null:"turnInto")},[]),m=x.useCallback(()=>{r(S=>S==="link"?null:"link")},[]),h=x.useCallback(()=>{r(S=>S==="colorPicker"?null:"colorPicker")},[]),v=(t==null?void 0:t.isBold)??!1,p=(t==null?void 0:t.isItalic)??!1,g=(t==null?void 0:t.isUnderline)??!1,C=(t==null?void 0:t.isStrike)??!1,y=(t==null?void 0:t.isCode)??!1;return i.jsxs(i.Fragment,{children:[i.jsx(Wl,{editor:e,isOpen:o==="turnInto",onToggle:u,onClose:()=>r(null)}),i.jsx(En,{}),i.jsx(Be,{active:v,onClick:a,"data-tooltip":Pe(n.toolbar.bold,at.bold),"data-testid":"toolbar-bold","aria-label":n.aria.boldButton,children:i.jsx(si,{})}),i.jsx(Be,{active:p,onClick:s,"data-tooltip":Pe(n.toolbar.italic,at.italic),"data-testid":"toolbar-italic","aria-label":n.aria.italicButton,children:i.jsx(li,{})}),i.jsx(Be,{active:g,onClick:l,"data-tooltip":Pe(n.toolbar.underline,at.underline),"data-testid":"toolbar-underline","aria-label":n.aria.underlineButton,children:i.jsx(ci,{})}),i.jsx(Be,{active:C,onClick:c,"data-tooltip":Pe(n.toolbar.strike,at.strike),"data-testid":"toolbar-strike","aria-label":n.aria.strikeButton,children:i.jsx(ui,{})}),i.jsx(Be,{active:y,onClick:f,"data-tooltip":Pe(n.toolbar.code,at.code),"data-testid":"toolbar-code","aria-label":n.aria.codeButton,children:i.jsx(di,{})}),i.jsx(En,{}),i.jsx(Jl,{editor:e,isOpen:o==="link",onToggle:m,onClose:()=>r(null),selectionState:t}),i.jsx(nc,{editor:e,isOpen:o==="colorPicker",onToggle:h,onClose:()=>r(null)})]})}const it=8;function $e(e){return!e.isDestroyed}function rc(e,t){if(!t)return{top:0,left:0,visible:!1};const{view:n}=e,{from:o,to:r}=n.state.selection,a=n.coordsAtPos(o),s=n.coordsAtPos(r),l=Math.min(a.top,s.top),c=Math.min(a.left,s.left),f=Math.max(a.right,s.right),u=t.getBoundingClientRect(),m=u.width,h=u.height,v=Math.max(a.bottom,s.bottom),p=Lo(l,v,h,it);let g;p==="top"?g=l-h-it:g=v+it;const y=Bo(c,f,m,"center",it).left,S=window.innerWidth,T=window.innerHeight,d=it,A=Math.max(d,Math.min(y,S-m-d));return{top:Math.max(d,Math.min(g,T-h-d)),left:A,visible:!0}}function So({editor:e,className:t,children:n,onVisibilityChange:o}){const r=x.useRef(null),a=x.useRef(!1),s=x.useRef(0),l=x.useRef(!1),[c,f]=x.useState({top:0,left:0,visible:!1}),[u,m]=x.useState(null),[h,v]=x.useState(!1),p=x.useRef([]),g=x.useMemo(()=>!$e(e)||a.current||!h?!1:Pt(e),[e,u,h]),C=x.useCallback(()=>{if(!$e(e))return;const T=cn(e);m(T)},[e]),y=x.useCallback(()=>{if(!g||!r.current){f(T=>({...T,visible:!1}));return}Y(()=>{if(!$e(e))return;const T=rc(e,r.current);f(T)})},[e,g]);x.useEffect(()=>{if(!$e(e))return;const d=e.view.dom.closest(".pubwave-editor"),A=j=>{const I=j.target,N=r.current;if(N&&I&&N.contains(I)){a.current=!1;return}d&&I&&d.contains(I)?l.current=!0:l.current=!1,a.current=!0,v(!1)},k=j=>{const I=Date.now(),B=I-s.current<300;s.current=I;const _=j.target,b=r.current;if(b&&_&&b.contains(_)){a.current=!1;return}if(a.current=!1,!l.current){v(!1);return}setTimeout(()=>{$e(e)&&(Pt(e)?(C(),v(!0),Y(()=>{y()})):(v(!1),f(M=>({...M,visible:!1}))))},B?100:10)};return document.addEventListener("mousedown",A),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("mouseup",k)}},[e,C,y]),x.useEffect(()=>{if(!$e(e))return;C();const T=()=>{!a.current&&h&&C()},d=()=>{a.current||(C(),Pt(e)?v(!0):v(!1),Y(()=>{y()}))},A=()=>{setTimeout(()=>{const k=document.activeElement,j=r.current;j&&k&&j.contains(k)||(v(!1),T())},0)};return e.on("update",T),e.on("selectionUpdate",d),e.on("focus",d),e.on("blur",A),()=>{e.off("update",T),e.off("selectionUpdate",d),e.off("focus",d),e.off("blur",A)}},[e,C,y,h]),x.useEffect(()=>{y(),o==null||o(g)},[g,y,o]),x.useEffect(()=>{if(!g)return;const T=()=>{y()};return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[g,y]);const S=We();return x.useEffect(()=>{if(!vt()){if(!g||!c.visible||!r.current){p.current.forEach(T=>T.destroy()),p.current=[];return}return p.current.forEach(T=>T.destroy()),p.current=[],Y(()=>{if(!r.current)return;r.current.querySelectorAll("[data-tooltip]").forEach(d=>{const A=d.getAttribute("data-tooltip");if(A){const k=Ie(d,{content:A,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});p.current.push(k)}})}),()=>{p.current.forEach(T=>T.destroy()),p.current=[]}}},[g,c.visible,S]),$e(e)?i.jsx("div",{ref:r,className:Ve("pubwave-toolbar",g&&c.visible?"pubwave-toolbar--visible":"pubwave-toolbar--hidden",t),style:{position:"fixed",top:c.top,left:c.left,zIndex:z.zIndex.toolbar,opacity:g&&c.visible?1:0,pointerEvents:g&&c.visible?"auto":"none",transform:g&&c.visible?"translateY(0)":"translateY(4px)",transition:`opacity ${z.transition.fast}, transform ${z.transition.fast}`,isolation:"isolate"},role:"toolbar","aria-label":Et.toolbar,"aria-hidden":!g||!c.visible,"data-testid":"bubble-toolbar",children:i.jsx("div",{className:"pubwave-toolbar__content",style:{display:"flex",alignItems:"center",gap:0,padding:"var(--pubwave-spacing-1, 4px)",backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",color:"var(--pubwave-text)",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))"},children:n??i.jsx(oc,{editor:e,selectionState:u})})}):null}const ac=768;function ic(e,t,n){if(!e||!(e instanceof Node))return null;try{if(e instanceof HTMLElement){const a=e.closest("table");if(a&&t.contains(a))return a}const o=n.view.posAtDOM(e,0),r=n.state.doc.resolve(o);if(r.depth>=1){const a=r.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(a.type.name)){const l=n.view.nodeDOM(r.before(1));if(l&&t.contains(l))return l}}for(let a=r.depth;a>0;a--)if(r.node(a).isBlock){const l=r.before(a),c=n.view.nodeDOM(l);if(c&&t.contains(c))return c}}catch{let r=e instanceof HTMLElement?e:e.parentElement;for(;r&&r.parentElement;){if(r.parentElement===t)return r;r=r.parentElement}}return null}function Mo({editor:e}){const t=x.useRef(null),n=x.useRef(null),o=x.useRef(!1),r=x.useRef(null),[a,s]=x.useState(!1),[l,c]=x.useState(!1),[f,u]=x.useState({top:0}),[m,h]=x.useState(!1),[v,p]=x.useState(!1);x.useEffect(()=>{const k=()=>{h(vt()),p(window.innerWidth<ac)};return k(),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[]);const g=x.useCallback(()=>{const k=t.current,j=n.current;if(!k||!j)return;const I=k.closest(".pubwave-editor");if(!I)return;I.offsetHeight;const N=I.getBoundingClientRect();let B=14,_=j;if(["UL","OL","BLOCKQUOTE"].includes(j.tagName)&&j.firstElementChild instanceof HTMLElement&&(_=j.firstElementChild),j.tagName==="TABLE"){const M=j.querySelector("thead")||j.querySelector("tr");M instanceof HTMLElement&&(_=M)}_.offsetHeight;const b=_.getBoundingClientRect();try{const M=window.getComputedStyle(_),E=M.lineHeight;if(E&&E!=="normal"){const $=parseFloat(E);isNaN($)||(B=$/2)}else{const $=parseFloat(M.fontSize);isNaN($)||(B=$*1.5/2)}}catch{}const L=b.top-N.top+B;!isNaN(L)&&isFinite(L)&&L>=0&&u({top:L})},[]),C=x.useCallback(k=>{n.current=k,s(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[g]),y=x.useCallback(()=>{o.current||(n.current=null,s(!1))},[]),S=x.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);x.useEffect(()=>{const k=e.view.dom,j=k.closest(".pubwave-editor");if(!j)return;const I=b=>{if(o.current)return;const L=b.target;if(!L||(S(),L.closest(".pubwave-block-handle"))||!k.contains(L))return;const M=ic(L,k,e);M&&(M!==n.current?C(M):s(!0))},N=b=>{if(o.current)return;const L=b.relatedTarget;if(!L){S(),r.current=setTimeout(()=>{y()},150);return}L.closest(".pubwave-block-handle")||k.contains(L)||L.closest(".pubwave-editor")||(S(),r.current=setTimeout(()=>{y()},150))},B=()=>{o.current||(S(),r.current=setTimeout(()=>{y()},150))};k.addEventListener("mouseover",I),k.addEventListener("mouseout",N),j.addEventListener("mouseleave",B);const _=({transaction:b})=>{b.docChanged&&!o.current&&y()};return e.on("transaction",_),()=>{k.removeEventListener("mouseover",I),k.removeEventListener("mouseout",N),j.removeEventListener("mouseleave",B),e.off("transaction",_),S()}},[e,C,y,S]),x.useEffect(()=>{a&&n.current&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[a,g]),x.useEffect(()=>{if(!a)return;const k=()=>{n.current&&g()};return window.addEventListener("scroll",k,!0),()=>window.removeEventListener("scroll",k,!0)},[a,g]);const T=x.useCallback(()=>{const k=n.current;if(k)try{const j=e.view.posAtDOM(k,0),I=e.state.doc.resolve(j);let N=j;for(let b=I.depth;b>0;b--)if(I.node(b).isBlock){N=I.start(b);break}const _=e.state.doc.resolve(N).after(1);e.chain().focus().insertContentAt(_,{type:"paragraph"}).setTextSelection(_+1).run(),setTimeout(()=>{e.commands.insertContent("/")},10)}catch(j){console.error("Failed to add block:",j)}},[e]),d=x.useCallback(k=>{const j=n.current;if(!j)return;o.current=!0,requestAnimationFrame(()=>{c(!0)});const I=e.view.posAtDOM(j,0),N=bt(e.state.doc,I);if(!N)return;const B=N.pos,_=`block-${B}`;Co(e,_,B),k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("application/x-pubwave-block",_),j.classList.add("pubwave-block--dragging");const b=j.cloneNode(!0);b.classList.add("pubwave-block--drag-preview"),b.style.opacity="1";const L=H=>{H.style.setProperty("color","#9b9a97","important"),H.style.setProperty("border-color","#9b9a97","important"),H.style.setProperty("--pubwave-text","#9b9a97","important"),Array.from(H.children).forEach(P=>{P instanceof HTMLElement&&L(P)})};L(b);const M=j.getBoundingClientRect();b.style.width=`${M.width}px`,b.style.position="static",b.style.transform="none";const E=document.createElement("div");E.className="pubwave-editor";const $=document.createElement("div");$.className="pubwave-editor__content";const q=document.createElement("div");q.className="ProseMirror",q.appendChild(b),$.appendChild(q),E.appendChild($),E.style.position="absolute",E.style.top="-9999px",E.style.left="-9999px",document.body.appendChild(E),k.dataTransfer.setDragImage(b,0,0),setTimeout(()=>{document.body.removeChild(E)},0)},[e]),A=x.useCallback(()=>{o.current=!1,c(!1),n.current&&n.current.classList.remove("pubwave-block--dragging"),s(!1)},[]);return m||v||!a?null:i.jsxs("div",{ref:t,className:"pubwave-block-handle","data-testid":"block-handle",style:{position:"absolute",left:"calc(var(--pubwave-container-padding-left, 140px) - 80px)",top:`${f.top}px`,transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:"2px",pointerEvents:"auto",transition:`opacity ${z.transition.fast}`,zIndex:z.zIndex.dragHandle,opacity:a&&!l?1:0},onMouseEnter:k=>{k.stopPropagation(),r.current&&(clearTimeout(r.current),r.current=null)},onMouseLeave:k=>{k.stopPropagation();const j=k.relatedTarget;j!=null&&j.closest(".pubwave-editor")||(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{y()},150))},children:[i.jsx("button",{type:"button",className:"pubwave-block-handle__add",onClick:T,"data-testid":"add-block-button",style:{width:"var(--pubwave-button-width, 28px)",height:"var(--pubwave-button-height, 28px)",display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:z.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${z.colors.textMuted})`,cursor:"pointer",transition:`background-color ${z.transition.fast}, color ${z.transition.fast}`},title:"Add block","aria-label":"Add block below",children:i.jsx(sc,{})}),i.jsx("div",{className:"pubwave-block-handle__drag",draggable:!0,onDragStart:d,onDragEnd:A,"data-testid":"drag-handle",style:{width:"44px",height:"44px",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:z.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${z.colors.textMuted})`,cursor:"grab",transition:`background-color ${z.transition.fast}, color ${z.transition.fast}`},role:"button",tabIndex:0,title:"Drag to move","aria-label":"Drag to reorder block",children:i.jsx(lc,{})})]})}function sc(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),i.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function lc(){return i.jsxs("svg",{width:"12",height:"18",viewBox:"0 0 10 16",fill:"currentColor",children:[i.jsx("circle",{cx:"2",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}function Po({visible:e,position:t,className:n}){return i.jsxs("div",{className:Ve("pubwave-drop-indicator",e&&"pubwave-drop-indicator--visible",`pubwave-drop-indicator--${t}`,n),"data-testid":"drop-indicator",style:{position:"absolute",left:0,right:0,height:"2px",backgroundColor:`var(--pubwave-drop-indicator-color, ${z.colors.dropIndicator})`,borderRadius:"1px",...t==="before"?{top:"-1px"}:{bottom:"-1px"},opacity:e?1:0,transform:e?"scaleX(1)":"scaleX(0.8)",transition:`opacity ${z.transition.fast}, transform ${z.transition.fast}`,zIndex:10,pointerEvents:"none"},"aria-hidden":"true",children:[i.jsx(Nn,{position:"left",visible:e}),i.jsx(Nn,{position:"right",visible:e})]})}function Nn({position:e,visible:t}){return i.jsx("div",{className:`pubwave-drop-indicator__cap pubwave-drop-indicator__cap--${e}`,style:{position:"absolute",top:"50%",transform:"translateY(-50%)",...e==="left"?{left:"-4px"}:{right:"-4px"},width:"8px",height:"8px",borderRadius:"50%",backgroundColor:`var(--pubwave-drop-indicator-color, ${z.colors.dropIndicator})`,opacity:t?1:0,transition:`opacity ${z.transition.fast}`}})}function cc({editor:e}){const[t,n]=x.useState(null),[o,r]=x.useState(null);return x.useEffect(()=>{const a=X.getState(e.state);a&&n(a);const s=()=>{const l=X.getState(e.state);l&&(l.dropTargetPos!==(t==null?void 0:t.dropTargetPos)||l.dropPosition!==(t==null?void 0:t.dropPosition))&&n(l)};return e.on("transaction",s),()=>{e.off("transaction",s)}},[e,t]),x.useEffect(()=>{if(!(t!=null&&t.dropTargetPos)||!t.dropPosition){r(null);return}const a=requestAnimationFrame(()=>{var v;const s=e.view,l=t.dropTargetPos;if(l===null)return;let c=s.nodeDOM(l);if(!c&&l>0){const p=s.domAtPos(l).node;p instanceof HTMLElement&&(c=p)}if(!c||!(c instanceof HTMLElement))return;const f=c.getBoundingClientRect(),u=(v=s.dom.closest(".pubwave-editor"))==null?void 0:v.getBoundingClientRect();if(!u)return;const m=8;let h=0;t.dropPosition==="before"?h=f.top-u.top-m:h=f.bottom-u.top+m,r({top:h,left:f.left-u.left,width:f.width})});return()=>cancelAnimationFrame(a)},[t,e]),!(t!=null&&t.dropTargetPos)||!t.dropPosition||!o?null:i.jsx("div",{style:{position:"absolute",top:o.top,left:o.left,width:o.width,height:"2px",pointerEvents:"none",zIndex:50},children:i.jsx(Po,{visible:!0,position:t.dropPosition,className:"pubwave-drop-indicator--overlay"})})}const uc=x.forwardRef(function(t,n){const{content:o,editable:r=!0,placeholder:a,theme:s,autofocus:l=!1,imageUpload:c,onChange:f,onSelectionChange:u,onFocus:m,onBlur:h,onReady:v,className:p,width:g,height:C,minHeight:y,"data-testid":S="pubwave-editor"}=t,T=jt(s==null?void 0:s.locale),d=a??T.placeholder??'Write,type "/" for commands...',A=Ae.useEditor({extensions:ln({placeholder:d,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:c,locale:s==null?void 0:s.locale}),content:o,editable:r,autofocus:l,immediatelyRender:!1,editorProps:{attributes:{class:`pubwave-editor__content ${(s==null?void 0:s.contentClassName)??""}`.trim(),"data-placeholder":d}},onUpdate:({editor:b})=>{f==null||f(b.getJSON())},onSelectionUpdate:()=>{u==null||u()},onFocus:()=>{m==null||m()},onBlur:()=>{h==null||h()},onCreate:({editor:b})=>{const L=k(b);v==null||v(L)}}),k=x.useCallback(b=>({getState:()=>({selection:{hasSelection:!(b!=null&&b.state.selection.empty),isMultiBlock:!1,from:(b==null?void 0:b.state.selection.from)??0,to:(b==null?void 0:b.state.selection.to)??0,isEmpty:(b==null?void 0:b.state.selection.empty)??!0},marks:{isBold:(b==null?void 0:b.isActive("bold"))??!1,isItalic:(b==null?void 0:b.isActive("italic"))??!1,isLink:(b==null?void 0:b.isActive("link"))??!1,linkHref:b?b.getAttributes("link").href:void 0},isFocused:(b==null?void 0:b.isFocused)??!1,isEditable:(b==null?void 0:b.isEditable)??!1,isEmpty:(b==null?void 0:b.isEmpty)??!0,characterCount:0}),getJSON:()=>(b==null?void 0:b.getJSON())??{type:"doc",content:[]},getHTML:()=>(b==null?void 0:b.getHTML())??"",getText:()=>(b==null?void 0:b.getText())??"",setContent:L=>b==null?void 0:b.commands.setContent(L),clearContent:()=>b==null?void 0:b.commands.clearContent(),setEditable:L=>b==null?void 0:b.setEditable(L),focus:L=>{L==="start"?b==null||b.commands.focus("start"):L==="end"?b==null||b.commands.focus("end"):b==null||b.commands.focus()},blur:()=>b==null?void 0:b.commands.blur(),toggleBold:()=>b==null?void 0:b.chain().focus().toggleBold().run(),toggleItalic:()=>b==null?void 0:b.chain().focus().toggleItalic().run(),setLink:L=>{L?b==null||b.chain().focus().setLink({href:L}).run():b==null||b.chain().focus().unsetLink().run()},destroy:()=>b==null?void 0:b.destroy(),tiptapEditor:b??null}),[]);x.useImperativeHandle(n,()=>A?k(A):null,[A,k]);const[j,I]=x.useState(!1);x.useEffect(()=>{I(!0)},[]),x.useEffect(()=>{var L;if(!((L=A==null?void 0:A.view)!=null&&L.dom))return;const b=A.view.dom;b&&b.setAttribute("data-placeholder",d)},[A,d,s==null?void 0:s.locale]);const N=["pubwave-editor",(s==null?void 0:s.classNamePrefix)??"",(s==null?void 0:s.containerClassName)??"",A?ql(A):"",C||y?"pubwave-editor--fixed-height":"",p].filter(Boolean).join(" "),B={position:"relative",overflow:C||y?"hidden":"visible",...C||y?{display:"flex",flexDirection:"column"}:{}};if(g&&(B["--pubwave-container-width"]=g,B.width=g,B["--pubwave-container-max-width"]=g,B.maxWidth=g),C&&(B["--pubwave-container-height"]=C,B.height=C),y&&(B["--pubwave-container-min-height"]=y,B.minHeight=y),s!=null&&s.colors){const{colors:b}=s,M=(b.text||"#1f2937").toLowerCase().trim(),E=M.startsWith("#f")||M.startsWith("#e")||M.includes("f1")||M.includes("f3")||M.includes("f0")||M.includes("fdf")||M.includes("ffb")||M.includes("ffc")||M.includes("ffd")||M.includes("ffe")||M.includes("fff")||M.includes("e0")||M.includes("e5")||M.includes("ecf")||M.includes("eef");b.background&&(b.background.includes("gradient")?(B.background=b.background,E?(B["--pubwave-surface"]="rgba(38, 38, 38, 0.95)",B["--pubwave-bg"]="#1a1a1a"):(B["--pubwave-surface"]="rgba(255, 255, 255, 0.95)",B["--pubwave-bg"]="#ffffff")):(B["--pubwave-bg"]=b.background,B["--pubwave-surface"]=b.background)),b.text&&(B["--pubwave-text"]=b.text),b.textMuted&&(B["--pubwave-text-muted"]=b.textMuted),b.border&&(B["--pubwave-border"]=b.border),b.primary&&(B["--pubwave-primary"]=b.primary),b.linkColor&&(B["--pubwave-link-color"]=b.linkColor),E?B["--pubwave-hover"]="rgba(255, 255, 255, 0.1)":B["--pubwave-hover"]="rgba(0, 0, 0, 0.05)"}if(s!=null&&s.backgroundImage){const b=s.backgroundImage,L=s.backgroundImageOptions||{};b.startsWith("url(")||b.includes("gradient")||b.includes("linear-gradient")||b.includes("radial-gradient")?B.backgroundImage=b:B.backgroundImage=`url(${b})`,L.repeat!==void 0?B.backgroundRepeat=L.repeat:B.backgroundRepeat="no-repeat",L.position!==void 0?B.backgroundPosition=L.position:B.backgroundPosition="center",L.size!==void 0?B.backgroundSize=L.size:B.backgroundSize="cover",L.attachment!==void 0?B.backgroundAttachment=L.attachment:B.backgroundAttachment="scroll"}if(!j||!A)return i.jsx(fn,{value:{locale:T},children:i.jsx("div",{className:N,"data-testid":S,role:"application","aria-label":Et.editor,style:B})});const _=b=>{if(!A||!r||b.button!==0||b.defaultPrevented)return;const L=b.target;if(!L)return;const M=A.view.dom;if(M&&M.contains(L))return;const E=M==null?void 0:M.lastElementChild,$=b.currentTarget.getBoundingClientRect();if(b.clientX<$.left||b.clientX>$.right||b.clientY<$.top||b.clientY>$.bottom)return;if(E){const W=E.getBoundingClientRect();if(b.clientY<=W.bottom+1)return}const{state:q}=A,H=q.schema.nodes.paragraph;if(!H)return;const P=q.doc.content.size,R=q.doc.lastChild;if(R&&R.type===H&&R.content.size===0){A.chain().focus().setTextSelection(Math.max(1,P-1)).run();return}A.chain().focus().insertContentAt(P,{type:"paragraph"}).setTextSelection(P+1).run()};return i.jsx(fn,{value:{locale:T},children:i.jsxs("div",{className:N,"data-testid":S,role:"application","aria-label":Et.editor,style:B,onMouseDown:_,children:[i.jsx(Ae.EditorContent,{editor:A}),r&&i.jsx(So,{editor:A}),r&&i.jsx(Mo,{editor:A}),r&&i.jsx(cc,{editor:A})]})})});function Ge(e){return!e.isDestroyed}function Do(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleBold().run();return Re(e),{success:t,message:t?"Bold toggled":"Could not toggle bold"}}function Io(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleItalic().run();return Re(e),{success:t,message:t?"Italic toggled":"Could not toggle italic"}}function Ro(e,t){if(!Ge(e))return{success:!1,message:"Editor not available"};if(!t.trim())return{success:!1,message:"URL is required"};let n=t.trim();!/^https?:\/\//i.test(n)&&!n.startsWith("/")&&(n=`https://${n}`);const o=e.chain().focus().setLink({href:n}).run();return Re(e),{success:o,message:o?"Link added":"Could not add link"}}function Eo(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().unsetLink().run();return Re(e),{success:t,message:t?"Link removed":"Could not remove link"}}function Oo(e,t=window.prompt.bind(window)){if(!Ge(e))return{success:!1,message:"Editor not available"};if(e.isActive("link"))return Eo(e);const o=t("Enter URL:");return o?Ro(e,o):(Re(e),{success:!1,message:"Link cancelled"})}function dc(e,t){if(!Ge(e))return{success:!1,message:"Editor not available"};const n=e.chain().focus().setHeading({level:t}).run();Re(e);const o=String(t);return{success:n,message:n?`Heading ${o} applied`:"Could not set heading"}}function pc(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().setParagraph().run();return Re(e),{success:t,message:t?"Paragraph applied":"Could not set paragraph"}}function fc(e,t,n){return()=>{const o=t(e);n==null||n(o)}}const hc=[{id:"bold",label:"Bold",shortcut:"Cmd+B",icon:"bold",action:Do,isActive:e=>e.isActive("bold")},{id:"italic",label:"Italic",shortcut:"Cmd+I",icon:"italic",action:Io,isActive:e=>e.isActive("italic")},{id:"link",label:"Link",icon:"link",action:e=>Oo(e),isActive:e=>e.isActive("link")}],Hn="44px",$n="20px";function bc({blockId:e,isHovered:t,isDragging:n=!1,onDragStart:o,onDragEnd:r,className:a}){const s=x.useRef(null),[l,c]=x.useState(!1),f=x.useCallback(p=>{if(p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",e),p.dataTransfer.setData("application/x-pubwave-block",e),s.current){const g=s.current.getBoundingClientRect();p.dataTransfer.setDragImage(s.current,g.width/2,g.height/2)}o==null||o(e,p)},[e,o]),u=x.useCallback(p=>{c(!1),r==null||r(e,p)},[e,r]),m=x.useCallback(()=>{c(!0)},[]),h=x.useCallback(()=>{c(!1)},[]),v=t||n;return i.jsx("div",{ref:s,className:Ve("pubwave-drag-handle",v&&"pubwave-drag-handle--visible",n&&"pubwave-drag-handle--dragging",l&&"pubwave-drag-handle--pressed",a),"data-testid":"drag-handle",style:{position:"absolute",left:"-32px",top:"50%",transform:"translateY(-50%)",width:Hn,height:Hn,display:"flex",alignItems:"center",justifyContent:"center",cursor:n?"grabbing":"grab",opacity:v?1:0,transition:`opacity ${z.transition.fast}`,userSelect:"none",WebkitUserSelect:"none"},draggable:!0,onDragStart:f,onDragEnd:u,onMouseDown:m,onMouseUp:h,role:"button","aria-label":Et.dragHandle,tabIndex:v?0:-1,children:i.jsx("div",{className:"pubwave-drag-handle__visual",style:{width:$n,height:$n,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:z.borderRadius.sm,backgroundColor:l?`var(--pubwave-drag-handle-active-bg, ${z.colors.focus})`:"transparent",transition:`background-color ${z.transition.fast}`},children:i.jsx(vc,{})})})}function vc(){return i.jsxs("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"currentColor",style:{color:`var(--pubwave-drag-handle-color, ${z.colors.textMuted})`},children:[i.jsx("circle",{cx:"3",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"13",r:"1.5"})]})}const Xt=50,gc=15;function zn(e){const t=1-e/Xt;return Math.round(t*gc)}function _o(e){const t={isActive:!1,direction:null,speed:0,animationId:null},n=()=>e??window,o=()=>{if(e){const a=e.getBoundingClientRect();return{top:a.top,bottom:a.bottom}}return{top:0,bottom:window.innerHeight}},r=()=>{if(!t.isActive||t.direction===null)return;const a=n(),s=t.direction==="up"?-t.speed:t.speed;a===window?window.scrollBy(0,s):a instanceof HTMLElement&&(a.scrollTop+=s),t.animationId=Y(r)};return{start(){t.isActive=!0},update(a){if(!t.isActive)return;const s=o(),l=a-s.top,c=s.bottom-a;l<Xt?(t.direction="up",t.speed=zn(l)):c<Xt?(t.direction="down",t.speed=zn(c)):(t.direction=null,t.speed=0),t.direction!==null&&t.animationId===null?t.animationId=Y(r):t.direction===null&&t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)},stop(){t.isActive=!1,t.direction=null,t.speed=0,t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)}}}function mc(e){let t=null;const n=()=>(t??(t=_o(e)),t);return{startAutoScroll(){n().start()},updateAutoScroll(o){n().update(o.clientY)},stopAutoScroll(){n().stop(),t=null}}}const xc=3e3;function No({message:e,type:t="info",duration:n=xc,onDismiss:o,className:r}){const[a,s]=x.useState(!0);x.useEffect(()=>{if(n<=0)return;const f=setTimeout(()=>{s(!1),o==null||o()},n);return()=>{clearTimeout(f)}},[n,o]);const l=x.useCallback(()=>{s(!1),o==null||o()},[o]),c={info:z.colors.text,success:"var(--pubwave-color-success, #10b981)",error:z.colors.error,warning:"var(--pubwave-color-warning, #f59e0b)"};return i.jsxs("div",{className:Ve("pubwave-toast",`pubwave-toast--${t}`,a?"pubwave-toast--visible":"pubwave-toast--hidden",r),style:{position:"fixed",bottom:"24px",left:"50%",transform:`translateX(-50%) translateY(${a?"0":"16px"})`,padding:`${z.spacing.sm} ${z.spacing.md}`,backgroundColor:`var(--pubwave-toast-bg, ${z.colors.surface})`,border:`1px solid var(--pubwave-toast-border, ${z.colors.border})`,borderRadius:z.borderRadius.md,boxShadow:z.shadow.md,color:c[t],fontSize:z.typography.fontSizeSmall,opacity:a?1:0,transition:`opacity ${z.transition.normal}, transform ${z.transition.normal}`,zIndex:100,maxWidth:"400px",textAlign:"center"},role:"status","aria-live":"polite",children:[i.jsx("span",{className:"pubwave-toast__message",children:e}),i.jsx("button",{type:"button",className:"pubwave-toast__dismiss",onClick:l,style:{marginLeft:z.spacing.sm,padding:"0 4px",background:"none",border:"none",color:z.colors.textMuted,cursor:"pointer",fontSize:"16px",lineHeight:1},"aria-label":"Dismiss",children:"×"})]})}function yc({toasts:e,onDismiss:t}){return i.jsx("div",{className:"pubwave-toast-container",children:e.map((n,o)=>{const r=24+o*56,a=100-o;return i.jsx("div",{style:{position:"fixed",bottom:`${String(r)}px`,left:"50%",transform:"translateX(-50%)",zIndex:a},children:i.jsx(No,{message:n.message,type:n.type,duration:n.duration,onDismiss:()=>{t(n.id)}})},n.id)})})}function wc(){const e=String(Date.now()),t=Math.random().toString(36).slice(2,9);return`toast-${e}-${t}`}exports.BlockHandle=Mo;exports.BubbleToolbar=So;exports.DragHandle=bc;exports.DropIndicator=Po;exports.PubwaveEditor=uc;exports.SUPPORTED_BLOCKS=bl;exports.SUPPORTED_MARKS=vl;exports.SlashMenuList=yo;exports.Toast=No;exports.ToastContainer=yc;exports.canUseDOM=Ot;exports.cancelDrag=cl;exports.clearFormatting=Il;exports.cn=Ve;exports.createActionHandler=fc;exports.createAutoScroller=_o;exports.createDndPlugin=ko;exports.createEditor=gl;exports.createExtensions=ln;exports.createFocusTrap=Xl;exports.createSlashCommandsExtension=xo;exports.createToastId=wc;exports.defaultSlashCommands=Xn;exports.defaultTokens=ll;exports.defaultToolbarActions=hc;exports.destroyEditor=ml;exports.dndPluginKey=X;exports.findBlockAtPos=bt;exports.focusAfterClick=Gl;exports.focusAt=Vl;exports.focusEditor=Pl;exports.getActiveLinkHref=_l;exports.getActiveMarks=Ol;exports.getDndState=sn;exports.getSelectionBounds=wl;exports.getSelectionState=cn;exports.handleSelectionClear=Kl;exports.isEditable=xt;exports.isEditorValid=xl;exports.isMarkActive=Rl;exports.isMobileDevice=vt;exports.isNodeActive=El;exports.isReadOnly=To;exports.isSSR=ai;exports.isSelectionEmpty=yl;exports.maintainFocus=Yl;exports.moveBlock=wo;exports.redo=Ml;exports.restoreFocus=Re;exports.restoreSelection=st;exports.saveSelection=Ao;exports.selectAll=Dl;exports.setHeading=Al;exports.setLink=Tl;exports.setParagraph=Bl;exports.shouldAllowInteraction=zl;exports.shouldAllowToolbar=Hl;exports.shouldRenderEditUI=Nl;exports.shouldShowDragHandle=$l;exports.shouldShowToolbar=Pt;exports.startDrag=Co;exports.toggleBold=kl;exports.toggleHeading=jl;exports.toggleItalic=Cl;exports.tokens=z;exports.toolbarRemoveLink=Eo;exports.toolbarSetHeading=dc;exports.toolbarSetLink=Ro;exports.toolbarSetParagraph=pc;exports.toolbarToggleBold=Do;exports.toolbarToggleItalic=Io;exports.toolbarToggleLink=Oo;exports.undo=Sl;exports.unsetLink=Ll;exports.useAutoScroll=mc;
103
+ `,gl=vl;function Ve(...e){return e.filter(Boolean).join(" ")}const Rt={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"};function ko(e,t,n){var a;const o=e??(t||n?Zt(t,n):Qn),r=((a=n==null?void 0:n.slashMenu)==null?void 0:a.groups)||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"};return be.Extension.create({name:"slashCommands",addOptions(){return{suggestion:{char:"/",command:({editor:s,range:l,props:c})=>{if(c.id==="taskList"){s.chain().focus().deleteRange(l).toggleTaskList().run();return}s.chain().focus().deleteRange(l).run(),c.action(s)}}}},addProseMirrorPlugins(){const s=this.editor;return[Mr({editor:this.editor,...this.options.suggestion,allowed:({state:l,range:c})=>{try{if(s.isActive("codeBlock"))return!1;const f=l.doc.resolve(c.from);for(let p=f.depth;p>=1;p--)if(f.node(p).type.name==="codeBlock")return!1;return!0}catch{return!0}},items:({query:l,state:c})=>{let f=o;try{const p=c.doc.resolve(c.selection.from);for(let y=p.depth;y>=0;y--)if(p.node(y).type.name==="layoutColumn"){f=o.filter(b=>b.group!=="layout");break}}catch{}return Oi(f,l)},render:()=>{let l,c;return{onStart:f=>{this.editor.isActive("codeBlock")||(l=new Pe.ReactRenderer(Co,{props:{...f,query:f.query,editor:this.editor,groupLabels:r},editor:this.editor}),f.clientRect&&(c=Oe("body",{getReferenceClientRect:f.clientRect,appendTo:()=>document.body,content:l.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",offset:[0,8],zIndex:_.zIndex.dropdown,arrow:!1,duration:[0,0],animation:!1,popperOptions:{modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:8,altAxis:!0}},{name:"flip",options:{fallbackPlacements:["top-start","bottom-end","top"]}}]},onShow(p){const y=p.popper.querySelector(".tippy-box");y&&(y.style.zIndex=String(_.zIndex.dropdown),y.style.backgroundColor="transparent",y.style.background="transparent",y.style.border="none");const d=p.popper.querySelector(".pubwave-slash-menu");if(d){const b=document.querySelector(".ProseMirror");if(b){const h=d.getBoundingClientRect(),C=b.getBoundingClientRect().bottom-h.top-16,m=Math.max(200,Math.min(280,C));d.style.maxHeight=`${m}px`}}}})))},onUpdate(f){var p,y,d;if(l.updateProps({...f,query:f.query,editor:f.editor,groupLabels:r}),f.items.length===0){if(c[0]){c[0].hide();const b=c[0].popper.querySelector(".tippy-box");b&&(b.style.opacity="0",b.style.pointerEvents="none")}return}f.clientRect&&((p=c[0])==null||p.setProps({getReferenceClientRect:f.clientRect}),(y=c[0])!=null&&y.state.isVisible||(d=c[0])==null||d.show())},onKeyDown(f){var p,y;return f.event.key==="Escape"?((p=c[0])==null||p.hide(),!0):((y=l.ref)==null?void 0:y.onKeyDown(f))??!1},onExit(){var f;(f=c[0])==null||f.destroy(),l.destroy()}}}})]}})}const Co=w.forwardRef(function({items:t,command:n,query:o="",groupLabels:r},a){const[s,l]=w.useState(-1),c=w.useRef(null),f=w.useRef(null);w.useEffect(()=>{t.length>0&&o.length>0?l(0):(t.length,l(-1))},[t,o]),ni(s,c,f);const p=w.useMemo(()=>{const h={};for(const v of t){const C=h[v.group]??[];C.push(v),h[v.group]=C}return h},[t]),y=t,d=w.useCallback(h=>{const v=y[h];v&&n(v)},[y,n]);w.useImperativeHandle(a,()=>({onKeyDown:({event:h})=>y.length===0?!1:h.key==="ArrowUp"?(l(v=>v<0?y.length-1:v<=0?0:v-1),!0):h.key==="ArrowDown"?(l(v=>v<0?0:v>=y.length-1?y.length-1:v+1),!0):h.key==="Enter"&&s>=0&&s<y.length?(d(s),!0):!1}));const b=r||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"};return t.length===0?null:i.jsx("div",{className:"pubwave-slash-menu",ref:c,style:oi,"data-testid":"slash-menu",children:i.jsx("div",{style:{padding:"var(--pubwave-spacing-1, 4px) 0"},children:(()=>{let h=0;return["basic","list","media","advanced","layout"].map(C=>{const m=p[C];return!m||m.length===0?null:i.jsxs("div",{className:"pubwave-slash-menu__group",style:ri,children:[i.jsx("div",{className:"pubwave-slash-menu__group-label",style:ai,children:b[C]||C}),m.map(B=>{const k=h++,u=k===s;return i.jsxs("button",{ref:u?f:null,className:`pubwave-slash-menu__item ${u?"pubwave-slash-menu__item--selected":""}`,style:{...ii,backgroundColor:u?"var(--pubwave-hover-bg, #f3f4f6)":"transparent"},onClick:()=>d(k),onMouseEnter:()=>l(k),children:[i.jsx("span",{className:"pubwave-slash-menu__item-icon",style:si,children:B.icon}),i.jsx("span",{className:"pubwave-slash-menu__item-title",style:li,children:B.title})]},B.id)})]},C)})})()})})}),pe=new Ae.PluginKey("pubwave-dnd"),It={draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null,cancelled:!1};function qe(e,t){switch(t.type){case"START_DRAG":return{...e,draggingBlockId:t.blockId,draggingBlockPos:t.pos,dropTargetPos:null,dropPosition:null,cancelled:!1};case"UPDATE_DROP_TARGET":return{...e,dropTargetPos:t.pos,dropPosition:t.position};case"CANCEL_DRAG":return{...e,cancelled:!0,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"COMPLETE_DRAG":return{...e,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"RESET":return It;default:return e}}function ot(e,t){const n=Math.max(0,Math.min(t,e.content.size));try{const o=e.resolve(n);if(o.depth>=1){const r=o.node(1);if(["taskList","bulletList","orderedList","blockquote","table"].includes(r.type.name))return{node:r,pos:o.before(1)}}for(let r=o.depth;r>0;r--){const a=o.node(r);if(a.isBlock)return{node:a,pos:o.before(r)}}if(o.depth===0&&e.childCount>0){let r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r+s.nodeSize>n)return{node:s,pos:r};r+=s.nodeSize}return{node:e.lastChild,pos:e.content.size-e.lastChild.nodeSize}}return null}catch{let o=null,r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r<=n&&r+s.nodeSize>n){o={node:s,pos:r};break}r+=s.nodeSize}return o}}function To(e,t,n,o){const{state:r}=e,{tr:a,doc:s}=r,l=ot(s,t);if(!l)return!1;const c=ot(s,n);if(!c)return!1;let f=c.pos;if(o==="after"&&(f=c.pos+c.node.nodeSize),l.pos===c.pos||f===l.pos||f===l.pos+l.node.nodeSize)return!1;const p=l.node,y=l.pos,d=l.pos+p.nodeSize,b=s.slice(y,d);let h=f;y<f&&(h=f-p.nodeSize),a.delete(y,d);const v=a.doc.content.size;if(h<0?h=0:h>v&&(h=v),h>=0&&h<=v)a.insert(h,b.content);else return!1;return a.setSelection(r.selection.map(a.doc,a.mapping)),e.view.dispatch(a),!0}function On(e,t){const n=e.state.doc;if(n.childCount===0)return null;const o=0,r=e.nodeDOM(o);let a=0;for(let f=0;f<n.childCount-1;f++)a+=n.child(f).nodeSize;const s=e.nodeDOM(a),l=t.clientY;if(r){const f=r.getBoundingClientRect();if(l<f.top+50)return{pos:o,position:"before"}}if(s){const f=s.getBoundingClientRect();if(l>f.bottom-50)return{pos:a,position:"after"}}const c=e.posAtCoords({left:t.clientX,top:t.clientY});if(c){const f=ot(n,c.pos);if(f){const p=e.nodeDOM(f.pos);if(p){const y=p.getBoundingClientRect(),d=y.top+y.height/2;return{pos:f.pos,position:l<d?"before":"after"}}}}return null}function Lo(e){let t=It;return new Ae.Plugin({key:pe,state:{init(){return It},apply(n,o){const r=n.getMeta(pe);return r!==void 0?(t=r,r):(t=o,o)}},props:{handleKeyDown(n,o){return o.key==="Escape"&&t.draggingBlockId?(t=qe(t,{type:"CANCEL_DRAG"}),n.dispatch(n.state.tr.setMeta(pe,t)),!0):!1},handleDOMEvents:{dragover(n,o){var s;if(!((s=o.dataTransfer)!=null&&s.types.includes("application/x-pubwave-block")))return!1;o.preventDefault(),o.dataTransfer.dropEffect="move",t=pe.getState(n.state)??t;const a=On(n,o);return a?(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:a.pos,position:a.position}),n.dispatch(n.state.tr.setMeta(pe,t))):t.dropTargetPos!==null&&(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(pe,t))),!0},drop(n,o){var d;const r=(d=o.dataTransfer)==null?void 0:d.getData("application/x-pubwave-block");if(!r)return!1;o.preventDefault(),o.stopPropagation();let l=(pe.getState(n.state)??t).draggingBlockPos;if(l===null&&r.startsWith("block-")){const b=parseInt(r.replace("block-",""),10);isNaN(b)||(l=b)}if(l===null)return!1;const c=On(n,o);if(!c)return!1;const{pos:f,position:p}=c;if(f===l||!e)return!1;const y=To(e,l,f,p);return t=qe(t,{type:"COMPLETE_DRAG"}),n.dispatch(n.state.tr.setMeta(pe,t)),y},dragleave(n,o){const r=o.relatedTarget;return r!=null&&r.closest(".pubwave-editor")||(t=qe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(pe,t))),!1}}}})}function ln(e){return pe.getState(e.state)??It}function Bo(e,t,n){const{view:o}=e,r={type:"START_DRAG",blockId:t,pos:n},a=qe(ln(e),r);o.dispatch(o.state.tr.setMeta(pe,a))}function ml(e){const{view:t}=e,n={type:"CANCEL_DRAG"},o=qe(ln(e),n);t.dispatch(t.state.tr.setMeta(pe,o))}const wl=new Ae.PluginKey("editorBehaviors");function Kt(e,t){return e.type===t&&e.content.size===0}function yl(e,t){return e.content.content.every(n=>n.type.name!=="layoutColumn"||n.childCount!==1?!1:Kt(n.child(0),t))}function xl(e,t){const n=e.dom,o=n.getBoundingClientRect();if(t.clientX<o.left||t.clientX>o.right||t.clientY<o.top||t.clientY>o.bottom)return!1;const r=n.lastElementChild;if(!r)return!0;const a=r.getBoundingClientRect();return t.clientY>a.bottom+1}function kl(e,t){if(t.button!==0||t.defaultPrevented||!xl(e,t))return!1;const{state:n}=e,o=n.schema.nodes.paragraph;if(!o)return!1;const r=n.doc.content.size,a=n.doc.lastChild,s=n.tr;return a&&a.type===o&&a.content.size===0?(s.setSelection(Ae.TextSelection.create(n.doc,Math.max(1,r-1))),e.dispatch(s),e.focus(),!0):(s.insert(r,o.create()),s.setSelection(Ae.TextSelection.create(s.doc,r+1)),e.dispatch(s.scrollIntoView()),e.focus(),!0)}function Cl(e,t){if(t.key!=="Enter"||t.defaultPrevented)return!1;const{state:n}=e,{selection:o}=n;if(!o.empty)return!1;const{$from:r}=o,a=n.schema.nodes.paragraph;if(!a||r.parent.type!==a||r.parent.content.size!==0)return!1;let s=-1,l=-1;for(let u=r.depth;u>0;u--){const T=r.node(u);T.type.name==="layoutColumn"&&s===-1&&(s=u),T.type.name==="layout"&&l===-1&&(l=u)}if(s===-1||l===-1)return!1;const c=r.node(s);if(r.index(s)!==c.childCount-1||c.childCount<2)return!1;const p=c.child(c.childCount-1),y=c.child(c.childCount-2);if(!Kt(p,a)||!Kt(y,a))return!1;t.preventDefault();const d=n.tr,b=r.before(r.depth),h=r.parent.nodeSize,v=r.before(l),C=r.node(l);let m=!1;c.childCount>1?d.delete(b,b+h):C&&yl(C,a)&&(d.delete(v,v+C.nodeSize),m=!0);const B=d.mapping.map(v);let k=B;if(!m){const u=d.doc.nodeAt(B);if(!u)return!1;k=B+u.nodeSize}return d.insert(k,a.create()),d.setSelection(Ae.TextSelection.create(d.doc,k+1)),e.dispatch(d.scrollIntoView()),e.focus(),!0}function Tl(e,t){if(t.key!=="Enter"||t.defaultPrevented)return!1;const{state:n}=e,{selection:o}=n;if(!o.empty)return!1;const{$from:r}=o,a=n.schema.nodes.paragraph;if(!a||r.parent.type!==a||r.parent.content.size!==0)return!1;let s=-1,l=null;for(let c=r.depth;c>0;c--){const f=r.node(c);f.type.name==="layoutColumn"&&s===-1&&(s=c),(f.type.name==="listItem"||f.type.name==="taskItem")&&l===null&&(l=f.type)}return s===-1||!l?!1:(t.preventDefault(),Rr.liftListItem(l)(n,e.dispatch))}function Ll(){return new Ae.Plugin({key:wl,props:{handleClick(e,t,n){return n instanceof MouseEvent?kl(e,n):!1},handleKeyDown(e,t){return Tl(e,t)?!0:Cl(e,t)}}})}const Bl=["paragraph","heading","bulletList","orderedList","taskList","table","blockquote","codeBlock","horizontalRule","image","chart","layout"],Al=["bold","italic","underline","strike","code","link"];function cn(e={}){const{placeholder:t,historyDepth:n=100,headingLevels:o,linkOpenInNewTab:r,linkOpenOnClick:a,enableChart:s,enableLayout:l,enableSlashCommands:c=!0,slashCommands:f,imageUpload:p,locale:y}=e,d=y?jt(y):null,b=t??(d==null?void 0:d.placeholder)??'Write,type "/" for commands...',h=[...Za({headingLevels:o,imageUpload:p,enableChart:s,enableLayout:l}),...ti({linkOpenInNewTab:r,linkOpenOnClick:a}),tr.configure({placeholder:b,emptyEditorClass:"pubwave-editor--empty",emptyNodeClass:"pubwave-editor__node--empty"}),nr.configure({depth:n}),or.configure({color:"var(--pubwave-dropcursor-color, #3b82f6)",width:2}),rr,be.Extension.create({name:"dragAndDrop",addProseMirrorPlugins(){return[Lo(this.editor)]}}),be.Extension.create({name:"editorBehaviors",addProseMirrorPlugins(){return[Ll()]}})];if(c){const v=jt(y||"en"),C=Zt(p,v);let m=f?[...C,...f]:C;s===!1&&(m=m.filter(B=>B.id!=="chart")),l===!1&&(m=m.filter(B=>B.group!=="layout")),h.push(ko(m,p,v))}return h}function jl(e={}){if(!Ot)throw new Error("createEditor() cannot be called server-side. Ensure this function is only called in client-side code (e.g., useEffect, event handlers).");const{content:t,editable:n=!0,placeholder:o,autofocus:r=!1,imageUpload:a,enableChart:s,enableLayout:l,onUpdate:c,onSelectionUpdate:f,onFocus:p,onBlur:y,onCreate:d,onDestroy:b}=e,v={extensions:cn({placeholder:o,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:a,enableChart:s,enableLayout:l}),content:t,editable:n,autofocus:r,editorProps:{attributes:{class:"pubwave-editor__content","data-placeholder":o??'Write,type "/" for commands...'}},onUpdate:c?({editor:C})=>{c({editor:C})}:void 0,onSelectionUpdate:f?({editor:C})=>{f({editor:C})}:void 0,onFocus:p?({editor:C})=>{p({editor:C})}:void 0,onBlur:y?({editor:C})=>{y({editor:C})}:void 0,onCreate:d?({editor:C})=>{d({editor:C})}:void 0,onDestroy:b?()=>{b()}:void 0};return new be.Editor(v)}function Sl(e){e&&!e.isDestroyed&&e.destroy()}function Rl(e){return e!==null&&!e.isDestroyed}function un(e){const{state:t}=e,{selection:n}=t,{from:o,to:r,empty:a}=n,s=a?"":t.doc.textBetween(o,r," "),l=n instanceof Object&&"node"in n,c=s.length>0,f=e.isActive("bold"),p=e.isActive("italic"),y=e.isActive("underline"),d=e.isActive("strike"),b=e.isActive("code"),h=e.isActive("link"),v=h?e.getAttributes("link").href:null;return{hasSelection:!a||l,isEmpty:a&&!l,hasTextContent:c,isNodeSelection:l,selectedText:s,from:o,to:r,isBold:f,isItalic:p,isUnderline:y,isStrike:d,isCode:b,hasLink:h,linkHref:v}}function Ml(e){return e.state.selection.empty}function Mt(e){const t=un(e);return t.isEmpty?!1:!!t.hasTextContent}function Pl(e){if(typeof window>"u")return null;const{view:t}=e,{from:n,to:o}=t.state.selection;if(n===o)return null;const r=t.coordsAtPos(n),a=t.coordsAtPos(o),s=Math.min(r.top,a.top),l=Math.max(r.bottom,a.bottom),c=Math.min(r.left,a.left),f=Math.max(r.right,a.right);return{top:s,left:c,right:f,bottom:l,width:f-c,height:l-s}}function Dl(e){return e.chain().focus().toggleBold().run()}function Il(e){return e.chain().focus().toggleItalic().run()}function El(e,t){return t?e.chain().focus().setLink({href:t}).run():e.chain().focus().unsetLink().run()}function Ol(e){return e.chain().focus().unsetLink().run()}function _l(e){return e.chain().focus().setParagraph().run()}function Nl(e,t){return e.chain().focus().setHeading({level:t}).run()}function Hl(e,t){return e.chain().focus().toggleHeading({level:t}).run()}function zl(e){return e.chain().focus().undo().run()}function $l(e){return e.chain().focus().redo().run()}function ql(e,t){return e.chain().focus(t).run()}function Ul(e){return e.chain().focus().selectAll().run()}function Fl(e){return e.chain().focus().unsetAllMarks().run()}function Wl(e,t){return e.isActive(t)}function Vl(e,t,n){return e.isActive(t,n)}function Gl(e){const t=[];return e.isActive("bold")&&t.push("bold"),e.isActive("italic")&&t.push("italic"),e.isActive("link")&&t.push("link"),t}function Yl(e){return e.getAttributes("link").href??null}function Ao(e){return e?!e.isEditable:!0}function wt(e){return e?e.isEditable:!1}function Xl(e){return wt(e)}function Kl(e){return wt(e)}function Jl(e){return wt(e)}function Zl(e){return wt(e)}function Ql(e){return Ao(e)?"pubwave-editor--readonly":""}const Et={editor:"Rich text editor",toolbar:"Text formatting toolbar",dragHandle:"Drag to reorder block"},it={bold:"Cmd+B",italic:"Cmd+I",underline:"Cmd+U",strike:"Cmd+Shift+X",code:"Cmd+E"};function Ie(e,t){return t?`${e} (${t})`:e}const Me=w.forwardRef(({active:e=!1,disabled:t=!1,onClick:n,"data-tooltip":o,"data-testid":r,"aria-label":a,children:s,style:l},c)=>i.jsx("button",{ref:c,type:"button",className:Ve("pubwave-toolbar__button",e&&"pubwave-toolbar__button--active",t&&"pubwave-toolbar__button--disabled"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:(l==null?void 0:l.width)??"var(--pubwave-button-width, 28px)",height:(l==null?void 0:l.height)??"var(--pubwave-button-height, 28px)",minWidth:l==null?void 0:l.minWidth,padding:(l==null?void 0:l.padding)??0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:e?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"color 0.1s ease, background-color 0.1s ease",...l},onClick:f=>{f.preventDefault(),f.stopPropagation(),n()},disabled:t,"data-tooltip":o,"data-testid":r,"aria-label":a,"aria-pressed":e,onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},children:s}));Me.displayName="ToolbarButton";function _n(){return i.jsx("div",{className:"pubwave-toolbar__divider",style:{width:"var(--pubwave-divider-width, 1px)",height:"var(--pubwave-divider-height, 20px)",backgroundColor:"var(--pubwave-border)",margin:"0 var(--pubwave-spacing-1, 4px)"},role:"separator","aria-orientation":"vertical"})}function jo(e,t,n,o=8){const r=e,a=window.innerHeight-t,s=n+o;return r>=s?"top":a>=s?"bottom":r>=a?"top":"bottom"}function ec(e,t,n=8){return jo(e.top,e.bottom,t,n)}function So(e,t,n,o="left",r=8){const a=window.innerWidth,s=(e+t)/2,l=e,c=a-t,f=n+r,p=n+r,y=n/2+r;let d=o,b;return o==="left"?(b=e,(b<r||b+n>a-r)&&(c>=p&&t+n<=a-r?(d="right",b=t-n):l>=y&&s-n/2>=r?(d="center",b=s-n/2):(c>=l?(d="right",b=t-n):(d="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):o==="center"?(b=s-n/2,(b<r||b+n>a-r)&&(c>=p&&t+n<=a-r?(d="right",b=t-n):l>=f&&e+n<=a-r?(d="left",b=e):(c>=l?(d="right",b=t-n):(d="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):(b=t-n,(b<r||b+n>a-r)&&(l>=f&&e+n<=a-r?(d="left",b=e):l>=y&&s-n/2>=r?(d="center",b=s-n/2):(l>=c?(d="left",b=e):(d="right",b=t-n),b=Math.max(r,Math.min(b,a-n-r))))),b=Math.max(r,Math.min(b,a-n-r)),{align:d,left:b}}function tc(e,t,n="left",o=8){return So(e.left,e.right,t,n,o)}function dn({isOpen:e,buttonRef:t,children:n,className:o,style:r,align:a="left",margin:s=8,onClickOutside:l,onClick:c,"data-testid":f}){const[p,y]=w.useState("top"),[d,b]=w.useState(null),h=w.useRef(null);if(w.useEffect(()=>{if(!e||!t.current)return;const C=()=>{if(!h.current||!t.current)return;const B=t.current.getBoundingClientRect(),k=h.current.offsetHeight||300,u=h.current.offsetWidth||240,T=ec(B,k,s);y(T);let A=t.current.parentElement;for(;A;){const H=window.getComputedStyle(A);if(H.position==="relative"||H.position==="absolute"||H.position==="fixed")break;A=A.parentElement}const E=tc(B,u,a,s);if(A){const H=A.getBoundingClientRect(),G=E.left-H.left;b({align:E.align,left:G})}else b(E)};C();const m=requestAnimationFrame(()=>{C()});return()=>cancelAnimationFrame(m)},[e,t,s,a]),w.useEffect(()=>{if(!e||!l)return;const C=m=>{h.current&&!h.current.contains(m.target)&&t.current&&!t.current.contains(m.target)&&l(m)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[e,l,t]),!e)return null;const v=()=>{if(d)return{left:`${d.left}px`};switch(a){case"center":return{left:"50%",transform:"translateX(-50%)"};case"right":return{right:0};case"left":default:return{left:0}}};return i.jsx("div",{ref:h,className:o,"data-testid":f,style:{position:"absolute",...p==="top"?{bottom:"100%",marginBottom:`${s}px`}:{top:"100%",marginTop:`${s}px`},...v(),...r},onClick:C=>{C.stopPropagation(),c==null||c(C)},children:n})}function nc({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=We(),a=w.useRef(null),s=w.useCallback(()=>e.isActive("heading",{level:1})?"heading1":e.isActive("heading",{level:2})?"heading2":e.isActive("heading",{level:3})?"heading3":e.isActive("bulletList")?"bulletList":e.isActive("orderedList")?"orderedList":e.isActive("taskList")?"taskList":e.isActive("blockquote")?"blockquote":e.isActive("codeBlock")?"codeBlock":"paragraph",[e]),l=w.useMemo(()=>[{id:"paragraph",label:r.toolbar.blockTypes.text,icon:i.jsx(Gn,{}),action:d=>d.chain().focus().setParagraph().run(),isActive:d=>d.isActive("paragraph")},{id:"heading1",label:r.toolbar.blockTypes.heading1,icon:i.jsx(Yn,{}),action:d=>d.chain().focus().setHeading({level:1}).run(),isActive:d=>d.isActive("heading",{level:1})},{id:"heading2",label:r.toolbar.blockTypes.heading2,icon:i.jsx(Xn,{}),action:d=>d.chain().focus().setHeading({level:2}).run(),isActive:d=>d.isActive("heading",{level:2})},{id:"heading3",label:r.toolbar.blockTypes.heading3,icon:i.jsx(Kn,{}),action:d=>d.chain().focus().setHeading({level:3}).run(),isActive:d=>d.isActive("heading",{level:3})},{id:"bulletList",label:r.toolbar.blockTypes.bulletedList,icon:i.jsx(Jn,{}),action:d=>d.chain().focus().toggleBulletList().run(),isActive:d=>d.isActive("bulletList")},{id:"orderedList",label:r.toolbar.blockTypes.numberedList,icon:i.jsx(Zn,{}),action:d=>d.chain().focus().toggleOrderedList().run(),isActive:d=>d.isActive("orderedList")}],[r]),c=s(),f=l.find(d=>d.id===c),p=w.useCallback(d=>{d.action(e),o(),setTimeout(()=>{e.chain().blur().run()},0)},[e,o]),y=d=>d===r.toolbar.blockTypes.heading1?r.toolbar.blockTypes.heading1:d===r.toolbar.blockTypes.heading2?r.toolbar.blockTypes.heading2:d===r.toolbar.blockTypes.heading3?r.toolbar.blockTypes.heading3:d===r.toolbar.blockTypes.bulletedList?r.toolbar.blockTypes.bulletedList:d===r.toolbar.blockTypes.numberedList?r.toolbar.blockTypes.numberedList:r.toolbar.blockTypes.text;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Me,{ref:a,active:t,onClick:n,"data-tooltip":Ie(r.toolbar.turnInto),"data-testid":"toolbar-turnInto","aria-label":r.aria.turnIntoButton,style:{width:"auto",minWidth:"auto",padding:"0 8px",height:"var(--pubwave-button-height, 28px)"},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:f?y(f.label):r.toolbar.blockTypes.text}),i.jsx(di,{})]})}),i.jsxs(dn,{isOpen:t,buttonRef:a,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-turn-into-dropdown","data-testid":"turn-into-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-1, 4px)",minWidth:"240px",zIndex:_.zIndex.dropdown+1},children:[i.jsx("div",{style:Rt,children:r.toolbar.turnInto}),l.map(d=>{const b=d.isActive(e);return i.jsxs("button",{type:"button",className:Ve("pubwave-toolbar__turn-into-option",b&&"pubwave-toolbar__turn-into-option--active"),onClick:()=>p(d),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-2, 8px)",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",backgroundColor:b?"var(--pubwave-primary-faded)":"transparent",color:b?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:"pointer",fontSize:"var(--pubwave-font-size-base, 14px)",textAlign:"left",borderRadius:"var(--pubwave-border-radius-sm, 0.25rem)",transition:"background-color 0.1s ease"},children:[i.jsx("span",{style:{display:"flex",alignItems:"center",width:"18px",height:"18px",flexShrink:0},children:d.icon}),i.jsx("span",{children:d.label})]},d.id)})]})]})}function Se(e){return!!(e&&!e.isDestroyed)}function oc(e,t){Se(e)&&ce(()=>{if(Se(e))switch(t){case"start":e.commands.focus("start");break;case"end":e.commands.focus("end");break;case"preserve":e.commands.focus();break;default:typeof t=="number"&&(e.commands.setTextSelection(t),e.commands.focus())}})}function _e(e){Se(e)&&ce(()=>{Se(e)&&(e.isFocused||e.commands.focus())})}function rc(e,t){Se(e)&&(t.preventDefault(),ce(()=>{Se(e)&&e.commands.focus()}))}function ac(e){if(!Se(e))return function(){};const t=o=>{const r=o.relatedTarget;if(r){const a=e.view.dom.closest(".pubwave-editor");a&&!a.contains(r)&&r.closest(".pubwave-toolbar, .pubwave-menu, .pubwave-dialog")}},n=e.view.dom;return n.addEventListener("focusout",t),()=>{n.removeEventListener("focusout",t)}}function Ro(e){if(!Se(e))return null;const{from:t,to:n,empty:o}=e.state.selection;return{from:t,to:n,empty:o}}function lt(e,t){if(!Se(e)||!t)return;const{from:n,to:o}=t,r=e.state.doc.content.size,a=Math.min(n,r),s=Math.min(o,r);e.commands.setTextSelection({from:a,to:s})}function ic(e){if(!Se(e))return;const{selection:t}=e.state;if(t.$anchor.pos>0){e.commands.focus();return}e.commands.focus("end")}function sc(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1],r=a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),o==null||o.focus()):document.activeElement===o&&(a.preventDefault(),n==null||n.focus()))};return{activate(){e.addEventListener("keydown",r),n==null||n.focus()},deactivate(){e.removeEventListener("keydown",r)}}}function lc({editor:e,isOpen:t,onToggle:n,onClose:o,selectionState:r}){const a=We(),s=w.useRef(null),l=w.useRef(null),c=w.useRef(null),f=w.useRef([]),p=w.useRef(null),[y,d]=w.useState(""),b=(r==null?void 0:r.hasLink)??!1,h=(r==null?void 0:r.linkHref)??null;w.useEffect(()=>{t?(p.current=Ro(e),d(h||""),setTimeout(()=>{var k,u;(k=l.current)==null||k.focus(),(u=l.current)==null||u.select()},50)):p.current=null},[t,h,e]),w.useEffect(()=>{if(!vt()){if(!t){f.current.forEach(k=>k.destroy()),f.current=[];return}return f.current.forEach(k=>k.destroy()),f.current=[],ce(()=>{ce(()=>{if(!c.current)return;c.current.querySelectorAll("[data-tooltip]").forEach(u=>{const T=u.getAttribute("data-tooltip");if(T){const A=Oe(u,{content:T,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});f.current.push(A)}})})}),()=>{f.current.forEach(k=>k.destroy()),f.current=[]}}},[t,a,y,h]);const v=w.useCallback(k=>{if(k==null||k.preventDefault(),!y.trim()){p.current&&lt(e,p.current),e.chain().focus().unsetLink().run(),p.current&&ce(()=>{ce(()=>{lt(e,p.current)})}),o();return}let u=y.trim();!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),p.current&&lt(e,p.current),e.chain().focus().setLink({href:u}).run(),p.current&&ce(()=>{ce(()=>{lt(e,p.current)})}),o()},[e,y,o]),C=w.useCallback(()=>{const k=y.trim()||h;if(k){let u=k;!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),window.open(u,"_blank","noopener,noreferrer")}},[y,h]),m=w.useCallback(()=>{var k;d(""),(k=l.current)==null||k.focus()},[]),B=w.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),v()):k.key==="Escape"&&(k.preventDefault(),o(),e.chain().focus().run())},[v,o,e]);return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Me,{ref:s,active:b,onClick:n,"data-tooltip":Ie(a.toolbar.link),"data-testid":"toolbar-link","aria-label":a.aria.linkButton,children:i.jsx(gi,{})}),i.jsx(dn,{isOpen:t,buttonRef:s,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-link-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-2, 8px)",minWidth:"280px",zIndex:_.zIndex.dropdown+1},children:i.jsx("div",{ref:c,children:i.jsx("form",{onSubmit:v,style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[i.jsx("input",{ref:l,type:"text",value:y,onChange:k=>d(k.target.value),onKeyDown:B,placeholder:a.linkPlaceholder,"data-testid":"link-input","aria-label":a.aria.linkUrlInput,style:{flex:1,padding:"6px 100px 6px 8px",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-sm, 4px)",fontSize:"var(--pubwave-font-size-base, 14px)",backgroundColor:"var(--pubwave-bg)",color:"var(--pubwave-text)",outline:"none"}}),i.jsxs("div",{style:{position:"absolute",right:"4px",display:"flex",alignItems:"center",gap:"2px"},children:[i.jsx("button",{type:"button",onClick:v,"data-tooltip":a.toolbar.confirmLink,"data-testid":"link-confirm-button","aria-label":a.aria.linkConfirmButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:k=>{k.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:k=>{k.currentTarget.style.backgroundColor="transparent"},children:i.jsx(wi,{})}),(y.trim()||h)&&i.jsx("button",{type:"button",onClick:C,"data-tooltip":a.toolbar.openLink,"data-testid":"link-open-button","aria-label":a.aria.linkOpenButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:k=>{k.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:k=>{k.currentTarget.style.backgroundColor="transparent"},children:i.jsx(mi,{})}),i.jsx("button",{type:"button",onClick:m,"data-tooltip":a.toolbar.clearLink,"data-testid":"link-clear-button","aria-label":a.aria.linkClearButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:k=>{k.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:k=>{k.currentTarget.style.backgroundColor="transparent"},children:i.jsx(yi,{})})]})]})})})})]})}const cc=[{name:"Default",value:null,color:"#1f2937"},{name:"Gray",value:"#6b7280",color:"#6b7280"},{name:"Brown",value:"#92400e",color:"#92400e"},{name:"Orange",value:"#ea580c",color:"#ea580c"},{name:"Orange Dark",value:"#c2410c",color:"#c2410c"},{name:"Green",value:"#16a34a",color:"#16a34a"},{name:"Blue",value:"#2563eb",color:"#2563eb"},{name:"Purple",value:"#9333ea",color:"#9333ea"},{name:"Pink",value:"#ec4899",color:"#ec4899"},{name:"Red",value:"#dc2626",color:"#dc2626"}],uc=[{name:"Default",value:null,color:"#ffffff"},{name:"Gray",value:"#f3f4f6",color:"#f3f4f6"},{name:"Peach",value:"#fed7aa",color:"#fed7aa"},{name:"Orange",value:"#fdba74",color:"#fdba74"},{name:"Yellow",value:"#fde047",color:"#fde047"},{name:"Green",value:"#86efac",color:"#86efac"},{name:"Blue",value:"#93c5fd",color:"#93c5fd"},{name:"Purple",value:"#c084fc",color:"#c084fc"},{name:"Pink",value:"#f9a8d4",color:"#f9a8d4"},{name:"Red",value:"#fca5a5",color:"#fca5a5"}],Mo="pubwave-editor-recent-colors",Nn=5;function dc(){if(typeof window>"u")return[];try{const e=localStorage.getItem(Mo);if(e)return JSON.parse(e)}catch{}return[]}function Hn(e){if(!(typeof window>"u"))try{localStorage.setItem(Mo,JSON.stringify(e))}catch{}}function pc({editor:e,onClose:t,buttonRef:n}){const o=We(),[r,a]=w.useState([]),s=w.useRef(null),l=w.useRef([]);w.useEffect(()=>{const h=dc();h.length>0&&a(h)},[]);const c=()=>{try{const h=e.getAttributes("textColor");return(h==null?void 0:h.color)||null}catch{return null}},f=()=>{try{const h=e.getAttributes("backgroundColor");return(h==null?void 0:h.backgroundColor)||null}catch{return null}},p=c(),y=f(),d=h=>{h===null?e.chain().focus().unsetColor().run():(e.chain().focus().setColor(h).run(),a(v=>{const m=[{type:"text",value:h},...v.filter(B=>!(B.type==="text"&&B.value===h))].slice(0,Nn);return Hn(m),m}))},b=h=>{h===null?e.chain().focus().unsetBackgroundColor().run():(e.chain().focus().setBackgroundColor(h).run(),a(v=>{const m=[{type:"background",value:h},...v.filter(B=>!(B.type==="background"&&B.value===h))].slice(0,Nn);return Hn(m),m}))};return w.useEffect(()=>{if(!vt()&&s.current)return l.current.forEach(h=>h.destroy()),l.current=[],requestAnimationFrame(()=>{if(!s.current)return;s.current.querySelectorAll("[data-tooltip]").forEach(v=>{const C=v.getAttribute("data-tooltip");if(C){const m=Oe(v,{content:C,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});l.current.push(m)}})}),()=>{l.current.forEach(h=>h.destroy()),l.current=[]}},[r,p,y,o]),i.jsx(dn,{isOpen:!0,buttonRef:n,align:"center",margin:8,onClickOutside:()=>t==null?void 0:t(),className:"pubwave-color-picker","data-testid":"color-picker",style:{backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1))",padding:"12px",minWidth:"240px",zIndex:_.zIndex.dropdown+1},children:i.jsxs("div",{ref:s,children:[r.length>0&&i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...Rt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.recentlyUsed}),i.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:r.map((h,v)=>i.jsx("button",{type:"button",onClick:()=>{h.type==="text"?d(h.value):b(h.value)},style:{width:"24px",height:"24px",borderRadius:"4px",border:"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:h.type==="background"?h.value:"#ffffff",cursor:"pointer",padding:h.type==="text"?"4px":0,display:h.type==="text"?"flex":"block",alignItems:h.type==="text"?"center":"normal",justifyContent:h.type==="text"?"center":"normal"},"data-tooltip":h.type==="text"?`${h.value} text`:`${h.value} background`,children:h.type==="text"&&i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:h.value,lineHeight:1},children:"A"})},`${h.type}-${h.value}-${v}`))})]}),i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...Rt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.textColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:cc.map(h=>{const v=p===h.value;return i.jsx("button",{type:"button",onClick:()=>d(h.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:v?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:"#ffffff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center"},"data-tooltip":h.value?`${h.name} text`:"Default text",children:i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:h.color},children:"A"})},h.name)})})]}),i.jsxs("div",{children:[i.jsx("div",{style:{...Rt,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.backgroundColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:uc.map(h=>{const v=y===h.value;return i.jsx("button",{type:"button",onClick:()=>b(h.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:v?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:h.color,cursor:"pointer",padding:0},"data-tooltip":h.value?`${h.name} background`:"Default background"},h.name)})})]})]})})}function fc({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=We(),a=w.useRef(null),s=()=>{try{const h=e.getAttributes("textColor");return(h==null?void 0:h.color)||null}catch{return null}},l=()=>{try{if(!e.isActive("backgroundColor"))return null;const h=e.getAttributes("backgroundColor");return(h==null?void 0:h.backgroundColor)||null}catch{return null}},c=s(),f=l(),p=c||f,d=c||(()=>{if(typeof window>"u")return"#1f2937";const h=document.querySelector(".pubwave-editor");return h&&window.getComputedStyle(h).getPropertyValue("--pubwave-text").trim()||"#1f2937"})(),b=f;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(Me,{ref:a,active:!!p,onClick:n,"data-tooltip":Ie(r.toolbar.textColor),"data-testid":"toolbar-colorPicker","aria-label":r.aria.colorPickerButton,children:i.jsx(xi,{textColor:d,backgroundColor:b})}),t&&i.jsx(pc,{editor:e,onClose:o,buttonRef:a})]})}function hc({editor:e,selectionState:t}){const n=We(),[o,r]=w.useState(null),a=w.useCallback(()=>{r(null),e.chain().focus().toggleBold().run()},[e]),s=w.useCallback(()=>{r(null),e.chain().focus().toggleItalic().run()},[e]),l=w.useCallback(()=>{r(null),e.chain().focus().toggleUnderline().run()},[e]),c=w.useCallback(()=>{r(null),e.chain().focus().toggleStrike().run()},[e]),f=w.useCallback(()=>{r(null),e.chain().focus().toggleCode().run()},[e]),p=w.useCallback(()=>{r(B=>B==="turnInto"?null:"turnInto")},[]),y=w.useCallback(()=>{r(B=>B==="link"?null:"link")},[]),d=w.useCallback(()=>{r(B=>B==="colorPicker"?null:"colorPicker")},[]),b=(t==null?void 0:t.isBold)??!1,h=(t==null?void 0:t.isItalic)??!1,v=(t==null?void 0:t.isUnderline)??!1,C=(t==null?void 0:t.isStrike)??!1,m=(t==null?void 0:t.isCode)??!1;return i.jsxs(i.Fragment,{children:[i.jsx(nc,{editor:e,isOpen:o==="turnInto",onToggle:p,onClose:()=>r(null)}),i.jsx(_n,{}),i.jsx(Me,{active:b,onClick:a,"data-tooltip":Ie(n.toolbar.bold,it.bold),"data-testid":"toolbar-bold","aria-label":n.aria.boldButton,children:i.jsx(pi,{})}),i.jsx(Me,{active:h,onClick:s,"data-tooltip":Ie(n.toolbar.italic,it.italic),"data-testid":"toolbar-italic","aria-label":n.aria.italicButton,children:i.jsx(fi,{})}),i.jsx(Me,{active:v,onClick:l,"data-tooltip":Ie(n.toolbar.underline,it.underline),"data-testid":"toolbar-underline","aria-label":n.aria.underlineButton,children:i.jsx(hi,{})}),i.jsx(Me,{active:C,onClick:c,"data-tooltip":Ie(n.toolbar.strike,it.strike),"data-testid":"toolbar-strike","aria-label":n.aria.strikeButton,children:i.jsx(bi,{})}),i.jsx(Me,{active:m,onClick:f,"data-tooltip":Ie(n.toolbar.code,it.code),"data-testid":"toolbar-code","aria-label":n.aria.codeButton,children:i.jsx(vi,{})}),i.jsx(_n,{}),i.jsx(lc,{editor:e,isOpen:o==="link",onToggle:y,onClose:()=>r(null),selectionState:t}),i.jsx(fc,{editor:e,isOpen:o==="colorPicker",onToggle:d,onClose:()=>r(null)})]})}const st=8;function ze(e){return!e.isDestroyed}function bc(e,t){if(!t)return{top:0,left:0,visible:!1};const{view:n}=e,{from:o,to:r}=n.state.selection,a=n.coordsAtPos(o),s=n.coordsAtPos(r),l=Math.min(a.top,s.top),c=Math.min(a.left,s.left),f=Math.max(a.right,s.right),p=t.getBoundingClientRect(),y=p.width,d=p.height,b=Math.max(a.bottom,s.bottom),h=jo(l,b,d,st);let v;h==="top"?v=l-d-st:v=b+st;const m=So(c,f,y,"center",st).left,B=window.innerWidth,k=window.innerHeight,u=st,T=Math.max(u,Math.min(m,B-y-u));return{top:Math.max(u,Math.min(v,k-d-u)),left:T,visible:!0}}function Po({editor:e,className:t,children:n,onVisibilityChange:o}){const r=w.useRef(null),a=w.useRef(!1),s=w.useRef(0),l=w.useRef(!1),[c,f]=w.useState({top:0,left:0,visible:!1}),[p,y]=w.useState(null),[d,b]=w.useState(!1),h=w.useRef([]),v=w.useMemo(()=>!ze(e)||a.current||!d?!1:Mt(e),[e,p,d]),C=w.useCallback(()=>{if(!ze(e))return;const k=un(e);y(k)},[e]),m=w.useCallback(()=>{if(!v||!r.current){f(k=>({...k,visible:!1}));return}ce(()=>{if(!ze(e))return;const k=bc(e,r.current);f(k)})},[e,v]);w.useEffect(()=>{if(!ze(e))return;const u=e.view.dom.closest(".pubwave-editor"),T=E=>{const H=E.target,G=r.current;if(G&&H&&G.contains(H)){a.current=!1;return}u&&H&&u.contains(H)?l.current=!0:l.current=!1,a.current=!0,b(!1)},A=E=>{const H=Date.now(),S=H-s.current<300;s.current=H;const K=E.target,g=r.current;if(g&&K&&g.contains(K)){a.current=!1;return}if(a.current=!1,!l.current){b(!1);return}setTimeout(()=>{ze(e)&&(Mt(e)?(C(),b(!0),ce(()=>{m()})):(b(!1),f(I=>({...I,visible:!1}))))},S?100:10)};return document.addEventListener("mousedown",T),document.addEventListener("mouseup",A),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("mouseup",A)}},[e,C,m]),w.useEffect(()=>{if(!ze(e))return;C();const k=()=>{!a.current&&d&&C()},u=()=>{a.current||(C(),Mt(e)?b(!0):b(!1),ce(()=>{m()}))},T=()=>{setTimeout(()=>{const A=document.activeElement,E=r.current;E&&A&&E.contains(A)||(b(!1),k())},0)};return e.on("update",k),e.on("selectionUpdate",u),e.on("focus",u),e.on("blur",T),()=>{e.off("update",k),e.off("selectionUpdate",u),e.off("focus",u),e.off("blur",T)}},[e,C,m,d]),w.useEffect(()=>{m(),o==null||o(v)},[v,m,o]),w.useEffect(()=>{if(!v)return;const k=()=>{m()};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[v,m]);const B=We();return w.useEffect(()=>{if(!vt()){if(!v||!c.visible||!r.current){h.current.forEach(k=>k.destroy()),h.current=[];return}return h.current.forEach(k=>k.destroy()),h.current=[],ce(()=>{if(!r.current)return;r.current.querySelectorAll("[data-tooltip]").forEach(u=>{const T=u.getAttribute("data-tooltip");if(T){const A=Oe(u,{content:T,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});h.current.push(A)}})}),()=>{h.current.forEach(k=>k.destroy()),h.current=[]}}},[v,c.visible,B]),ze(e)?i.jsx("div",{ref:r,className:Ve("pubwave-toolbar",v&&c.visible?"pubwave-toolbar--visible":"pubwave-toolbar--hidden",t),style:{position:"fixed",top:c.top,left:c.left,zIndex:_.zIndex.toolbar,opacity:v&&c.visible?1:0,pointerEvents:v&&c.visible?"auto":"none",transform:v&&c.visible?"translateY(0)":"translateY(4px)",transition:`opacity ${_.transition.fast}, transform ${_.transition.fast}`,isolation:"isolate"},role:"toolbar","aria-label":Et.toolbar,"aria-hidden":!v||!c.visible,"data-testid":"bubble-toolbar",children:i.jsx("div",{className:"pubwave-toolbar__content",style:{display:"flex",alignItems:"center",gap:0,padding:"var(--pubwave-spacing-1, 4px)",backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",color:"var(--pubwave-text)",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))"},children:n??i.jsx(hc,{editor:e,selectionState:p})})}):null}const vc=768;function gc(e,t,n){if(!e||!(e instanceof Node))return null;try{if(e instanceof HTMLElement){const a=e.closest("table");if(a&&t.contains(a))return a}const o=n.view.posAtDOM(e,0),r=n.state.doc.resolve(o);for(let a=r.depth;a>0;a--)if(r.node(a).type.name==="layout"){const l=n.view.nodeDOM(r.before(a));if(l&&t.contains(l))return l;break}if(r.depth>=1){const a=r.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(a.type.name)){const l=n.view.nodeDOM(r.before(1));if(l&&t.contains(l))return l}}for(let a=r.depth;a>0;a--)if(r.node(a).isBlock){const l=r.before(a),c=n.view.nodeDOM(l);if(c&&t.contains(c))return c}}catch{let r=e instanceof HTMLElement?e:e.parentElement;for(;r&&r.parentElement;){if(r.parentElement===t)return r;r=r.parentElement}}return null}function zn(e,t,n,o){if(e.childCount===0)return null;let r=t+1;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(a===n){let l=r+1;for(let c=0;c<s.childCount;c++){const f=s.child(c);if(c===o)return l+1;l+=f.nodeSize}return null}r+=s.nodeSize}return null}function Do({editor:e}){var ne,oe,se;const t=w.useRef(null),n=w.useRef(null),o=w.useRef(!1),r=w.useRef(null),[a,s]=w.useState(!1),[l,c]=w.useState(!1),[f,p]=w.useState({top:0}),[y,d]=w.useState(!1),[b,h]=w.useState(!1),[v,C]=w.useState({showRow:!1,showCol:!1,rect:null}),m=w.useRef(null),B=w.useRef(v),k=w.useRef(null),u=w.useRef(null),T=w.useCallback(L=>{var O,U,V,J,$,Y,q,Z;const R=B.current;R.showRow===L.showRow&&R.showCol===L.showCol&&((O=R.rect)==null?void 0:O.top)===((U=L.rect)==null?void 0:U.top)&&((V=R.rect)==null?void 0:V.left)===((J=L.rect)==null?void 0:J.left)&&(($=R.rect)==null?void 0:$.width)===((Y=L.rect)==null?void 0:Y.width)&&((q=R.rect)==null?void 0:q.height)===((Z=L.rect)==null?void 0:Z.height)||(B.current=L,C(L))},[]),A=w.useCallback((L,R)=>{var ie;if(o.current||y||b){T({showRow:!1,showCol:!1,rect:null}),m.current=null;return}const O=L.target;if(!O){T({showRow:!1,showCol:!1,rect:null}),m.current=null;return}const U=O.closest(".pubwave-table-add-column"),V=O.closest(".pubwave-table-add-row");if(U||V){const ee=((ie=m.current)==null?void 0:ie.getBoundingClientRect())??B.current.rect;if(!ee)return;T({showRow:V?!0:B.current.showRow,showCol:U?!0:B.current.showCol,rect:ee});return}const J=O.closest(".tableWrapper");let $=O.closest("table");!$&&J instanceof HTMLElement&&($=J.querySelector("table"));const Y=14,q=56,Z=20,re=ee=>{const ae=L.clientY>=ee.top-Z&&L.clientY<=ee.bottom+Z,ue=L.clientX>=ee.left-Z&&L.clientX<=ee.right+Z,ve=ae&&L.clientX>=ee.right-Y&&L.clientX<=ee.right+q,ge=ue&&L.clientY>=ee.bottom-Y&&L.clientY<=ee.bottom+q;return{nearRight:ve,nearBottom:ge}};if($&&R.contains($)){const ee=$.getBoundingClientRect(),{nearRight:ae,nearBottom:ue}=re(ee);if(!ae&&!ue){T({showRow:!1,showCol:!1,rect:null}),m.current=null;return}m.current=$,T({showRow:ue,showCol:ae,rect:ee});return}if(m.current){const ee=m.current.getBoundingClientRect(),{nearRight:ae,nearBottom:ue}=re(ee);if(ae||ue){T({showRow:ue,showCol:ae,rect:ee});return}}T({showRow:!1,showCol:!1,rect:null}),m.current=null},[y,b,T]),E=w.useCallback(()=>{const L=m.current;if(!L)return null;try{const R=e.view.posAtDOM(L,0),O=ot(e.state.doc,R);return!O||O.node.type.name!=="table"?null:O}catch{return null}},[e]),H=w.useCallback(()=>{const L=E();if(!L)return;const R=Math.max(0,L.node.childCount-1),O=L.node.child(R),U=Math.max(0,O.childCount-1),V=zn(L.node,L.pos,R,U);V!=null&&(e.chain().focus().setTextSelection(V).addRowAfter().run(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(m.current){const J=m.current.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:J})}})}))},[e,E]),G=w.useCallback(()=>{const L=E();if(!L)return;const R=L.node.child(0),O=Math.max(0,R.childCount-1),U=zn(L.node,L.pos,0,O);U!=null&&(e.chain().focus().setTextSelection(U).addColumnAfter().run(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(m.current){const V=m.current.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:V})}})}))},[e,E]);w.useEffect(()=>{const L=()=>{d(vt()),h(window.innerWidth<vc)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[]);const S=w.useCallback(()=>{const L=t.current,R=n.current;if(!L||!R)return;const O=L.closest(".pubwave-editor");if(!O)return;O.offsetHeight;const U=O.getBoundingClientRect();let V=14,J=R;if(R.classList.contains("pubwave-editor__layout")||R.getAttribute("data-type")==="layout"){const q=R.querySelector(".pubwave-layout__column-content p");q instanceof HTMLElement&&(J=q)}if(["UL","OL","BLOCKQUOTE"].includes(R.tagName)&&R.firstElementChild instanceof HTMLElement&&(J=R.firstElementChild),R.tagName==="TABLE"){const q=R.querySelector("thead")||R.querySelector("tr");q instanceof HTMLElement&&(J=q)}J.offsetHeight;const $=J.getBoundingClientRect();try{const q=window.getComputedStyle(J),Z=q.lineHeight;if(Z&&Z!=="normal"){const re=parseFloat(Z);isNaN(re)||(V=re/2)}else{const re=parseFloat(q.fontSize);isNaN(re)||(V=re*1.5/2)}}catch{}const Y=$.top-U.top+V;!isNaN(Y)&&isFinite(Y)&&Y>=0&&p({top:Y})},[]),K=w.useCallback(L=>{n.current=L,s(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{S()})})},[S]),g=w.useCallback(()=>{o.current||(n.current=null,s(!1))},[]),j=w.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);w.useEffect(()=>{const L=e.view.dom,R=L.closest(".pubwave-editor");if(!R)return;const O=Y=>{if(o.current)return;const q=Y.target;if(!q||(j(),q.closest(".pubwave-block-handle"))||!L.contains(q))return;const Z=gc(q,L,e);Z&&(Z!==n.current?K(Z):s(!0))},U=Y=>{if(o.current)return;const q=Y.relatedTarget;if(!q){j(),r.current=setTimeout(()=>{g()},150);return}q.closest(".pubwave-block-handle")||L.contains(q)||q.closest(".pubwave-editor")||(j(),r.current=setTimeout(()=>{g()},150))},V=Y=>{const q=Y.target;if(!q){A(Y,L);return}if(q.closest(".pubwave-table-add-column")||q.closest(".pubwave-table-add-row")){A(Y,L);return}if(!R.contains(q)){T({showRow:!1,showCol:!1,rect:null}),m.current=null;return}A(Y,L)},J=()=>{o.current||(j(),r.current=setTimeout(()=>{g()},150),T({showRow:!1,showCol:!1,rect:null}),m.current=null)};L.addEventListener("mouseover",O),L.addEventListener("mouseout",U),document.addEventListener("mousemove",V),R.addEventListener("mouseleave",J);const $=({transaction:Y})=>{Y.docChanged&&!o.current&&g()};return e.on("transaction",$),()=>{L.removeEventListener("mouseover",O),L.removeEventListener("mouseout",U),document.removeEventListener("mousemove",V),R.removeEventListener("mouseleave",J),e.off("transaction",$),j()}},[e,K,g,j,A,T]),w.useEffect(()=>{a&&n.current&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{S()})})},[a,S]),w.useEffect(()=>{if(!a&&!v.showRow&&!v.showCol)return;const L=()=>{if(n.current&&S(),m.current&&B.current.rect){const R=m.current.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:R})}};return window.addEventListener("scroll",L,!0),()=>window.removeEventListener("scroll",L,!0)},[a,v.showRow,v.showCol,S,T]),w.useEffect(()=>{const L=m.current;if(!(L&&(v.showRow||v.showCol))){k.current&&(k.current.disconnect(),k.current=null),u.current=null;return}if(u.current!==L){if(k.current&&k.current.disconnect(),typeof ResizeObserver<"u"){const U=new ResizeObserver(()=>{if(!m.current)return;const V=m.current.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:V})});U.observe(L),k.current=U}u.current=L}if(L){const U=L.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:U})}const O=()=>{if(!m.current)return;const U=m.current.getBoundingClientRect();T({showRow:B.current.showRow,showCol:B.current.showCol,rect:U})};return window.addEventListener("resize",O),()=>{window.removeEventListener("resize",O),k.current&&(k.current.disconnect(),k.current=null),u.current=null}},[v.showRow,v.showCol,T]);const I=w.useCallback(()=>{const L=n.current;if(L)try{const R=e.view.posAtDOM(L,0),O=e.state.doc.resolve(R);let U=R;for(let $=O.depth;$>0;$--)if(O.node($).isBlock){U=O.start($);break}const J=e.state.doc.resolve(U).after(1);e.chain().focus().insertContentAt(J,{type:"paragraph"}).setTextSelection(J+1).run(),setTimeout(()=>{e.commands.insertContent("/")},10)}catch(R){console.error("Failed to add block:",R)}},[e]),F=w.useCallback(L=>{const R=n.current;if(!R)return;o.current=!0,requestAnimationFrame(()=>{c(!0)});const O=e.view.posAtDOM(R,0),U=ot(e.state.doc,O);if(!U)return;const V=U.pos,J=`block-${V}`;Bo(e,J,V),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("application/x-pubwave-block",J),R.classList.add("pubwave-block--dragging");const $=R.cloneNode(!0);$.classList.add("pubwave-block--drag-preview"),$.style.opacity="1";const Y=ee=>{ee.style.setProperty("color","#9b9a97","important"),ee.style.setProperty("border-color","#9b9a97","important"),ee.style.setProperty("--pubwave-text","#9b9a97","important"),Array.from(ee.children).forEach(ae=>{ae instanceof HTMLElement&&Y(ae)})};Y($);const q=R.getBoundingClientRect();$.style.width=`${q.width}px`,$.style.position="static",$.style.transform="none";const Z=document.createElement("div");Z.className="pubwave-editor";const re=document.createElement("div");re.className="pubwave-editor__content";const ie=document.createElement("div");ie.className="ProseMirror",ie.appendChild($),re.appendChild(ie),Z.appendChild(re),Z.style.position="absolute",Z.style.top="-9999px",Z.style.left="-9999px",document.body.appendChild(Z),L.dataTransfer.setDragImage($,0,0),setTimeout(()=>{document.body.removeChild(Z)},0)},[e]),X=w.useCallback(()=>{o.current=!1,c(!1),n.current&&n.current.classList.remove("pubwave-block--dragging"),s(!1)},[]),W=v.showRow||v.showCol;if(y||b||!a&&!W)return null;const z=((ne=m.current)==null?void 0:ne.closest(".pubwave-editor"))||((oe=t.current)==null?void 0:oe.closest(".pubwave-editor")),M=z?z.getBoundingClientRect():null,D=((se=m.current)==null?void 0:se.getBoundingClientRect())||v.rect;return i.jsxs(i.Fragment,{children:[D&&M&&i.jsxs(i.Fragment,{children:[v.showCol&&i.jsx("button",{type:"button",className:"pubwave-table-add-column",onClick:L=>{L.stopPropagation(),G()},style:{position:"fixed",left:`${D.right+2}px`,top:`${D.top}px`,width:"16px",height:`${D.height}px`,border:"none",padding:0,background:"transparent",cursor:"pointer",zIndex:_.zIndex.dragHandle},"aria-label":"Add column",title:"Add column",children:i.jsx("div",{style:{position:"relative",width:"12px",height:"100%",margin:"0 auto",borderRadius:"999px",background:`var(--pubwave-border, ${_.colors.border})`},children:i.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",alignItems:"center",justifyContent:"center",color:`var(--pubwave-text-muted, ${_.colors.textMuted})`,fontSize:"14px",fontWeight:700,lineHeight:"14px"},children:"+"})})}),v.showRow&&i.jsx("button",{type:"button",className:"pubwave-table-add-row",onClick:L=>{L.stopPropagation(),H()},style:{position:"fixed",left:`${D.left}px`,top:`${D.bottom+2}px`,width:`${D.width}px`,height:"16px",border:"none",padding:0,background:"transparent",cursor:"pointer",zIndex:_.zIndex.dragHandle},"aria-label":"Add row",title:"Add row",children:i.jsx("div",{style:{position:"relative",width:"100%",height:"12px",margin:"0 auto",borderRadius:"999px",background:`var(--pubwave-border, ${_.colors.border})`},children:i.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",alignItems:"center",justifyContent:"center",color:`var(--pubwave-text-muted, ${_.colors.textMuted})`,fontSize:"14px",fontWeight:700,lineHeight:"14px"},children:"+"})})})]}),i.jsxs("div",{ref:t,className:"pubwave-block-handle","data-testid":"block-handle",style:{position:"absolute",left:"calc(var(--pubwave-container-padding-left, 140px) - 80px)",top:`${f.top}px`,transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:"2px",pointerEvents:"auto",transition:`opacity ${_.transition.fast}`,zIndex:_.zIndex.dragHandle,opacity:a&&!l?1:0},onMouseEnter:L=>{L.stopPropagation(),r.current&&(clearTimeout(r.current),r.current=null)},onMouseLeave:L=>{L.stopPropagation();const R=L.relatedTarget,O=R instanceof Element?R:null;O!=null&&O.closest(".pubwave-editor")||(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{g()},150))},children:[i.jsx("button",{type:"button",className:"pubwave-block-handle__add",onClick:I,"data-testid":"add-block-button",style:{width:"var(--pubwave-button-width, 28px)",height:"var(--pubwave-button-height, 28px)",display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:_.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${_.colors.textMuted})`,cursor:"pointer",transition:`background-color ${_.transition.fast}, color ${_.transition.fast}`},title:"Add block","aria-label":"Add block below",children:i.jsx(mc,{})}),i.jsx("div",{className:"pubwave-block-handle__drag",draggable:!0,onDragStart:F,onDragEnd:X,"data-testid":"drag-handle",style:{width:"44px",height:"44px",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:_.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${_.colors.textMuted})`,cursor:"grab",transition:`background-color ${_.transition.fast}, color ${_.transition.fast}`},role:"button",tabIndex:-1,title:"Drag to move","aria-label":"Drag to reorder block",children:i.jsx(wc,{})})]})]})}function mc(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),i.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function wc(){return i.jsxs("svg",{width:"12",height:"18",viewBox:"0 0 10 16",fill:"currentColor",children:[i.jsx("circle",{cx:"2",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}function Io({visible:e,position:t,className:n}){return i.jsxs("div",{className:Ve("pubwave-drop-indicator",e&&"pubwave-drop-indicator--visible",`pubwave-drop-indicator--${t}`,n),"data-testid":"drop-indicator",style:{position:"absolute",left:0,right:0,height:"2px",backgroundColor:`var(--pubwave-drop-indicator-color, ${_.colors.dropIndicator})`,borderRadius:"1px",...t==="before"?{top:"-1px"}:{bottom:"-1px"},opacity:e?1:0,transform:e?"scaleX(1)":"scaleX(0.8)",transition:`opacity ${_.transition.fast}, transform ${_.transition.fast}`,zIndex:10,pointerEvents:"none"},"aria-hidden":"true",children:[i.jsx($n,{position:"left",visible:e}),i.jsx($n,{position:"right",visible:e})]})}function $n({position:e,visible:t}){return i.jsx("div",{className:`pubwave-drop-indicator__cap pubwave-drop-indicator__cap--${e}`,style:{position:"absolute",top:"50%",transform:"translateY(-50%)",...e==="left"?{left:"-4px"}:{right:"-4px"},width:"8px",height:"8px",borderRadius:"50%",backgroundColor:`var(--pubwave-drop-indicator-color, ${_.colors.dropIndicator})`,opacity:t?1:0,transition:`opacity ${_.transition.fast}`}})}function yc({editor:e}){const[t,n]=w.useState(null),[o,r]=w.useState(null);return w.useEffect(()=>{const a=pe.getState(e.state);a&&n(a);const s=()=>{const l=pe.getState(e.state);l&&(l.dropTargetPos!==(t==null?void 0:t.dropTargetPos)||l.dropPosition!==(t==null?void 0:t.dropPosition))&&n(l)};return e.on("transaction",s),()=>{e.off("transaction",s)}},[e,t]),w.useEffect(()=>{if(!(t!=null&&t.dropTargetPos)||!t.dropPosition){r(null);return}const a=requestAnimationFrame(()=>{var b;const s=e.view,l=t.dropTargetPos;if(l===null)return;let c=s.nodeDOM(l);if(!c&&l>0){const h=s.domAtPos(l).node;h instanceof HTMLElement&&(c=h)}if(!c||!(c instanceof HTMLElement))return;const f=c.getBoundingClientRect(),p=(b=s.dom.closest(".pubwave-editor"))==null?void 0:b.getBoundingClientRect();if(!p)return;const y=8;let d=0;t.dropPosition==="before"?d=f.top-p.top-y:d=f.bottom-p.top+y,r({top:d,left:f.left-p.left,width:f.width})});return()=>cancelAnimationFrame(a)},[t,e]),!(t!=null&&t.dropTargetPos)||!t.dropPosition||!o?null:i.jsx("div",{style:{position:"absolute",top:o.top,left:o.left,width:o.width,height:"2px",pointerEvents:"none",zIndex:50},children:i.jsx(Io,{visible:!0,position:t.dropPosition,className:"pubwave-drop-indicator--overlay"})})}const xc=w.forwardRef(function(t,n){const{content:o,editable:r=!0,placeholder:a,theme:s,autofocus:l=!1,imageUpload:c,onChange:f,onSelectionChange:p,onFocus:y,onBlur:d,onReady:b,className:h,width:v,height:C,minHeight:m,"data-testid":B="pubwave-editor"}=t,k=jt(s==null?void 0:s.locale),u=a??k.placeholder??'Write,type "/" for commands...',T=Pe.useEditor({extensions:cn({placeholder:u,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:c,locale:s==null?void 0:s.locale}),content:o,editable:r,autofocus:l,immediatelyRender:!1,editorProps:{attributes:{class:`pubwave-editor__content ${(s==null?void 0:s.contentClassName)??""}`.trim(),"data-placeholder":u}},onUpdate:({editor:g})=>{f==null||f(g.getJSON())},onSelectionUpdate:()=>{p==null||p()},onFocus:()=>{y==null||y()},onBlur:()=>{d==null||d()},onCreate:({editor:g})=>{const j=A(g);b==null||b(j)}}),A=w.useCallback(g=>({getState:()=>({selection:{hasSelection:!(g!=null&&g.state.selection.empty),isMultiBlock:!1,from:(g==null?void 0:g.state.selection.from)??0,to:(g==null?void 0:g.state.selection.to)??0,isEmpty:(g==null?void 0:g.state.selection.empty)??!0},marks:{isBold:(g==null?void 0:g.isActive("bold"))??!1,isItalic:(g==null?void 0:g.isActive("italic"))??!1,isLink:(g==null?void 0:g.isActive("link"))??!1,linkHref:g?g.getAttributes("link").href:void 0},isFocused:(g==null?void 0:g.isFocused)??!1,isEditable:(g==null?void 0:g.isEditable)??!1,isEmpty:(g==null?void 0:g.isEmpty)??!0,characterCount:0}),getJSON:()=>(g==null?void 0:g.getJSON())??{type:"doc",content:[]},getHTML:()=>(g==null?void 0:g.getHTML())??"",getText:()=>(g==null?void 0:g.getText())??"",setContent:j=>g==null?void 0:g.commands.setContent(j),clearContent:()=>g==null?void 0:g.commands.clearContent(),setEditable:j=>g==null?void 0:g.setEditable(j),focus:j=>{j==="start"?g==null||g.commands.focus("start"):j==="end"?g==null||g.commands.focus("end"):g==null||g.commands.focus()},blur:()=>g==null?void 0:g.commands.blur(),toggleBold:()=>g==null?void 0:g.chain().focus().toggleBold().run(),toggleItalic:()=>g==null?void 0:g.chain().focus().toggleItalic().run(),setLink:j=>{j?g==null||g.chain().focus().setLink({href:j}).run():g==null||g.chain().focus().unsetLink().run()},destroy:()=>g==null?void 0:g.destroy(),tiptapEditor:g??null}),[]);w.useImperativeHandle(n,()=>T?A(T):null,[T,A]);const[E,H]=w.useState(!1);w.useEffect(()=>{H(!0)},[]),w.useEffect(()=>{var j;if(!((j=T==null?void 0:T.view)!=null&&j.dom))return;const g=T.view.dom;g&&g.setAttribute("data-placeholder",u)},[T,u,s==null?void 0:s.locale]);const G=["pubwave-editor",(s==null?void 0:s.classNamePrefix)??"",(s==null?void 0:s.containerClassName)??"",T?Ql(T):"",C||m?"pubwave-editor--fixed-height":"",h].filter(Boolean).join(" "),S={position:"relative",overflow:C||m?"hidden":"visible",...C||m?{display:"flex",flexDirection:"column"}:{}};if(v&&(S["--pubwave-container-width"]=v,S.width=v,S["--pubwave-container-max-width"]=v,S.maxWidth=v),C&&(S["--pubwave-container-height"]=C,S.height=C),m&&(S["--pubwave-container-min-height"]=m,S.minHeight=m),s!=null&&s.colors){const{colors:g}=s,I=(g.text||"#1f2937").toLowerCase().trim(),F=I.startsWith("#f")||I.startsWith("#e")||I.includes("f1")||I.includes("f3")||I.includes("f0")||I.includes("fdf")||I.includes("ffb")||I.includes("ffc")||I.includes("ffd")||I.includes("ffe")||I.includes("fff")||I.includes("e0")||I.includes("e5")||I.includes("ecf")||I.includes("eef");g.background&&(g.background.includes("gradient")?(S.background=g.background,F?(S["--pubwave-surface"]="rgba(38, 38, 38, 0.95)",S["--pubwave-bg"]="#1a1a1a"):(S["--pubwave-surface"]="rgba(255, 255, 255, 0.95)",S["--pubwave-bg"]="#ffffff")):(S["--pubwave-bg"]=g.background,S["--pubwave-surface"]=g.background)),g.text&&(S["--pubwave-text"]=g.text),g.textMuted&&(S["--pubwave-text-muted"]=g.textMuted),g.border&&(S["--pubwave-border"]=g.border),g.primary&&(S["--pubwave-primary"]=g.primary),g.linkColor&&(S["--pubwave-link-color"]=g.linkColor),F?S["--pubwave-hover"]="rgba(255, 255, 255, 0.1)":S["--pubwave-hover"]="rgba(0, 0, 0, 0.05)"}if(s!=null&&s.backgroundImage){const g=s.backgroundImage,j=s.backgroundImageOptions||{};g.startsWith("url(")||g.includes("gradient")||g.includes("linear-gradient")||g.includes("radial-gradient")?S.backgroundImage=g:S.backgroundImage=`url(${g})`,j.repeat!==void 0?S.backgroundRepeat=j.repeat:S.backgroundRepeat="no-repeat",j.position!==void 0?S.backgroundPosition=j.position:S.backgroundPosition="center",j.size!==void 0?S.backgroundSize=j.size:S.backgroundSize="cover",j.attachment!==void 0?S.backgroundAttachment=j.attachment:S.backgroundAttachment="scroll"}if(!E||!T)return i.jsx(hn,{value:{locale:k},children:i.jsx("div",{className:G,"data-testid":B,role:"application","aria-label":Et.editor,style:S})});const K=g=>{if(!T||!r||g.button!==0||g.defaultPrevented)return;const j=g.target;if(!j)return;const I=T.view.dom;if(I&&I.contains(j))return;const F=I==null?void 0:I.lastElementChild,X=g.currentTarget.getBoundingClientRect();if(g.clientX<X.left||g.clientX>X.right||g.clientY<X.top||g.clientY>X.bottom)return;if(F){const ne=F.getBoundingClientRect();if(g.clientY<=ne.bottom+1)return}const{state:W}=T,z=W.schema.nodes.paragraph;if(!z)return;const M=W.doc.content.size,D=W.doc.lastChild;if(D&&D.type===z&&D.content.size===0){T.chain().focus().setTextSelection(Math.max(1,M-1)).run();return}T.chain().focus().insertContentAt(M,{type:"paragraph"}).setTextSelection(M+1).run()};return i.jsx(hn,{value:{locale:k},children:i.jsxs("div",{className:G,"data-testid":B,role:"application","aria-label":Et.editor,style:S,onMouseDown:K,children:[i.jsx(Pe.EditorContent,{editor:T}),r&&i.jsx(Po,{editor:T}),r&&i.jsx(Do,{editor:T}),r&&i.jsx(yc,{editor:T})]})})});function Ge(e){return!e.isDestroyed}function Eo(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleBold().run();return _e(e),{success:t,message:t?"Bold toggled":"Could not toggle bold"}}function Oo(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleItalic().run();return _e(e),{success:t,message:t?"Italic toggled":"Could not toggle italic"}}function _o(e,t){if(!Ge(e))return{success:!1,message:"Editor not available"};if(!t.trim())return{success:!1,message:"URL is required"};let n=t.trim();!/^https?:\/\//i.test(n)&&!n.startsWith("/")&&(n=`https://${n}`);const o=e.chain().focus().setLink({href:n}).run();return _e(e),{success:o,message:o?"Link added":"Could not add link"}}function No(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().unsetLink().run();return _e(e),{success:t,message:t?"Link removed":"Could not remove link"}}function Ho(e,t=window.prompt.bind(window)){if(!Ge(e))return{success:!1,message:"Editor not available"};if(e.isActive("link"))return No(e);const o=t("Enter URL:");return o?_o(e,o):(_e(e),{success:!1,message:"Link cancelled"})}function kc(e,t){if(!Ge(e))return{success:!1,message:"Editor not available"};const n=e.chain().focus().setHeading({level:t}).run();_e(e);const o=String(t);return{success:n,message:n?`Heading ${o} applied`:"Could not set heading"}}function Cc(e){if(!Ge(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().setParagraph().run();return _e(e),{success:t,message:t?"Paragraph applied":"Could not set paragraph"}}function Tc(e,t,n){return()=>{const o=t(e);n==null||n(o)}}const Lc=[{id:"bold",label:"Bold",shortcut:"Cmd+B",icon:"bold",action:Eo,isActive:e=>e.isActive("bold")},{id:"italic",label:"Italic",shortcut:"Cmd+I",icon:"italic",action:Oo,isActive:e=>e.isActive("italic")},{id:"link",label:"Link",icon:"link",action:e=>Ho(e),isActive:e=>e.isActive("link")}],qn="44px",Un="20px";function Bc({blockId:e,isHovered:t,isDragging:n=!1,onDragStart:o,onDragEnd:r,className:a}){const s=w.useRef(null),[l,c]=w.useState(!1),f=w.useCallback(h=>{if(h.dataTransfer.effectAllowed="move",h.dataTransfer.setData("text/plain",e),h.dataTransfer.setData("application/x-pubwave-block",e),s.current){const v=s.current.getBoundingClientRect();h.dataTransfer.setDragImage(s.current,v.width/2,v.height/2)}o==null||o(e,h)},[e,o]),p=w.useCallback(h=>{c(!1),r==null||r(e,h)},[e,r]),y=w.useCallback(()=>{c(!0)},[]),d=w.useCallback(()=>{c(!1)},[]),b=t||n;return i.jsx("div",{ref:s,className:Ve("pubwave-drag-handle",b&&"pubwave-drag-handle--visible",n&&"pubwave-drag-handle--dragging",l&&"pubwave-drag-handle--pressed",a),"data-testid":"drag-handle",style:{position:"absolute",left:"-32px",top:"50%",transform:"translateY(-50%)",width:qn,height:qn,display:"flex",alignItems:"center",justifyContent:"center",cursor:n?"grabbing":"grab",opacity:b?1:0,transition:`opacity ${_.transition.fast}`,userSelect:"none",WebkitUserSelect:"none"},draggable:!0,onDragStart:f,onDragEnd:p,onMouseDown:y,onMouseUp:d,role:"button","aria-label":Et.dragHandle,tabIndex:b?0:-1,children:i.jsx("div",{className:"pubwave-drag-handle__visual",style:{width:Un,height:Un,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:_.borderRadius.sm,backgroundColor:l?`var(--pubwave-drag-handle-active-bg, ${_.colors.focus})`:"transparent",transition:`background-color ${_.transition.fast}`},children:i.jsx(Ac,{})})})}function Ac(){return i.jsxs("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"currentColor",style:{color:`var(--pubwave-drag-handle-color, ${_.colors.textMuted})`},children:[i.jsx("circle",{cx:"3",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"13",r:"1.5"})]})}const Jt=50,jc=15;function Fn(e){const t=1-e/Jt;return Math.round(t*jc)}function zo(e){const t={isActive:!1,direction:null,speed:0,animationId:null},n=()=>e??window,o=()=>{if(e){const a=e.getBoundingClientRect();return{top:a.top,bottom:a.bottom}}return{top:0,bottom:window.innerHeight}},r=()=>{if(!t.isActive||t.direction===null)return;const a=n(),s=t.direction==="up"?-t.speed:t.speed;a===window?window.scrollBy(0,s):a instanceof HTMLElement&&(a.scrollTop+=s),t.animationId=ce(r)};return{start(){t.isActive=!0},update(a){if(!t.isActive)return;const s=o(),l=a-s.top,c=s.bottom-a;l<Jt?(t.direction="up",t.speed=Fn(l)):c<Jt?(t.direction="down",t.speed=Fn(c)):(t.direction=null,t.speed=0),t.direction!==null&&t.animationId===null?t.animationId=ce(r):t.direction===null&&t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)},stop(){t.isActive=!1,t.direction=null,t.speed=0,t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)}}}function Sc(e){let t=null;const n=()=>(t??(t=zo(e)),t);return{startAutoScroll(){n().start()},updateAutoScroll(o){n().update(o.clientY)},stopAutoScroll(){n().stop(),t=null}}}const Rc=3e3;function $o({message:e,type:t="info",duration:n=Rc,onDismiss:o,className:r}){const[a,s]=w.useState(!0);w.useEffect(()=>{if(n<=0)return;const f=setTimeout(()=>{s(!1),o==null||o()},n);return()=>{clearTimeout(f)}},[n,o]);const l=w.useCallback(()=>{s(!1),o==null||o()},[o]),c={info:_.colors.text,success:"var(--pubwave-color-success, #10b981)",error:_.colors.error,warning:"var(--pubwave-color-warning, #f59e0b)"};return i.jsxs("div",{className:Ve("pubwave-toast",`pubwave-toast--${t}`,a?"pubwave-toast--visible":"pubwave-toast--hidden",r),style:{position:"fixed",bottom:"24px",left:"50%",transform:`translateX(-50%) translateY(${a?"0":"16px"})`,padding:`${_.spacing.sm} ${_.spacing.md}`,backgroundColor:`var(--pubwave-toast-bg, ${_.colors.surface})`,border:`1px solid var(--pubwave-toast-border, ${_.colors.border})`,borderRadius:_.borderRadius.md,boxShadow:_.shadow.md,color:c[t],fontSize:_.typography.fontSizeSmall,opacity:a?1:0,transition:`opacity ${_.transition.normal}, transform ${_.transition.normal}`,zIndex:100,maxWidth:"400px",textAlign:"center"},role:"status","aria-live":"polite",children:[i.jsx("span",{className:"pubwave-toast__message",children:e}),i.jsx("button",{type:"button",className:"pubwave-toast__dismiss",onClick:l,style:{marginLeft:_.spacing.sm,padding:"0 4px",background:"none",border:"none",color:_.colors.textMuted,cursor:"pointer",fontSize:"16px",lineHeight:1},"aria-label":"Dismiss",children:"×"})]})}function Mc({toasts:e,onDismiss:t}){return i.jsx("div",{className:"pubwave-toast-container",children:e.map((n,o)=>{const r=24+o*56,a=100-o;return i.jsx("div",{style:{position:"fixed",bottom:`${String(r)}px`,left:"50%",transform:"translateX(-50%)",zIndex:a},children:i.jsx($o,{message:n.message,type:n.type,duration:n.duration,onDismiss:()=>{t(n.id)}})},n.id)})})}function Pc(){const e=String(Date.now()),t=Math.random().toString(36).slice(2,9);return`toast-${e}-${t}`}exports.BlockHandle=Do;exports.BubbleToolbar=Po;exports.DragHandle=Bc;exports.DropIndicator=Io;exports.PubwaveEditor=xc;exports.SUPPORTED_BLOCKS=Bl;exports.SUPPORTED_MARKS=Al;exports.SlashMenuList=Co;exports.Toast=$o;exports.ToastContainer=Mc;exports.canUseDOM=Ot;exports.cancelDrag=ml;exports.clearFormatting=Fl;exports.cn=Ve;exports.createActionHandler=Tc;exports.createAutoScroller=zo;exports.createDndPlugin=Lo;exports.createEditor=jl;exports.createExtensions=cn;exports.createFocusTrap=sc;exports.createSlashCommandsExtension=ko;exports.createToastId=Pc;exports.defaultSlashCommands=Qn;exports.defaultTokens=gl;exports.defaultToolbarActions=Lc;exports.destroyEditor=Sl;exports.dndPluginKey=pe;exports.findBlockAtPos=ot;exports.focusAfterClick=rc;exports.focusAt=oc;exports.focusEditor=ql;exports.getActiveLinkHref=Yl;exports.getActiveMarks=Gl;exports.getDndState=ln;exports.getSelectionBounds=Pl;exports.getSelectionState=un;exports.handleSelectionClear=ic;exports.isEditable=wt;exports.isEditorValid=Rl;exports.isMarkActive=Wl;exports.isMobileDevice=vt;exports.isNodeActive=Vl;exports.isReadOnly=Ao;exports.isSSR=ci;exports.isSelectionEmpty=Ml;exports.maintainFocus=ac;exports.moveBlock=To;exports.redo=$l;exports.restoreFocus=_e;exports.restoreSelection=lt;exports.saveSelection=Ro;exports.selectAll=Ul;exports.setHeading=Nl;exports.setLink=El;exports.setParagraph=_l;exports.shouldAllowInteraction=Zl;exports.shouldAllowToolbar=Kl;exports.shouldRenderEditUI=Xl;exports.shouldShowDragHandle=Jl;exports.shouldShowToolbar=Mt;exports.startDrag=Bo;exports.toggleBold=Dl;exports.toggleHeading=Hl;exports.toggleItalic=Il;exports.tokens=_;exports.toolbarRemoveLink=No;exports.toolbarSetHeading=kc;exports.toolbarSetLink=_o;exports.toolbarSetParagraph=Cc;exports.toolbarToggleBold=Eo;exports.toolbarToggleItalic=Oo;exports.toolbarToggleLink=Ho;exports.undo=zl;exports.unsetLink=Ol;exports.useAutoScroll=Sc;