@nevuto/editors 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -21
- package/dist/index.mjs +57 -57
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -234,32 +234,32 @@ ${n}
|
|
|
234
234
|
<path d="M9 20h6" />`,...t}));Jw.displayName="TypeIcon";var kR=Jw,Gw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M6 4v6a6 6 0 0 0 12 0V4" />
|
|
235
235
|
<line x1="4" x2="20" y1="20" y2="20" />`,...t}));Gw.displayName="UnderlineIcon";var Yw=Gw,Xw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" />
|
|
236
236
|
<path d="M12 9v4" />
|
|
237
|
-
<path d="M12 17h.01" />`,...t}));Xw.displayName="TriangleAlertIcon";var Xf=Xw,Qw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="
|
|
237
|
+
<path d="M12 17h.01" />`,...t}));Xw.displayName="TriangleAlertIcon";var Xf=Xw,Qw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
|
|
238
|
+
<path d="M3 6h18" />
|
|
239
|
+
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />`,...t}));Qw.displayName="TrashIcon";var SR=Qw,Zw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M10 11v6" />
|
|
238
240
|
<path d="M14 11v6" />
|
|
239
241
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
|
|
240
242
|
<path d="M3 6h18" />
|
|
241
|
-
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />`,...t}));
|
|
242
|
-
<path d="M3 6h18" />
|
|
243
|
-
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />`,...t}));Zw.displayName="TrashIcon";var SR=Zw,e1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M17 5H3" />
|
|
243
|
+
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />`,...t}));Zw.displayName="Trash2Icon";var Et=Zw,e1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M17 5H3" />
|
|
244
244
|
<path d="M21 12H8" />
|
|
245
245
|
<path d="M21 19H8" />
|
|
246
246
|
<path d="M3 12v7" />`,...t}));e1.displayName="TextQuoteIcon";var t1=e1,n1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5H3" />
|
|
247
|
+
<path d="M15 12H3" />
|
|
248
|
+
<path d="M17 19H3" />`,...t}));n1.displayName="TextAlignStartIcon";var CR=n1,r1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5H3" />
|
|
247
249
|
<path d="M17 12H7" />
|
|
248
|
-
<path d="M19 19H5" />`,...t}));
|
|
250
|
+
<path d="M19 19H5" />`,...t}));r1.displayName="TextAlignCenterIcon";var ER=r1,s1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5H3" />
|
|
249
251
|
<path d="M21 12H9" />
|
|
250
|
-
<path d="M21 19H7" />`,...t}));
|
|
251
|
-
<path d="
|
|
252
|
-
<path d="
|
|
252
|
+
<path d="M21 19H7" />`,...t}));s1.displayName="TextAlignEndIcon";var TR=s1,i1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 15V9" />
|
|
253
|
+
<path d="M3 15h18" />
|
|
254
|
+
<path d="M3 9h18" />
|
|
255
|
+
<rect width="18" height="18" x="3" y="3" rx="2" />`,...t}));i1.displayName="TableCellsSplitIcon";var MR=i1,o1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 3v18" />
|
|
253
256
|
<rect width="18" height="18" x="3" y="3" rx="2" />
|
|
254
257
|
<path d="M3 9h18" />
|
|
255
|
-
<path d="M3 15h18" />`,...t}));
|
|
258
|
+
<path d="M3 15h18" />`,...t}));o1.displayName="TableIcon";var l1=o1,a1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 21v-6" />
|
|
256
259
|
<path d="M12 9V3" />
|
|
257
260
|
<path d="M3 15h18" />
|
|
258
261
|
<path d="M3 9h18" />
|
|
259
|
-
<rect width="18" height="18" x="3" y="3" rx="2" />`,...t}));
|
|
260
|
-
<path d="M3 15h18" />
|
|
261
|
-
<path d="M3 9h18" />
|
|
262
|
-
<rect width="18" height="18" x="3" y="3" rx="2" />`,...t}));a1.displayName="TableCellsSplitIcon";var AR=a1,c1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 4H9a3 3 0 0 0-2.83 4" />
|
|
262
|
+
<rect width="18" height="18" x="3" y="3" rx="2" />`,...t}));a1.displayName="TableCellsMergeIcon";var AR=a1,c1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 4H9a3 3 0 0 0-2.83 4" />
|
|
263
263
|
<path d="M14 12a4 4 0 0 1 0 8H6" />
|
|
264
264
|
<line x1="4" x2="20" y1="12" y2="12" />`,...t}));c1.displayName="StrikethroughIcon";var u1=c1,d1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<rect width="18" height="18" x="3" y="3" rx="2" />',...t}));d1.displayName="SquareIcon";var Qf=d1,f1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z" />
|
|
265
265
|
<path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6" />`,...t}));f1.displayName="SquareMousePointerIcon";var _R=f1,h1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" />',...t}));h1.displayName="SparkleIcon";var NR=h1,p1=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="18" height="18" x="3" y="3" rx="2" />
|
|
@@ -361,15 +361,15 @@ ${n}
|
|
|
361
361
|
<path d="M15 3v18" />`,...t}));tx.displayName="Columns3Icon";var KR=tx,nx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="m16 18 6-6-6-6" />
|
|
362
362
|
<path d="m8 6-6 6 6 6" />`,...t}));nx.displayName="CodeIcon";var nc=nx,rx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="m18 16 4-4-4-4" />
|
|
363
363
|
<path d="m6 8-4 4 4 4" />
|
|
364
|
-
<path d="m14.5 4-5 16" />`,...t}));rx.displayName="CodeXmlIcon";var JR=rx,sx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="m9 18 6-6-6-6" />',...t}));sx.displayName="ChevronRightIcon";var GR=sx,ix=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M20 6 9 17l-5-5" />',...t}));ix.displayName="CheckIcon";var YR=ix,ox=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="m6 9 6 6 6-6" />',...t}));ox.displayName="CaretDownIcon";var wl=ox,lx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',...t}));lx.displayName="BoldIcon";var _d=lx,ax=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M17 6H3" /><path d="M21 12H8" /><path d="M21 18H8" /><path d="M3 12v6" />',...t}));ax.displayName="BlockquoteIcon";var Jm=ax,cx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="
|
|
365
|
-
<path d="m22 15-3-3 3-3" />
|
|
366
|
-
<rect width="13" height="7" x="3" y="14" rx="1" />`,...t}));cx.displayName="BetweenHorizontalEndIcon";var XR=cx,ux=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="8" y="3" rx="1" />
|
|
364
|
+
<path d="m14.5 4-5 16" />`,...t}));rx.displayName="CodeXmlIcon";var JR=rx,sx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="m9 18 6-6-6-6" />',...t}));sx.displayName="ChevronRightIcon";var GR=sx,ix=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M20 6 9 17l-5-5" />',...t}));ix.displayName="CheckIcon";var YR=ix,ox=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="m6 9 6 6 6-6" />',...t}));ox.displayName="CaretDownIcon";var wl=ox,lx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',...t}));lx.displayName="BoldIcon";var _d=lx,ax=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M17 6H3" /><path d="M21 12H8" /><path d="M21 18H8" /><path d="M3 12v6" />',...t}));ax.displayName="BlockquoteIcon";var Jm=ax,cx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="8" y="3" rx="1" />
|
|
367
365
|
<path d="m2 9 3 3-3 3" />
|
|
368
|
-
<rect width="13" height="7" x="8" y="14" rx="1" />`,...t}));
|
|
366
|
+
<rect width="13" height="7" x="8" y="14" rx="1" />`,...t}));cx.displayName="BetweenHorizontalStartIcon";var XR=cx,ux=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="7" height="13" x="3" y="3" rx="1" />
|
|
369
367
|
<path d="m9 22 3-3 3 3" />
|
|
370
|
-
<rect width="7" height="13" x="14" y="3" rx="1" />`,...t}));
|
|
368
|
+
<rect width="7" height="13" x="14" y="3" rx="1" />`,...t}));ux.displayName="BetweenVerticalEndIcon";var QR=ux,dx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="7" height="13" x="3" y="8" rx="1" />
|
|
371
369
|
<path d="m15 2-3 3-3-3" />
|
|
372
|
-
<rect width="7" height="13" x="14" y="8" rx="1" />`,...t}));
|
|
370
|
+
<rect width="7" height="13" x="14" y="8" rx="1" />`,...t}));dx.displayName="BetweenVerticalStartIcon";var ZR=dx,fx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="3" y="3" rx="1" />
|
|
371
|
+
<path d="m22 15-3-3 3-3" />
|
|
372
|
+
<rect width="13" height="7" x="3" y="14" rx="1" />`,...t}));fx.displayName="BetweenHorizontalEndIcon";var eD=fx,hx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<circle cx="12" cy="12" r="10" />
|
|
373
373
|
<path d="M4.929 4.929 19.07 19.071" />`,...t}));hx.displayName="BanIcon";var tD=hx,px=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="m5 12 7-7 7 7" />
|
|
374
374
|
<path d="M12 19V5" />`,...t}));px.displayName="ArrowUpIcon";var nD=px,mx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 5v14" />
|
|
375
375
|
<path d="m19 12-7 7-7-7" />`,...t}));mx.displayName="ArrowDownIcon";var rD=mx,gx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5H3" />
|
|
@@ -378,8 +378,8 @@ ${n}
|
|
|
378
378
|
<path d="M15 12H3" />
|
|
379
379
|
<path d="M17 19H3" />`,...t}));yx.displayName="AlignLeftIcon";var Ym=yx,bx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5H3" />
|
|
380
380
|
<path d="M17 12H7" />
|
|
381
|
-
<path d="M19 19H5" />`,...t}));bx.displayName="AlignCenterIcon";var Xm=bx;const sD="_wrap_1pdh5_1",iD="_dropdown_1pdh5_6",oD="_dropdownRight_1pdh5_13",lD="_panel_1pdh5_20",aD="_search_1pdh5_32",cD="_list_1pdh5_36",uD="_group_1pdh5_43",dD="_empty_1pdh5_47",Gn={wrap:sD,dropdown:iD,dropdownRight:oD,panel:lD,search:aD,list:cD,group:uD,empty:dD},au="Other";function fD(t){var r;const e=new Map;for(const s of t){const i=((r=s.category)==null?void 0:r.trim())||au,o=e.get(i);o?o.push(s):e.set(i,[s])}const n=[...e.entries()].map(([s,i])=>({category:s,items:i}));return n.sort((s,i)=>s.category===i.category?0:s.category===au?1:i.category===au?-1:0),n}function Qm({editor:t,variables:e,disabled:n=!1,buttonClassName:r,align:s="left",onVariableInsert:i}){const[o,l]=S.useState(!1),[a,c]=S.useState(""),u=S.useRef(null),d=S.useRef(null),f=S.useRef(null),h=S.useRef(null),p=S.useMemo(()=>{const k=a.trim().toLowerCase();return k?e.filter(C=>C.label.toLowerCase().includes(k)||C.key.toLowerCase().includes(k)):e},[e,a]),g=S.useMemo(()=>fD(p),[p]);S.useEffect(()=>{n&&l(!1)},[n]),S.useEffect(()=>{function k(C){u.current&&!u.current.contains(C.target)&&l(!1)}return o&&document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[o]),S.useEffect(()=>{if(!o){c("");return}const k=window.setTimeout(()=>{var C;return(C=d.current)==null?void 0:C.focus()},0);return()=>window.clearTimeout(k)},[o]);function y(){return f.current?[...f.current.querySelectorAll('[role="menuitem"]:not([disabled])')]:[]}function b(k){var _;const C=y();if(C.length===0)return;const E=C.indexOf(document.activeElement),O=E===-1?k===1?0:C.length-1:(E+k+C.length)%C.length;(_=C[O])==null||_.focus()}function x(k){l(!1),t.commands.focus()}function w(k){if(n)return;const C=h.current;t.chain().focus().setTextSelection(C??t.state.selection).insertDynamicVariable(k).run(),l(!1),i==null||i(k.key)}function v(k){if(k.key==="Escape"){k.preventDefault(),x();return}if(k.key==="ArrowDown"){k.preventDefault(),b(1);return}if(k.key==="ArrowUp"){k.preventDefault(),b(-1);return}if(k.key==="Enter"&&k.target===d.current){k.preventDefault();const C=p[0];C&&w(C)}}return m.jsxs("div",{className:Gn.wrap,ref:u,children:[m.jsx(A.Tooltip,{content:"Insert variable",placement:"top",children:m.jsx("button",{type:"button",className:r,disabled:n,"aria-label":"Insert variable","aria-haspopup":"dialog","aria-expanded":o,onMouseDown:k=>{if(k.preventDefault(),!n){if(!o){const{from:C,to:E}=t.state.selection;h.current={from:C,to:E}}l(C=>!C)}},children:m.jsx(WR,{size:14})})}),o&&m.jsx("div",{className:[Gn.dropdown,s==="right"&&Gn.dropdownRight].filter(Boolean).join(" "),children:m.jsxs("div",{className:Gn.panel,role:"dialog","aria-label":"Insert variable",onKeyDown:v,onMouseDown:k=>k.stopPropagation(),children:[m.jsx("div",{className:Gn.search,children:m.jsx(A.SearchInput,{ref:d,size:"sm","aria-label":"Search variables",placeholder:"Search variables…",value:a,onChange:k=>c(k.target.value)})}),m.jsx(A.Scrollable,{size:"thin",maxHeight:"264px",children:m.jsx("div",{className:Gn.list,ref:f,role:"menu","aria-label":"Variables",children:g.length===0?m.jsx("div",{className:Gn.empty,children:"No variables found"}):g.map(k=>m.jsxs("div",{className:Gn.group,role:"group","aria-label":k.category,children:[m.jsx(A.MenuTitle,{children:k.category}),k.items.map(C=>m.jsx(A.MenuItem,{label:C.label,onClick:()=>w(C)},C.key))]},k.category))})})]})})]})}const hD="_menubar_x0rrp_1",pD="_group_x0rrp_11",mD="_divider_x0rrp_17",gD="_spacer_x0rrp_25",yD="_btn_x0rrp_30",bD="_active_x0rrp_46",wD="_blockWrap_x0rrp_63",xD="_blockTrigger_x0rrp_67",vD="_blockTriggerCompact_x0rrp_86",kD="_blockDropdown_x0rrp_107",SD="_moreDropdown_x0rrp_115",CD="_alignTrigger_x0rrp_124",ED="_colorWrap_x0rrp_156",TD="_colorDropdown_x0rrp_160",MD="_colorTabs_x0rrp_172",AD="_colorTab_x0rrp_172",_D="_colorTabActive_x0rrp_201",ND="_menubarWrap_x0rrp_218",OD="_aiPanel_x0rrp_224",ID="_aiInputRow_x0rrp_233",RD="_aiTextarea_x0rrp_247",DD="_aiLoadingText_x0rrp_271",Y={menubar:hD,group:pD,divider:mD,spacer:gD,btn:yD,active:bD,blockWrap:wD,blockTrigger:xD,blockTriggerCompact:vD,blockDropdown:kD,moreDropdown:SD,alignTrigger:CD,colorWrap:ED,colorDropdown:TD,colorTabs:MD,colorTab:AD,colorTabActive:_D,menubarWrap:ND,aiPanel:OD,aiInputRow:ID,aiTextarea:RD,aiLoadingText:DD},LD=S.memo(function({editor:e,disabled:n,showHtml:r,compact:s=!1,onLinkClick:i,onCodeClick:o,variables:l,showVariablePicker:a=!1,onVariableInsert:c,onAiSubmit:u,aiSubmitDisabled:d=!1}){const[f,h]=S.useState(!1),[p,g]=S.useState(""),[y,b]=S.useState(!1),x=S.useRef(null),w=S.useRef(null),[v,k]=S.useState(!1),C=S.useRef(null),[E,O]=S.useState(!1),_=S.useRef(null),T=S.useRef(null),[D,I]=S.useState(!1),P=S.useRef(null),N=S.useRef(null),[R,j]=S.useState(!1),F=S.useRef(null),[$,V]=S.useState(!1),[fe,we]=S.useState("text"),[Te,Tt]=S.useState("#000000"),[Me,Ie]=S.useState("#ffff00"),$e=S.useRef(null),q=S.useRef(null),ie=S.useRef(null),U=vo({editor:e,selector:({editor:M})=>({isBold:M.isActive("bold"),isItalic:M.isActive("italic"),isUnderline:M.isActive("underline"),isStrike:M.isActive("strike"),isAlignLeft:M.isActive({textAlign:"left"}),isAlignCenter:M.isActive({textAlign:"center"}),isAlignRight:M.isActive({textAlign:"right"}),isH1:M.isActive("heading",{level:1}),isH2:M.isActive("heading",{level:2}),isH3:M.isActive("heading",{level:3}),isH4:M.isActive("heading",{level:4}),isH5:M.isActive("heading",{level:5}),isH6:M.isActive("heading",{level:6}),isBlockquote:M.isActive("blockquote"),isBulletList:M.isActive("bulletList"),isOrderedList:M.isActive("orderedList"),isLink:M.isActive("link"),isTable:M.isActive("tableCell")||M.isActive("tableHeader"),hasSelection:!M.state.selection.empty})});S.useEffect(()=>{function M(ne){w.current&&!w.current.contains(ne.target)&&h(!1)}return f&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[f]),S.useEffect(()=>{function M(ne){C.current&&!C.current.contains(ne.target)&&k(!1)}return v&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[v]),S.useEffect(()=>{function M(ne){_.current&&!_.current.contains(ne.target)&&O(!1)}return E&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[E]),S.useEffect(()=>{function M(ne){P.current&&!P.current.contains(ne.target)&&I(!1)}return D&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[D]),S.useEffect(()=>{function M(ne){F.current&&!F.current.contains(ne.target)&&j(!1)}return R&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[R]),S.useEffect(()=>{function M(){k(!1),O(!1),I(!1),j(!1)}return e.on("focus",M),()=>{e.off("focus",M)}},[e]),S.useEffect(()=>{function M(ne){$e.current&&!$e.current.contains(ne.target)&&V(!1)}return $&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[$]);const Wt=S.useCallback(()=>{h(M=>{const ne=!M;return ne&&setTimeout(()=>{var xt;return(xt=x.current)==null?void 0:xt.focus()},0),ne})},[]);async function qt(){if(!p.trim()||y||d)return;const M=p;g(""),x.current&&(x.current.style.height="auto"),b(!0);try{await(u==null?void 0:u(M))}finally{b(!1),h(!1)}}const ce=n||!!r,H=l??[],B=a&&H.length>0;S.useEffect(()=>{ce&&(h(!1),k(!1),O(!1),I(!1),j(!1),V(!1))},[ce]);function K(M){ce||M()}function G(...M){return[Y.btn,...M].filter(Boolean).join(" ")}const xe=U.isH1?"Heading 1":U.isH2?"Heading 2":U.isH3?"Heading 3":U.isH4?"Heading 4":U.isH5?"Heading 5":U.isH6?"Heading 6":U.isBlockquote?"Blockquote":"Paragraph",He=U.isH1?"H1":U.isH2?"H2":U.isH3?"H3":U.isH4?"H4":U.isH5?"H5":U.isH6?"H6":U.isBlockquote?"Quote":"Text";return s?m.jsx("div",{className:Y.menubarWrap,ref:w,onClick:M=>M.stopPropagation(),children:m.jsxs("div",{className:Y.menubar,children:[m.jsxs("div",{className:Y.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:`${Y.blockTrigger} ${Y.blockTriggerCompact}`,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(ie.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:He}),m.jsx(wl,{size:12})]}),v&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!U.isH1&&!U.isH2&&!U.isH3&&!U.isH4&&!U.isH5&&!U.isH6&&!U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Md,{size:16}),checked:U.isH1,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:U.isH2,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:U.isH3,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:U.isH4,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:U.isH5,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Td,{size:16}),checked:U.isH6,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBold&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isItalic&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isLink&&Y.active),disabled:ce||!U.hasSelection&&!U.isLink,onMouseDown:M=>{M.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsx(A.Tooltip,{content:"Numbered list",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isOrderedList&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().focus().toggleOrderedList().run())},"aria-label":"Numbered list",children:m.jsx(Km,{size:14})})}),m.jsx(A.Tooltip,{content:"Bullet list",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBulletList&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().focus().toggleBulletList().run())},"aria-label":"Bullet list",children:m.jsx(ga,{size:14})})})]}),B&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Y.spacer}),m.jsx("div",{className:Y.group,children:m.jsx(Qm,{editor:e,variables:H,disabled:ce,buttonClassName:G(),align:"right",onVariableInsert:c})})]})]})}):m.jsxs("div",{className:Y.menubarWrap,ref:w,onClick:M=>M.stopPropagation(),children:[m.jsxs("div",{className:Y.menubar,children:[m.jsx(A.Tooltip,{content:"AI",placement:"top",children:m.jsx("button",{type:"button",className:G(f&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||Wt()},"aria-label":"AI",children:m.jsx(NR,{size:14})})}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:Y.blockTrigger,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(ie.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:xe}),m.jsx(wl,{size:12})]}),v&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!U.isH1&&!U.isH2&&!U.isH3&&!U.isH4&&!U.isH5&&!U.isH6&&!U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Md,{size:16}),checked:U.isH1,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:U.isH2,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:U.isH3,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:U.isH4,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:U.isH5,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Td,{size:16}),checked:U.isH6,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBold&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isItalic&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})}),m.jsx(A.Tooltip,{content:"Underline",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isUnderline&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleUnderline().run())},"aria-label":"Underline",children:m.jsx(Yw,{size:14})})}),m.jsxs("div",{className:Y.colorWrap,ref:$e,children:[m.jsx(A.Tooltip,{content:"Color",placement:"top",children:m.jsx("button",{type:"button",className:G($&&Y.active),disabled:ce,onMouseDown:M=>{if(M.preventDefault(),!ce){if(!$){const{from:ne,to:xt}=e.state.selection;q.current={from:ne,to:xt}}V(ne=>!ne)}},"aria-label":"Color",children:m.jsx(k1,{size:14})})}),$&&m.jsxs("div",{className:Y.colorDropdown,children:[m.jsxs("div",{className:Y.colorTabs,children:[m.jsx("button",{type:"button",className:`${Y.colorTab} ${fe==="text"?Y.colorTabActive:""}`,onMouseDown:M=>{M.preventDefault(),we("text")},children:"Text"}),m.jsx("button",{type:"button",className:`${Y.colorTab} ${fe==="bg"?Y.colorTabActive:""}`,onMouseDown:M=>{M.preventDefault(),we("bg")},children:"Background"})]}),fe==="text"?m.jsx(A.ColorPicker,{alwaysOpen:!0,value:Te,onChange:M=>{Tt(M);const ne=q.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setColor(M).run():e.chain().setColor(M).run()}}):m.jsx(A.ColorPicker,{alwaysOpen:!0,value:Me,onChange:M=>{Ie(M);const ne=q.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setHighlight({color:M}).run():e.chain().setHighlight({color:M}).run()}})]})]})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:_,children:[m.jsxs("button",{type:"button",className:Y.alignTrigger,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(T.current={from:e.state.selection.from,to:e.state.selection.to},O(ne=>!ne))},"aria-label":"Text alignment",children:[U.isAlignCenter?m.jsx(Xm,{size:14}):U.isAlignRight?m.jsx(Gm,{size:14}):m.jsx(Ym,{size:14}),m.jsx(wl,{size:12})]}),E&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Align left",leftIcon:m.jsx(Ym,{size:16}),checked:!U.isAlignCenter&&!U.isAlignRight,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("left").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align center",leftIcon:m.jsx(Xm,{size:16}),checked:U.isAlignCenter,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("center").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align right",leftIcon:m.jsx(Gm,{size:16}),checked:U.isAlignRight,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("right").run(),O(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isLink&&Y.active),disabled:ce||!U.hasSelection&&!U.isLink,onMouseDown:M=>{M.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsxs("div",{className:Y.blockWrap,ref:F,children:[m.jsx(A.Tooltip,{content:"Table",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isTable&&Y.active),disabled:ce,onMouseDown:M=>{if(M.preventDefault(),ce)return;e.isActive("tableCell")||e.isActive("tableHeader")?j(xt=>!xt):e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},"aria-label":"Table",children:m.jsx(o1,{size:14})})}),R&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItem,{label:"Add row above",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowBefore().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add row below",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowAfter().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add column left",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnBefore().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add column right",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnAfter().run(),j(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItem,{label:"Delete row",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteRow().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Delete column",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteColumn().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Delete table",leftIcon:m.jsx(SR,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteTable().run(),j(!1)}})]})})]})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:P,children:[m.jsx(A.Tooltip,{content:"Lists & formatting",placement:"top",children:m.jsx("button",{type:"button",className:G((D||U.isBulletList||U.isOrderedList)&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(N.current={from:e.state.selection.from,to:e.state.selection.to},I(ne=>!ne))},"aria-label":"Lists and formatting",children:m.jsx(UR,{size:16})})}),D&&m.jsx("div",{className:Y.moreDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Strikethrough",leftIcon:m.jsx(u1,{size:16}),checked:U.isStrike,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleStrike().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Bullet list",leftIcon:m.jsx(ga,{size:16}),checked:U.isBulletList,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBulletList().run(),I(!1)}}),m.jsx(A.MenuItemRadio,{label:"Numbered list",leftIcon:m.jsx(Km,{size:16}),checked:U.isOrderedList,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleOrderedList().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Increase indent",leftIcon:m.jsx(BR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).increaseIndent().run(),I(!1)}}),m.jsx(A.MenuItemRadio,{label:"Decrease indent",leftIcon:m.jsx(PR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).decreaseIndent().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Clear formatting",leftIcon:m.jsx(IR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).unsetAllMarks().run(),I(!1)}})]})})]}),m.jsx("div",{className:Y.spacer}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"HTML source",placement:"top",children:m.jsx("button",{type:"button",className:G(r&&Y.active),onMouseDown:M=>{M.preventDefault(),o()},"aria-label":"HTML source",children:m.jsx(nc,{size:14})})}),B&&m.jsx(Qm,{editor:e,variables:H,disabled:ce,buttonClassName:G(),align:"right",onVariableInsert:c})]})]}),f&&m.jsx("div",{className:Y.aiPanel,children:m.jsxs("div",{className:Y.aiInputRow,children:[y?m.jsx("span",{className:Y.aiLoadingText,children:"Generating…"}):m.jsx("textarea",{ref:x,className:Y.aiTextarea,placeholder:"Describe your changes…",value:p,rows:1,onChange:M=>{g(M.target.value),M.target.style.height="auto",M.target.style.height=`${M.target.scrollHeight}px`},onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),qt()),M.key==="Escape"&&h(!1)}}),m.jsx(A.IconButton,{icon:m.jsx(FR,{size:14}),"aria-label":"Send",size:"xsmall",radius:"full",variant:"neutral",disabled:!p.trim()||y||d,onMouseDown:M=>{M.preventDefault(),qt()}})]})})]})}),jD="_form_1nh56_1",PD="_field_1nh56_8",BD="_urlGroup_1nh56_14",zD="_footer_1nh56_20",$D="_removeBtn_1nh56_28",HD="_footerActions_1nh56_32",Sr={form:jD,field:PD,urlGroup:BD,footer:zD,removeBtn:$D,footerActions:HD};function Zm(t){return t.replace(/^https?:\/\//i,"")}function FD(t){const e=t.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function VD({editor:t,open:e,onClose:n}){const[r,s]=S.useState(""),[i,o]=S.useState(""),[l,a]=S.useState(!1),c=!!t.getAttributes("link").href;S.useEffect(()=>{if(e){const f=t.getAttributes("link");s(Zm(f.href??"")),o(f.title??""),a(f.target==="_blank")}},[e,t]);function u(){const f=FD(r);f?t.chain().focus().extendMarkRange("link").setLink({href:f,target:l?"_blank":null,title:i.trim()||null}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}function d(){t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}return m.jsx(A.Modal,{open:e,onClose:n,title:c?"Edit link":"Add link",size:"sm",footer:m.jsxs("div",{className:Sr.footer,children:[c&&m.jsx(A.Button,{variant:"danger",size:"sm",onClick:d,className:Sr.removeBtn,children:"Remove"}),m.jsxs("div",{className:Sr.footerActions,children:[m.jsx(A.Button,{variant:"neutral",size:"sm",onClick:n,children:"Cancel"}),m.jsx(A.Button,{variant:"inverted",size:"sm",onClick:u,children:"Save"})]})]}),children:m.jsxs("form",{onSubmit:f=>{f.preventDefault(),u()},noValidate:!0,className:Sr.form,children:[m.jsxs("div",{className:Sr.urlGroup,children:[m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-url",children:"Link Address"}),m.jsx(A.UrlInput,{id:"link-url",value:r,onChange:f=>s(Zm(f.target.value)),autoFocus:!0})]}),m.jsx(A.Checkbox,{label:"Open in new tab",checked:l,onChange:f=>a(f.target.checked)})]}),m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-header",optional:!0,children:"Link header"}),m.jsx(A.Input,{id:"link-header",placeholder:"Enter link header",value:i,onChange:f=>o(f.target.value)}),m.jsx(A.Hint,{children:"Used for accessibility and SEO"})]})]})})}const UD="_chip_v3xby_5",WD={chip:UD},Pi="dynamicVariable",Bi=/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g,eg=/<span\s+data-dynamic-variable="true"\s+data-key="([A-Za-z0-9_.-]*)"\s*>[^<]*<\/span>/g;function tg(t){return typeof t=="string"?t.replace(/[^A-Za-z0-9_.-]/g,""):""}function wx(t){const e=new Map;for(const n of t??[])n&&typeof n.key=="string"&&n.key&&e.set(n.key,n);return e}function ng(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function qD(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function KD(t){const e=t.label||t.key;return`<span data-dynamic-variable="true" data-key="${ng(t.key)}" data-label="${ng(e)}">${qD(e)}</span>`}function xx(t){return!t||t.indexOf("data-dynamic-variable")===-1?t:(eg.lastIndex=0,t.replace(eg,(e,n)=>`{{${n}}}`))}function rg(t,e){return Bi.lastIndex=0,t.replace(Bi,(n,r)=>{const s=e.get(r);return s?KD(s):n})}function ki(t,e){if(!t)return t;const n=wx(e);if(n.size===0)return t;let r="",s=0;for(;s<t.length;){const i=t.indexOf("<",s);if(i===-1){r+=rg(t.slice(s),n);break}r+=rg(t.slice(s,i),n);const o=t.indexOf(">",i);if(o===-1){r+=t.slice(i);break}r+=t.slice(i,o+1),s=o+1}return r}function JD(t,e,n){const r=t.text??"",s=e.schema,i=[];let o=0;Bi.lastIndex=0;let l=Bi.exec(r);for(;l;){const a=n.get(l[1]);a&&(l.index>o&&i.push(s.text(r.slice(o,l.index),t.marks)),i.push(e.create({key:a.key,label:a.label||a.key},null,t.marks)),o=l.index+l[0].length),l=Bi.exec(r)}return i.length===0?[t]:(o<r.length&&i.push(s.text(r.slice(o),t.marks)),i)}function vx(t,e,n){if(n.size===0)return t;const r=[];return t.forEach(s=>{s.isText?r.push(...JD(s,e,n)):s.content.size>0?r.push(s.copy(vx(s.content,e,n))):r.push(s)}),L.fromArray(r)}const kx=Se.create({name:Pi,inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!1,addOptions(){return{variables:[]}},addStorage(){var t;return{variables:((t=this.options)==null?void 0:t.variables)??[]}},addAttributes(){return{key:{default:"",parseHTML:t=>tg(t.getAttribute("data-key")),renderHTML:()=>({})},label:{default:null,parseHTML:t=>t.getAttribute("data-label")||t.textContent||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-dynamic-variable]"}]},renderHTML({node:t}){const e=tg(t.attrs.key),n=t.attrs.label||e;return["span",{"data-dynamic-variable":"true","data-key":e},n]},renderText({node:t}){return`{{${t.attrs.key}}}`},addNodeView(){return({node:t})=>{const e=document.createElement("span"),n=r=>{e.setAttribute("data-dynamic-variable","true"),e.setAttribute("data-key",r.attrs.key),e.setAttribute("contenteditable","false"),e.setAttribute("title",`{{${r.attrs.key}}}`),e.className=WD.chip,e.textContent=r.attrs.label||r.attrs.key};return n(t),{dom:e,update(r){return r.type.name!==Pi?!1:(n(r),!0)},ignoreMutation:()=>!0}}},addCommands(){return{insertDynamicVariable:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{key:t.key,label:t.label||t.key}})}},addKeyboardShortcuts(){const t=e=>()=>{const{state:n,view:r}=this.editor,{selection:s}=n;if(s instanceof Q&&s.node.type.name===this.name)return r.dispatch(n.tr.deleteSelection()),!0;if(!s.empty)return!1;const i=s.$from,o=e===-1?i.nodeBefore:i.nodeAfter;if(!o||o.type.name!==this.name)return!1;const l=e===-1?i.pos-o.nodeSize:i.pos;return r.dispatch(n.tr.delete(l,l+o.nodeSize)),!0};return{Backspace:t(-1),Delete:t(1)}},addProseMirrorPlugins(){const t=this.type,e=this.editor,n=this.options.variables;return[new ue({key:new ae("dynamicVariablePaste"),props:{transformPasted:r=>{var o,l;const s=((l=(o=e==null?void 0:e.storage)==null?void 0:o[Pi])==null?void 0:l.variables)??n,i=wx(s);return i.size===0?r:new W(vx(r.content,t,i),r.openStart,r.openEnd)}}})]}}),GD=SN.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),title:{default:null}}}});function Xo(t){return xx(t.getHTML())}const YD=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,minHeight:s,maxHeight:i="400px",onChange:o,onFocus:l,onBlur:a,error:c=!1,disabled:u=!1,readOnly:d=!1,variant:f="white",compact:h=!1,className:p,onAiSubmit:g,aiSubmitDisabled:y,variables:b,showVariablePicker:x=!1,onVariableInsert:w},v){const[k,C]=S.useState(!1),[E,O]=S.useState(!1),[_,T]=S.useState(""),D=S.useRef(!1),I=(b??[]).map($=>`${$.key}\0${$.label}`).join(""),P=S.useMemo(()=>b??[],[I]),N=O0({extensions:[Mw.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),_w.configure({multicolor:!0}),GD.configure({openOnClick:!1}),Jf.configure({resizable:!1}),Kf,qf,Wf,...r!==void 0?[Aw.configure({placeholder:r})]:[],Gf,Yf,qI.configure({types:["heading","paragraph"]}),jO,kx.configure({variables:P})],content:ki(e??n??"",P),editable:!u&&!d,shouldRerenderOnTransaction:!1,onUpdate({editor:$}){D.current=!0,o==null||o($.isEmpty?null:Xo($))},onFocus(){l==null||l()},onBlur(){a==null||a()}});S.useEffect(()=>{N==null||N.setEditable(!u&&!d)},[N,u,d]),S.useEffect(()=>{if(!N||e===void 0)return;if(D.current){D.current=!1;return}Xo(N)!==e&&N.commands.setContent(ki(e??"",P),{emitUpdate:!1})},[N,e,P]),S.useEffect(()=>{if(!N)return;const $=N.storage[Pi];$&&($.variables=P)},[N,P]);const R=S.useRef(I);S.useEffect(()=>{N&&R.current!==I&&(R.current=I,N.commands.setContent(ki(Xo(N),P),{emitUpdate:!1}))},[N,I,P]),S.useImperativeHandle(v,()=>({focus:($="end")=>N==null?void 0:N.commands.focus($)}));function j(){N&&(E?N.commands.setContent(ki(_,P)):T(Xo(N)),O($=>!$))}const F=[Tn.wrapper,Tn[f],c&&Tn.error,u&&Tn.disabled,d&&Tn.readOnly,p].filter(Boolean).join(" ");return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:F,style:s?{"--rte-min-height":s}:void 0,onClick:$=>{if(u||d||E)return;const V=$.target;if(V.closest('button, input, select, a, [role="menu"], [role="menuitem"], [role="menuitemradio"]'))return;const fe=$.currentTarget.querySelector(".ProseMirror");fe&&fe.contains(V)||N==null||N.commands.focus("end")},children:[N&&!d&&m.jsx("div",{className:Tn.menuBarRegion,children:m.jsx(LD,{editor:N,disabled:u,showHtml:E,compact:h,onLinkClick:()=>C(!0),onCodeClick:j,variables:P,showVariablePicker:x,onVariableInsert:w,onAiSubmit:g,aiSubmitDisabled:y})}),E?m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Fw,{value:_,onValueChange:T,highlight:$=>ma.highlight($,ma.languages.markup,"markup"),padding:12,className:Tn.htmlSource,textareaClassName:Tn.htmlSourceTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})}):m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Af,{editor:N,className:Tn.content})})]}),N&&m.jsx(VD,{editor:N,open:k,onClose:()=>C(!1)})]})}),Ye=16;function sg(t,e){var r;const n=t.extensionManager.extensions.find(s=>s.name===e);return typeof((r=n==null?void 0:n.options)==null?void 0:r.onPick)=="function"}const Sx=[{id:"paragraph",label:"Text",icon:m.jsx(kR,{size:Ye}),group:"Basic",shortcut:"/text",keywords:["paragraph","body","plain"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("paragraph").run()}},{id:"heading",label:"Heading",icon:m.jsx($R,{size:Ye}),group:"Basic",shortcut:"/heading",keywords:["title","header","h1","h2","h3"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("heading",{level:2}).run()}},{id:"bullet-list",label:"Bulleted list",icon:m.jsx(ga,{size:Ye}),group:"Basic",shortcut:"/ul",keywords:["unordered","bullets","points"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{id:"ordered-list",label:"Numbered list",icon:m.jsx(N1,{size:Ye}),group:"Basic",shortcut:"/ol",keywords:["ordered","numbers","steps"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{id:"blockquote",label:"Quote",icon:m.jsx(t1,{size:Ye}),group:"Basic",shortcut:"/quote",keywords:["blockquote","citation"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{id:"code-block",label:"Code",icon:m.jsx(nc,{size:Ye}),group:"Basic",shortcut:"/code",keywords:["snippet","pre","syntax"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{id:"divider",label:"Divider",icon:m.jsx(wd,{size:Ye}),group:"Basic",shortcut:"/hr",keywords:["horizontal rule","separator","line"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{id:"table",label:"Table",icon:m.jsx(o1,{size:Ye}),group:"Basic",shortcut:"/table",keywords:["grid","rows","columns","spreadsheet"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{id:"callout",label:"Callout",icon:m.jsx(LR,{size:Ye}),group:"Basic",shortcut:"/callout",keywords:["note","info","warning","tip","aside"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCalloutBlock().run()}},{id:"toggle",label:"Toggle",icon:m.jsx(DR,{size:Ye}),group:"Basic",shortcut:"/toggle",keywords:["accordion","collapse","details","faq","expand"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertToggleBlock().run()}},{id:"image",label:"Image",icon:m.jsx(zR,{size:Ye}),group:"Media",shortcut:"/image",keywords:["photo","picture","upload","media"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertImageBlock().run()}},{id:"gallery",label:"Gallery",icon:m.jsx(jR,{size:Ye}),group:"Media",shortcut:"/gallery",keywords:["images","photos","grid","album"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertGalleryBlock().run()}},{id:"video",label:"Video",icon:m.jsx(qw,{size:Ye}),group:"Media",shortcut:"/video",keywords:["youtube","vimeo","embed","media","mp4"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertVideoBlock().run()}},{id:"html",label:"HTML",icon:m.jsx(JR,{size:Ye}),group:"Media",shortcut:"/html",keywords:["embed","markup","script","custom","raw"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertHtmlBlock().run()}},{id:"product",label:"Product",icon:m.jsx(C1,{size:Ye}),group:"Commerce",shortcut:"/product",keywords:["item","sku","shop","store"],isAvailable:t=>sg(t,"productBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertProductBlock().run()}},{id:"collection",label:"Collection",icon:m.jsx(D1,{size:Ye}),group:"Commerce",shortcut:"/collection",keywords:["category","catalog","group"],isAvailable:t=>sg(t,"collectionBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCollectionBlock().run()}},{id:"button",label:"Button",icon:m.jsx(_R,{size:Ye}),group:"Media",shortcut:"/button",keywords:["cta","call to action","link"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertButtonBlock().run()}}];function Cx(t,e,n){const r=n?t.filter(i=>{var o;return((o=i.isAvailable)==null?void 0:o.call(i,n))??!0}):t,s=e.trim().toLowerCase();return s?r.filter(i=>i.label.toLowerCase().includes(s)||(i.keywords??[]).some(o=>o.toLowerCase().includes(s))):r}function Ex(t){const e=[];for(const n of t){const r=e.find(s=>s.group===n.group);r?r.blocks.push(n):e.push({group:n.group,blocks:[n]})}return e}const XD="_panel_1hllz_5",QD="_menu_1hllz_25",ZD="_shortcut_1hllz_31",eL="_empty_1hllz_37",Qo={panel:XD,menu:QD,shortcut:ZD,empty:eL},ig=300,rs=8,tL=S.forwardRef(function({blocks:e,getAnchor:n,query:r,onSelect:s,onClose:i,emptyLabel:o="No blocks found",captureKeys:l=!1},a){const[c,u]=S.useState(0),d=S.useRef(null),f=S.useRef([]),[h,p]=S.useState(null),g=S.useMemo(()=>Ex(e),[e]),y=S.useMemo(()=>g.flatMap(w=>w.blocks),[g]);S.useEffect(()=>{u(0)},[r,e.length]);const b=S.useCallback(()=>{const w=d.current,v=n();if(!w||!v)return;const k=w.offsetHeight,E=window.innerHeight-v.bottom<k+rs&&v.top>k+rs?v.top-k-rs:v.bottom+rs,O=Math.min(v.left,window.innerWidth-ig-rs);p({top:E,left:Math.max(rs,O)})},[n]);S.useLayoutEffect(b,[b,e.length]),S.useEffect(()=>(window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}),[b]),S.useEffect(()=>{var w;(w=f.current[c])==null||w.scrollIntoView({block:"nearest"})},[c]);const x=S.useCallback(w=>{const v=y.length;if(w.key==="ArrowDown")return u(k=>v?(k+1)%v:0),!0;if(w.key==="ArrowUp")return u(k=>v?(k-1+v)%v:0),!0;if(w.key==="Enter"){const k=y[c];return k&&s(k),!0}return w.key==="Escape"?(i(),!0):!1},[y,c,s,i]);return S.useImperativeHandle(a,()=>({onKeyDown:x}),[x]),S.useEffect(()=>{if(!l)return;function w(v){x(v)&&(v.preventDefault(),v.stopPropagation())}return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[l,x]),S.useEffect(()=>{function w(v){var k;(k=d.current)!=null&&k.contains(v.target)||i()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),zs.createPortal(m.jsx("div",{ref:d,className:Qo.panel,style:{top:(h==null?void 0:h.top)??0,left:(h==null?void 0:h.left)??0,width:ig,visibility:h?"visible":"hidden"},children:m.jsx(A.Scrollable,{size:"thin",maxHeight:"320px",children:m.jsxs(A.Menu,{className:Qo.menu,children:[y.length===0&&m.jsx("div",{className:Qo.empty,children:o}),g.map(({group:w,blocks:v},k)=>{const C=g.slice(0,k).reduce((E,O)=>E+O.blocks.length,0);return m.jsx(A.MenuGroup,{label:w,children:v.map((E,O)=>{const _=C+O;return m.jsx("div",{ref:T=>{f.current[_]=T},children:m.jsx(A.MenuItem,{label:E.label,leftIcon:E.icon,rightSlot:E.shortcut?m.jsx("span",{className:Qo.shortcut,children:E.shortcut}):void 0,forceHover:_===c,onClick:()=>s(E)})},E.id)})},w)})]})})}),document.body)});function nL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=aA(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",f=s?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),x=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(b);if(i!==null&&!x)return null;const w=g+y.index;let v=w+y[0].length;return a&&u.test(p.slice(v-1,v+1))&&(y[0]+=" ",v+=1),w<l.pos&&v>=l.pos?{range:{from:w,to:v},query:y[0].slice(n.length),text:y[0]}:null}function rL(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!(n!=null&&n.content))return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
382
|
-
`);return/\s/.test(r)}):!1}var sL=new ae("suggestion");function iL({pluginKey:t=sL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=nL,shouldShow:y,shouldResetDismissed:b}){let x;const w=h==null?void 0:h(),v=r&&!s,k=()=>{const T=e.state.selection.$anchor.pos,D=e.view.coordsAtPos(T),{top:I,right:P,bottom:N,left:R}=D;try{return new DOMRect(R,I,P-R,N-I)}catch{return null}},C=(T,D)=>D?()=>{const I=t.getState(e.state),P=I==null?void 0:I.decorationId,N=T.dom.querySelector(`[data-decoration-id="${P}"]`);return(N==null?void 0:N.getBoundingClientRect())||null}:k,E=({match:T,dismissedRange:D,state:I,transaction:P})=>b!=null&&b({editor:e,state:I,range:D,match:T,transaction:P,allowSpaces:v})?!1:v?T.range.from===D.from:T.range.from===D.from&&!rL(P);function O(T,D){var I;try{const N=t.getState(T.state),R=N!=null&&N.decorationId?T.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null,j={editor:e,range:(N==null?void 0:N.range)||{from:0,to:0},query:(N==null?void 0:N.query)||null,text:(N==null?void 0:N.text)||null,items:[],command:F=>d({editor:e,range:(N==null?void 0:N.range)||{from:0,to:0},props:F}),decorationNode:R,clientRect:C(T,R)};(I=w==null?void 0:w.onExit)==null||I.call(w,j)}catch{}const P=T.state.tr.setMeta(D,{exit:!0});T.dispatch(P)}const _=new ue({key:t,view(){return{update:async(T,D)=>{var I,P,N,R,j,F,$;const V=(I=this.key)==null?void 0:I.getState(D),fe=(P=this.key)==null?void 0:P.getState(T.state),we=V.active&&fe.active&&V.range.from!==fe.range.from,Te=!V.active&&fe.active,Tt=V.active&&!fe.active,Me=!Te&&!Tt&&V.query!==fe.query,Ie=Te||we&&Me,$e=Me||we,q=Tt||we&&Me;if(!Ie&&!$e&&!q)return;const ie=q&&!Ie?V:fe,U=T.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);x={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:Wt=>d({editor:e,range:ie.range,props:Wt}),decorationNode:U,clientRect:C(T,U)},Ie&&((N=w==null?void 0:w.onBeforeStart)==null||N.call(w,x)),$e&&((R=w==null?void 0:w.onBeforeUpdate)==null||R.call(w,x)),($e||Ie)&&(x.items=await f({editor:e,query:ie.query})),q&&((j=w==null?void 0:w.onExit)==null||j.call(w,x)),$e&&((F=w==null?void 0:w.onUpdate)==null||F.call(w,x)),Ie&&(($=w==null?void 0:w.onStart)==null||$.call(w,x))},destroy:()=>{var T;x&&((T=w==null?void 0:w.onExit)==null||T.call(w,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(T,D,I,P){const{isEditable:N}=e,{composing:R}=e.view,{selection:j}=T,{empty:F,from:$}=j,V={...D},fe=T.getMeta(t);if(fe&&fe.exit)return V.active=!1,V.decorationId=null,V.range={from:0,to:0},V.query=null,V.text=null,V.dismissedRange=D.active?{...D.range}:D.dismissedRange,V;if(V.composing=R,T.docChanged&&V.dismissedRange!==null&&(V.dismissedRange={from:T.mapping.map(V.dismissedRange.from),to:T.mapping.map(V.dismissedRange.to)}),N&&(F||e.view.composing)){($<D.range.from||$>D.range.to)&&!R&&!D.composing&&(V.active=!1);const we=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:j.$from}),Te=`id_${Math.floor(Math.random()*4294967295)}`;we&&p({editor:e,state:P,range:we.range,isActive:D.active})&&(!y||y({editor:e,range:we.range,query:we.query,text:we.text,transaction:T}))?(V.dismissedRange!==null&&!E({match:we,dismissedRange:V.dismissedRange,state:P,transaction:T})&&(V.dismissedRange=null),V.dismissedRange===null?(V.active=!0,V.decorationId=D.decorationId?D.decorationId:Te,V.range=we.range,V.query=we.query,V.text=we.text):V.active=!1):(we||(V.dismissedRange=null),V.active=!1)}else V.active=!1;return V.active||(V.decorationId=null,V.range={from:0,to:0},V.query=null,V.text=null),V}},props:{handleKeyDown(T,D){var I,P;const{active:N,range:R}=_.getState(T.state);if(!N)return!1;if(D.key==="Escape"||D.key==="Esc"){const F=_.getState(T.state);return(I=w==null?void 0:w.onKeyDown)==null||I.call(w,{view:T,event:D,range:F.range}),O(T,t),!0}return((P=w==null?void 0:w.onKeyDown)==null?void 0:P.call(w,{view:T,event:D,range:R}))||!1},decorations(T){const{active:D,range:I,decorationId:P,query:N}=_.getState(T);if(!D)return null;const R=!(N!=null&&N.length),j=[a];return R&&j.push(u),pe.create(T.doc,[Le.inline(I.from,I.to,{nodeName:l,class:j.join(" "),"data-decoration-id":P,"data-decoration-content":c})])}}});return _}var oL=iL;const Tx=new ae("blockEditorSlashCommand"),Mx=oe.create({name:"blockEditorSlashCommand",addOptions(){return{onStateChange:()=>{},onKeyDown:()=>!1}},addProseMirrorPlugins(){const t=this.options;return[oL({editor:this.editor,pluginKey:Tx,char:"/",startOfLine:!0,allow:({state:e,range:n})=>e.doc.resolve(n.from).parent.type.name!=="codeBlock",items:()=>[],render:()=>({onStart:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onUpdate:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onKeyDown:({event:e})=>t.onKeyDown(e),onExit:()=>t.onStateChange(null)})})]}});function Vs({commands:t,state:e,node:n}){const{$from:r}=e.selection,s=r.depth>0,o=(s?r.after():r.pos)>=e.doc.content.size?[n,{type:"paragraph"}]:[n];return s&&r.parent.type.name==="paragraph"&&r.parent.content.size===0?t.insertContentAt({from:r.before(),to:r.after()},o):t.insertContent(o)}const lL="_wrapper_1wcz7_5",aL="_normal_1wcz7_10",cL="_wide_1wcz7_14",uL="_full_1wcz7_23",dL="_selected_1wcz7_29",fL="_figure_1wcz7_29",hL="_placeholder_1wcz7_30",pL="_fileInput_1wcz7_34",mL="_image_1wcz7_45",gL="_toolbar_1wcz7_58",yL="_toolbarDivider_1wcz7_79",bL="_altToggle_1wcz7_91",wL="_altToggleSet_1wcz7_120",xL="_caption_1wcz7_130",vL="_captionInput_1wcz7_138",kL="_captionAlt_1wcz7_167",SL="_altBadge_1wcz7_174",CL="_altInput_1wcz7_186",EL="_overlay_1wcz7_200",TL="_dragOver_1wcz7_224",ML="_placeholderBody_1wcz7_229",AL="_placeholderIcon_1wcz7_245",_L="_placeholderText_1wcz7_249",NL="_urlInput_1wcz7_254",OL="_placeholderDelete_1wcz7_271",IL="_error_1wcz7_284",ge={wrapper:lL,normal:aL,wide:cL,full:uL,selected:dL,figure:fL,placeholder:hL,fileInput:pL,image:mL,toolbar:gL,toolbarDivider:yL,altToggle:bL,altToggleSet:wL,caption:xL,captionInput:vL,captionAlt:kL,altBadge:SL,altInput:CL,overlay:EL,dragOver:TL,placeholderBody:ML,placeholderIcon:AL,placeholderText:_L,urlInput:NL,placeholderDelete:OL,error:IL},RL=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function DL({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const{src:o,alt:l,caption:a,layout:c}=t.attrs,u=i.options,d=S.useRef(null),f=S.useRef(null),[h,p]=S.useState(!1),[g,y]=S.useState(null),[b,x]=S.useState(!1),[w,v]=S.useState(!1),k=r.isEditable;S.useEffect(()=>{var T;w&&((T=f.current)==null||T.focus())},[w]);async function C(T){if(!u.onUpload){y("Uploading is not configured");return}y(null),p(!0);try{const D=await u.onUpload(T);e({src:D})}catch(D){y(D instanceof Error?D.message:"Upload failed")}finally{p(!1)}}function E(){var T;y(null),(T=d.current)==null||T.click()}function O(T){if(!w)return;const D=T.relatedTarget;D&&T.currentTarget.contains(D)||v(!1)}const _=[ge.wrapper,ge[c],s&&ge.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:_,"data-drag-handle":!0,children:[m.jsx("input",{ref:d,type:"file",accept:u.accept,className:ge.fileInput,onChange:T=>{var I;const D=(I=T.target.files)==null?void 0:I[0];T.target.value="",D&&C(D)}}),o?m.jsxs("figure",{className:ge.figure,contentEditable:!1,onBlur:O,children:[m.jsx("img",{src:o,alt:l??"",className:ge.image}),k&&m.jsxs("div",{className:ge.toolbar,children:[RL.map(({value:T,label:D,icon:I})=>m.jsx(A.Tooltip,{content:D,children:m.jsx(A.IconButton,{"aria-label":D,variant:c===T?"neutral":"transparent",size:"xsmall",icon:m.jsx(I,{size:14}),onClick:()=>e({layout:T})})},T)),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(A.Tooltip,{content:l?`Alt text: ${l}`:"Describe this image (alt text)",children:m.jsx("button",{type:"button","aria-label":"Edit alt text","aria-pressed":w,className:[ge.altToggle,l&&ge.altToggleSet].filter(Boolean).join(" "),onClick:()=>v(T=>!T),children:"ALT"})}),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace image",variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),onClick:E})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete image",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),(k||a)&&m.jsxs("figcaption",{className:[ge.caption,w&&ge.captionAlt].filter(Boolean).join(" "),children:[!k&&a,k&&w&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:ge.altBadge,"aria-hidden":"true",children:"ALT"}),m.jsx("input",{ref:f,type:"text",className:[ge.captionInput,ge.altInput].join(" "),value:l??"","aria-label":"Alt text",placeholder:"Describe this image for screen readers",onChange:T=>e({alt:T.target.value}),onKeyDown:T=>{T.key!=="Enter"&&T.key!=="Escape"||(T.preventDefault(),v(!1))}})]}),k&&!w&&m.jsx("input",{type:"text",className:ge.captionInput,value:a??"","aria-label":"Caption",placeholder:"Type caption for image (optional)",onChange:T=>e({caption:T.target.value})})]}),h&&m.jsx("div",{className:ge.overlay,children:m.jsx(A.Spinner,{size:"md"})})]}):m.jsxs("div",{className:[ge.placeholder,b&&ge.dragOver].filter(Boolean).join(" "),contentEditable:!1,onDragOver:T=>{k&&(T.preventDefault(),x(!0))},onDragLeave:()=>x(!1),onDrop:T=>{var I;if(!k)return;T.preventDefault(),x(!1);const D=(I=T.dataTransfer.files)==null?void 0:I[0];D&&C(D)},children:[h?m.jsxs("div",{className:ge.placeholderBody,children:[m.jsx(A.Spinner,{size:"md"}),m.jsx("span",{className:ge.placeholderText,children:"Uploading…"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:ge.placeholderBody,onClick:E,disabled:!k,children:[m.jsx(kd,{size:22,className:ge.placeholderIcon}),m.jsx("span",{className:ge.placeholderText,children:u.onUpload?"Click to select an image, or drag one here":"Paste an image URL below"})]}),m.jsx("input",{type:"url",className:ge.urlInput,placeholder:"…or paste an image URL",onKeyDown:T=>{if(T.key!=="Enter")return;T.preventDefault();const D=T.target.value.trim();D&&e({src:D})}})]}),g&&m.jsxs("p",{className:ge.error,children:[m.jsx(Xf,{size:14}),g]}),k&&m.jsx("div",{className:ge.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})}const Ax="image",_x=Se.create({name:Ax,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*",HTMLAttributes:{}}},addAttributes(){return{src:{default:null},alt:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-image-block]"},{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),alt:t.getAttribute("alt")})}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,alt:r,caption:s}=e.attrs;return["figure",le({"data-image-block":""},this.options.HTMLAttributes,{"data-layout":t["data-layout"]}),["img",{src:n,alt:r??""}],...s?[["figcaption",{},s]]:[]]},addNodeView(){return vr(DL)},addCommands(){return{insertImageBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),LL="_wrapper_1mu6t_3",jL="_information_1mu6t_16",PL="_success_1mu6t_21",BL="_warning_1mu6t_26",zL="_error_1mu6t_31",$L="_neutral_1mu6t_36",HL="_selected_1mu6t_41",FL="_marker_1mu6t_46",VL="_emojiButton_1mu6t_54",UL="_accentLine_1mu6t_74",WL="_emojiMenu_1mu6t_84",qL="_emojiGrid_1mu6t_88",KL="_emojiChoice_1mu6t_94",JL="_emojiChoiceActive_1mu6t_115",GL="_body_1mu6t_121",YL="_toolbar_1mu6t_131",XL="_toneButton_1mu6t_151",QL="_toneSwatch_1mu6t_168",ze={wrapper:LL,information:jL,success:PL,warning:BL,error:zL,neutral:$L,selected:HL,marker:FL,emojiButton:VL,accentLine:UL,emojiMenu:WL,emojiGrid:qL,emojiChoice:KL,emojiChoiceActive:JL,body:GL,toolbar:YL,toneButton:XL,toneSwatch:QL},ZL=["💡","📌","⚠️","✅","❌","🔥","📣","🎯","📝","🚀","❓","⭐"],e2=[{value:"information",label:"Information"},{value:"success",label:"Success"},{value:"warning",label:"Warning"},{value:"error",label:"Error"},{value:"neutral",label:"Neutral"}];function t2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{emoji:i,tone:o}=t.attrs,[l,a]=S.useState(!1),[c,u]=S.useState(!1),d=r.isEditable,f=[ze.wrapper,ze[o],s&&ze.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:f,children:[m.jsx("div",{className:ze.marker,contentEditable:!1,children:d?m.jsx(A.Popover,{open:l,onOpenChange:a,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:ze.emojiButton,"aria-label":"Change emoji",children:i||m.jsx("span",{className:ze.accentLine})}),children:m.jsx(A.Menu,{className:ze.emojiMenu,children:m.jsxs("div",{className:ze.emojiGrid,children:[m.jsx("button",{type:"button",className:[ze.emojiChoice,!i&&ze.emojiChoiceActive].filter(Boolean).join(" "),"aria-label":"No emoji",onClick:()=>{e({emoji:null}),a(!1)},children:m.jsx(tD,{size:16})}),ZL.map(h=>m.jsx("button",{type:"button",className:[ze.emojiChoice,i===h&&ze.emojiChoiceActive].filter(Boolean).join(" "),onClick:()=>{e({emoji:h}),a(!1)},children:h},h))]})})}):i||m.jsx("span",{className:ze.accentLine})}),m.jsx(L0,{className:ze.body}),d&&m.jsxs("div",{className:ze.toolbar,contentEditable:!1,children:[m.jsx(A.Popover,{open:c,onOpenChange:u,placement:"bottom-end",bare:!0,trigger:m.jsx("button",{type:"button",className:ze.toneButton,"aria-label":"Change colour",children:m.jsx("span",{className:ze.toneSwatch})}),children:m.jsx(A.Menu,{children:e2.map(({value:h,label:p})=>m.jsx(A.MenuItemRadio,{label:p,leftIcon:m.jsx("span",{className:[ze.toneSwatch,ze[h]].join(" ")}),checked:o===h,onClick:()=>{e({tone:h}),u(!1)}},h))})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete callout",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})}const Nx="callout",Ox=Se.create({name:Nx,group:"block",content:"block+",defining:!0,addAttributes(){return{emoji:{default:"💡"},tone:{default:"information",parseHTML:t=>t.getAttribute("data-tone")??"information",renderHTML:t=>({"data-tone":t.tone})}}},parseHTML(){return[{tag:"div[data-callout-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{emoji:n}=e.attrs;return["div",le({"data-callout-block":""},{"data-tone":t["data-tone"]}),...n?[["span",{"data-callout-emoji":""},n]]:[],["div",{"data-callout-body":""},0]]},addNodeView(){return vr(t2)},addCommands(){return{insertCalloutBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{emoji:"💡",tone:"information",...t},content:[{type:"paragraph"}]})}}}),n2="_wrapper_1bsti_1",r2="_buttonRow_1bsti_6",s2="_selected_1bsti_14",i2="_outline_1bsti_21",o2="_settings_1bsti_31",l2="_fields_1bsti_53",a2="_field_1bsti_53",c2="_fieldLabel_1bsti_65",u2="_input_1bsti_71",d2="_controls_1bsti_89",f2="_styleToggle_1bsti_98",h2="_styleOption_1bsti_105",p2="_styleOptionActive_1bsti_117",m2="_alignGroup_1bsti_122",Fe={wrapper:n2,buttonRow:r2,"align-left":"_align-left_1bsti_10","align-center":"_align-center_1bsti_11","align-right":"_align-right_1bsti_12",selected:s2,outline:i2,settings:o2,fields:l2,field:a2,fieldLabel:c2,input:u2,controls:d2,styleToggle:f2,styleOption:h2,styleOptionActive:p2,alignGroup:m2},g2=[{value:"left",label:"Align left",icon:TR},{value:"center",label:"Align centre",icon:CR},{value:"right",label:"Align right",icon:ER}],y2=[{value:"fill",label:"Fill"},{value:"outline",label:"Outline"}];function b2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{text:i,href:o,style:l,align:a}=t.attrs,c=r.isEditable,u=[Fe.wrapper,Fe[`align-${a}`],s&&Fe.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:u,"data-drag-handle":!0,children:[m.jsx("div",{className:Fe.buttonRow,contentEditable:!1,children:m.jsx(A.Button,{variant:l==="fill"?"inverted":"transparent",className:l==="outline"?Fe.outline:void 0,onClick:d=>d.preventDefault(),children:i||"Button"})}),c&&m.jsxs("div",{className:Fe.settings,contentEditable:!1,children:[m.jsxs("div",{className:Fe.fields,children:[m.jsxs("label",{className:Fe.field,children:[m.jsx("span",{className:Fe.fieldLabel,children:"Button text"}),m.jsx("input",{type:"text",className:Fe.input,value:i??"",placeholder:"Add button text",onChange:d=>e({text:d.target.value})})]}),m.jsxs("label",{className:Fe.field,children:[m.jsx("span",{className:Fe.fieldLabel,children:"Button URL"}),m.jsx("input",{type:"url",className:Fe.input,value:o??"",placeholder:"https://",onChange:d=>e({href:d.target.value||null})})]})]}),m.jsxs("div",{className:Fe.controls,children:[m.jsx("div",{className:Fe.styleToggle,children:y2.map(({value:d,label:f})=>m.jsx("button",{type:"button",className:[Fe.styleOption,l===d&&Fe.styleOptionActive].filter(Boolean).join(" "),onClick:()=>e({style:d}),children:f},d))}),m.jsx("div",{className:Fe.alignGroup,children:g2.map(({value:d,label:f,icon:h})=>m.jsx(A.Tooltip,{content:f,children:m.jsx(A.IconButton,{"aria-label":f,variant:a===d?"neutral":"transparent",size:"xsmall",icon:m.jsx(h,{size:14}),onClick:()=>e({align:d})})},d))}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete button block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})]})}const Ix="buttonBlock",Rx=Se.create({name:Ix,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{text:{default:"Button"},href:{default:null},style:{default:"fill",parseHTML:t=>t.getAttribute("data-style")??"fill",renderHTML:t=>({"data-style":t.style})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align")??"center",renderHTML:t=>({"data-align":t.align})}}},parseHTML(){return[{tag:"div[data-button-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{text:n,href:r}=e.attrs;return["div",le({"data-button-block":""},{"data-style":t["data-style"],"data-align":t["data-align"]}),["a",{href:r??"#"},n??""]]},addNodeView(){return vr(b2)},addCommands(){return{insertButtonBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{text:"Button",style:"fill",align:"center",...t}}})}}}),w2="_wrapper_1g9li_1",x2="_selected_1g9li_6",v2="_editor_1g9li_6",k2="_previewShell_1g9li_7",S2="_editorHeader_1g9li_19",C2="_label_1g9li_27",E2="_code_1g9li_36",T2="_codeTextarea_1g9li_42",M2="_preview_1g9li_7",A2="_empty_1g9li_71",_2="_previewToolbar_1g9li_79",Kt={wrapper:w2,selected:x2,editor:v2,previewShell:k2,editorHeader:S2,label:C2,code:E2,codeTextarea:T2,preview:M2,empty:A2,previewToolbar:_2};function N2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const i=t.attrs.html??"",o=r.isEditable,[l,a]=S.useState(!i),c=[Kt.wrapper,s&&Kt.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:c,"data-drag-handle":!0,children:m.jsx("div",{contentEditable:!1,children:l&&o?m.jsxs("div",{className:Kt.editor,children:[m.jsxs("div",{className:Kt.editorHeader,children:[m.jsx("span",{className:Kt.label,children:"HTML"}),m.jsx(A.Tooltip,{content:"Preview",children:m.jsx(A.IconButton,{"aria-label":"Preview HTML",variant:"transparent",size:"xsmall",icon:m.jsx(VR,{size:14}),onClick:()=>a(!1)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),m.jsx(Fw,{value:i,onValueChange:u=>e({html:u}),highlight:u=>ma.highlight(u,ma.languages.markup,"markup"),padding:12,placeholder:"<p>Paste or write HTML…</p>",className:Kt.code,textareaClassName:Kt.codeTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})]}):m.jsxs("div",{className:Kt.previewShell,children:[i?m.jsx("div",{className:Kt.preview,dangerouslySetInnerHTML:{__html:i}}):m.jsx("p",{className:Kt.empty,children:"Empty HTML block"}),o&&m.jsxs("div",{className:Kt.previewToolbar,children:[m.jsx(A.Tooltip,{content:"Edit HTML",children:m.jsx(A.IconButton,{"aria-label":"Edit HTML",variant:"transparent",size:"xsmall",icon:m.jsx(nc,{size:14}),onClick:()=>a(!0)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})})})}const Dx="htmlBlock",Lx=Se.create({name:Dx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{html:{default:""}}},parseHTML(){return[{tag:"div[data-html-block]",getAttrs:t=>({html:t.innerHTML})}]},renderHTML({node:t}){return["div",le({"data-html-block":""}),t.attrs.html??""]},addNodeView(){return vr(N2)},addCommands(){return{insertHtmlBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{html:"",...t}}})}}}),O2="_wrapper_n5xg6_3",I2="_normal_n5xg6_8",R2="_wide_n5xg6_12",D2="_full_n5xg6_21",L2="_selected_n5xg6_27",j2="_figure_n5xg6_27",P2="_placeholder_n5xg6_28",B2="_frame_n5xg6_39",z2="_media_n5xg6_52",$2="_toolbar_n5xg6_62",H2="_toolbarDivider_n5xg6_82",F2="_caption_n5xg6_90",V2="_captionInput_n5xg6_98",U2="_placeholderIcon_n5xg6_134",W2="_placeholderText_n5xg6_138",q2="_urlInput_n5xg6_144",K2="_placeholderDelete_n5xg6_162",nt={wrapper:O2,normal:I2,wide:R2,full:D2,selected:L2,figure:j2,placeholder:P2,frame:B2,media:z2,toolbar:$2,toolbarDivider:H2,caption:F2,captionInput:V2,placeholderIcon:U2,placeholderText:W2,urlInput:q2,placeholderDelete:K2},J2=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function G2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{src:i,caption:o,layout:l}=t.attrs,[a,c]=S.useState(""),u=r.isEditable,d=nh(i??""),f=[nt.wrapper,nt[l],s&&nt.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:f,"data-drag-handle":!0,children:d?m.jsxs("figure",{className:nt.figure,contentEditable:!1,children:[m.jsx("div",{className:nt.frame,children:d.kind==="iframe"?m.jsx("iframe",{src:d.url,title:o??"Video",className:nt.media,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):m.jsx("video",{src:d.url,className:nt.media,controls:!0})}),u&&m.jsxs("div",{className:nt.toolbar,children:[J2.map(({value:h,label:p,icon:g})=>m.jsx(A.Tooltip,{content:p,children:m.jsx(A.IconButton,{"aria-label":p,variant:l===h?"neutral":"transparent",size:"xsmall",icon:m.jsx(g,{size:14}),onClick:()=>e({layout:h})})},h)),m.jsx("span",{className:nt.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace video",variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),onClick:()=>{c(i??""),e({src:null})}})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete video",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),(u||o)&&m.jsx("figcaption",{className:nt.caption,children:u?m.jsx("input",{type:"text",className:nt.captionInput,value:o??"",placeholder:"Type caption for video (optional)",onChange:h=>e({caption:h.target.value})}):o})]}):m.jsxs("div",{className:nt.placeholder,contentEditable:!1,children:[m.jsx(qw,{size:22,className:nt.placeholderIcon}),m.jsx("p",{className:nt.placeholderText,children:"Paste a YouTube, Vimeo or direct video URL"}),m.jsx("input",{type:"url",className:nt.urlInput,value:a,placeholder:"https://youtube.com/watch?v=…",autoFocus:!0,onChange:h=>c(h.target.value),onKeyDown:h=>{if(h.key!=="Enter")return;h.preventDefault();const p=a.trim();p&&e({src:p})}}),u&&m.jsx("div",{className:nt.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})})}const jx="videoBlock";function nh(t){const e=t.trim();if(!e)return null;const n=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/i);if(n)return{kind:"iframe",url:`https://www.youtube.com/embed/${n[1]}`};const r=e.match(/vimeo\.com\/(?:video\/)?(\d+)/i);return r?{kind:"iframe",url:`https://player.vimeo.com/video/${r[1]}`}:{kind:"file",url:e}}const Px=Se.create({name:jx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{src:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-video-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,caption:r}=e.attrs,s=nh(n??"");return["figure",le({"data-video-block":""},{"data-layout":t["data-layout"]}),(s==null?void 0:s.kind)==="file"?["video",{src:s.url,controls:"true"}]:["iframe",{src:(s==null?void 0:s.url)??"",frameborder:"0",allowfullscreen:"true"}],...r?[["figcaption",{},r]]:[]]},addNodeView(){return vr(G2)},addCommands(){return{insertVideoBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),Y2="_wrapper_1fr97_3",X2="_normal_1fr97_8",Q2="_wide_1fr97_12",Z2="_full_1fr97_21",ej="_selected_1fr97_27",tj="_figure_1fr97_27",nj="_fileInput_1fr97_32",rj="_grid_1fr97_42",sj="_gridDragOver_1fr97_50",ij="_cell_1fr97_56",oj="_image_1fr97_64",lj="_removeImage_1fr97_71",aj="_cellEditing_1fr97_97",cj="_altBadgeButton_1fr97_105",uj="_altBadgeButtonSet_1fr97_136",dj="_placeholder_1fr97_142",fj="_dragOver_1fr97_153",hj="_placeholderBody_1fr97_158",pj="_placeholderIcon_1fr97_173",mj="_placeholderText_1fr97_177",gj="_toolbar_1fr97_183",yj="_toolbarDivider_1fr97_203",bj="_caption_1fr97_211",wj="_captionInput_1fr97_218",xj="_captionAlt_1fr97_244",vj="_altBadge_1fr97_105",kj="_altInput_1fr97_263",Sj="_error_1fr97_276",ye={wrapper:Y2,normal:X2,wide:Q2,full:Z2,selected:ej,figure:tj,fileInput:nj,grid:rj,gridDragOver:sj,cell:ij,image:oj,removeImage:lj,cellEditing:aj,altBadgeButton:cj,altBadgeButtonSet:uj,placeholder:dj,dragOver:fj,placeholderBody:hj,placeholderIcon:pj,placeholderText:mj,toolbar:gj,toolbarDivider:yj,caption:bj,captionInput:wj,captionAlt:xj,altBadge:vj,altInput:kj,error:Sj},Cj=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}],Ej=3;function Tj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const o=t.attrs.images??[],{caption:l,layout:a}=t.attrs,c=i.options,u=S.useRef(null),d=S.useRef(null),[f,h]=S.useState(!1),[p,g]=S.useState(null),[y,b]=S.useState(!1),[x,w]=S.useState(null),v=r.isEditable,k=x!==null&&x<o.length?x:null;S.useEffect(()=>{var R;k!==null&&((R=d.current)==null||R.focus())},[k]);async function C(R){if(!c.onUpload){g("Uploading is not configured");return}g(null),h(!0);try{const j=[];for(const F of R){const $=await c.onUpload(F);j.push({src:$})}e({images:[...o,...j]})}catch(j){g(j instanceof Error?j.message:"Upload failed")}finally{h(!1)}}function E(R){return Array.from(R.dataTransfer.types??[]).includes("Files")}function O(R){!v||!E(R)||(R.preventDefault(),b(!0))}function _(){b(!1)}function T(R){if(!v||!E(R))return;R.preventDefault(),b(!1);const j=Array.from(R.dataTransfer.files??[]).filter(F=>F.type.startsWith("image/"));j.length&&C(j)}function D(R){e({images:o.filter((j,F)=>F!==R)}),w(null)}function I(R,j){e({images:o.map((F,$)=>$===R?{...F,alt:j}:F)})}function P(R){if(k===null)return;const j=R.relatedTarget;j&&R.currentTarget.contains(j)||w(null)}const N=[ye.wrapper,ye[a],s&&ye.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:N,"data-drag-handle":!0,children:[m.jsx("input",{ref:u,type:"file",accept:c.accept,multiple:!0,className:ye.fileInput,onChange:R=>{const j=Array.from(R.target.files??[]);R.target.value="",j.length&&C(j)}}),m.jsxs("figure",{className:ye.figure,contentEditable:!1,onBlur:P,onDragOver:O,onDragLeave:_,onDrop:T,children:[o.length>0?m.jsx("div",{className:[ye.grid,y&&ye.gridDragOver].filter(Boolean).join(" "),style:{"--gallery-columns":Math.min(Ej,o.length)},children:o.map((R,j)=>m.jsxs("div",{className:[ye.cell,k===j&&ye.cellEditing].filter(Boolean).join(" "),children:[m.jsx("img",{src:R.src,alt:R.alt??"",className:ye.image}),v&&m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:[ye.altBadgeButton,R.alt&&ye.altBadgeButtonSet].filter(Boolean).join(" "),"aria-label":`Edit alt text for image ${j+1}`,"aria-pressed":k===j,onClick:()=>w(F=>F===j?null:j),children:"ALT"}),m.jsx("button",{type:"button",className:ye.removeImage,"aria-label":"Remove image",onClick:()=>D(j),children:m.jsx(xR,{size:13})})]})]},`${R.src}-${j}`))}):m.jsx("div",{className:[ye.placeholder,y&&ye.dragOver].filter(Boolean).join(" "),children:m.jsxs("button",{type:"button",className:ye.placeholderBody,onClick:()=>{var R;return(R=u.current)==null?void 0:R.click()},disabled:!v||f,children:[f?m.jsx(A.Spinner,{size:"md"}):m.jsx(kd,{size:22,className:ye.placeholderIcon}),m.jsx("span",{className:ye.placeholderText,children:f?"Uploading…":"Click to select images, or drag them here"})]})}),v&&m.jsxs("div",{className:ye.toolbar,children:[o.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(A.Tooltip,{content:"Add images",children:m.jsx(A.IconButton,{"aria-label":"Add images",variant:"transparent",size:"xsmall",icon:m.jsx(kd,{size:14}),loading:f,onClick:()=>{var R;return(R=u.current)==null?void 0:R.click()}})}),m.jsx("span",{className:ye.toolbarDivider})]}),Cj.map(({value:R,label:j,icon:F})=>m.jsx(A.Tooltip,{content:j,children:m.jsx(A.IconButton,{"aria-label":j,variant:a===R?"neutral":"transparent",size:"xsmall",icon:m.jsx(F,{size:14}),onClick:()=>e({layout:R})})},R)),m.jsx("span",{className:ye.toolbarDivider}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete gallery",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),p&&m.jsxs("p",{className:ye.error,children:[m.jsx(Xf,{size:14}),p]}),(v||l)&&o.length>0&&m.jsxs("figcaption",{className:[ye.caption,k!==null&&ye.captionAlt].filter(Boolean).join(" "),children:[!v&&l,v&&k!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:ye.altBadge,"aria-hidden":"true",children:["ALT ",k+1]}),m.jsx("input",{ref:d,type:"text",className:[ye.captionInput,ye.altInput].join(" "),value:o[k].alt??"","aria-label":`Alt text for image ${k+1}`,placeholder:"Describe this image for screen readers",onChange:R=>I(k,R.target.value),onKeyDown:R=>{R.key!=="Enter"&&R.key!=="Escape"||(R.preventDefault(),w(null))}})]}),v&&k===null&&m.jsx("input",{type:"text",className:ye.captionInput,value:l??"","aria-label":"Caption",placeholder:"Type caption for gallery (optional)",onChange:R=>e({caption:R.target.value})})]})]})]})}const Bx="gallery",zx=Se.create({name:Bx,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*"}},addAttributes(){return{images:{default:[],parseHTML:t=>{const e=t.getAttribute("data-images");if(!e)return[];try{return JSON.parse(e)}catch{return[]}},renderHTML:t=>({"data-images":JSON.stringify(t.images??[])})},caption:{default:null},layout:{default:"wide",parseHTML:t=>t.getAttribute("data-layout")??"wide",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-gallery-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.images??[],{caption:r}=e.attrs;return["figure",le({"data-gallery-block":""},t),["div",{"data-gallery-grid":""},...n.map(s=>["img",{src:s.src,alt:s.alt??""}])],...r?[["figcaption",{},r]]:[]]},addNodeView(){return vr(Tj)},addCommands(){return{insertGalleryBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{images:[],layout:"wide",...t}}})}}}),Mj="_wrapper_1cd7f_1",Aj="_selected_1cd7f_9",_j="_header_1cd7f_14",Nj="_chevron_1cd7f_22",Oj="_chevronOpen_1cd7f_43",Ij="_summary_1cd7f_47",Rj="_summaryInput_1cd7f_48",Dj="_actions_1cd7f_68",Lj="_defaultState_1cd7f_83",jj="_defaultStateOn_1cd7f_95",Pj="_body_1cd7f_101",Bj="_bodyCollapsed_1cd7f_105",Rt={wrapper:Mj,selected:Aj,header:_j,chevron:Nj,chevronOpen:Oj,summary:Ij,summaryInput:Rj,actions:Dj,defaultState:Lj,defaultStateOn:jj,body:Pj,bodyCollapsed:Bj};function zj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{summary:i,open:o}=t.attrs,l=r.isEditable,[a,c]=S.useState(!1),u=!a,d=[Rt.wrapper,s&&Rt.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:d,children:[m.jsxs("div",{className:Rt.header,contentEditable:!1,children:[m.jsx("button",{type:"button",className:[Rt.chevron,u&&Rt.chevronOpen].filter(Boolean).join(" "),"aria-label":u?"Collapse":"Expand","aria-expanded":u,onClick:()=>c(f=>!f),children:m.jsx(GR,{size:16})}),l?m.jsx("input",{type:"text",className:Rt.summaryInput,value:i??"",placeholder:"Toggle heading",onChange:f=>e({summary:f.target.value})}):m.jsx("span",{className:Rt.summary,children:i}),l&&m.jsxs("div",{className:Rt.actions,children:[m.jsx(A.Tooltip,{content:o?"Open by default":"Closed by default",children:m.jsx("button",{type:"button",className:[Rt.defaultState,o&&Rt.defaultStateOn].filter(Boolean).join(" "),onClick:()=>e({open:!o}),children:o?"Open by default":"Closed by default"})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete toggle",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]}),m.jsx(L0,{className:[Rt.body,!u&&Rt.bodyCollapsed].filter(Boolean).join(" ")})]})}const $x="toggleBlock",Hx=Se.create({name:$x,group:"block",content:"block+",defining:!0,addAttributes(){return{summary:{default:""},open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:t=>t.open?{open:"true"}:{}}}},parseHTML(){return[{tag:"details[data-toggle-block]"}]},renderHTML({HTMLAttributes:t,node:e}){return["details",le({"data-toggle-block":""},t),["summary",{},e.attrs.summary??""],["div",{"data-toggle-body":""},0]]},addNodeView(){return vr(zj)},addCommands(){return{insertToggleBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{summary:"",open:!1,...t},content:[{type:"paragraph"}]})}}}),$j="_wrapper_1uoda_1",Hj="_selected_1uoda_6",Fj="_card_1uoda_6",Vj="_placeholder_1uoda_7",Uj="_thumb_1uoda_23",Wj="_thumbImage_1uoda_35",qj="_thumbFallback_1uoda_42",Kj="_body_1uoda_47",Jj="_title_1uoda_52",Gj="_subtitle_1uoda_64",Yj="_meta_1uoda_70",Xj="_toolbar_1uoda_77",Qj="_placeholderBody_1uoda_110",Zj="_placeholderIcon_1uoda_126",eP="_placeholderText_1uoda_131",tP="_placeholderDelete_1uoda_136",nP="_error_1uoda_149",Xe={wrapper:$j,selected:Hj,card:Fj,placeholder:Vj,thumb:Uj,thumbImage:Wj,thumbFallback:qj,body:Kj,title:Jj,subtitle:Gj,meta:Yj,toolbar:Xj,placeholderBody:Qj,placeholderIcon:Zj,placeholderText:eP,placeholderDelete:tP,error:nP};function rP({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i,noun:o,icon:l}){const a=t.attrs.entity,c=i.options,[u,d]=S.useState(!1),[f,h]=S.useState(null),p=r.isEditable;async function g(){if(!c.onPick){h("No picker is configured");return}h(null),d(!0);try{const b=await c.onPick();b&&e({entity:b})}catch(b){h(b instanceof Error?b.message:"Could not load the selection")}finally{d(!1)}}const y=[Xe.wrapper,s&&Xe.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:y,"data-drag-handle":!0,children:a?m.jsxs("div",{className:Xe.card,contentEditable:!1,children:[m.jsx("div",{className:Xe.thumb,children:a.imageUrl?m.jsx("img",{src:a.imageUrl,alt:"",className:Xe.thumbImage}):m.jsx("span",{className:Xe.thumbFallback,children:l})}),m.jsxs("div",{className:Xe.body,children:[m.jsx("p",{className:Xe.title,children:a.title}),a.subtitle&&m.jsx("p",{className:Xe.subtitle,children:a.subtitle}),a.meta&&m.jsx("p",{className:Xe.meta,children:a.meta})]}),p&&m.jsxs("div",{className:Xe.toolbar,children:[m.jsx(A.Tooltip,{content:`Change ${o}`,children:m.jsx(A.IconButton,{"aria-label":`Change ${o}`,variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),loading:u,onClick:g})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":`Delete ${o} block`,variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]}):m.jsxs("div",{className:Xe.placeholder,contentEditable:!1,children:[m.jsxs("button",{type:"button",className:Xe.placeholderBody,onClick:g,disabled:!p||u,children:[u?m.jsx(A.Spinner,{size:"md"}):m.jsx("span",{className:Xe.placeholderIcon,children:l}),m.jsx("span",{className:Xe.placeholderText,children:u?"Opening…":`Click to select a ${o}`})]}),f&&m.jsxs("p",{className:Xe.error,children:[m.jsx(Xf,{size:14}),f]}),p&&m.jsx("div",{className:Xe.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})})}const Fx="productBlock",Vx="collectionBlock";function Ux(t){return Se.create({name:t.name,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onPick:void 0}},addAttributes(){return{entity:{default:null,parseHTML:e=>{const n=e.getAttribute("data-entity");if(!n)return null;try{return JSON.parse(n)}catch{return null}},renderHTML:e=>({"data-entity":e.entity?JSON.stringify(e.entity):null})}}},parseHTML(){return[{tag:`div[${t.dataAttribute}]`}]},renderHTML({HTMLAttributes:e}){return["div",le({[t.dataAttribute]:""},e)]},addNodeView(){return vr(e=>m.jsx(rP,{...e,noun:t.noun,icon:t.icon}))},addCommands(){return{[t.command]:e=>({commands:n,state:r})=>Vs({commands:n,state:r,node:{type:t.name,attrs:{entity:e??null}}})}}})}const Wx=Ux({name:Fx,dataAttribute:"data-product-block",command:"insertProductBlock",noun:"product",icon:m.jsx(C1,{size:22})}),qx=Ux({name:Vx,dataAttribute:"data-collection-block",command:"insertCollectionBlock",noun:"collection",icon:m.jsx(D1,{size:22})}),sP="_title_b828n_3",iP={title:sP};function oP({value:t,placeholder:e,readOnly:n,onChange:r,onLeave:s}){const i=S.useRef(null);return S.useLayoutEffect(()=>{const o=i.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[t]),m.jsx("textarea",{ref:i,className:iP.title,value:t,placeholder:e,readOnly:n,rows:1,spellCheck:!1,onChange:o=>r(o.target.value.replace(/\n/g,"")),onKeyDown:o=>{(o.key==="Enter"||o.key==="ArrowDown")&&(o.preventDefault(),s())}})}const Kx=["top","right","bottom","left"],og=["start","end"],lg=Kx.reduce((t,e)=>t.concat(e,e+"-"+og[0],e+"-"+og[1]),[]),bn=Math.min,ht=Math.max,ya=Math.round,pn=t=>({x:t,y:t}),lP={left:"right",right:"left",bottom:"top",top:"bottom"};function Nd(t,e,n){return ht(t,bn(e,n))}function Hn(t,e){return typeof t=="function"?t(e):t}function Ut(t){return t.split("-")[0]}function Xt(t){return t.split("-")[1]}function Jx(t){return t==="x"?"y":"x"}function rh(t){return t==="y"?"height":"width"}function dn(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function sh(t){return Jx(dn(t))}function Gx(t,e,n){n===void 0&&(n=!1);const r=Xt(t),s=sh(t),i=rh(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wa(o)),[o,wa(o)]}function aP(t){const e=wa(t);return[ba(t),e,ba(e)]}function ba(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const ag=["left","right"],cg=["right","left"],cP=["top","bottom"],uP=["bottom","top"];function dP(t,e,n){switch(t){case"top":case"bottom":return n?e?cg:ag:e?ag:cg;case"left":case"right":return e?cP:uP;default:return[]}}function fP(t,e,n,r){const s=Xt(t);let i=dP(Ut(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(ba)))),i}function wa(t){const e=Ut(t);return lP[e]+t.slice(e.length)}function hP(t){return{top:0,right:0,bottom:0,left:0,...t}}function ih(t){return typeof t!="number"?hP(t):{top:t,right:t,bottom:t,left:t}}function Os(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function ug(t,e,n){let{reference:r,floating:s}=t;const i=dn(e),o=sh(e),l=rh(o),a=Ut(e),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[l]/2-s[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Xt(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}async function pP(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=Hn(e,t),p=ih(h),y=l[f?d==="floating"?"reference":"floating":d],b=Os(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),x=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),v=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},k=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:w,strategy:a}):x);return{top:(b.top-k.top+p.top)/v.y,bottom:(k.bottom-b.bottom+p.bottom)/v.y,left:(b.left-k.left+p.left)/v.x,right:(k.right-b.right+p.right)/v.x}}const mP=50,gP=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:pP},a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=ug(c,r,a),f=r,h=0;const p={};for(let g=0;g<i.length;g++){const y=i[g];if(!y)continue;const{name:b,fn:x}=y,{x:w,y:v,data:k,reset:C}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});u=w??u,d=v??d,p[b]={...p[b],...k},C&&h<mP&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):C.rects),{x:u,y:d}=ug(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},yP=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=Hn(t,e)||{};if(c==null)return{};const d=ih(u),f={x:n,y:r},h=sh(s),p=rh(h),g=await o.getDimensions(c),y=h==="y",b=y?"top":"left",x=y?"bottom":"right",w=y?"clientHeight":"clientWidth",v=i.reference[p]+i.reference[h]-f[h]-i.floating[p],k=f[h]-i.reference[h],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let E=C?C[w]:0;(!E||!await(o.isElement==null?void 0:o.isElement(C)))&&(E=l.floating[w]||i.floating[p]);const O=v/2-k/2,_=E/2-g[p]/2-1,T=bn(d[b],_),D=bn(d[x],_),I=T,P=E-g[p]-D,N=E/2-g[p]/2+O,R=Nd(I,N,P),j=!a.arrow&&Xt(s)!=null&&N!==R&&i.reference[p]/2-(N<I?T:D)-g[p]/2<0,F=j?N<I?N-I:N-P:0;return{[h]:f[h]+F,data:{[h]:R,centerOffset:N-R-F,...j&&{alignmentOffset:F}},reset:j}}});function bP(t,e,n){return(t?[...n.filter(s=>Xt(s)===t),...n.filter(s=>Xt(s)!==t)]:n.filter(s=>Ut(s)===s)).filter(s=>t?Xt(s)===t||(e?ba(s)!==s:!1):!0)}const wP=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=lg,autoAlignment:h=!0,...p}=Hn(t,e),g=d!==void 0||f===lg?bP(d||null,h,f):f,y=await a.detectOverflow(e,p),b=((n=o.autoPlacement)==null?void 0:n.index)||0,x=g[b];if(x==null)return{};const w=Gx(x,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==x)return{reset:{placement:g[0]}};const v=[y[Ut(x)],y[w[0]],y[w[1]]],k=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:x,overflows:v}],C=g[b+1];if(C)return{data:{index:b+1,overflows:k},reset:{placement:C}};const E=k.map(T=>{const D=Xt(T.placement);return[T.placement,D&&u?T.overflows.slice(0,2).reduce((I,P)=>I+P,0):T.overflows[0],T.overflows]}).sort((T,D)=>T[1]-D[1]),_=((s=E.filter(T=>T[2].slice(0,Xt(T[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||E[0][0];return _!==l?{data:{index:b+1,overflows:k},reset:{placement:_}}:{}}}},xP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=Hn(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Ut(s),x=dn(l),w=Ut(l)===l,v=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=f||(w||!g?[wa(l)]:aP(l)),C=p!=="none";!f&&C&&k.push(...fP(l,g,p,v));const E=[l,...k],O=await a.detectOverflow(e,y),_=[];let T=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&_.push(O[b]),d){const N=Gx(s,o,v);_.push(O[N[0]],O[N[1]])}if(T=[...T,{placement:s,overflows:_}],!_.every(N=>N<=0)){var D,I;const N=(((D=i.flip)==null?void 0:D.index)||0)+1,R=E[N];if(R&&(!(d==="alignment"?x!==dn(R):!1)||T.every($=>dn($.placement)===x?$.overflows[0]>0:!0)))return{data:{index:N,overflows:T},reset:{placement:R}};let j=(I=T.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:I.placement;if(!j)switch(h){case"bestFit":{var P;const F=(P=T.filter($=>{if(C){const V=dn($.placement);return V===x||V==="y"}return!0}).map($=>[$.placement,$.overflows.filter(V=>V>0).reduce((V,fe)=>V+fe,0)]).sort(($,V)=>$[1]-V[1])[0])==null?void 0:P[0];F&&(j=F);break}case"initialPlacement":j=l;break}if(s!==j)return{reset:{placement:j}}}return{}}}};function dg(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function fg(t){return Kx.some(e=>t[e]>=0)}const vP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=Hn(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=dg(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:fg(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),l=dg(o,n.floating);return{data:{escapedOffsets:l,escaped:fg(l)}}}default:return{}}}}};function Yx(t){const e=bn(...t.map(i=>i.left)),n=bn(...t.map(i=>i.top)),r=ht(...t.map(i=>i.right)),s=ht(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function kP(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>Os(Yx(s)))}const SP=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:o}=e,{padding:l=2,x:a,y:c}=Hn(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),d=kP(u),f=Os(Yx(u)),h=ih(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-h.left&&a<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom)||f;if(d.length>=2){if(dn(n)==="y"){const T=d[0],D=d[d.length-1],I=Ut(n)==="top",P=T.top,N=D.bottom,R=I?T.left:D.left,j=I?T.right:D.right,F=j-R,$=N-P;return{top:P,bottom:N,left:R,right:j,width:F,height:$,x:R,y:P}}const y=Ut(n)==="left",b=ht(...d.map(T=>T.right)),x=bn(...d.map(T=>T.left)),w=d.filter(T=>y?T.left===x:T.right===b),v=w[0].top,k=w[w.length-1].bottom,C=x,E=b,O=E-C,_=k-v;return{top:v,bottom:k,left:C,right:E,width:O,height:_,x:C,y:v}}return f}const g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return s.reference.x!==g.reference.x||s.reference.y!==g.reference.y||s.reference.width!==g.reference.width||s.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},CP=new Set(["left","top"]);async function EP(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Ut(n),l=Xt(n),a=dn(n)==="y",c=CP.has(o)?-1:1,u=i&&a?-1:1,d=Hn(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const TP=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await EP(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},MP=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:b=>{let{x,y:w}=b;return{x,y:w}}},...c}=Hn(t,e),u={x:n,y:r},d=await i.detectOverflow(e,c),f=dn(Ut(s)),h=Jx(f);let p=u[h],g=u[f];if(o){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=p+d[b],v=p-d[x];p=Nd(w,p,v)}if(l){const b=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=g+d[b],v=g-d[x];g=Nd(w,g,v)}const y=a.fn({...e,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:o,[f]:l}}}}}},AP=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=Hn(t,e),u=await o.detectOverflow(e,c),d=Ut(s),f=Xt(s),h=dn(s)==="y",{width:p,height:g}=i.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,w=p-u.left-u.right,v=bn(g-u[y],x),k=bn(p-u[b],w),C=!e.middlewareData.shift;let E=v,O=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=w),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(E=x),C&&!f){const T=ht(u.left,0),D=ht(u.right,0),I=ht(u.top,0),P=ht(u.bottom,0);h?O=p-2*(T!==0||D!==0?T+D:ht(u.left,u.right)):E=g-2*(I!==0||P!==0?I+P:ht(u.top,u.bottom))}await a({...e,availableWidth:O,availableHeight:E});const _=await o.getDimensions(l.floating);return p!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function Us(t){return Xx(t)?(t.nodeName||"").toLowerCase():"#document"}function Nt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Fn(t){var e;return(e=(Xx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xx(t){return rc()?t instanceof Node||t instanceof Nt(t).Node:!1}function Zt(t){return rc()?t instanceof Element||t instanceof Nt(t).Element:!1}function Vn(t){return rc()?t instanceof HTMLElement||t instanceof Nt(t).HTMLElement:!1}function hg(t){return!rc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Nt(t).ShadowRoot}function ko(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=en(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function _P(t){return/^(table|td|th)$/.test(Us(t))}function sc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const NP=/transform|translate|scale|rotate|perspective|filter/,OP=/paint|layout|strict|content/,Cr=t=>!!t&&t!=="none";let cu;function oh(t){const e=Zt(t)?en(t):t;return Cr(e.transform)||Cr(e.translate)||Cr(e.scale)||Cr(e.rotate)||Cr(e.perspective)||!lh()&&(Cr(e.backdropFilter)||Cr(e.filter))||NP.test(e.willChange||"")||OP.test(e.contain||"")}function IP(t){let e=hr(t);for(;Vn(e)&&!Is(e);){if(oh(e))return e;if(sc(e))return null;e=hr(e)}return null}function lh(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Is(t){return/^(html|body|#document)$/.test(Us(t))}function en(t){return Nt(t).getComputedStyle(t)}function ic(t){return Zt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function hr(t){if(Us(t)==="html")return t;const e=t.assignedSlot||t.parentNode||hg(t)&&t.host||Fn(t);return hg(e)?e.host:e}function Qx(t){const e=hr(t);return Is(e)?t.ownerDocument?t.ownerDocument.body:t.body:Vn(e)&&ko(e)?e:Qx(e)}function Zx(t,e,n){var r;e===void 0&&(e=[]);const s=Qx(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Nt(s);return i?(Od(o),e.concat(o,o.visualViewport||[],ko(s)?s:[],[])):e.concat(s,Zx(s,[]))}function Od(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ev(t){const e=en(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Vn(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=ya(n)!==i||ya(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function tv(t){return Zt(t)?t:t.contextElement}function gs(t){const e=tv(t);if(!Vn(e))return pn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=ev(e);let o=(i?ya(n.width):n.width)/r,l=(i?ya(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const RP=pn(0);function nv(t){const e=Nt(t);return!lh()||!e.visualViewport?RP:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function DP(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Nt(t)?!1:e}function no(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=tv(t);let o=pn(1);e&&(r?Zt(r)&&(o=gs(r)):o=gs(t));const l=DP(i,n,r)?nv(i):pn(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const f=Nt(i),h=r&&Zt(r)?Nt(r):r;let p=f,g=Od(p);for(;g&&r&&h!==p;){const y=gs(g),b=g.getBoundingClientRect(),x=en(g),w=b.left+(g.clientLeft+parseFloat(x.paddingLeft))*y.x,v=b.top+(g.clientTop+parseFloat(x.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=w,c+=v,p=Nt(g),g=Od(p)}}return Os({width:u,height:d,x:a,y:c})}function oc(t,e){const n=ic(t).scrollLeft;return e?e.left+n:no(Fn(t)).left+n}function rv(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-oc(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function LP(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Fn(r),l=e?sc(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=pn(1);const u=pn(0),d=Vn(r);if((d||!d&&!i)&&((Us(r)!=="body"||ko(o))&&(a=ic(r)),d)){const h=no(r);c=gs(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=o&&!d&&!i?rv(o,a):pn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-a.scrollTop*c.y+u.y+f.y}}function jP(t){return Array.from(t.getClientRects())}function PP(t){const e=Fn(t),n=ic(t),r=t.ownerDocument.body,s=ht(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ht(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+oc(t);const l=-n.scrollTop;return en(r).direction==="rtl"&&(o+=ht(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const pg=25;function BP(t,e){const n=Nt(t),r=Fn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const u=lh();(!u||u&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=oc(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=pg&&(i-=p)}else c<=pg&&(i+=c);return{width:i,height:o,x:l,y:a}}function zP(t,e){const n=no(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Vn(t)?gs(t):pn(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function mg(t,e,n){let r;if(e==="viewport")r=BP(t,n);else if(e==="document")r=PP(Fn(t));else if(Zt(e))r=zP(e,n);else{const s=nv(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Os(r)}function sv(t,e){const n=hr(t);return n===e||!Zt(n)||Is(n)?!1:en(n).position==="fixed"||sv(n,e)}function $P(t,e){const n=e.get(t);if(n)return n;let r=Zx(t,[]).filter(l=>Zt(l)&&Us(l)!=="body"),s=null;const i=en(t).position==="fixed";let o=i?hr(t):t;for(;Zt(o)&&!Is(o);){const l=en(o),a=oh(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ko(o)&&!a&&sv(t,o))?r=r.filter(u=>u!==o):s=l,o=hr(o)}return e.set(t,r),r}function HP(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?sc(e)?[]:$P(e,this._c):[].concat(n),r],l=mg(e,o[0],s);let a=l.top,c=l.right,u=l.bottom,d=l.left;for(let f=1;f<o.length;f++){const h=mg(e,o[f],s);a=ht(h.top,a),c=bn(h.right,c),u=bn(h.bottom,u),d=ht(h.left,d)}return{width:c-d,height:u-a,x:d,y:a}}function FP(t){const{width:e,height:n}=ev(t);return{width:e,height:n}}function VP(t,e,n){const r=Vn(e),s=Fn(e),i=n==="fixed",o=no(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=pn(0);function c(){a.x=oc(s)}if(r||!r&&!i)if((Us(e)!=="body"||ko(s))&&(l=ic(e)),r){const h=no(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?rv(s,l):pn(0),d=o.left+l.scrollLeft-a.x-u.x,f=o.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function uu(t){return en(t).position==="static"}function gg(t,e){if(!Vn(t)||en(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Fn(t)===n&&(n=n.ownerDocument.body),n}function iv(t,e){const n=Nt(t);if(sc(t))return n;if(!Vn(t)){let s=hr(t);for(;s&&!Is(s);){if(Zt(s)&&!uu(s))return s;s=hr(s)}return n}let r=gg(t,e);for(;r&&_P(r)&&uu(r);)r=gg(r,e);return r&&Is(r)&&uu(r)&&!oh(r)?n:r||IP(t)||n}const UP=async function(t){const e=this.getOffsetParent||iv,n=this.getDimensions,r=await n(t.floating);return{reference:VP(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WP(t){return en(t).direction==="rtl"}const qP={convertOffsetParentRelativeRectToViewportRelativeRect:LP,getDocumentElement:Fn,getClippingRect:HP,getOffsetParent:iv,getElementRects:UP,getClientRects:jP,getDimensions:FP,getScale:gs,isElement:Zt,isRTL:WP},ov=TP,lv=wP,av=MP,cv=xP,uv=AP,dv=vP,fv=yP,hv=SP,ah=(t,e,n)=>{const r=new Map,s={platform:qP,...n},i={...s.platform,_c:r};return gP(t,e,{...s,platform:i})};function KP(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,l=r-n,a=s,c=n;return new DOMRect(a,c,o,l)}var JP=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:s=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:f,from:h,to:p})=>{const{doc:g,selection:y}=f,{empty:b}=y,x=!g.textBetween(h,p).length&&Ja(f.selection),w=this.element.contains(document.activeElement);return!(!(d.hasFocus()||w)||b||x||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d!=null&&d.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(d.relatedTarget))||(d==null?void 0:d.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,f)=>{const h=!(f!=null&&f.selection.eq(d.state.selection)),p=!(f!=null&&f.doc.eq(d.state.doc));!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,h,p,f)},this.updateDelay))},this.updateHandler=(d,f,h,p)=>{const{composing:g}=d;if(g||!f&&!h)return;if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:d})=>{const f=d.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"?this.updateOptions(f.options):f==="hide"?this.hide():f==="show"&&(this.updatePosition(),this.show())};var u;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(u=c==null?void 0:c.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,s=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(s)return s;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const i=d0(this.view,r.from,r.to);let o={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof Q){let l=this.view.nodeDOM(r.from);const a=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");a&&(l=a),l&&(o={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(r instanceof be){const{$anchorCell:l,$headCell:a}=r,c=l?l.pos:a.pos,u=a?a.pos:l.pos,d=this.view.nodeDOM(c),f=this.view.nodeDOM(u);if(!d||!f)return;const h=d===f?d.getBoundingClientRect():KP(d.getBoundingClientRect(),f.getBoundingClientRect());o={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&ah(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:s})=>{var i,o;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=s.hide)!=null&&i.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!(e!=null&&e.selection.eq(t.state.selection)),i=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pv=t=>new ue({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new JP({view:e,...t})});oe.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[pv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var GP=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:s=250,resizeDelay:i=60,options:o,appendTo:l,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:f}=d,{$anchor:h,empty:p}=f,g=h.depth===1,y=h.parent.isTextblock&&!h.parent.type.spec.code&&!h.parent.textContent&&h.parent.childCount===0&&!this.getTextContent(h.parent);return!(!u.hasFocus()||!p||!g||!y||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,f,h)=>{const{composing:p}=u;if(p||!d&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(c=o==null?void 0:o.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return i0(t,{textSerializers:vf(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!((e=(t=this.view)==null?void 0:t.dom)!=null&&e.parentNode))return;const{selection:n}=this.editor.state,r=d0(this.view,n.from,n.to);ah({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:l,middlewareData:a})=>{var c,u;if((c=a.hide)!=null&&c.referenceHidden||(u=a.hide)!=null&&u.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=l,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!(e!=null&&e.selection.eq(t.state.selection)),r=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},mv=t=>new ue({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new GP({view:e,...t})});oe.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[mv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function gv(t,e){return t??new ae(e)}var YP=typeof window<"u"?S.useLayoutEffect:S.useEffect,yv=new Set(["left","opacity","position","top","visibility","width"]),XP=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),QP=new Set(["children","className","style"]),ZP=new Set(["tabIndex"]),eB=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),tB={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Id(t,e){return/^on[A-Z]/.test(t)&&typeof e=="function"}function nB(t){return t.startsWith("aria-")||t.startsWith("data-"),t}function rB(t){return t.startsWith("aria-")||t.startsWith("data-")||eB.has(t)}function bv(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function sB(t){var e;const n=t.endsWith("Capture"),s=(n?t.slice(0,-7):t).slice(2);return{eventName:(e=tB[s])!=null?e:s.toLowerCase(),options:n?{capture:!0}:void 0}}function iB(t,e){let n=e.defaultPrevented,r=!1;const s=Object.create(e);return Object.defineProperties(s,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),s}function du(t){return ZP.has(t)}function yg(t,e,n){if(e==="tabIndex"){t.tabIndex=Number(n);return}t[e]=n}function oB(t,e){if(e==="tabIndex"){t.removeAttribute("tabindex");return}const n=t[e];if(typeof n=="boolean"){t[e]=!1;return}if(typeof n=="number"){t[e]=0;return}t[e]=""}function lB(t,e){return typeof e!="number"||e===0||t.startsWith("--")||XP.has(t)?String(e):`${e}px`}function aB(t,e){yv.has(e)||t.style.removeProperty(bv(e))}function cB(t,e,n){yv.has(e)||t.style.setProperty(bv(e),lB(e,n))}function uB(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(s=>{if(QP.has(s)||!rB(s)||Id(s,e[s])||Id(s,n[s]))return;const i=e[s],o=n[s];if(i===o)return;const l=nB(s);if(o==null||o===!1){du(s)&&oB(t,s),t.removeAttribute(l);return}if(o===!0){du(s)&&yg(t,s,!0),t.setAttribute(l,"");return}if(du(s)){yg(t,s,o);return}t.setAttribute(l,String(o))})}function dB(t,e,n){if(e!==n){if(n){t.className=n;return}t.removeAttribute("class")}}function fB(t,e,n){const r=e??{},s=n??{};new Set([...Object.keys(r),...Object.keys(s)]).forEach(o=>{const l=r[o],a=s[o];if(l!==a){if(a==null){aB(t,o);return}cB(t,o,a)}})}function hB(t,e,n){e.forEach(({eventName:s,listener:i,options:o})=>{t.removeEventListener(s,i,o)});const r=[];return Object.entries(n).forEach(([s,i])=>{if(!Id(s,i))return;const{eventName:o,options:l}=sB(s),a=c=>{i(iB(t,c))};t.addEventListener(o,a,l),r.push({eventName:o,listener:a,options:l})}),r}function wv(t,e){const n=S.useRef({}),r=S.useRef([]);YP(()=>{const s=n.current;return dB(t,s.className,e.className),fB(t,s.style,e.style),uB(t,s,e),r.current=hB(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:i,listener:o,options:l})=>{t.removeEventListener(i,o,l)}),r.current=[]}},[t,e])}var xv=S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,getReferencedVirtualElement:o,options:l,children:a,...c},u)=>{const d=S.useRef(document.createElement("div")),f=S.useRef(gv(t,"bubbleMenu")).current;wv(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:h}=I0(),p=e||h,g={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:f,shouldShow:i,getReferencedVirtualElement:o,options:l},y=S.useRef(g);y.current=g;const[b,x]=S.useState(!1),w=S.useRef(!0);return S.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=d.current;v.style.visibility="hidden",v.style.position="absolute";const k=pv({...y.current,editor:p,element:v});p.registerPlugin(k);const C=y.current.pluginKey;return w.current=!0,x(!0),()=>{x(!1),p.unregisterPlugin(C),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[p]),S.useEffect(()=>{if(!(!b||!p||p.isDestroyed)){if(w.current){w.current=!1;return}p.view.dispatch(p.state.tr.setMeta(f,{type:"updateOptions",options:y.current}))}},[b,p,n,r,i,l,s,o,f]),zs.createPortal(a,d.current)});S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,options:o,children:l,...a},c)=>{const u=S.useRef(document.createElement("div")),d=S.useRef(gv(t,"floatingMenu")).current;wv(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:f}=I0(),h=e||f,p={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:d,shouldShow:i,options:o},g=S.useRef(p);g.current=p;const[y,b]=S.useState(!1),x=S.useRef(!0);return S.useEffect(()=>{if(h!=null&&h.isDestroyed)return;if(!h){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const w=u.current;w.style.visibility="hidden",w.style.position="absolute";const v=mv({...g.current,editor:h,element:w});h.registerPlugin(v);const k=g.current.pluginKey;return x.current=!0,b(!0),()=>{b(!1),h.unregisterPlugin(k),window.requestAnimationFrame(()=>{w.parentNode&&w.parentNode.removeChild(w)})}},[h]),S.useEffect(()=>{if(!(!y||!h||h.isDestroyed)){if(x.current){x.current=!1;return}h.view.dispatch(h.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[y,h,n,r,i,o,s,d]),zs.createPortal(l,u.current)});const pB="_menu_1hbgh_2",mB="_row_1hbgh_9",gB="_linkRow_1hbgh_10",yB="_button_1hbgh_19",bB="_active_1hbgh_37",wB="_divider_1hbgh_53",xB="_styleTrigger_1hbgh_61",vB="_panelWrap_1hbgh_89",kB="_dropdown_1hbgh_94",SB="_colorPanel_1hbgh_102",CB="_colorTabs_1hbgh_109",EB="_colorTab_1hbgh_109",TB="_colorTabActive_1hbgh_136",MB="_linkInput_1hbgh_152",ee={menu:pB,row:mB,linkRow:gB,button:yB,active:bB,divider:wB,styleTrigger:xB,panelWrap:vB,dropdown:kB,colorPanel:SB,colorTabs:CB,colorTab:EB,colorTabActive:TB,linkInput:MB};function ch(t){return t.state.selection instanceof be}function vv({editor:t}){const e=vo({editor:t,selector:({editor:n})=>({headerRow:n.isActive("tableHeader"),canMerge:n.can().mergeCells(),canSplit:n.can().splitCell()})});return m.jsx(xv,{editor:t,pluginKey:"blockEditorTableMenu",options:{placement:"top",offset:8},shouldShow:({editor:n,state:r,from:s,to:i})=>!n.isEditable||!n.isActive("table")||r.selection instanceof Q?!1:s===i||ch(n),className:ee.menu,children:m.jsxs("div",{className:ee.row,children:[m.jsx(A.Tooltip,{content:"Insert column before",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addColumnBefore().run(),"aria-label":"Insert column before",children:m.jsx(eD,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert column after",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addColumnAfter().run(),"aria-label":"Insert column after",children:m.jsx(ZR,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete column",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteColumn().run(),"aria-label":"Delete column",children:m.jsx(KR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Insert row above",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addRowBefore().run(),"aria-label":"Insert row above",children:m.jsx(QR,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert row below",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addRowAfter().run(),"aria-label":"Insert row below",children:m.jsx(XR,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete row",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteRow().run(),"aria-label":"Delete row",children:m.jsx(OR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Toggle header row",children:m.jsx("button",{type:"button",className:[ee.button,e.headerRow&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleHeaderRow().run(),"aria-label":"Toggle header row",children:m.jsx(RR,{size:15})})}),e.canSplit?m.jsx(A.Tooltip,{content:"Split cell",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().splitCell().run(),"aria-label":"Split cell",children:m.jsx(AR,{size:15})})}):m.jsx(A.Tooltip,{content:"Merge cells",children:m.jsx("button",{type:"button",className:ee.button,disabled:!e.canMerge,onClick:()=>t.chain().focus().mergeCells().run(),"aria-label":"Merge cells",children:m.jsx(MR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Delete table",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteTable().run(),"aria-label":"Delete table",children:m.jsx(Et,{size:15})})})]})})}const bg=[1,2,3,4,5,6],AB={1:Md,2:Ad,3:Sd,4:Cd,5:Ed,6:Td};function _B(t){const e=t.trim();return e?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(e)?e:`https://${e}`:""}function kv({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState(""),[i,o]=S.useState(!1),[l,a]=S.useState("text"),[c,u]=S.useState(!1),d=S.useRef(null),f=S.useRef(null),h=vo({editor:t,selector:({editor:v})=>({bold:v.isActive("bold"),italic:v.isActive("italic"),underline:v.isActive("underline"),strike:v.isActive("strike"),code:v.isActive("code"),blockquote:v.isActive("blockquote"),bulletList:v.isActive("bulletList"),orderedList:v.isActive("orderedList"),link:v.isActive("link"),headingLevel:bg.find(k=>v.isActive("heading",{level:k}))??null,textColor:v.getAttributes("textStyle").color??"",highlightColor:v.getAttributes("highlight").color??""})});S.useEffect(()=>{var v;e&&((v=d.current)==null||v.focus())},[e]),S.useEffect(()=>{function v(){n(!1),o(!1),u(!1)}return t.on("selectionUpdate",v),()=>{t.off("selectionUpdate",v)}},[t]);function p(){const{from:v,to:k}=t.state.selection;f.current={from:v,to:k}}function g(){const v=t.chain().focus(),k=f.current;return k&&k.from!==k.to?v.setTextSelection(k):v}function y(v){l==="text"?g().setColor(v).run():g().setHighlight({color:v}).run()}function b(){s(t.getAttributes("link").href??""),n(!0)}function x(){const v=_B(r);v?t.chain().focus().extendMarkRange("link").setLink({href:v}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n(!1)}const w=h.headingLevel?`H${h.headingLevel}`:h.blockquote?"Quote":"Text";return m.jsx(xv,{editor:t,options:{placement:"top",offset:8},shouldShow:({editor:v,state:k,from:C,to:E})=>!v.isEditable||C===E||k.selection instanceof Q||ch(v)||v.isActive("codeBlock")?!1:k.doc.textBetween(C,E," "," ").trim().length>0,className:ee.menu,children:e?m.jsxs("div",{className:ee.linkRow,children:[m.jsx("input",{ref:d,type:"text",className:ee.linkInput,value:r,placeholder:"Paste or type a link",onChange:v=>s(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),x()),v.key==="Escape"&&(v.preventDefault(),n(!1))}}),m.jsx("button",{type:"button",className:ee.button,onClick:x,"aria-label":"Apply link",children:m.jsx(YR,{size:15})})]}):m.jsxs("div",{className:ee.row,children:[m.jsxs("div",{className:ee.panelWrap,children:[m.jsxs("button",{type:"button",className:[ee.styleTrigger,c&&ee.active].filter(Boolean).join(" "),onMouseDown:v=>{v.preventDefault(),c||p(),u(k=>!k)},"aria-label":"Text style",children:[m.jsx("span",{children:w}),m.jsx(wl,{size:12})]}),c&&m.jsx("div",{className:ee.dropdown,onMouseDown:v=>v.preventDefault(),children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Text",leftIcon:m.jsx(bd,{size:16}),checked:!h.headingLevel&&!h.blockquote,onClick:()=>{g().setParagraph().run(),u(!1)}}),bg.map(v=>{const k=AB[v];return m.jsx(A.MenuItemRadio,{label:`Heading ${v}`,leftIcon:m.jsx(k,{size:16}),checked:h.headingLevel===v,onClick:()=>{g().toggleHeading({level:v}).run(),u(!1)}},v)}),m.jsx(A.MenuItemRadio,{label:"Quote",leftIcon:m.jsx(t1,{size:16}),checked:h.blockquote,onClick:()=>{g().toggleBlockquote().run(),u(!1)}})]})})]}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Bold",children:m.jsx("button",{type:"button",className:[ee.button,h.bold&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBold().run(),"aria-label":"Bold",children:m.jsx(_d,{size:15})})}),m.jsx(A.Tooltip,{content:"Italic",children:m.jsx("button",{type:"button",className:[ee.button,h.italic&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleItalic().run(),"aria-label":"Italic",children:m.jsx(vd,{size:15})})}),m.jsx(A.Tooltip,{content:"Underline",children:m.jsx("button",{type:"button",className:[ee.button,h.underline&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleUnderline().run(),"aria-label":"Underline",children:m.jsx(Yw,{size:15})})}),m.jsx(A.Tooltip,{content:"Strikethrough",children:m.jsx("button",{type:"button",className:[ee.button,h.strike&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleStrike().run(),"aria-label":"Strikethrough",children:m.jsx(u1,{size:15})})}),m.jsx(A.Tooltip,{content:"Inline code",children:m.jsx("button",{type:"button",className:[ee.button,h.code&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleCode().run(),"aria-label":"Inline code",children:m.jsx(nc,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Bulleted list",children:m.jsx("button",{type:"button",className:[ee.button,h.bulletList&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBulletList().run(),"aria-label":"Bulleted list",children:m.jsx(ga,{size:15})})}),m.jsx(A.Tooltip,{content:"Numbered list",children:m.jsx("button",{type:"button",className:[ee.button,h.orderedList&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleOrderedList().run(),"aria-label":"Numbered list",children:m.jsx(N1,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsxs("div",{className:ee.panelWrap,children:[m.jsx("button",{type:"button",className:[ee.button,i&&ee.active].filter(Boolean).join(" "),onMouseDown:v=>{v.preventDefault(),i||p(),o(k=>!k)},"aria-label":"Colour",children:m.jsx(k1,{size:15})}),i&&m.jsx("div",{className:ee.dropdown,onMouseDown:v=>v.preventDefault(),children:m.jsxs("div",{className:ee.colorPanel,children:[m.jsxs("div",{className:ee.colorTabs,children:[m.jsx("button",{type:"button",className:[ee.colorTab,l==="text"&&ee.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("text"),children:"Text"}),m.jsx("button",{type:"button",className:[ee.colorTab,l==="bg"&&ee.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("bg"),children:"Background"})]}),m.jsx(A.ColorPicker,{alwaysOpen:!0,value:l==="text"?h.textColor:h.highlightColor,onChange:y})]})})]}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:h.link?"Edit link":"Add link",children:m.jsx("button",{type:"button",className:[ee.button,h.link&&ee.active].filter(Boolean).join(" "),onClick:b,"aria-label":h.link?"Edit link":"Add link",children:m.jsx(xd,{size:15})})}),h.link&&m.jsx(A.Tooltip,{content:"Remove link",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().extendMarkRange("link").unsetLink().run(),"aria-label":"Remove link",children:m.jsx(vR,{size:15})})})]})})}const Qt=()=>new Map,Rd=t=>{const e=Qt();return t.forEach((n,r)=>{e.set(r,n)}),e},Un=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},NB=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},OB=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},qr=()=>new Set,fu=t=>t[t.length-1],IB=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Kr=Array.from,uh=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},dh=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},RB=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Rs=Array.isArray;class Sv{constructor(){this._observers=Qt()}on(e,n){return Un(this._observers,e,qr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Kr((this._observers.get(e)||Qt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Qt()}}const tn=Math.floor,xl=Math.abs,Jr=(t,e)=>t<e?t:e,pr=(t,e)=>t>e?t:e,Cv=t=>t!==0?t<0:1/t<0,wg=1,xg=2,hu=4,pu=8,ro=32,jn=64,gt=128,DB=1<<29,lc=31,Dd=63,Pr=127,LB=2147483647,xa=Number.MAX_SAFE_INTEGER,vg=Number.MIN_SAFE_INTEGER,jB=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&tn(t)===t),Ev=String.fromCharCode,PB=t=>t.toLowerCase(),BB=/^\s*/g,zB=t=>t.replace(BB,""),$B=/([A-Z])/g,kg=(t,e)=>zB(t.replace($B,n=>`${e}${PB(n)}`)),HB=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},so=typeof TextEncoder<"u"?new TextEncoder:null,FB=t=>so.encode(t),VB=so?FB:HB;let zi=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zi&&zi.decode(new Uint8Array).length===1&&(zi=null);const UB=(t,e)=>RB(e,()=>t).join("");class So{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Co=()=>new So,WB=t=>{const e=Co();return t(e),Yt(e)},qB=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Yt=t=>{const e=new Uint8Array(qB(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},KB=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(pr(n,e)*2),t.cpos=0)},Ue=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Ld=Ue,de=(t,e)=>{for(;e>Pr;)Ue(t,gt|Pr&e),e=tn(e/128);Ue(t,Pr&e)},fh=(t,e)=>{const n=Cv(e);for(n&&(e=-e),Ue(t,(e>Dd?gt:0)|(n?jn:0)|Dd&e),e=tn(e/64);e>0;)Ue(t,(e>Pr?gt:0)|Pr&e),e=tn(e/128)},jd=new Uint8Array(3e4),JB=jd.length/3,GB=(t,e)=>{if(e.length<JB){const n=so.encodeInto(e,jd).written||0;de(t,n);for(let r=0;r<n;r++)Ue(t,jd[r])}else At(t,VB(e))},YB=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;de(t,r);for(let s=0;s<r;s++)Ue(t,n.codePointAt(s))},ys=so&&so.encodeInto?GB:YB,ac=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Jr(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(pr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},At=(t,e)=>{de(t,e.byteLength),ac(t,e)},hh=(t,e)=>{KB(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},XB=(t,e)=>hh(t,4).setFloat32(0,e,!1),QB=(t,e)=>hh(t,8).setFloat64(0,e,!1),ZB=(t,e)=>hh(t,8).setBigInt64(0,e,!1),Sg=new DataView(new ArrayBuffer(4)),ez=t=>(Sg.setFloat32(0,t),Sg.getFloat32(0)===t),Ds=(t,e)=>{switch(typeof e){case"string":Ue(t,119),ys(t,e);break;case"number":jB(e)&&xl(e)<=LB?(Ue(t,125),fh(t,e)):ez(e)?(Ue(t,124),XB(t,e)):(Ue(t,123),QB(t,e));break;case"bigint":Ue(t,122),ZB(t,e);break;case"object":if(e===null)Ue(t,126);else if(Rs(e)){Ue(t,117),de(t,e.length);for(let n=0;n<e.length;n++)Ds(t,e[n])}else if(e instanceof Uint8Array)Ue(t,116),At(t,e);else{Ue(t,118);const n=Object.keys(e);de(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ys(t,s),Ds(t,e[s])}}break;case"boolean":Ue(t,e?120:121);break;default:Ue(t,127)}};class Cg extends So{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&de(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Eg=t=>{t.count>0&&(fh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&de(t.encoder,t.count-2))};class vl{constructor(){this.encoder=new So,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Eg(this),this.count=1,this.s=e)}toUint8Array(){return Eg(this),Yt(this.encoder)}}const Tg=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);fh(t.encoder,e),t.count>1&&de(t.encoder,t.count-2)}};class mu{constructor(){this.encoder=new So,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Tg(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Tg(this),Yt(this.encoder)}}class tz{constructor(){this.sarr=[],this.s="",this.lensE=new vl}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new So;return this.sarr.push(this.s),this.s="",ys(e,this.sarr.join("")),ac(e,this.lensE.toUint8Array()),Yt(e)}}const wn=t=>new Error(t),Ht=()=>{throw wn("Method unimplemented")},wt=()=>{throw wn("Unexpected case")},Tv=wn("Unexpected end of array"),Mv=wn("Integer out of Range");class cc{constructor(e){this.arr=e,this.pos=0}}const ph=t=>new cc(t),nz=t=>t.pos!==t.arr.length,rz=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Lt=t=>rz(t,Ee(t)),io=t=>t.arr[t.pos++],Ee=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Pr)*n,n*=128,s<gt)return e;if(e>xa)throw Mv}throw Tv},mh=t=>{let e=t.arr[t.pos++],n=e&Dd,r=64;const s=(e&jn)>0?-1:1;if(!(e>))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Pr)*r,r*=128,e<gt)return s*n;if(n>xa)throw Mv}throw Tv},sz=t=>{let e=Ee(t);if(e===0)return"";{let n=String.fromCodePoint(io(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(io(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},iz=t=>zi.decode(Lt(t)),Pd=zi?iz:sz,gh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},oz=t=>gh(t,4).getFloat32(0,!1),lz=t=>gh(t,8).getFloat64(0,!1),az=t=>gh(t,8).getBigInt64(0,!1),cz=[t=>{},t=>null,mh,oz,lz,az,t=>!1,t=>!0,Pd,t=>{const e=Ee(t),n={};for(let r=0;r<e;r++){const s=Pd(t);n[s]=va(t)}return n},t=>{const e=Ee(t),n=[];for(let r=0;r<e;r++)n.push(va(t));return n},Lt],va=t=>cz[127-io(t)](t);class Mg extends cc{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),nz(this)?this.count=Ee(this)+1:this.count=-1),this.count--,this.s}}class kl extends cc{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=mh(this);const e=Cv(this.s);this.count=1,e&&(this.s=-this.s,this.count=Ee(this)+2)}return this.count--,this.s}}class gu extends cc{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=mh(this),n=e&1;this.diff=tn(e/2),this.count=1,n&&(this.count=Ee(this)+2)}return this.s+=this.diff,this.count--,this.s}}class uz{constructor(e){this.decoder=new kl(e),this.str=Pd(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const dz=crypto.getRandomValues.bind(crypto),fz=Math.random,Av=()=>dz(new Uint32Array(1))[0],hz=t=>t[tn(fz()*t.length)],pz="10000000-1000-4000-8000"+-1e11,mz=()=>pz.replace(/[018]/g,t=>(t^Av()&15>>t/4).toString(16)),gz=Date.now,Ag=t=>new Promise(t);Promise.all.bind(Promise);const _g=t=>t===void 0?null:t;class yz{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let _v=new yz,bz=!0;try{typeof localStorage<"u"&&localStorage&&(_v=localStorage,bz=!1)}catch{}const wz=_v,oo=Symbol("Equality"),Nv=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[oo])!=null&&n.call(t,e))||!1},xz=t=>typeof t=="object",vz=Object.assign,Ov=Object.keys,kz=(t,e)=>{for(const n in t)e(t[n],n)},ka=t=>Ov(t).length,Sz=t=>{for(const e in t)return!1;return!0},Ws=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},yh=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Cz=(t,e)=>t===e||ka(t)===ka(e)&&Ws(t,(n,r)=>(n!==void 0||yh(e,r))&&Nv(e[r],n)),Ez=Object.freeze,Iv=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Iv(t[e])}return Ez(t)},bh=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&bh(t,e,n+1)}},Sl=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[oo]!=null)return t[oo](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Sl(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ka(t)!==ka(e))return!1;for(const n in t)if(!yh(t,n)||!Sl(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Sl(t[n],e[n]))return!1;break;default:return!1}return!0},Tz=(t,e)=>e.includes(t),Ls=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Rv=typeof window<"u"&&typeof document<"u"&&!Ls;let an;const Mz=()=>{if(an===void 0)if(Ls){an=Qt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&an.set(e,""),e=r):e!==null&&(an.set(e,r),e=null)}e!==null&&an.set(e,"")}else typeof location=="object"?(an=Qt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");an.set(`--${kg(e,"-")}`,n),an.set(`-${kg(e,"-")}`,n)}})):an=Qt();return an},Bd=t=>Mz().has(t),Sa=t=>_g(Ls?process.env[t.toUpperCase().replaceAll("-","_")]:wz.getItem(t)),Dv=t=>Bd("--"+t)||Sa(t)!==null,Az=Dv("production"),_z=Ls&&Tz(process.env.FORCE_COLOR,["true","1","2"]),Nz=_z||!Bd("--no-colors")&&!Dv("no-color")&&(!Ls||process.stdout.isTTY)&&(!Ls||Bd("--color")||Sa("COLORTERM")!==null||(Sa("TERM")||"").includes("color")),Oz=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Ev(t[n]);return btoa(e)},Iz=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Rz=Rv?Oz:Iz,Dz=t=>WB(e=>Ds(e,t));class Lz{constructor(e,n){this.left=e,this.right=n}}const Mn=(t,e)=>new Lz(t,e),Ng=t=>t.next()>=.5,yu=(t,e,n)=>tn(t.next()*(n+1-e)+e),Lv=(t,e,n)=>tn(t.next()*(n+1-e)+e),wh=(t,e,n)=>Lv(t,e,n),jz=t=>Ev(wh(t,97,122)),Pz=(t,e=0,n=20)=>{const r=wh(t,e,n);let s="";for(let i=0;i<r;i++)s+=jz(t);return s},bu=(t,e)=>e[wh(t,0,e.length-1)],Bz=Symbol("0schema");class zz{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(UB(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
381
|
+
<path d="M19 19H5" />`,...t}));bx.displayName="AlignCenterIcon";var Xm=bx;const sD="_wrap_1pdh5_1",iD="_dropdown_1pdh5_6",oD="_dropdownRight_1pdh5_13",lD="_panel_1pdh5_20",aD="_search_1pdh5_32",cD="_list_1pdh5_36",uD="_group_1pdh5_43",dD="_empty_1pdh5_47",Gn={wrap:sD,dropdown:iD,dropdownRight:oD,panel:lD,search:aD,list:cD,group:uD,empty:dD},au="Other";function fD(t){var r;const e=new Map;for(const s of t){const i=((r=s.category)==null?void 0:r.trim())||au,o=e.get(i);o?o.push(s):e.set(i,[s])}const n=[...e.entries()].map(([s,i])=>({category:s,items:i}));return n.sort((s,i)=>s.category===i.category?0:s.category===au?1:i.category===au?-1:0),n}function Qm({editor:t,variables:e,disabled:n=!1,buttonClassName:r,align:s="left",onVariableInsert:i}){const[o,l]=S.useState(!1),[a,c]=S.useState(""),u=S.useRef(null),d=S.useRef(null),f=S.useRef(null),h=S.useRef(null),p=S.useMemo(()=>{const k=a.trim().toLowerCase();return k?e.filter(C=>C.label.toLowerCase().includes(k)||C.key.toLowerCase().includes(k)):e},[e,a]),g=S.useMemo(()=>fD(p),[p]);S.useEffect(()=>{n&&l(!1)},[n]),S.useEffect(()=>{function k(C){u.current&&!u.current.contains(C.target)&&l(!1)}return o&&document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[o]),S.useEffect(()=>{if(!o){c("");return}const k=window.setTimeout(()=>{var C;return(C=d.current)==null?void 0:C.focus()},0);return()=>window.clearTimeout(k)},[o]);function y(){return f.current?[...f.current.querySelectorAll('[role="menuitem"]:not([disabled])')]:[]}function b(k){var _;const C=y();if(C.length===0)return;const E=C.indexOf(document.activeElement),O=E===-1?k===1?0:C.length-1:(E+k+C.length)%C.length;(_=C[O])==null||_.focus()}function x(k){l(!1),t.commands.focus()}function w(k){if(n)return;const C=h.current;t.chain().focus().setTextSelection(C??t.state.selection).insertDynamicVariable(k).run(),l(!1),i==null||i(k.key)}function v(k){if(k.key==="Escape"){k.preventDefault(),x();return}if(k.key==="ArrowDown"){k.preventDefault(),b(1);return}if(k.key==="ArrowUp"){k.preventDefault(),b(-1);return}if(k.key==="Enter"&&k.target===d.current){k.preventDefault();const C=p[0];C&&w(C)}}return m.jsxs("div",{className:Gn.wrap,ref:u,children:[m.jsx(A.Tooltip,{content:"Insert variable",placement:"top",children:m.jsx("button",{type:"button",className:r,disabled:n,"aria-label":"Insert variable","aria-haspopup":"dialog","aria-expanded":o,onMouseDown:k=>{if(k.preventDefault(),!n){if(!o){const{from:C,to:E}=t.state.selection;h.current={from:C,to:E}}l(C=>!C)}},children:m.jsx(WR,{size:14})})}),o&&m.jsx("div",{className:[Gn.dropdown,s==="right"&&Gn.dropdownRight].filter(Boolean).join(" "),children:m.jsxs("div",{className:Gn.panel,role:"dialog","aria-label":"Insert variable",onKeyDown:v,onMouseDown:k=>k.stopPropagation(),children:[m.jsx("div",{className:Gn.search,children:m.jsx(A.SearchInput,{ref:d,size:"sm","aria-label":"Search variables",placeholder:"Search variables…",value:a,onChange:k=>c(k.target.value)})}),m.jsx(A.Scrollable,{size:"thin",maxHeight:"264px",children:m.jsx("div",{className:Gn.list,ref:f,role:"menu","aria-label":"Variables",children:g.length===0?m.jsx("div",{className:Gn.empty,children:"No variables found"}):g.map(k=>m.jsxs("div",{className:Gn.group,role:"group","aria-label":k.category,children:[m.jsx(A.MenuTitle,{children:k.category}),k.items.map(C=>m.jsx(A.MenuItem,{label:C.label,onClick:()=>w(C)},C.key))]},k.category))})})]})})]})}const hD="_menubar_x0rrp_1",pD="_group_x0rrp_11",mD="_divider_x0rrp_17",gD="_spacer_x0rrp_25",yD="_btn_x0rrp_30",bD="_active_x0rrp_46",wD="_blockWrap_x0rrp_63",xD="_blockTrigger_x0rrp_67",vD="_blockTriggerCompact_x0rrp_86",kD="_blockDropdown_x0rrp_107",SD="_moreDropdown_x0rrp_115",CD="_alignTrigger_x0rrp_124",ED="_colorWrap_x0rrp_156",TD="_colorDropdown_x0rrp_160",MD="_colorTabs_x0rrp_172",AD="_colorTab_x0rrp_172",_D="_colorTabActive_x0rrp_201",ND="_menubarWrap_x0rrp_218",OD="_aiPanel_x0rrp_224",ID="_aiInputRow_x0rrp_233",RD="_aiTextarea_x0rrp_247",DD="_aiLoadingText_x0rrp_271",Y={menubar:hD,group:pD,divider:mD,spacer:gD,btn:yD,active:bD,blockWrap:wD,blockTrigger:xD,blockTriggerCompact:vD,blockDropdown:kD,moreDropdown:SD,alignTrigger:CD,colorWrap:ED,colorDropdown:TD,colorTabs:MD,colorTab:AD,colorTabActive:_D,menubarWrap:ND,aiPanel:OD,aiInputRow:ID,aiTextarea:RD,aiLoadingText:DD},LD=S.memo(function({editor:e,disabled:n,showHtml:r,compact:s=!1,onLinkClick:i,onCodeClick:o,variables:l,showVariablePicker:a=!1,onVariableInsert:c,onAiSubmit:u,aiSubmitDisabled:d=!1}){const[f,h]=S.useState(!1),[p,g]=S.useState(""),[y,b]=S.useState(!1),x=S.useRef(null),w=S.useRef(null),[v,k]=S.useState(!1),C=S.useRef(null),[E,O]=S.useState(!1),_=S.useRef(null),T=S.useRef(null),[D,I]=S.useState(!1),P=S.useRef(null),N=S.useRef(null),[R,j]=S.useState(!1),F=S.useRef(null),[$,V]=S.useState(!1),[fe,we]=S.useState("text"),[Te,Tt]=S.useState("#000000"),[Me,Ie]=S.useState("#ffff00"),$e=S.useRef(null),q=S.useRef(null),ie=S.useRef(null),U=vo({editor:e,selector:({editor:M})=>({isBold:M.isActive("bold"),isItalic:M.isActive("italic"),isUnderline:M.isActive("underline"),isStrike:M.isActive("strike"),isAlignLeft:M.isActive({textAlign:"left"}),isAlignCenter:M.isActive({textAlign:"center"}),isAlignRight:M.isActive({textAlign:"right"}),isH1:M.isActive("heading",{level:1}),isH2:M.isActive("heading",{level:2}),isH3:M.isActive("heading",{level:3}),isH4:M.isActive("heading",{level:4}),isH5:M.isActive("heading",{level:5}),isH6:M.isActive("heading",{level:6}),isBlockquote:M.isActive("blockquote"),isBulletList:M.isActive("bulletList"),isOrderedList:M.isActive("orderedList"),isLink:M.isActive("link"),isTable:M.isActive("tableCell")||M.isActive("tableHeader"),hasSelection:!M.state.selection.empty})});S.useEffect(()=>{function M(ne){w.current&&!w.current.contains(ne.target)&&h(!1)}return f&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[f]),S.useEffect(()=>{function M(ne){C.current&&!C.current.contains(ne.target)&&k(!1)}return v&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[v]),S.useEffect(()=>{function M(ne){_.current&&!_.current.contains(ne.target)&&O(!1)}return E&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[E]),S.useEffect(()=>{function M(ne){P.current&&!P.current.contains(ne.target)&&I(!1)}return D&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[D]),S.useEffect(()=>{function M(ne){F.current&&!F.current.contains(ne.target)&&j(!1)}return R&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[R]),S.useEffect(()=>{function M(){k(!1),O(!1),I(!1),j(!1)}return e.on("focus",M),()=>{e.off("focus",M)}},[e]),S.useEffect(()=>{function M(ne){$e.current&&!$e.current.contains(ne.target)&&V(!1)}return $&&document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[$]);const Wt=S.useCallback(()=>{h(M=>{const ne=!M;return ne&&setTimeout(()=>{var xt;return(xt=x.current)==null?void 0:xt.focus()},0),ne})},[]);async function qt(){if(!p.trim()||y||d)return;const M=p;g(""),x.current&&(x.current.style.height="auto"),b(!0);try{await(u==null?void 0:u(M))}finally{b(!1),h(!1)}}const ce=n||!!r,H=l??[],B=a&&H.length>0;S.useEffect(()=>{ce&&(h(!1),k(!1),O(!1),I(!1),j(!1),V(!1))},[ce]);function K(M){ce||M()}function G(...M){return[Y.btn,...M].filter(Boolean).join(" ")}const xe=U.isH1?"Heading 1":U.isH2?"Heading 2":U.isH3?"Heading 3":U.isH4?"Heading 4":U.isH5?"Heading 5":U.isH6?"Heading 6":U.isBlockquote?"Blockquote":"Paragraph",He=U.isH1?"H1":U.isH2?"H2":U.isH3?"H3":U.isH4?"H4":U.isH5?"H5":U.isH6?"H6":U.isBlockquote?"Quote":"Text";return s?m.jsx("div",{className:Y.menubarWrap,ref:w,onClick:M=>M.stopPropagation(),children:m.jsxs("div",{className:Y.menubar,children:[m.jsxs("div",{className:Y.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:`${Y.blockTrigger} ${Y.blockTriggerCompact}`,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(ie.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:He}),m.jsx(wl,{size:12})]}),v&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!U.isH1&&!U.isH2&&!U.isH3&&!U.isH4&&!U.isH5&&!U.isH6&&!U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Md,{size:16}),checked:U.isH1,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:U.isH2,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:U.isH3,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:U.isH4,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:U.isH5,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Td,{size:16}),checked:U.isH6,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBold&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isItalic&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isLink&&Y.active),disabled:ce||!U.hasSelection&&!U.isLink,onMouseDown:M=>{M.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsx(A.Tooltip,{content:"Numbered list",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isOrderedList&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().focus().toggleOrderedList().run())},"aria-label":"Numbered list",children:m.jsx(Km,{size:14})})}),m.jsx(A.Tooltip,{content:"Bullet list",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBulletList&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().focus().toggleBulletList().run())},"aria-label":"Bullet list",children:m.jsx(ga,{size:14})})})]}),B&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Y.spacer}),m.jsx("div",{className:Y.group,children:m.jsx(Qm,{editor:e,variables:H,disabled:ce,buttonClassName:G(),align:"right",onVariableInsert:c})})]})]})}):m.jsxs("div",{className:Y.menubarWrap,ref:w,onClick:M=>M.stopPropagation(),children:[m.jsxs("div",{className:Y.menubar,children:[m.jsx(A.Tooltip,{content:"AI",placement:"top",children:m.jsx("button",{type:"button",className:G(f&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||Wt()},"aria-label":"AI",children:m.jsx(NR,{size:14})})}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:Y.blockTrigger,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(ie.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:xe}),m.jsx(wl,{size:12})]}),v&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!U.isH1&&!U.isH2&&!U.isH3&&!U.isH4&&!U.isH5&&!U.isH6&&!U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:U.isBlockquote,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Md,{size:16}),checked:U.isH1,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:U.isH2,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:U.isH3,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:U.isH4,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:U.isH5,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Td,{size:16}),checked:U.isH6,onClick:()=>{const M=ie.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isBold&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isItalic&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})}),m.jsx(A.Tooltip,{content:"Underline",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isUnderline&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),K(()=>e.chain().toggleUnderline().run())},"aria-label":"Underline",children:m.jsx(Yw,{size:14})})}),m.jsxs("div",{className:Y.colorWrap,ref:$e,children:[m.jsx(A.Tooltip,{content:"Color",placement:"top",children:m.jsx("button",{type:"button",className:G($&&Y.active),disabled:ce,onMouseDown:M=>{if(M.preventDefault(),!ce){if(!$){const{from:ne,to:xt}=e.state.selection;q.current={from:ne,to:xt}}V(ne=>!ne)}},"aria-label":"Color",children:m.jsx(k1,{size:14})})}),$&&m.jsxs("div",{className:Y.colorDropdown,children:[m.jsxs("div",{className:Y.colorTabs,children:[m.jsx("button",{type:"button",className:`${Y.colorTab} ${fe==="text"?Y.colorTabActive:""}`,onMouseDown:M=>{M.preventDefault(),we("text")},children:"Text"}),m.jsx("button",{type:"button",className:`${Y.colorTab} ${fe==="bg"?Y.colorTabActive:""}`,onMouseDown:M=>{M.preventDefault(),we("bg")},children:"Background"})]}),fe==="text"?m.jsx(A.ColorPicker,{alwaysOpen:!0,value:Te,onChange:M=>{Tt(M);const ne=q.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setColor(M).run():e.chain().setColor(M).run()}}):m.jsx(A.ColorPicker,{alwaysOpen:!0,value:Me,onChange:M=>{Ie(M);const ne=q.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setHighlight({color:M}).run():e.chain().setHighlight({color:M}).run()}})]})]})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:_,children:[m.jsxs("button",{type:"button",className:Y.alignTrigger,disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(T.current={from:e.state.selection.from,to:e.state.selection.to},O(ne=>!ne))},"aria-label":"Text alignment",children:[U.isAlignCenter?m.jsx(Xm,{size:14}):U.isAlignRight?m.jsx(Gm,{size:14}):m.jsx(Ym,{size:14}),m.jsx(wl,{size:12})]}),E&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Align left",leftIcon:m.jsx(Ym,{size:16}),checked:!U.isAlignCenter&&!U.isAlignRight,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("left").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align center",leftIcon:m.jsx(Xm,{size:16}),checked:U.isAlignCenter,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("center").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align right",leftIcon:m.jsx(Gm,{size:16}),checked:U.isAlignRight,onClick:()=>{const M=T.current;e.chain().focus().setTextSelection(M??e.state.selection).setTextAlign("right").run(),O(!1)}})]})})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isLink&&Y.active),disabled:ce||!U.hasSelection&&!U.isLink,onMouseDown:M=>{M.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsxs("div",{className:Y.blockWrap,ref:F,children:[m.jsx(A.Tooltip,{content:"Table",placement:"top",children:m.jsx("button",{type:"button",className:G(U.isTable&&Y.active),disabled:ce,onMouseDown:M=>{if(M.preventDefault(),ce)return;e.isActive("tableCell")||e.isActive("tableHeader")?j(xt=>!xt):e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},"aria-label":"Table",children:m.jsx(l1,{size:14})})}),R&&m.jsx("div",{className:Y.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItem,{label:"Add row above",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowBefore().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add row below",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowAfter().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add column left",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnBefore().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Add column right",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnAfter().run(),j(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItem,{label:"Delete row",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteRow().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Delete column",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteColumn().run(),j(!1)}}),m.jsx(A.MenuItem,{label:"Delete table",leftIcon:m.jsx(SR,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteTable().run(),j(!1)}})]})})]})]}),m.jsx("div",{className:Y.divider}),m.jsxs("div",{className:Y.blockWrap,ref:P,children:[m.jsx(A.Tooltip,{content:"Lists & formatting",placement:"top",children:m.jsx("button",{type:"button",className:G((D||U.isBulletList||U.isOrderedList)&&Y.active),disabled:ce,onMouseDown:M=>{M.preventDefault(),ce||(N.current={from:e.state.selection.from,to:e.state.selection.to},I(ne=>!ne))},"aria-label":"Lists and formatting",children:m.jsx(UR,{size:16})})}),D&&m.jsx("div",{className:Y.moreDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Strikethrough",leftIcon:m.jsx(u1,{size:16}),checked:U.isStrike,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleStrike().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Bullet list",leftIcon:m.jsx(ga,{size:16}),checked:U.isBulletList,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleBulletList().run(),I(!1)}}),m.jsx(A.MenuItemRadio,{label:"Numbered list",leftIcon:m.jsx(Km,{size:16}),checked:U.isOrderedList,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).toggleOrderedList().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Increase indent",leftIcon:m.jsx(BR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).increaseIndent().run(),I(!1)}}),m.jsx(A.MenuItemRadio,{label:"Decrease indent",leftIcon:m.jsx(PR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).decreaseIndent().run(),I(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Clear formatting",leftIcon:m.jsx(IR,{size:16}),checked:!1,onClick:()=>{const M=N.current;e.chain().focus().setTextSelection(M??e.state.selection).unsetAllMarks().run(),I(!1)}})]})})]}),m.jsx("div",{className:Y.spacer}),m.jsxs("div",{className:Y.group,children:[m.jsx(A.Tooltip,{content:"HTML source",placement:"top",children:m.jsx("button",{type:"button",className:G(r&&Y.active),onMouseDown:M=>{M.preventDefault(),o()},"aria-label":"HTML source",children:m.jsx(nc,{size:14})})}),B&&m.jsx(Qm,{editor:e,variables:H,disabled:ce,buttonClassName:G(),align:"right",onVariableInsert:c})]})]}),f&&m.jsx("div",{className:Y.aiPanel,children:m.jsxs("div",{className:Y.aiInputRow,children:[y?m.jsx("span",{className:Y.aiLoadingText,children:"Generating…"}):m.jsx("textarea",{ref:x,className:Y.aiTextarea,placeholder:"Describe your changes…",value:p,rows:1,onChange:M=>{g(M.target.value),M.target.style.height="auto",M.target.style.height=`${M.target.scrollHeight}px`},onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),qt()),M.key==="Escape"&&h(!1)}}),m.jsx(A.IconButton,{icon:m.jsx(FR,{size:14}),"aria-label":"Send",size:"xsmall",radius:"full",variant:"neutral",disabled:!p.trim()||y||d,onMouseDown:M=>{M.preventDefault(),qt()}})]})})]})}),jD="_form_1nh56_1",PD="_field_1nh56_8",BD="_urlGroup_1nh56_14",zD="_footer_1nh56_20",$D="_removeBtn_1nh56_28",HD="_footerActions_1nh56_32",Sr={form:jD,field:PD,urlGroup:BD,footer:zD,removeBtn:$D,footerActions:HD};function Zm(t){return t.replace(/^https?:\/\//i,"")}function FD(t){const e=t.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function VD({editor:t,open:e,onClose:n}){const[r,s]=S.useState(""),[i,o]=S.useState(""),[l,a]=S.useState(!1),c=!!t.getAttributes("link").href;S.useEffect(()=>{if(e){const f=t.getAttributes("link");s(Zm(f.href??"")),o(f.title??""),a(f.target==="_blank")}},[e,t]);function u(){const f=FD(r);f?t.chain().focus().extendMarkRange("link").setLink({href:f,target:l?"_blank":null,title:i.trim()||null}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}function d(){t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}return m.jsx(A.Modal,{open:e,onClose:n,title:c?"Edit link":"Add link",size:"sm",footer:m.jsxs("div",{className:Sr.footer,children:[c&&m.jsx(A.Button,{variant:"danger",size:"sm",onClick:d,className:Sr.removeBtn,children:"Remove"}),m.jsxs("div",{className:Sr.footerActions,children:[m.jsx(A.Button,{variant:"neutral",size:"sm",onClick:n,children:"Cancel"}),m.jsx(A.Button,{variant:"inverted",size:"sm",onClick:u,children:"Save"})]})]}),children:m.jsxs("form",{onSubmit:f=>{f.preventDefault(),u()},noValidate:!0,className:Sr.form,children:[m.jsxs("div",{className:Sr.urlGroup,children:[m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-url",children:"Link Address"}),m.jsx(A.UrlInput,{id:"link-url",value:r,onChange:f=>s(Zm(f.target.value)),autoFocus:!0})]}),m.jsx(A.Checkbox,{label:"Open in new tab",checked:l,onChange:f=>a(f.target.checked)})]}),m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-header",optional:!0,children:"Link header"}),m.jsx(A.Input,{id:"link-header",placeholder:"Enter link header",value:i,onChange:f=>o(f.target.value)}),m.jsx(A.Hint,{children:"Used for accessibility and SEO"})]})]})})}const UD="_chip_v3xby_5",WD={chip:UD},Pi="dynamicVariable",Bi=/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g,eg=/<span\s+data-dynamic-variable="true"\s+data-key="([A-Za-z0-9_.-]*)"\s*>[^<]*<\/span>/g;function tg(t){return typeof t=="string"?t.replace(/[^A-Za-z0-9_.-]/g,""):""}function wx(t){const e=new Map;for(const n of t??[])n&&typeof n.key=="string"&&n.key&&e.set(n.key,n);return e}function ng(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function qD(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function KD(t){const e=t.label||t.key;return`<span data-dynamic-variable="true" data-key="${ng(t.key)}" data-label="${ng(e)}">${qD(e)}</span>`}function xx(t){return!t||t.indexOf("data-dynamic-variable")===-1?t:(eg.lastIndex=0,t.replace(eg,(e,n)=>`{{${n}}}`))}function rg(t,e){return Bi.lastIndex=0,t.replace(Bi,(n,r)=>{const s=e.get(r);return s?KD(s):n})}function ki(t,e){if(!t)return t;const n=wx(e);if(n.size===0)return t;let r="",s=0;for(;s<t.length;){const i=t.indexOf("<",s);if(i===-1){r+=rg(t.slice(s),n);break}r+=rg(t.slice(s,i),n);const o=t.indexOf(">",i);if(o===-1){r+=t.slice(i);break}r+=t.slice(i,o+1),s=o+1}return r}function JD(t,e,n){const r=t.text??"",s=e.schema,i=[];let o=0;Bi.lastIndex=0;let l=Bi.exec(r);for(;l;){const a=n.get(l[1]);a&&(l.index>o&&i.push(s.text(r.slice(o,l.index),t.marks)),i.push(e.create({key:a.key,label:a.label||a.key},null,t.marks)),o=l.index+l[0].length),l=Bi.exec(r)}return i.length===0?[t]:(o<r.length&&i.push(s.text(r.slice(o),t.marks)),i)}function vx(t,e,n){if(n.size===0)return t;const r=[];return t.forEach(s=>{s.isText?r.push(...JD(s,e,n)):s.content.size>0?r.push(s.copy(vx(s.content,e,n))):r.push(s)}),L.fromArray(r)}const kx=Se.create({name:Pi,inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!1,addOptions(){return{variables:[]}},addStorage(){var t;return{variables:((t=this.options)==null?void 0:t.variables)??[]}},addAttributes(){return{key:{default:"",parseHTML:t=>tg(t.getAttribute("data-key")),renderHTML:()=>({})},label:{default:null,parseHTML:t=>t.getAttribute("data-label")||t.textContent||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-dynamic-variable]"}]},renderHTML({node:t}){const e=tg(t.attrs.key),n=t.attrs.label||e;return["span",{"data-dynamic-variable":"true","data-key":e},n]},renderText({node:t}){return`{{${t.attrs.key}}}`},addNodeView(){return({node:t})=>{const e=document.createElement("span"),n=r=>{e.setAttribute("data-dynamic-variable","true"),e.setAttribute("data-key",r.attrs.key),e.setAttribute("contenteditable","false"),e.setAttribute("title",`{{${r.attrs.key}}}`),e.className=WD.chip,e.textContent=r.attrs.label||r.attrs.key};return n(t),{dom:e,update(r){return r.type.name!==Pi?!1:(n(r),!0)},ignoreMutation:()=>!0}}},addCommands(){return{insertDynamicVariable:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{key:t.key,label:t.label||t.key}})}},addKeyboardShortcuts(){const t=e=>()=>{const{state:n,view:r}=this.editor,{selection:s}=n;if(s instanceof Q&&s.node.type.name===this.name)return r.dispatch(n.tr.deleteSelection()),!0;if(!s.empty)return!1;const i=s.$from,o=e===-1?i.nodeBefore:i.nodeAfter;if(!o||o.type.name!==this.name)return!1;const l=e===-1?i.pos-o.nodeSize:i.pos;return r.dispatch(n.tr.delete(l,l+o.nodeSize)),!0};return{Backspace:t(-1),Delete:t(1)}},addProseMirrorPlugins(){const t=this.type,e=this.editor,n=this.options.variables;return[new ue({key:new ae("dynamicVariablePaste"),props:{transformPasted:r=>{var o,l;const s=((l=(o=e==null?void 0:e.storage)==null?void 0:o[Pi])==null?void 0:l.variables)??n,i=wx(s);return i.size===0?r:new W(vx(r.content,t,i),r.openStart,r.openEnd)}}})]}}),GD=SN.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),title:{default:null}}}});function Xo(t){return xx(t.getHTML())}const YD=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,minHeight:s,maxHeight:i="400px",onChange:o,onFocus:l,onBlur:a,error:c=!1,disabled:u=!1,readOnly:d=!1,variant:f="white",compact:h=!1,className:p,onAiSubmit:g,aiSubmitDisabled:y,variables:b,showVariablePicker:x=!1,onVariableInsert:w},v){const[k,C]=S.useState(!1),[E,O]=S.useState(!1),[_,T]=S.useState(""),D=S.useRef(!1),I=(b??[]).map($=>`${$.key}\0${$.label}`).join(""),P=S.useMemo(()=>b??[],[I]),N=O0({extensions:[Mw.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),_w.configure({multicolor:!0}),GD.configure({openOnClick:!1}),Jf.configure({resizable:!1}),Kf,qf,Wf,...r!==void 0?[Aw.configure({placeholder:r})]:[],Gf,Yf,qI.configure({types:["heading","paragraph"]}),jO,kx.configure({variables:P})],content:ki(e??n??"",P),editable:!u&&!d,shouldRerenderOnTransaction:!1,onUpdate({editor:$}){D.current=!0,o==null||o($.isEmpty?null:Xo($))},onFocus(){l==null||l()},onBlur(){a==null||a()}});S.useEffect(()=>{N==null||N.setEditable(!u&&!d)},[N,u,d]),S.useEffect(()=>{if(!N||e===void 0)return;if(D.current){D.current=!1;return}Xo(N)!==e&&N.commands.setContent(ki(e??"",P),{emitUpdate:!1})},[N,e,P]),S.useEffect(()=>{if(!N)return;const $=N.storage[Pi];$&&($.variables=P)},[N,P]);const R=S.useRef(I);S.useEffect(()=>{N&&R.current!==I&&(R.current=I,N.commands.setContent(ki(Xo(N),P),{emitUpdate:!1}))},[N,I,P]),S.useImperativeHandle(v,()=>({focus:($="end")=>N==null?void 0:N.commands.focus($)}));function j(){N&&(E?N.commands.setContent(ki(_,P)):T(Xo(N)),O($=>!$))}const F=[Tn.wrapper,Tn[f],c&&Tn.error,u&&Tn.disabled,d&&Tn.readOnly,p].filter(Boolean).join(" ");return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:F,style:s?{"--rte-min-height":s}:void 0,onClick:$=>{if(u||d||E)return;const V=$.target;if(V.closest('button, input, select, a, [role="menu"], [role="menuitem"], [role="menuitemradio"]'))return;const fe=$.currentTarget.querySelector(".ProseMirror");fe&&fe.contains(V)||N==null||N.commands.focus("end")},children:[N&&!d&&m.jsx("div",{className:Tn.menuBarRegion,children:m.jsx(LD,{editor:N,disabled:u,showHtml:E,compact:h,onLinkClick:()=>C(!0),onCodeClick:j,variables:P,showVariablePicker:x,onVariableInsert:w,onAiSubmit:g,aiSubmitDisabled:y})}),E?m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Fw,{value:_,onValueChange:T,highlight:$=>ma.highlight($,ma.languages.markup,"markup"),padding:12,className:Tn.htmlSource,textareaClassName:Tn.htmlSourceTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})}):m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Af,{editor:N,className:Tn.content})})]}),N&&m.jsx(VD,{editor:N,open:k,onClose:()=>C(!1)})]})}),Ye=16;function sg(t,e){var r;const n=t.extensionManager.extensions.find(s=>s.name===e);return typeof((r=n==null?void 0:n.options)==null?void 0:r.onPick)=="function"}const Sx=[{id:"paragraph",label:"Text",icon:m.jsx(kR,{size:Ye}),group:"Basic",shortcut:"/text",keywords:["paragraph","body","plain"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("paragraph").run()}},{id:"heading",label:"Heading",icon:m.jsx($R,{size:Ye}),group:"Basic",shortcut:"/heading",keywords:["title","header","h1","h2","h3"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("heading",{level:2}).run()}},{id:"bullet-list",label:"Bulleted list",icon:m.jsx(ga,{size:Ye}),group:"Basic",shortcut:"/ul",keywords:["unordered","bullets","points"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{id:"ordered-list",label:"Numbered list",icon:m.jsx(N1,{size:Ye}),group:"Basic",shortcut:"/ol",keywords:["ordered","numbers","steps"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{id:"blockquote",label:"Quote",icon:m.jsx(t1,{size:Ye}),group:"Basic",shortcut:"/quote",keywords:["blockquote","citation"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{id:"code-block",label:"Code",icon:m.jsx(nc,{size:Ye}),group:"Basic",shortcut:"/code",keywords:["snippet","pre","syntax"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{id:"divider",label:"Divider",icon:m.jsx(wd,{size:Ye}),group:"Basic",shortcut:"/hr",keywords:["horizontal rule","separator","line"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{id:"table",label:"Table",icon:m.jsx(l1,{size:Ye}),group:"Basic",shortcut:"/table",keywords:["grid","rows","columns","spreadsheet"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{id:"callout",label:"Callout",icon:m.jsx(LR,{size:Ye}),group:"Basic",shortcut:"/callout",keywords:["note","info","warning","tip","aside"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCalloutBlock().run()}},{id:"toggle",label:"Toggle",icon:m.jsx(DR,{size:Ye}),group:"Basic",shortcut:"/toggle",keywords:["accordion","collapse","details","faq","expand"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertToggleBlock().run()}},{id:"image",label:"Image",icon:m.jsx(zR,{size:Ye}),group:"Media",shortcut:"/image",keywords:["photo","picture","upload","media"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertImageBlock().run()}},{id:"gallery",label:"Gallery",icon:m.jsx(jR,{size:Ye}),group:"Media",shortcut:"/gallery",keywords:["images","photos","grid","album"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertGalleryBlock().run()}},{id:"video",label:"Video",icon:m.jsx(qw,{size:Ye}),group:"Media",shortcut:"/video",keywords:["youtube","vimeo","embed","media","mp4"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertVideoBlock().run()}},{id:"html",label:"HTML",icon:m.jsx(JR,{size:Ye}),group:"Media",shortcut:"/html",keywords:["embed","markup","script","custom","raw"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertHtmlBlock().run()}},{id:"product",label:"Product",icon:m.jsx(C1,{size:Ye}),group:"Commerce",shortcut:"/product",keywords:["item","sku","shop","store"],isAvailable:t=>sg(t,"productBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertProductBlock().run()}},{id:"collection",label:"Collection",icon:m.jsx(D1,{size:Ye}),group:"Commerce",shortcut:"/collection",keywords:["category","catalog","group"],isAvailable:t=>sg(t,"collectionBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCollectionBlock().run()}},{id:"button",label:"Button",icon:m.jsx(_R,{size:Ye}),group:"Media",shortcut:"/button",keywords:["cta","call to action","link"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertButtonBlock().run()}}];function Cx(t,e,n){const r=n?t.filter(i=>{var o;return((o=i.isAvailable)==null?void 0:o.call(i,n))??!0}):t,s=e.trim().toLowerCase();return s?r.filter(i=>i.label.toLowerCase().includes(s)||(i.keywords??[]).some(o=>o.toLowerCase().includes(s))):r}function Ex(t){const e=[];for(const n of t){const r=e.find(s=>s.group===n.group);r?r.blocks.push(n):e.push({group:n.group,blocks:[n]})}return e}const XD="_panel_1hllz_5",QD="_menu_1hllz_25",ZD="_shortcut_1hllz_31",eL="_empty_1hllz_37",Qo={panel:XD,menu:QD,shortcut:ZD,empty:eL},ig=300,rs=8,tL=S.forwardRef(function({blocks:e,getAnchor:n,query:r,onSelect:s,onClose:i,emptyLabel:o="No blocks found",captureKeys:l=!1},a){const[c,u]=S.useState(0),d=S.useRef(null),f=S.useRef([]),[h,p]=S.useState(null),g=S.useMemo(()=>Ex(e),[e]),y=S.useMemo(()=>g.flatMap(w=>w.blocks),[g]);S.useEffect(()=>{u(0)},[r,e.length]);const b=S.useCallback(()=>{const w=d.current,v=n();if(!w||!v)return;const k=w.offsetHeight,E=window.innerHeight-v.bottom<k+rs&&v.top>k+rs?v.top-k-rs:v.bottom+rs,O=Math.min(v.left,window.innerWidth-ig-rs);p({top:E,left:Math.max(rs,O)})},[n]);S.useLayoutEffect(b,[b,e.length]),S.useEffect(()=>(window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}),[b]),S.useEffect(()=>{var w;(w=f.current[c])==null||w.scrollIntoView({block:"nearest"})},[c]);const x=S.useCallback(w=>{const v=y.length;if(w.key==="ArrowDown")return u(k=>v?(k+1)%v:0),!0;if(w.key==="ArrowUp")return u(k=>v?(k-1+v)%v:0),!0;if(w.key==="Enter"){const k=y[c];return k&&s(k),!0}return w.key==="Escape"?(i(),!0):!1},[y,c,s,i]);return S.useImperativeHandle(a,()=>({onKeyDown:x}),[x]),S.useEffect(()=>{if(!l)return;function w(v){x(v)&&(v.preventDefault(),v.stopPropagation())}return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[l,x]),S.useEffect(()=>{function w(v){var k;(k=d.current)!=null&&k.contains(v.target)||i()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),zs.createPortal(m.jsx("div",{ref:d,className:Qo.panel,style:{top:(h==null?void 0:h.top)??0,left:(h==null?void 0:h.left)??0,width:ig,visibility:h?"visible":"hidden"},children:m.jsx(A.Scrollable,{size:"thin",maxHeight:"320px",children:m.jsxs(A.Menu,{className:Qo.menu,children:[y.length===0&&m.jsx("div",{className:Qo.empty,children:o}),g.map(({group:w,blocks:v},k)=>{const C=g.slice(0,k).reduce((E,O)=>E+O.blocks.length,0);return m.jsx(A.MenuGroup,{label:w,children:v.map((E,O)=>{const _=C+O;return m.jsx("div",{ref:T=>{f.current[_]=T},children:m.jsx(A.MenuItem,{label:E.label,leftIcon:E.icon,rightSlot:E.shortcut?m.jsx("span",{className:Qo.shortcut,children:E.shortcut}):void 0,forceHover:_===c,onClick:()=>s(E)})},E.id)})},w)})]})})}),document.body)});function nL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=aA(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",f=s?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),x=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(b);if(i!==null&&!x)return null;const w=g+y.index;let v=w+y[0].length;return a&&u.test(p.slice(v-1,v+1))&&(y[0]+=" ",v+=1),w<l.pos&&v>=l.pos?{range:{from:w,to:v},query:y[0].slice(n.length),text:y[0]}:null}function rL(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!(n!=null&&n.content))return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
382
|
+
`);return/\s/.test(r)}):!1}var sL=new ae("suggestion");function iL({pluginKey:t=sL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=nL,shouldShow:y,shouldResetDismissed:b}){let x;const w=h==null?void 0:h(),v=r&&!s,k=()=>{const T=e.state.selection.$anchor.pos,D=e.view.coordsAtPos(T),{top:I,right:P,bottom:N,left:R}=D;try{return new DOMRect(R,I,P-R,N-I)}catch{return null}},C=(T,D)=>D?()=>{const I=t.getState(e.state),P=I==null?void 0:I.decorationId,N=T.dom.querySelector(`[data-decoration-id="${P}"]`);return(N==null?void 0:N.getBoundingClientRect())||null}:k,E=({match:T,dismissedRange:D,state:I,transaction:P})=>b!=null&&b({editor:e,state:I,range:D,match:T,transaction:P,allowSpaces:v})?!1:v?T.range.from===D.from:T.range.from===D.from&&!rL(P);function O(T,D){var I;try{const N=t.getState(T.state),R=N!=null&&N.decorationId?T.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null,j={editor:e,range:(N==null?void 0:N.range)||{from:0,to:0},query:(N==null?void 0:N.query)||null,text:(N==null?void 0:N.text)||null,items:[],command:F=>d({editor:e,range:(N==null?void 0:N.range)||{from:0,to:0},props:F}),decorationNode:R,clientRect:C(T,R)};(I=w==null?void 0:w.onExit)==null||I.call(w,j)}catch{}const P=T.state.tr.setMeta(D,{exit:!0});T.dispatch(P)}const _=new ue({key:t,view(){return{update:async(T,D)=>{var I,P,N,R,j,F,$;const V=(I=this.key)==null?void 0:I.getState(D),fe=(P=this.key)==null?void 0:P.getState(T.state),we=V.active&&fe.active&&V.range.from!==fe.range.from,Te=!V.active&&fe.active,Tt=V.active&&!fe.active,Me=!Te&&!Tt&&V.query!==fe.query,Ie=Te||we&&Me,$e=Me||we,q=Tt||we&&Me;if(!Ie&&!$e&&!q)return;const ie=q&&!Ie?V:fe,U=T.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);x={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:Wt=>d({editor:e,range:ie.range,props:Wt}),decorationNode:U,clientRect:C(T,U)},Ie&&((N=w==null?void 0:w.onBeforeStart)==null||N.call(w,x)),$e&&((R=w==null?void 0:w.onBeforeUpdate)==null||R.call(w,x)),($e||Ie)&&(x.items=await f({editor:e,query:ie.query})),q&&((j=w==null?void 0:w.onExit)==null||j.call(w,x)),$e&&((F=w==null?void 0:w.onUpdate)==null||F.call(w,x)),Ie&&(($=w==null?void 0:w.onStart)==null||$.call(w,x))},destroy:()=>{var T;x&&((T=w==null?void 0:w.onExit)==null||T.call(w,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(T,D,I,P){const{isEditable:N}=e,{composing:R}=e.view,{selection:j}=T,{empty:F,from:$}=j,V={...D},fe=T.getMeta(t);if(fe&&fe.exit)return V.active=!1,V.decorationId=null,V.range={from:0,to:0},V.query=null,V.text=null,V.dismissedRange=D.active?{...D.range}:D.dismissedRange,V;if(V.composing=R,T.docChanged&&V.dismissedRange!==null&&(V.dismissedRange={from:T.mapping.map(V.dismissedRange.from),to:T.mapping.map(V.dismissedRange.to)}),N&&(F||e.view.composing)){($<D.range.from||$>D.range.to)&&!R&&!D.composing&&(V.active=!1);const we=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:j.$from}),Te=`id_${Math.floor(Math.random()*4294967295)}`;we&&p({editor:e,state:P,range:we.range,isActive:D.active})&&(!y||y({editor:e,range:we.range,query:we.query,text:we.text,transaction:T}))?(V.dismissedRange!==null&&!E({match:we,dismissedRange:V.dismissedRange,state:P,transaction:T})&&(V.dismissedRange=null),V.dismissedRange===null?(V.active=!0,V.decorationId=D.decorationId?D.decorationId:Te,V.range=we.range,V.query=we.query,V.text=we.text):V.active=!1):(we||(V.dismissedRange=null),V.active=!1)}else V.active=!1;return V.active||(V.decorationId=null,V.range={from:0,to:0},V.query=null,V.text=null),V}},props:{handleKeyDown(T,D){var I,P;const{active:N,range:R}=_.getState(T.state);if(!N)return!1;if(D.key==="Escape"||D.key==="Esc"){const F=_.getState(T.state);return(I=w==null?void 0:w.onKeyDown)==null||I.call(w,{view:T,event:D,range:F.range}),O(T,t),!0}return((P=w==null?void 0:w.onKeyDown)==null?void 0:P.call(w,{view:T,event:D,range:R}))||!1},decorations(T){const{active:D,range:I,decorationId:P,query:N}=_.getState(T);if(!D)return null;const R=!(N!=null&&N.length),j=[a];return R&&j.push(u),pe.create(T.doc,[Le.inline(I.from,I.to,{nodeName:l,class:j.join(" "),"data-decoration-id":P,"data-decoration-content":c})])}}});return _}var oL=iL;const Tx=new ae("blockEditorSlashCommand"),Mx=oe.create({name:"blockEditorSlashCommand",addOptions(){return{onStateChange:()=>{},onKeyDown:()=>!1}},addProseMirrorPlugins(){const t=this.options;return[oL({editor:this.editor,pluginKey:Tx,char:"/",startOfLine:!0,allow:({state:e,range:n})=>e.doc.resolve(n.from).parent.type.name!=="codeBlock",items:()=>[],render:()=>({onStart:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onUpdate:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onKeyDown:({event:e})=>t.onKeyDown(e),onExit:()=>t.onStateChange(null)})})]}});function Vs({commands:t,state:e,node:n}){const{$from:r}=e.selection,s=r.depth>0,o=(s?r.after():r.pos)>=e.doc.content.size?[n,{type:"paragraph"}]:[n];return s&&r.parent.type.name==="paragraph"&&r.parent.content.size===0?t.insertContentAt({from:r.before(),to:r.after()},o):t.insertContent(o)}const lL="_wrapper_1wcz7_5",aL="_normal_1wcz7_10",cL="_wide_1wcz7_14",uL="_full_1wcz7_23",dL="_selected_1wcz7_29",fL="_figure_1wcz7_29",hL="_placeholder_1wcz7_30",pL="_fileInput_1wcz7_34",mL="_image_1wcz7_45",gL="_toolbar_1wcz7_58",yL="_toolbarDivider_1wcz7_79",bL="_altToggle_1wcz7_91",wL="_altToggleSet_1wcz7_120",xL="_caption_1wcz7_130",vL="_captionInput_1wcz7_138",kL="_captionAlt_1wcz7_167",SL="_altBadge_1wcz7_174",CL="_altInput_1wcz7_186",EL="_overlay_1wcz7_200",TL="_dragOver_1wcz7_224",ML="_placeholderBody_1wcz7_229",AL="_placeholderIcon_1wcz7_245",_L="_placeholderText_1wcz7_249",NL="_urlInput_1wcz7_254",OL="_placeholderDelete_1wcz7_271",IL="_error_1wcz7_284",ge={wrapper:lL,normal:aL,wide:cL,full:uL,selected:dL,figure:fL,placeholder:hL,fileInput:pL,image:mL,toolbar:gL,toolbarDivider:yL,altToggle:bL,altToggleSet:wL,caption:xL,captionInput:vL,captionAlt:kL,altBadge:SL,altInput:CL,overlay:EL,dragOver:TL,placeholderBody:ML,placeholderIcon:AL,placeholderText:_L,urlInput:NL,placeholderDelete:OL,error:IL},RL=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function DL({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const{src:o,alt:l,caption:a,layout:c}=t.attrs,u=i.options,d=S.useRef(null),f=S.useRef(null),[h,p]=S.useState(!1),[g,y]=S.useState(null),[b,x]=S.useState(!1),[w,v]=S.useState(!1),k=r.isEditable;S.useEffect(()=>{var T;w&&((T=f.current)==null||T.focus())},[w]);async function C(T){if(!u.onUpload){y("Uploading is not configured");return}y(null),p(!0);try{const D=await u.onUpload(T);e({src:D})}catch(D){y(D instanceof Error?D.message:"Upload failed")}finally{p(!1)}}function E(){var T;y(null),(T=d.current)==null||T.click()}function O(T){if(!w)return;const D=T.relatedTarget;D&&T.currentTarget.contains(D)||v(!1)}const _=[ge.wrapper,ge[c],s&&ge.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:_,"data-drag-handle":!0,children:[m.jsx("input",{ref:d,type:"file",accept:u.accept,className:ge.fileInput,onChange:T=>{var I;const D=(I=T.target.files)==null?void 0:I[0];T.target.value="",D&&C(D)}}),o?m.jsxs("figure",{className:ge.figure,contentEditable:!1,onBlur:O,children:[m.jsx("img",{src:o,alt:l??"",className:ge.image}),k&&m.jsxs("div",{className:ge.toolbar,children:[RL.map(({value:T,label:D,icon:I})=>m.jsx(A.Tooltip,{content:D,children:m.jsx(A.IconButton,{"aria-label":D,variant:c===T?"neutral":"transparent",size:"xsmall",icon:m.jsx(I,{size:14}),onClick:()=>e({layout:T})})},T)),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(A.Tooltip,{content:l?`Alt text: ${l}`:"Describe this image (alt text)",children:m.jsx("button",{type:"button","aria-label":"Edit alt text","aria-pressed":w,className:[ge.altToggle,l&&ge.altToggleSet].filter(Boolean).join(" "),onClick:()=>v(T=>!T),children:"ALT"})}),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace image",variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),onClick:E})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete image",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),(k||a)&&m.jsxs("figcaption",{className:[ge.caption,w&&ge.captionAlt].filter(Boolean).join(" "),children:[!k&&a,k&&w&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:ge.altBadge,"aria-hidden":"true",children:"ALT"}),m.jsx("input",{ref:f,type:"text",className:[ge.captionInput,ge.altInput].join(" "),value:l??"","aria-label":"Alt text",placeholder:"Describe this image for screen readers",onChange:T=>e({alt:T.target.value}),onKeyDown:T=>{T.key!=="Enter"&&T.key!=="Escape"||(T.preventDefault(),v(!1))}})]}),k&&!w&&m.jsx("input",{type:"text",className:ge.captionInput,value:a??"","aria-label":"Caption",placeholder:"Type caption for image (optional)",onChange:T=>e({caption:T.target.value})})]}),h&&m.jsx("div",{className:ge.overlay,children:m.jsx(A.Spinner,{size:"md"})})]}):m.jsxs("div",{className:[ge.placeholder,b&&ge.dragOver].filter(Boolean).join(" "),contentEditable:!1,onDragOver:T=>{k&&(T.preventDefault(),x(!0))},onDragLeave:()=>x(!1),onDrop:T=>{var I;if(!k)return;T.preventDefault(),x(!1);const D=(I=T.dataTransfer.files)==null?void 0:I[0];D&&C(D)},children:[h?m.jsxs("div",{className:ge.placeholderBody,children:[m.jsx(A.Spinner,{size:"md"}),m.jsx("span",{className:ge.placeholderText,children:"Uploading…"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:ge.placeholderBody,onClick:E,disabled:!k,children:[m.jsx(kd,{size:22,className:ge.placeholderIcon}),m.jsx("span",{className:ge.placeholderText,children:u.onUpload?"Click to select an image, or drag one here":"Paste an image URL below"})]}),m.jsx("input",{type:"url",className:ge.urlInput,placeholder:"…or paste an image URL",onKeyDown:T=>{if(T.key!=="Enter")return;T.preventDefault();const D=T.target.value.trim();D&&e({src:D})}})]}),g&&m.jsxs("p",{className:ge.error,children:[m.jsx(Xf,{size:14}),g]}),k&&m.jsx("div",{className:ge.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})}const Ax="image",_x=Se.create({name:Ax,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*",HTMLAttributes:{}}},addAttributes(){return{src:{default:null},alt:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-image-block]"},{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),alt:t.getAttribute("alt")})}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,alt:r,caption:s}=e.attrs;return["figure",le({"data-image-block":""},this.options.HTMLAttributes,{"data-layout":t["data-layout"]}),["img",{src:n,alt:r??""}],...s?[["figcaption",{},s]]:[]]},addNodeView(){return vr(DL)},addCommands(){return{insertImageBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),LL="_wrapper_1mu6t_3",jL="_information_1mu6t_16",PL="_success_1mu6t_21",BL="_warning_1mu6t_26",zL="_error_1mu6t_31",$L="_neutral_1mu6t_36",HL="_selected_1mu6t_41",FL="_marker_1mu6t_46",VL="_emojiButton_1mu6t_54",UL="_accentLine_1mu6t_74",WL="_emojiMenu_1mu6t_84",qL="_emojiGrid_1mu6t_88",KL="_emojiChoice_1mu6t_94",JL="_emojiChoiceActive_1mu6t_115",GL="_body_1mu6t_121",YL="_toolbar_1mu6t_131",XL="_toneButton_1mu6t_151",QL="_toneSwatch_1mu6t_168",ze={wrapper:LL,information:jL,success:PL,warning:BL,error:zL,neutral:$L,selected:HL,marker:FL,emojiButton:VL,accentLine:UL,emojiMenu:WL,emojiGrid:qL,emojiChoice:KL,emojiChoiceActive:JL,body:GL,toolbar:YL,toneButton:XL,toneSwatch:QL},ZL=["💡","📌","⚠️","✅","❌","🔥","📣","🎯","📝","🚀","❓","⭐"],e2=[{value:"information",label:"Information"},{value:"success",label:"Success"},{value:"warning",label:"Warning"},{value:"error",label:"Error"},{value:"neutral",label:"Neutral"}];function t2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{emoji:i,tone:o}=t.attrs,[l,a]=S.useState(!1),[c,u]=S.useState(!1),d=r.isEditable,f=[ze.wrapper,ze[o],s&&ze.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:f,children:[m.jsx("div",{className:ze.marker,contentEditable:!1,children:d?m.jsx(A.Popover,{open:l,onOpenChange:a,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:ze.emojiButton,"aria-label":"Change emoji",children:i||m.jsx("span",{className:ze.accentLine})}),children:m.jsx(A.Menu,{className:ze.emojiMenu,children:m.jsxs("div",{className:ze.emojiGrid,children:[m.jsx("button",{type:"button",className:[ze.emojiChoice,!i&&ze.emojiChoiceActive].filter(Boolean).join(" "),"aria-label":"No emoji",onClick:()=>{e({emoji:null}),a(!1)},children:m.jsx(tD,{size:16})}),ZL.map(h=>m.jsx("button",{type:"button",className:[ze.emojiChoice,i===h&&ze.emojiChoiceActive].filter(Boolean).join(" "),onClick:()=>{e({emoji:h}),a(!1)},children:h},h))]})})}):i||m.jsx("span",{className:ze.accentLine})}),m.jsx(L0,{className:ze.body}),d&&m.jsxs("div",{className:ze.toolbar,contentEditable:!1,children:[m.jsx(A.Popover,{open:c,onOpenChange:u,placement:"bottom-end",bare:!0,trigger:m.jsx("button",{type:"button",className:ze.toneButton,"aria-label":"Change colour",children:m.jsx("span",{className:ze.toneSwatch})}),children:m.jsx(A.Menu,{children:e2.map(({value:h,label:p})=>m.jsx(A.MenuItemRadio,{label:p,leftIcon:m.jsx("span",{className:[ze.toneSwatch,ze[h]].join(" ")}),checked:o===h,onClick:()=>{e({tone:h}),u(!1)}},h))})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete callout",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})}const Nx="callout",Ox=Se.create({name:Nx,group:"block",content:"block+",defining:!0,addAttributes(){return{emoji:{default:"💡"},tone:{default:"information",parseHTML:t=>t.getAttribute("data-tone")??"information",renderHTML:t=>({"data-tone":t.tone})}}},parseHTML(){return[{tag:"div[data-callout-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{emoji:n}=e.attrs;return["div",le({"data-callout-block":""},{"data-tone":t["data-tone"]}),...n?[["span",{"data-callout-emoji":""},n]]:[],["div",{"data-callout-body":""},0]]},addNodeView(){return vr(t2)},addCommands(){return{insertCalloutBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{emoji:"💡",tone:"information",...t},content:[{type:"paragraph"}]})}}}),n2="_wrapper_1bsti_1",r2="_buttonRow_1bsti_6",s2="_selected_1bsti_14",i2="_outline_1bsti_21",o2="_settings_1bsti_31",l2="_fields_1bsti_53",a2="_field_1bsti_53",c2="_fieldLabel_1bsti_65",u2="_input_1bsti_71",d2="_controls_1bsti_89",f2="_styleToggle_1bsti_98",h2="_styleOption_1bsti_105",p2="_styleOptionActive_1bsti_117",m2="_alignGroup_1bsti_122",Fe={wrapper:n2,buttonRow:r2,"align-left":"_align-left_1bsti_10","align-center":"_align-center_1bsti_11","align-right":"_align-right_1bsti_12",selected:s2,outline:i2,settings:o2,fields:l2,field:a2,fieldLabel:c2,input:u2,controls:d2,styleToggle:f2,styleOption:h2,styleOptionActive:p2,alignGroup:m2},g2=[{value:"left",label:"Align left",icon:CR},{value:"center",label:"Align centre",icon:ER},{value:"right",label:"Align right",icon:TR}],y2=[{value:"fill",label:"Fill"},{value:"outline",label:"Outline"}];function b2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{text:i,href:o,style:l,align:a}=t.attrs,c=r.isEditable,u=[Fe.wrapper,Fe[`align-${a}`],s&&Fe.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:u,"data-drag-handle":!0,children:[m.jsx("div",{className:Fe.buttonRow,contentEditable:!1,children:m.jsx(A.Button,{variant:l==="fill"?"inverted":"transparent",className:l==="outline"?Fe.outline:void 0,onClick:d=>d.preventDefault(),children:i||"Button"})}),c&&m.jsxs("div",{className:Fe.settings,contentEditable:!1,children:[m.jsxs("div",{className:Fe.fields,children:[m.jsxs("label",{className:Fe.field,children:[m.jsx("span",{className:Fe.fieldLabel,children:"Button text"}),m.jsx("input",{type:"text",className:Fe.input,value:i??"",placeholder:"Add button text",onChange:d=>e({text:d.target.value})})]}),m.jsxs("label",{className:Fe.field,children:[m.jsx("span",{className:Fe.fieldLabel,children:"Button URL"}),m.jsx("input",{type:"url",className:Fe.input,value:o??"",placeholder:"https://",onChange:d=>e({href:d.target.value||null})})]})]}),m.jsxs("div",{className:Fe.controls,children:[m.jsx("div",{className:Fe.styleToggle,children:y2.map(({value:d,label:f})=>m.jsx("button",{type:"button",className:[Fe.styleOption,l===d&&Fe.styleOptionActive].filter(Boolean).join(" "),onClick:()=>e({style:d}),children:f},d))}),m.jsx("div",{className:Fe.alignGroup,children:g2.map(({value:d,label:f,icon:h})=>m.jsx(A.Tooltip,{content:f,children:m.jsx(A.IconButton,{"aria-label":f,variant:a===d?"neutral":"transparent",size:"xsmall",icon:m.jsx(h,{size:14}),onClick:()=>e({align:d})})},d))}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete button block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})]})}const Ix="buttonBlock",Rx=Se.create({name:Ix,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{text:{default:"Button"},href:{default:null},style:{default:"fill",parseHTML:t=>t.getAttribute("data-style")??"fill",renderHTML:t=>({"data-style":t.style})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align")??"center",renderHTML:t=>({"data-align":t.align})}}},parseHTML(){return[{tag:"div[data-button-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{text:n,href:r}=e.attrs;return["div",le({"data-button-block":""},{"data-style":t["data-style"],"data-align":t["data-align"]}),["a",{href:r??"#"},n??""]]},addNodeView(){return vr(b2)},addCommands(){return{insertButtonBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{text:"Button",style:"fill",align:"center",...t}}})}}}),w2="_wrapper_1g9li_1",x2="_selected_1g9li_6",v2="_editor_1g9li_6",k2="_previewShell_1g9li_7",S2="_editorHeader_1g9li_19",C2="_label_1g9li_27",E2="_code_1g9li_36",T2="_codeTextarea_1g9li_42",M2="_preview_1g9li_7",A2="_empty_1g9li_71",_2="_previewToolbar_1g9li_79",Kt={wrapper:w2,selected:x2,editor:v2,previewShell:k2,editorHeader:S2,label:C2,code:E2,codeTextarea:T2,preview:M2,empty:A2,previewToolbar:_2};function N2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const i=t.attrs.html??"",o=r.isEditable,[l,a]=S.useState(!i),c=[Kt.wrapper,s&&Kt.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:c,"data-drag-handle":!0,children:m.jsx("div",{contentEditable:!1,children:l&&o?m.jsxs("div",{className:Kt.editor,children:[m.jsxs("div",{className:Kt.editorHeader,children:[m.jsx("span",{className:Kt.label,children:"HTML"}),m.jsx(A.Tooltip,{content:"Preview",children:m.jsx(A.IconButton,{"aria-label":"Preview HTML",variant:"transparent",size:"xsmall",icon:m.jsx(VR,{size:14}),onClick:()=>a(!1)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),m.jsx(Fw,{value:i,onValueChange:u=>e({html:u}),highlight:u=>ma.highlight(u,ma.languages.markup,"markup"),padding:12,placeholder:"<p>Paste or write HTML…</p>",className:Kt.code,textareaClassName:Kt.codeTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})]}):m.jsxs("div",{className:Kt.previewShell,children:[i?m.jsx("div",{className:Kt.preview,dangerouslySetInnerHTML:{__html:i}}):m.jsx("p",{className:Kt.empty,children:"Empty HTML block"}),o&&m.jsxs("div",{className:Kt.previewToolbar,children:[m.jsx(A.Tooltip,{content:"Edit HTML",children:m.jsx(A.IconButton,{"aria-label":"Edit HTML",variant:"transparent",size:"xsmall",icon:m.jsx(nc,{size:14}),onClick:()=>a(!0)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]})})})}const Dx="htmlBlock",Lx=Se.create({name:Dx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{html:{default:""}}},parseHTML(){return[{tag:"div[data-html-block]",getAttrs:t=>({html:t.innerHTML})}]},renderHTML({node:t}){return["div",le({"data-html-block":""}),t.attrs.html??""]},addNodeView(){return vr(N2)},addCommands(){return{insertHtmlBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{html:"",...t}}})}}}),O2="_wrapper_n5xg6_3",I2="_normal_n5xg6_8",R2="_wide_n5xg6_12",D2="_full_n5xg6_21",L2="_selected_n5xg6_27",j2="_figure_n5xg6_27",P2="_placeholder_n5xg6_28",B2="_frame_n5xg6_39",z2="_media_n5xg6_52",$2="_toolbar_n5xg6_62",H2="_toolbarDivider_n5xg6_82",F2="_caption_n5xg6_90",V2="_captionInput_n5xg6_98",U2="_placeholderIcon_n5xg6_134",W2="_placeholderText_n5xg6_138",q2="_urlInput_n5xg6_144",K2="_placeholderDelete_n5xg6_162",nt={wrapper:O2,normal:I2,wide:R2,full:D2,selected:L2,figure:j2,placeholder:P2,frame:B2,media:z2,toolbar:$2,toolbarDivider:H2,caption:F2,captionInput:V2,placeholderIcon:U2,placeholderText:W2,urlInput:q2,placeholderDelete:K2},J2=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function G2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{src:i,caption:o,layout:l}=t.attrs,[a,c]=S.useState(""),u=r.isEditable,d=nh(i??""),f=[nt.wrapper,nt[l],s&&nt.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:f,"data-drag-handle":!0,children:d?m.jsxs("figure",{className:nt.figure,contentEditable:!1,children:[m.jsx("div",{className:nt.frame,children:d.kind==="iframe"?m.jsx("iframe",{src:d.url,title:o??"Video",className:nt.media,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):m.jsx("video",{src:d.url,className:nt.media,controls:!0})}),u&&m.jsxs("div",{className:nt.toolbar,children:[J2.map(({value:h,label:p,icon:g})=>m.jsx(A.Tooltip,{content:p,children:m.jsx(A.IconButton,{"aria-label":p,variant:l===h?"neutral":"transparent",size:"xsmall",icon:m.jsx(g,{size:14}),onClick:()=>e({layout:h})})},h)),m.jsx("span",{className:nt.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace video",variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),onClick:()=>{c(i??""),e({src:null})}})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete video",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),(u||o)&&m.jsx("figcaption",{className:nt.caption,children:u?m.jsx("input",{type:"text",className:nt.captionInput,value:o??"",placeholder:"Type caption for video (optional)",onChange:h=>e({caption:h.target.value})}):o})]}):m.jsxs("div",{className:nt.placeholder,contentEditable:!1,children:[m.jsx(qw,{size:22,className:nt.placeholderIcon}),m.jsx("p",{className:nt.placeholderText,children:"Paste a YouTube, Vimeo or direct video URL"}),m.jsx("input",{type:"url",className:nt.urlInput,value:a,placeholder:"https://youtube.com/watch?v=…",autoFocus:!0,onChange:h=>c(h.target.value),onKeyDown:h=>{if(h.key!=="Enter")return;h.preventDefault();const p=a.trim();p&&e({src:p})}}),u&&m.jsx("div",{className:nt.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})})}const jx="videoBlock";function nh(t){const e=t.trim();if(!e)return null;const n=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/i);if(n)return{kind:"iframe",url:`https://www.youtube.com/embed/${n[1]}`};const r=e.match(/vimeo\.com\/(?:video\/)?(\d+)/i);return r?{kind:"iframe",url:`https://player.vimeo.com/video/${r[1]}`}:{kind:"file",url:e}}const Px=Se.create({name:jx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{src:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-video-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,caption:r}=e.attrs,s=nh(n??"");return["figure",le({"data-video-block":""},{"data-layout":t["data-layout"]}),(s==null?void 0:s.kind)==="file"?["video",{src:s.url,controls:"true"}]:["iframe",{src:(s==null?void 0:s.url)??"",frameborder:"0",allowfullscreen:"true"}],...r?[["figcaption",{},r]]:[]]},addNodeView(){return vr(G2)},addCommands(){return{insertVideoBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),Y2="_wrapper_1fr97_3",X2="_normal_1fr97_8",Q2="_wide_1fr97_12",Z2="_full_1fr97_21",ej="_selected_1fr97_27",tj="_figure_1fr97_27",nj="_fileInput_1fr97_32",rj="_grid_1fr97_42",sj="_gridDragOver_1fr97_50",ij="_cell_1fr97_56",oj="_image_1fr97_64",lj="_removeImage_1fr97_71",aj="_cellEditing_1fr97_97",cj="_altBadgeButton_1fr97_105",uj="_altBadgeButtonSet_1fr97_136",dj="_placeholder_1fr97_142",fj="_dragOver_1fr97_153",hj="_placeholderBody_1fr97_158",pj="_placeholderIcon_1fr97_173",mj="_placeholderText_1fr97_177",gj="_toolbar_1fr97_183",yj="_toolbarDivider_1fr97_203",bj="_caption_1fr97_211",wj="_captionInput_1fr97_218",xj="_captionAlt_1fr97_244",vj="_altBadge_1fr97_105",kj="_altInput_1fr97_263",Sj="_error_1fr97_276",ye={wrapper:Y2,normal:X2,wide:Q2,full:Z2,selected:ej,figure:tj,fileInput:nj,grid:rj,gridDragOver:sj,cell:ij,image:oj,removeImage:lj,cellEditing:aj,altBadgeButton:cj,altBadgeButtonSet:uj,placeholder:dj,dragOver:fj,placeholderBody:hj,placeholderIcon:pj,placeholderText:mj,toolbar:gj,toolbarDivider:yj,caption:bj,captionInput:wj,captionAlt:xj,altBadge:vj,altInput:kj,error:Sj},Cj=[{value:"normal",label:"Regular width",icon:Qf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}],Ej=3;function Tj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const o=t.attrs.images??[],{caption:l,layout:a}=t.attrs,c=i.options,u=S.useRef(null),d=S.useRef(null),[f,h]=S.useState(!1),[p,g]=S.useState(null),[y,b]=S.useState(!1),[x,w]=S.useState(null),v=r.isEditable,k=x!==null&&x<o.length?x:null;S.useEffect(()=>{var R;k!==null&&((R=d.current)==null||R.focus())},[k]);async function C(R){if(!c.onUpload){g("Uploading is not configured");return}g(null),h(!0);try{const j=[];for(const F of R){const $=await c.onUpload(F);j.push({src:$})}e({images:[...o,...j]})}catch(j){g(j instanceof Error?j.message:"Upload failed")}finally{h(!1)}}function E(R){return Array.from(R.dataTransfer.types??[]).includes("Files")}function O(R){!v||!E(R)||(R.preventDefault(),b(!0))}function _(){b(!1)}function T(R){if(!v||!E(R))return;R.preventDefault(),b(!1);const j=Array.from(R.dataTransfer.files??[]).filter(F=>F.type.startsWith("image/"));j.length&&C(j)}function D(R){e({images:o.filter((j,F)=>F!==R)}),w(null)}function I(R,j){e({images:o.map((F,$)=>$===R?{...F,alt:j}:F)})}function P(R){if(k===null)return;const j=R.relatedTarget;j&&R.currentTarget.contains(j)||w(null)}const N=[ye.wrapper,ye[a],s&&ye.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:N,"data-drag-handle":!0,children:[m.jsx("input",{ref:u,type:"file",accept:c.accept,multiple:!0,className:ye.fileInput,onChange:R=>{const j=Array.from(R.target.files??[]);R.target.value="",j.length&&C(j)}}),m.jsxs("figure",{className:ye.figure,contentEditable:!1,onBlur:P,onDragOver:O,onDragLeave:_,onDrop:T,children:[o.length>0?m.jsx("div",{className:[ye.grid,y&&ye.gridDragOver].filter(Boolean).join(" "),style:{"--gallery-columns":Math.min(Ej,o.length)},children:o.map((R,j)=>m.jsxs("div",{className:[ye.cell,k===j&&ye.cellEditing].filter(Boolean).join(" "),children:[m.jsx("img",{src:R.src,alt:R.alt??"",className:ye.image}),v&&m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:[ye.altBadgeButton,R.alt&&ye.altBadgeButtonSet].filter(Boolean).join(" "),"aria-label":`Edit alt text for image ${j+1}`,"aria-pressed":k===j,onClick:()=>w(F=>F===j?null:j),children:"ALT"}),m.jsx("button",{type:"button",className:ye.removeImage,"aria-label":"Remove image",onClick:()=>D(j),children:m.jsx(xR,{size:13})})]})]},`${R.src}-${j}`))}):m.jsx("div",{className:[ye.placeholder,y&&ye.dragOver].filter(Boolean).join(" "),children:m.jsxs("button",{type:"button",className:ye.placeholderBody,onClick:()=>{var R;return(R=u.current)==null?void 0:R.click()},disabled:!v||f,children:[f?m.jsx(A.Spinner,{size:"md"}):m.jsx(kd,{size:22,className:ye.placeholderIcon}),m.jsx("span",{className:ye.placeholderText,children:f?"Uploading…":"Click to select images, or drag them here"})]})}),v&&m.jsxs("div",{className:ye.toolbar,children:[o.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(A.Tooltip,{content:"Add images",children:m.jsx(A.IconButton,{"aria-label":"Add images",variant:"transparent",size:"xsmall",icon:m.jsx(kd,{size:14}),loading:f,onClick:()=>{var R;return(R=u.current)==null?void 0:R.click()}})}),m.jsx("span",{className:ye.toolbarDivider})]}),Cj.map(({value:R,label:j,icon:F})=>m.jsx(A.Tooltip,{content:j,children:m.jsx(A.IconButton,{"aria-label":j,variant:a===R?"neutral":"transparent",size:"xsmall",icon:m.jsx(F,{size:14}),onClick:()=>e({layout:R})})},R)),m.jsx("span",{className:ye.toolbarDivider}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete gallery",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]}),p&&m.jsxs("p",{className:ye.error,children:[m.jsx(Xf,{size:14}),p]}),(v||l)&&o.length>0&&m.jsxs("figcaption",{className:[ye.caption,k!==null&&ye.captionAlt].filter(Boolean).join(" "),children:[!v&&l,v&&k!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:ye.altBadge,"aria-hidden":"true",children:["ALT ",k+1]}),m.jsx("input",{ref:d,type:"text",className:[ye.captionInput,ye.altInput].join(" "),value:o[k].alt??"","aria-label":`Alt text for image ${k+1}`,placeholder:"Describe this image for screen readers",onChange:R=>I(k,R.target.value),onKeyDown:R=>{R.key!=="Enter"&&R.key!=="Escape"||(R.preventDefault(),w(null))}})]}),v&&k===null&&m.jsx("input",{type:"text",className:ye.captionInput,value:l??"","aria-label":"Caption",placeholder:"Type caption for gallery (optional)",onChange:R=>e({caption:R.target.value})})]})]})]})}const Bx="gallery",zx=Se.create({name:Bx,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*"}},addAttributes(){return{images:{default:[],parseHTML:t=>{const e=t.getAttribute("data-images");if(!e)return[];try{return JSON.parse(e)}catch{return[]}},renderHTML:t=>({"data-images":JSON.stringify(t.images??[])})},caption:{default:null},layout:{default:"wide",parseHTML:t=>t.getAttribute("data-layout")??"wide",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-gallery-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.images??[],{caption:r}=e.attrs;return["figure",le({"data-gallery-block":""},t),["div",{"data-gallery-grid":""},...n.map(s=>["img",{src:s.src,alt:s.alt??""}])],...r?[["figcaption",{},r]]:[]]},addNodeView(){return vr(Tj)},addCommands(){return{insertGalleryBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{images:[],layout:"wide",...t}}})}}}),Mj="_wrapper_1cd7f_1",Aj="_selected_1cd7f_9",_j="_header_1cd7f_14",Nj="_chevron_1cd7f_22",Oj="_chevronOpen_1cd7f_43",Ij="_summary_1cd7f_47",Rj="_summaryInput_1cd7f_48",Dj="_actions_1cd7f_68",Lj="_defaultState_1cd7f_83",jj="_defaultStateOn_1cd7f_95",Pj="_body_1cd7f_101",Bj="_bodyCollapsed_1cd7f_105",Rt={wrapper:Mj,selected:Aj,header:_j,chevron:Nj,chevronOpen:Oj,summary:Ij,summaryInput:Rj,actions:Dj,defaultState:Lj,defaultStateOn:jj,body:Pj,bodyCollapsed:Bj};function zj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{summary:i,open:o}=t.attrs,l=r.isEditable,[a,c]=S.useState(!1),u=!a,d=[Rt.wrapper,s&&Rt.selected].filter(Boolean).join(" ");return m.jsxs(xr,{className:d,children:[m.jsxs("div",{className:Rt.header,contentEditable:!1,children:[m.jsx("button",{type:"button",className:[Rt.chevron,u&&Rt.chevronOpen].filter(Boolean).join(" "),"aria-label":u?"Collapse":"Expand","aria-expanded":u,onClick:()=>c(f=>!f),children:m.jsx(GR,{size:16})}),l?m.jsx("input",{type:"text",className:Rt.summaryInput,value:i??"",placeholder:"Toggle heading",onChange:f=>e({summary:f.target.value})}):m.jsx("span",{className:Rt.summary,children:i}),l&&m.jsxs("div",{className:Rt.actions,children:[m.jsx(A.Tooltip,{content:o?"Open by default":"Closed by default",children:m.jsx("button",{type:"button",className:[Rt.defaultState,o&&Rt.defaultStateOn].filter(Boolean).join(" "),onClick:()=>e({open:!o}),children:o?"Open by default":"Closed by default"})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete toggle",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]}),m.jsx(L0,{className:[Rt.body,!u&&Rt.bodyCollapsed].filter(Boolean).join(" ")})]})}const $x="toggleBlock",Hx=Se.create({name:$x,group:"block",content:"block+",defining:!0,addAttributes(){return{summary:{default:""},open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:t=>t.open?{open:"true"}:{}}}},parseHTML(){return[{tag:"details[data-toggle-block]"}]},renderHTML({HTMLAttributes:t,node:e}){return["details",le({"data-toggle-block":""},t),["summary",{},e.attrs.summary??""],["div",{"data-toggle-body":""},0]]},addNodeView(){return vr(zj)},addCommands(){return{insertToggleBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{summary:"",open:!1,...t},content:[{type:"paragraph"}]})}}}),$j="_wrapper_1uoda_1",Hj="_selected_1uoda_6",Fj="_card_1uoda_6",Vj="_placeholder_1uoda_7",Uj="_thumb_1uoda_23",Wj="_thumbImage_1uoda_35",qj="_thumbFallback_1uoda_42",Kj="_body_1uoda_47",Jj="_title_1uoda_52",Gj="_subtitle_1uoda_64",Yj="_meta_1uoda_70",Xj="_toolbar_1uoda_77",Qj="_placeholderBody_1uoda_110",Zj="_placeholderIcon_1uoda_126",eP="_placeholderText_1uoda_131",tP="_placeholderDelete_1uoda_136",nP="_error_1uoda_149",Xe={wrapper:$j,selected:Hj,card:Fj,placeholder:Vj,thumb:Uj,thumbImage:Wj,thumbFallback:qj,body:Kj,title:Jj,subtitle:Gj,meta:Yj,toolbar:Xj,placeholderBody:Qj,placeholderIcon:Zj,placeholderText:eP,placeholderDelete:tP,error:nP};function rP({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i,noun:o,icon:l}){const a=t.attrs.entity,c=i.options,[u,d]=S.useState(!1),[f,h]=S.useState(null),p=r.isEditable;async function g(){if(!c.onPick){h("No picker is configured");return}h(null),d(!0);try{const b=await c.onPick();b&&e({entity:b})}catch(b){h(b instanceof Error?b.message:"Could not load the selection")}finally{d(!1)}}const y=[Xe.wrapper,s&&Xe.selected].filter(Boolean).join(" ");return m.jsx(xr,{className:y,"data-drag-handle":!0,children:a?m.jsxs("div",{className:Xe.card,contentEditable:!1,children:[m.jsx("div",{className:Xe.thumb,children:a.imageUrl?m.jsx("img",{src:a.imageUrl,alt:"",className:Xe.thumbImage}):m.jsx("span",{className:Xe.thumbFallback,children:l})}),m.jsxs("div",{className:Xe.body,children:[m.jsx("p",{className:Xe.title,children:a.title}),a.subtitle&&m.jsx("p",{className:Xe.subtitle,children:a.subtitle}),a.meta&&m.jsx("p",{className:Xe.meta,children:a.meta})]}),p&&m.jsxs("div",{className:Xe.toolbar,children:[m.jsx(A.Tooltip,{content:`Change ${o}`,children:m.jsx(A.IconButton,{"aria-label":`Change ${o}`,variant:"transparent",size:"xsmall",icon:m.jsx(Zf,{size:14}),loading:u,onClick:g})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":`Delete ${o} block`,variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})]}):m.jsxs("div",{className:Xe.placeholder,contentEditable:!1,children:[m.jsxs("button",{type:"button",className:Xe.placeholderBody,onClick:g,disabled:!p||u,children:[u?m.jsx(A.Spinner,{size:"md"}):m.jsx("span",{className:Xe.placeholderIcon,children:l}),m.jsx("span",{className:Xe.placeholderText,children:u?"Opening…":`Click to select a ${o}`})]}),f&&m.jsxs("p",{className:Xe.error,children:[m.jsx(Xf,{size:14}),f]}),p&&m.jsx("div",{className:Xe.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(Et,{size:14}),onClick:n})})]})})}const Fx="productBlock",Vx="collectionBlock";function Ux(t){return Se.create({name:t.name,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onPick:void 0}},addAttributes(){return{entity:{default:null,parseHTML:e=>{const n=e.getAttribute("data-entity");if(!n)return null;try{return JSON.parse(n)}catch{return null}},renderHTML:e=>({"data-entity":e.entity?JSON.stringify(e.entity):null})}}},parseHTML(){return[{tag:`div[${t.dataAttribute}]`}]},renderHTML({HTMLAttributes:e}){return["div",le({[t.dataAttribute]:""},e)]},addNodeView(){return vr(e=>m.jsx(rP,{...e,noun:t.noun,icon:t.icon}))},addCommands(){return{[t.command]:e=>({commands:n,state:r})=>Vs({commands:n,state:r,node:{type:t.name,attrs:{entity:e??null}}})}}})}const Wx=Ux({name:Fx,dataAttribute:"data-product-block",command:"insertProductBlock",noun:"product",icon:m.jsx(C1,{size:22})}),qx=Ux({name:Vx,dataAttribute:"data-collection-block",command:"insertCollectionBlock",noun:"collection",icon:m.jsx(D1,{size:22})}),sP="_title_b828n_3",iP={title:sP};function oP({value:t,placeholder:e,readOnly:n,onChange:r,onLeave:s}){const i=S.useRef(null);return S.useLayoutEffect(()=>{const o=i.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[t]),m.jsx("textarea",{ref:i,className:iP.title,value:t,placeholder:e,readOnly:n,rows:1,spellCheck:!1,onChange:o=>r(o.target.value.replace(/\n/g,"")),onKeyDown:o=>{(o.key==="Enter"||o.key==="ArrowDown")&&(o.preventDefault(),s())}})}const Kx=["top","right","bottom","left"],og=["start","end"],lg=Kx.reduce((t,e)=>t.concat(e,e+"-"+og[0],e+"-"+og[1]),[]),bn=Math.min,ht=Math.max,ya=Math.round,pn=t=>({x:t,y:t}),lP={left:"right",right:"left",bottom:"top",top:"bottom"};function Nd(t,e,n){return ht(t,bn(e,n))}function Hn(t,e){return typeof t=="function"?t(e):t}function Ut(t){return t.split("-")[0]}function Xt(t){return t.split("-")[1]}function Jx(t){return t==="x"?"y":"x"}function rh(t){return t==="y"?"height":"width"}function dn(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function sh(t){return Jx(dn(t))}function Gx(t,e,n){n===void 0&&(n=!1);const r=Xt(t),s=sh(t),i=rh(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wa(o)),[o,wa(o)]}function aP(t){const e=wa(t);return[ba(t),e,ba(e)]}function ba(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const ag=["left","right"],cg=["right","left"],cP=["top","bottom"],uP=["bottom","top"];function dP(t,e,n){switch(t){case"top":case"bottom":return n?e?cg:ag:e?ag:cg;case"left":case"right":return e?cP:uP;default:return[]}}function fP(t,e,n,r){const s=Xt(t);let i=dP(Ut(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(ba)))),i}function wa(t){const e=Ut(t);return lP[e]+t.slice(e.length)}function hP(t){return{top:0,right:0,bottom:0,left:0,...t}}function ih(t){return typeof t!="number"?hP(t):{top:t,right:t,bottom:t,left:t}}function Os(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function ug(t,e,n){let{reference:r,floating:s}=t;const i=dn(e),o=sh(e),l=rh(o),a=Ut(e),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[l]/2-s[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Xt(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}async function pP(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=Hn(e,t),p=ih(h),y=l[f?d==="floating"?"reference":"floating":d],b=Os(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),x=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),v=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},k=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:w,strategy:a}):x);return{top:(b.top-k.top+p.top)/v.y,bottom:(k.bottom-b.bottom+p.bottom)/v.y,left:(b.left-k.left+p.left)/v.x,right:(k.right-b.right+p.right)/v.x}}const mP=50,gP=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:pP},a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=ug(c,r,a),f=r,h=0;const p={};for(let g=0;g<i.length;g++){const y=i[g];if(!y)continue;const{name:b,fn:x}=y,{x:w,y:v,data:k,reset:C}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});u=w??u,d=v??d,p[b]={...p[b],...k},C&&h<mP&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):C.rects),{x:u,y:d}=ug(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},yP=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=Hn(t,e)||{};if(c==null)return{};const d=ih(u),f={x:n,y:r},h=sh(s),p=rh(h),g=await o.getDimensions(c),y=h==="y",b=y?"top":"left",x=y?"bottom":"right",w=y?"clientHeight":"clientWidth",v=i.reference[p]+i.reference[h]-f[h]-i.floating[p],k=f[h]-i.reference[h],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let E=C?C[w]:0;(!E||!await(o.isElement==null?void 0:o.isElement(C)))&&(E=l.floating[w]||i.floating[p]);const O=v/2-k/2,_=E/2-g[p]/2-1,T=bn(d[b],_),D=bn(d[x],_),I=T,P=E-g[p]-D,N=E/2-g[p]/2+O,R=Nd(I,N,P),j=!a.arrow&&Xt(s)!=null&&N!==R&&i.reference[p]/2-(N<I?T:D)-g[p]/2<0,F=j?N<I?N-I:N-P:0;return{[h]:f[h]+F,data:{[h]:R,centerOffset:N-R-F,...j&&{alignmentOffset:F}},reset:j}}});function bP(t,e,n){return(t?[...n.filter(s=>Xt(s)===t),...n.filter(s=>Xt(s)!==t)]:n.filter(s=>Ut(s)===s)).filter(s=>t?Xt(s)===t||(e?ba(s)!==s:!1):!0)}const wP=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=lg,autoAlignment:h=!0,...p}=Hn(t,e),g=d!==void 0||f===lg?bP(d||null,h,f):f,y=await a.detectOverflow(e,p),b=((n=o.autoPlacement)==null?void 0:n.index)||0,x=g[b];if(x==null)return{};const w=Gx(x,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==x)return{reset:{placement:g[0]}};const v=[y[Ut(x)],y[w[0]],y[w[1]]],k=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:x,overflows:v}],C=g[b+1];if(C)return{data:{index:b+1,overflows:k},reset:{placement:C}};const E=k.map(T=>{const D=Xt(T.placement);return[T.placement,D&&u?T.overflows.slice(0,2).reduce((I,P)=>I+P,0):T.overflows[0],T.overflows]}).sort((T,D)=>T[1]-D[1]),_=((s=E.filter(T=>T[2].slice(0,Xt(T[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||E[0][0];return _!==l?{data:{index:b+1,overflows:k},reset:{placement:_}}:{}}}},xP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=Hn(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Ut(s),x=dn(l),w=Ut(l)===l,v=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=f||(w||!g?[wa(l)]:aP(l)),C=p!=="none";!f&&C&&k.push(...fP(l,g,p,v));const E=[l,...k],O=await a.detectOverflow(e,y),_=[];let T=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&_.push(O[b]),d){const N=Gx(s,o,v);_.push(O[N[0]],O[N[1]])}if(T=[...T,{placement:s,overflows:_}],!_.every(N=>N<=0)){var D,I;const N=(((D=i.flip)==null?void 0:D.index)||0)+1,R=E[N];if(R&&(!(d==="alignment"?x!==dn(R):!1)||T.every($=>dn($.placement)===x?$.overflows[0]>0:!0)))return{data:{index:N,overflows:T},reset:{placement:R}};let j=(I=T.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:I.placement;if(!j)switch(h){case"bestFit":{var P;const F=(P=T.filter($=>{if(C){const V=dn($.placement);return V===x||V==="y"}return!0}).map($=>[$.placement,$.overflows.filter(V=>V>0).reduce((V,fe)=>V+fe,0)]).sort(($,V)=>$[1]-V[1])[0])==null?void 0:P[0];F&&(j=F);break}case"initialPlacement":j=l;break}if(s!==j)return{reset:{placement:j}}}return{}}}};function dg(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function fg(t){return Kx.some(e=>t[e]>=0)}const vP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=Hn(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=dg(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:fg(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),l=dg(o,n.floating);return{data:{escapedOffsets:l,escaped:fg(l)}}}default:return{}}}}};function Yx(t){const e=bn(...t.map(i=>i.left)),n=bn(...t.map(i=>i.top)),r=ht(...t.map(i=>i.right)),s=ht(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function kP(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>Os(Yx(s)))}const SP=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:o}=e,{padding:l=2,x:a,y:c}=Hn(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),d=kP(u),f=Os(Yx(u)),h=ih(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-h.left&&a<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom)||f;if(d.length>=2){if(dn(n)==="y"){const T=d[0],D=d[d.length-1],I=Ut(n)==="top",P=T.top,N=D.bottom,R=I?T.left:D.left,j=I?T.right:D.right,F=j-R,$=N-P;return{top:P,bottom:N,left:R,right:j,width:F,height:$,x:R,y:P}}const y=Ut(n)==="left",b=ht(...d.map(T=>T.right)),x=bn(...d.map(T=>T.left)),w=d.filter(T=>y?T.left===x:T.right===b),v=w[0].top,k=w[w.length-1].bottom,C=x,E=b,O=E-C,_=k-v;return{top:v,bottom:k,left:C,right:E,width:O,height:_,x:C,y:v}}return f}const g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return s.reference.x!==g.reference.x||s.reference.y!==g.reference.y||s.reference.width!==g.reference.width||s.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},CP=new Set(["left","top"]);async function EP(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Ut(n),l=Xt(n),a=dn(n)==="y",c=CP.has(o)?-1:1,u=i&&a?-1:1,d=Hn(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const TP=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await EP(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},MP=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:b=>{let{x,y:w}=b;return{x,y:w}}},...c}=Hn(t,e),u={x:n,y:r},d=await i.detectOverflow(e,c),f=dn(Ut(s)),h=Jx(f);let p=u[h],g=u[f];if(o){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=p+d[b],v=p-d[x];p=Nd(w,p,v)}if(l){const b=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=g+d[b],v=g-d[x];g=Nd(w,g,v)}const y=a.fn({...e,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:o,[f]:l}}}}}},AP=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=Hn(t,e),u=await o.detectOverflow(e,c),d=Ut(s),f=Xt(s),h=dn(s)==="y",{width:p,height:g}=i.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,w=p-u.left-u.right,v=bn(g-u[y],x),k=bn(p-u[b],w),C=!e.middlewareData.shift;let E=v,O=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=w),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(E=x),C&&!f){const T=ht(u.left,0),D=ht(u.right,0),I=ht(u.top,0),P=ht(u.bottom,0);h?O=p-2*(T!==0||D!==0?T+D:ht(u.left,u.right)):E=g-2*(I!==0||P!==0?I+P:ht(u.top,u.bottom))}await a({...e,availableWidth:O,availableHeight:E});const _=await o.getDimensions(l.floating);return p!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function Us(t){return Xx(t)?(t.nodeName||"").toLowerCase():"#document"}function Nt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Fn(t){var e;return(e=(Xx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xx(t){return rc()?t instanceof Node||t instanceof Nt(t).Node:!1}function Zt(t){return rc()?t instanceof Element||t instanceof Nt(t).Element:!1}function Vn(t){return rc()?t instanceof HTMLElement||t instanceof Nt(t).HTMLElement:!1}function hg(t){return!rc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Nt(t).ShadowRoot}function ko(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=en(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function _P(t){return/^(table|td|th)$/.test(Us(t))}function sc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const NP=/transform|translate|scale|rotate|perspective|filter/,OP=/paint|layout|strict|content/,Cr=t=>!!t&&t!=="none";let cu;function oh(t){const e=Zt(t)?en(t):t;return Cr(e.transform)||Cr(e.translate)||Cr(e.scale)||Cr(e.rotate)||Cr(e.perspective)||!lh()&&(Cr(e.backdropFilter)||Cr(e.filter))||NP.test(e.willChange||"")||OP.test(e.contain||"")}function IP(t){let e=hr(t);for(;Vn(e)&&!Is(e);){if(oh(e))return e;if(sc(e))return null;e=hr(e)}return null}function lh(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Is(t){return/^(html|body|#document)$/.test(Us(t))}function en(t){return Nt(t).getComputedStyle(t)}function ic(t){return Zt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function hr(t){if(Us(t)==="html")return t;const e=t.assignedSlot||t.parentNode||hg(t)&&t.host||Fn(t);return hg(e)?e.host:e}function Qx(t){const e=hr(t);return Is(e)?t.ownerDocument?t.ownerDocument.body:t.body:Vn(e)&&ko(e)?e:Qx(e)}function Zx(t,e,n){var r;e===void 0&&(e=[]);const s=Qx(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Nt(s);return i?(Od(o),e.concat(o,o.visualViewport||[],ko(s)?s:[],[])):e.concat(s,Zx(s,[]))}function Od(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ev(t){const e=en(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Vn(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=ya(n)!==i||ya(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function tv(t){return Zt(t)?t:t.contextElement}function gs(t){const e=tv(t);if(!Vn(e))return pn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=ev(e);let o=(i?ya(n.width):n.width)/r,l=(i?ya(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const RP=pn(0);function nv(t){const e=Nt(t);return!lh()||!e.visualViewport?RP:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function DP(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Nt(t)?!1:e}function no(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=tv(t);let o=pn(1);e&&(r?Zt(r)&&(o=gs(r)):o=gs(t));const l=DP(i,n,r)?nv(i):pn(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const f=Nt(i),h=r&&Zt(r)?Nt(r):r;let p=f,g=Od(p);for(;g&&r&&h!==p;){const y=gs(g),b=g.getBoundingClientRect(),x=en(g),w=b.left+(g.clientLeft+parseFloat(x.paddingLeft))*y.x,v=b.top+(g.clientTop+parseFloat(x.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=w,c+=v,p=Nt(g),g=Od(p)}}return Os({width:u,height:d,x:a,y:c})}function oc(t,e){const n=ic(t).scrollLeft;return e?e.left+n:no(Fn(t)).left+n}function rv(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-oc(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function LP(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Fn(r),l=e?sc(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=pn(1);const u=pn(0),d=Vn(r);if((d||!d&&!i)&&((Us(r)!=="body"||ko(o))&&(a=ic(r)),d)){const h=no(r);c=gs(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=o&&!d&&!i?rv(o,a):pn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-a.scrollTop*c.y+u.y+f.y}}function jP(t){return Array.from(t.getClientRects())}function PP(t){const e=Fn(t),n=ic(t),r=t.ownerDocument.body,s=ht(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ht(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+oc(t);const l=-n.scrollTop;return en(r).direction==="rtl"&&(o+=ht(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const pg=25;function BP(t,e){const n=Nt(t),r=Fn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const u=lh();(!u||u&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=oc(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=pg&&(i-=p)}else c<=pg&&(i+=c);return{width:i,height:o,x:l,y:a}}function zP(t,e){const n=no(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Vn(t)?gs(t):pn(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function mg(t,e,n){let r;if(e==="viewport")r=BP(t,n);else if(e==="document")r=PP(Fn(t));else if(Zt(e))r=zP(e,n);else{const s=nv(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Os(r)}function sv(t,e){const n=hr(t);return n===e||!Zt(n)||Is(n)?!1:en(n).position==="fixed"||sv(n,e)}function $P(t,e){const n=e.get(t);if(n)return n;let r=Zx(t,[]).filter(l=>Zt(l)&&Us(l)!=="body"),s=null;const i=en(t).position==="fixed";let o=i?hr(t):t;for(;Zt(o)&&!Is(o);){const l=en(o),a=oh(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ko(o)&&!a&&sv(t,o))?r=r.filter(u=>u!==o):s=l,o=hr(o)}return e.set(t,r),r}function HP(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?sc(e)?[]:$P(e,this._c):[].concat(n),r],l=mg(e,o[0],s);let a=l.top,c=l.right,u=l.bottom,d=l.left;for(let f=1;f<o.length;f++){const h=mg(e,o[f],s);a=ht(h.top,a),c=bn(h.right,c),u=bn(h.bottom,u),d=ht(h.left,d)}return{width:c-d,height:u-a,x:d,y:a}}function FP(t){const{width:e,height:n}=ev(t);return{width:e,height:n}}function VP(t,e,n){const r=Vn(e),s=Fn(e),i=n==="fixed",o=no(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=pn(0);function c(){a.x=oc(s)}if(r||!r&&!i)if((Us(e)!=="body"||ko(s))&&(l=ic(e)),r){const h=no(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?rv(s,l):pn(0),d=o.left+l.scrollLeft-a.x-u.x,f=o.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function uu(t){return en(t).position==="static"}function gg(t,e){if(!Vn(t)||en(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Fn(t)===n&&(n=n.ownerDocument.body),n}function iv(t,e){const n=Nt(t);if(sc(t))return n;if(!Vn(t)){let s=hr(t);for(;s&&!Is(s);){if(Zt(s)&&!uu(s))return s;s=hr(s)}return n}let r=gg(t,e);for(;r&&_P(r)&&uu(r);)r=gg(r,e);return r&&Is(r)&&uu(r)&&!oh(r)?n:r||IP(t)||n}const UP=async function(t){const e=this.getOffsetParent||iv,n=this.getDimensions,r=await n(t.floating);return{reference:VP(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WP(t){return en(t).direction==="rtl"}const qP={convertOffsetParentRelativeRectToViewportRelativeRect:LP,getDocumentElement:Fn,getClippingRect:HP,getOffsetParent:iv,getElementRects:UP,getClientRects:jP,getDimensions:FP,getScale:gs,isElement:Zt,isRTL:WP},ov=TP,lv=wP,av=MP,cv=xP,uv=AP,dv=vP,fv=yP,hv=SP,ah=(t,e,n)=>{const r=new Map,s={platform:qP,...n},i={...s.platform,_c:r};return gP(t,e,{...s,platform:i})};function KP(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,l=r-n,a=s,c=n;return new DOMRect(a,c,o,l)}var JP=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:s=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:f,from:h,to:p})=>{const{doc:g,selection:y}=f,{empty:b}=y,x=!g.textBetween(h,p).length&&Ja(f.selection),w=this.element.contains(document.activeElement);return!(!(d.hasFocus()||w)||b||x||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d!=null&&d.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(d.relatedTarget))||(d==null?void 0:d.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,f)=>{const h=!(f!=null&&f.selection.eq(d.state.selection)),p=!(f!=null&&f.doc.eq(d.state.doc));!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,h,p,f)},this.updateDelay))},this.updateHandler=(d,f,h,p)=>{const{composing:g}=d;if(g||!f&&!h)return;if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:d})=>{const f=d.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"?this.updateOptions(f.options):f==="hide"?this.hide():f==="show"&&(this.updatePosition(),this.show())};var u;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(u=c==null?void 0:c.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,s=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(s)return s;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const i=d0(this.view,r.from,r.to);let o={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof Q){let l=this.view.nodeDOM(r.from);const a=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");a&&(l=a),l&&(o={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(r instanceof be){const{$anchorCell:l,$headCell:a}=r,c=l?l.pos:a.pos,u=a?a.pos:l.pos,d=this.view.nodeDOM(c),f=this.view.nodeDOM(u);if(!d||!f)return;const h=d===f?d.getBoundingClientRect():KP(d.getBoundingClientRect(),f.getBoundingClientRect());o={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&ah(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:s})=>{var i,o;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=s.hide)!=null&&i.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!(e!=null&&e.selection.eq(t.state.selection)),i=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pv=t=>new ue({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new JP({view:e,...t})});oe.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[pv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var GP=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:s=250,resizeDelay:i=60,options:o,appendTo:l,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:f}=d,{$anchor:h,empty:p}=f,g=h.depth===1,y=h.parent.isTextblock&&!h.parent.type.spec.code&&!h.parent.textContent&&h.parent.childCount===0&&!this.getTextContent(h.parent);return!(!u.hasFocus()||!p||!g||!y||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,f,h)=>{const{composing:p}=u;if(p||!d&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(c=o==null?void 0:o.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return i0(t,{textSerializers:vf(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!((e=(t=this.view)==null?void 0:t.dom)!=null&&e.parentNode))return;const{selection:n}=this.editor.state,r=d0(this.view,n.from,n.to);ah({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:l,middlewareData:a})=>{var c,u;if((c=a.hide)!=null&&c.referenceHidden||(u=a.hide)!=null&&u.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=l,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!(e!=null&&e.selection.eq(t.state.selection)),r=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},mv=t=>new ue({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new GP({view:e,...t})});oe.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[mv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function gv(t,e){return t??new ae(e)}var YP=typeof window<"u"?S.useLayoutEffect:S.useEffect,yv=new Set(["left","opacity","position","top","visibility","width"]),XP=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),QP=new Set(["children","className","style"]),ZP=new Set(["tabIndex"]),eB=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),tB={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Id(t,e){return/^on[A-Z]/.test(t)&&typeof e=="function"}function nB(t){return t.startsWith("aria-")||t.startsWith("data-"),t}function rB(t){return t.startsWith("aria-")||t.startsWith("data-")||eB.has(t)}function bv(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function sB(t){var e;const n=t.endsWith("Capture"),s=(n?t.slice(0,-7):t).slice(2);return{eventName:(e=tB[s])!=null?e:s.toLowerCase(),options:n?{capture:!0}:void 0}}function iB(t,e){let n=e.defaultPrevented,r=!1;const s=Object.create(e);return Object.defineProperties(s,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),s}function du(t){return ZP.has(t)}function yg(t,e,n){if(e==="tabIndex"){t.tabIndex=Number(n);return}t[e]=n}function oB(t,e){if(e==="tabIndex"){t.removeAttribute("tabindex");return}const n=t[e];if(typeof n=="boolean"){t[e]=!1;return}if(typeof n=="number"){t[e]=0;return}t[e]=""}function lB(t,e){return typeof e!="number"||e===0||t.startsWith("--")||XP.has(t)?String(e):`${e}px`}function aB(t,e){yv.has(e)||t.style.removeProperty(bv(e))}function cB(t,e,n){yv.has(e)||t.style.setProperty(bv(e),lB(e,n))}function uB(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(s=>{if(QP.has(s)||!rB(s)||Id(s,e[s])||Id(s,n[s]))return;const i=e[s],o=n[s];if(i===o)return;const l=nB(s);if(o==null||o===!1){du(s)&&oB(t,s),t.removeAttribute(l);return}if(o===!0){du(s)&&yg(t,s,!0),t.setAttribute(l,"");return}if(du(s)){yg(t,s,o);return}t.setAttribute(l,String(o))})}function dB(t,e,n){if(e!==n){if(n){t.className=n;return}t.removeAttribute("class")}}function fB(t,e,n){const r=e??{},s=n??{};new Set([...Object.keys(r),...Object.keys(s)]).forEach(o=>{const l=r[o],a=s[o];if(l!==a){if(a==null){aB(t,o);return}cB(t,o,a)}})}function hB(t,e,n){e.forEach(({eventName:s,listener:i,options:o})=>{t.removeEventListener(s,i,o)});const r=[];return Object.entries(n).forEach(([s,i])=>{if(!Id(s,i))return;const{eventName:o,options:l}=sB(s),a=c=>{i(iB(t,c))};t.addEventListener(o,a,l),r.push({eventName:o,listener:a,options:l})}),r}function wv(t,e){const n=S.useRef({}),r=S.useRef([]);YP(()=>{const s=n.current;return dB(t,s.className,e.className),fB(t,s.style,e.style),uB(t,s,e),r.current=hB(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:i,listener:o,options:l})=>{t.removeEventListener(i,o,l)}),r.current=[]}},[t,e])}var xv=S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,getReferencedVirtualElement:o,options:l,children:a,...c},u)=>{const d=S.useRef(document.createElement("div")),f=S.useRef(gv(t,"bubbleMenu")).current;wv(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:h}=I0(),p=e||h,g={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:f,shouldShow:i,getReferencedVirtualElement:o,options:l},y=S.useRef(g);y.current=g;const[b,x]=S.useState(!1),w=S.useRef(!0);return S.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=d.current;v.style.visibility="hidden",v.style.position="absolute";const k=pv({...y.current,editor:p,element:v});p.registerPlugin(k);const C=y.current.pluginKey;return w.current=!0,x(!0),()=>{x(!1),p.unregisterPlugin(C),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[p]),S.useEffect(()=>{if(!(!b||!p||p.isDestroyed)){if(w.current){w.current=!1;return}p.view.dispatch(p.state.tr.setMeta(f,{type:"updateOptions",options:y.current}))}},[b,p,n,r,i,l,s,o,f]),zs.createPortal(a,d.current)});S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,options:o,children:l,...a},c)=>{const u=S.useRef(document.createElement("div")),d=S.useRef(gv(t,"floatingMenu")).current;wv(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:f}=I0(),h=e||f,p={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:d,shouldShow:i,options:o},g=S.useRef(p);g.current=p;const[y,b]=S.useState(!1),x=S.useRef(!0);return S.useEffect(()=>{if(h!=null&&h.isDestroyed)return;if(!h){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const w=u.current;w.style.visibility="hidden",w.style.position="absolute";const v=mv({...g.current,editor:h,element:w});h.registerPlugin(v);const k=g.current.pluginKey;return x.current=!0,b(!0),()=>{b(!1),h.unregisterPlugin(k),window.requestAnimationFrame(()=>{w.parentNode&&w.parentNode.removeChild(w)})}},[h]),S.useEffect(()=>{if(!(!y||!h||h.isDestroyed)){if(x.current){x.current=!1;return}h.view.dispatch(h.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[y,h,n,r,i,o,s,d]),zs.createPortal(l,u.current)});const pB="_menu_1hbgh_2",mB="_row_1hbgh_9",gB="_linkRow_1hbgh_10",yB="_button_1hbgh_19",bB="_active_1hbgh_37",wB="_divider_1hbgh_53",xB="_styleTrigger_1hbgh_61",vB="_panelWrap_1hbgh_89",kB="_dropdown_1hbgh_94",SB="_colorPanel_1hbgh_102",CB="_colorTabs_1hbgh_109",EB="_colorTab_1hbgh_109",TB="_colorTabActive_1hbgh_136",MB="_linkInput_1hbgh_152",ee={menu:pB,row:mB,linkRow:gB,button:yB,active:bB,divider:wB,styleTrigger:xB,panelWrap:vB,dropdown:kB,colorPanel:SB,colorTabs:CB,colorTab:EB,colorTabActive:TB,linkInput:MB};function ch(t){return t.state.selection instanceof be}function vv({editor:t}){const e=vo({editor:t,selector:({editor:n})=>({headerRow:n.isActive("tableHeader"),canMerge:n.can().mergeCells(),canSplit:n.can().splitCell()})});return m.jsx(xv,{editor:t,pluginKey:"blockEditorTableMenu",options:{placement:"top",offset:8},shouldShow:({editor:n,state:r,from:s,to:i})=>!n.isEditable||!n.isActive("table")||r.selection instanceof Q?!1:s===i||ch(n),className:ee.menu,children:m.jsxs("div",{className:ee.row,children:[m.jsx(A.Tooltip,{content:"Insert column before",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addColumnBefore().run(),"aria-label":"Insert column before",children:m.jsx(ZR,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert column after",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addColumnAfter().run(),"aria-label":"Insert column after",children:m.jsx(QR,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete column",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteColumn().run(),"aria-label":"Delete column",children:m.jsx(KR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Insert row above",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addRowBefore().run(),"aria-label":"Insert row above",children:m.jsx(XR,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert row below",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().addRowAfter().run(),"aria-label":"Insert row below",children:m.jsx(eD,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete row",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteRow().run(),"aria-label":"Delete row",children:m.jsx(OR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Toggle header row",children:m.jsx("button",{type:"button",className:[ee.button,e.headerRow&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleHeaderRow().run(),"aria-label":"Toggle header row",children:m.jsx(RR,{size:15})})}),e.canSplit?m.jsx(A.Tooltip,{content:"Split cell",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().splitCell().run(),"aria-label":"Split cell",children:m.jsx(MR,{size:15})})}):m.jsx(A.Tooltip,{content:"Merge cells",children:m.jsx("button",{type:"button",className:ee.button,disabled:!e.canMerge,onClick:()=>t.chain().focus().mergeCells().run(),"aria-label":"Merge cells",children:m.jsx(AR,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Delete table",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().deleteTable().run(),"aria-label":"Delete table",children:m.jsx(Et,{size:15})})})]})})}const bg=[1,2,3,4,5,6],AB={1:Md,2:Ad,3:Sd,4:Cd,5:Ed,6:Td};function _B(t){const e=t.trim();return e?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(e)?e:`https://${e}`:""}function kv({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState(""),[i,o]=S.useState(!1),[l,a]=S.useState("text"),[c,u]=S.useState(!1),d=S.useRef(null),f=S.useRef(null),h=vo({editor:t,selector:({editor:v})=>({bold:v.isActive("bold"),italic:v.isActive("italic"),underline:v.isActive("underline"),strike:v.isActive("strike"),code:v.isActive("code"),blockquote:v.isActive("blockquote"),bulletList:v.isActive("bulletList"),orderedList:v.isActive("orderedList"),link:v.isActive("link"),headingLevel:bg.find(k=>v.isActive("heading",{level:k}))??null,textColor:v.getAttributes("textStyle").color??"",highlightColor:v.getAttributes("highlight").color??""})});S.useEffect(()=>{var v;e&&((v=d.current)==null||v.focus())},[e]),S.useEffect(()=>{function v(){n(!1),o(!1),u(!1)}return t.on("selectionUpdate",v),()=>{t.off("selectionUpdate",v)}},[t]);function p(){const{from:v,to:k}=t.state.selection;f.current={from:v,to:k}}function g(){const v=t.chain().focus(),k=f.current;return k&&k.from!==k.to?v.setTextSelection(k):v}function y(v){l==="text"?g().setColor(v).run():g().setHighlight({color:v}).run()}function b(){s(t.getAttributes("link").href??""),n(!0)}function x(){const v=_B(r);v?t.chain().focus().extendMarkRange("link").setLink({href:v}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n(!1)}const w=h.headingLevel?`H${h.headingLevel}`:h.blockquote?"Quote":"Text";return m.jsx(xv,{editor:t,options:{placement:"top",offset:8},shouldShow:({editor:v,state:k,from:C,to:E})=>!v.isEditable||C===E||k.selection instanceof Q||ch(v)||v.isActive("codeBlock")?!1:k.doc.textBetween(C,E," "," ").trim().length>0,className:ee.menu,children:e?m.jsxs("div",{className:ee.linkRow,children:[m.jsx("input",{ref:d,type:"text",className:ee.linkInput,value:r,placeholder:"Paste or type a link",onChange:v=>s(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),x()),v.key==="Escape"&&(v.preventDefault(),n(!1))}}),m.jsx("button",{type:"button",className:ee.button,onClick:x,"aria-label":"Apply link",children:m.jsx(YR,{size:15})})]}):m.jsxs("div",{className:ee.row,children:[m.jsxs("div",{className:ee.panelWrap,children:[m.jsxs("button",{type:"button",className:[ee.styleTrigger,c&&ee.active].filter(Boolean).join(" "),onMouseDown:v=>{v.preventDefault(),c||p(),u(k=>!k)},"aria-label":"Text style",children:[m.jsx("span",{children:w}),m.jsx(wl,{size:12})]}),c&&m.jsx("div",{className:ee.dropdown,onMouseDown:v=>v.preventDefault(),children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Text",leftIcon:m.jsx(bd,{size:16}),checked:!h.headingLevel&&!h.blockquote,onClick:()=>{g().setParagraph().run(),u(!1)}}),bg.map(v=>{const k=AB[v];return m.jsx(A.MenuItemRadio,{label:`Heading ${v}`,leftIcon:m.jsx(k,{size:16}),checked:h.headingLevel===v,onClick:()=>{g().toggleHeading({level:v}).run(),u(!1)}},v)}),m.jsx(A.MenuItemRadio,{label:"Quote",leftIcon:m.jsx(t1,{size:16}),checked:h.blockquote,onClick:()=>{g().toggleBlockquote().run(),u(!1)}})]})})]}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Bold",children:m.jsx("button",{type:"button",className:[ee.button,h.bold&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBold().run(),"aria-label":"Bold",children:m.jsx(_d,{size:15})})}),m.jsx(A.Tooltip,{content:"Italic",children:m.jsx("button",{type:"button",className:[ee.button,h.italic&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleItalic().run(),"aria-label":"Italic",children:m.jsx(vd,{size:15})})}),m.jsx(A.Tooltip,{content:"Underline",children:m.jsx("button",{type:"button",className:[ee.button,h.underline&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleUnderline().run(),"aria-label":"Underline",children:m.jsx(Yw,{size:15})})}),m.jsx(A.Tooltip,{content:"Strikethrough",children:m.jsx("button",{type:"button",className:[ee.button,h.strike&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleStrike().run(),"aria-label":"Strikethrough",children:m.jsx(u1,{size:15})})}),m.jsx(A.Tooltip,{content:"Inline code",children:m.jsx("button",{type:"button",className:[ee.button,h.code&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleCode().run(),"aria-label":"Inline code",children:m.jsx(nc,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:"Bulleted list",children:m.jsx("button",{type:"button",className:[ee.button,h.bulletList&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBulletList().run(),"aria-label":"Bulleted list",children:m.jsx(ga,{size:15})})}),m.jsx(A.Tooltip,{content:"Numbered list",children:m.jsx("button",{type:"button",className:[ee.button,h.orderedList&&ee.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleOrderedList().run(),"aria-label":"Numbered list",children:m.jsx(N1,{size:15})})}),m.jsx("span",{className:ee.divider}),m.jsxs("div",{className:ee.panelWrap,children:[m.jsx("button",{type:"button",className:[ee.button,i&&ee.active].filter(Boolean).join(" "),onMouseDown:v=>{v.preventDefault(),i||p(),o(k=>!k)},"aria-label":"Colour",children:m.jsx(k1,{size:15})}),i&&m.jsx("div",{className:ee.dropdown,onMouseDown:v=>v.preventDefault(),children:m.jsxs("div",{className:ee.colorPanel,children:[m.jsxs("div",{className:ee.colorTabs,children:[m.jsx("button",{type:"button",className:[ee.colorTab,l==="text"&&ee.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("text"),children:"Text"}),m.jsx("button",{type:"button",className:[ee.colorTab,l==="bg"&&ee.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("bg"),children:"Background"})]}),m.jsx(A.ColorPicker,{alwaysOpen:!0,value:l==="text"?h.textColor:h.highlightColor,onChange:y})]})})]}),m.jsx("span",{className:ee.divider}),m.jsx(A.Tooltip,{content:h.link?"Edit link":"Add link",children:m.jsx("button",{type:"button",className:[ee.button,h.link&&ee.active].filter(Boolean).join(" "),onClick:b,"aria-label":h.link?"Edit link":"Add link",children:m.jsx(xd,{size:15})})}),h.link&&m.jsx(A.Tooltip,{content:"Remove link",children:m.jsx("button",{type:"button",className:ee.button,onClick:()=>t.chain().focus().extendMarkRange("link").unsetLink().run(),"aria-label":"Remove link",children:m.jsx(vR,{size:15})})})]})})}const Qt=()=>new Map,Rd=t=>{const e=Qt();return t.forEach((n,r)=>{e.set(r,n)}),e},Un=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},NB=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},OB=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},qr=()=>new Set,fu=t=>t[t.length-1],IB=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Kr=Array.from,uh=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},dh=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},RB=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Rs=Array.isArray;class Sv{constructor(){this._observers=Qt()}on(e,n){return Un(this._observers,e,qr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Kr((this._observers.get(e)||Qt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Qt()}}const tn=Math.floor,xl=Math.abs,Jr=(t,e)=>t<e?t:e,pr=(t,e)=>t>e?t:e,Cv=t=>t!==0?t<0:1/t<0,wg=1,xg=2,hu=4,pu=8,ro=32,jn=64,gt=128,DB=1<<29,lc=31,Dd=63,Pr=127,LB=2147483647,xa=Number.MAX_SAFE_INTEGER,vg=Number.MIN_SAFE_INTEGER,jB=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&tn(t)===t),Ev=String.fromCharCode,PB=t=>t.toLowerCase(),BB=/^\s*/g,zB=t=>t.replace(BB,""),$B=/([A-Z])/g,kg=(t,e)=>zB(t.replace($B,n=>`${e}${PB(n)}`)),HB=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},so=typeof TextEncoder<"u"?new TextEncoder:null,FB=t=>so.encode(t),VB=so?FB:HB;let zi=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zi&&zi.decode(new Uint8Array).length===1&&(zi=null);const UB=(t,e)=>RB(e,()=>t).join("");class So{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Co=()=>new So,WB=t=>{const e=Co();return t(e),Yt(e)},qB=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Yt=t=>{const e=new Uint8Array(qB(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},KB=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(pr(n,e)*2),t.cpos=0)},Ue=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Ld=Ue,de=(t,e)=>{for(;e>Pr;)Ue(t,gt|Pr&e),e=tn(e/128);Ue(t,Pr&e)},fh=(t,e)=>{const n=Cv(e);for(n&&(e=-e),Ue(t,(e>Dd?gt:0)|(n?jn:0)|Dd&e),e=tn(e/64);e>0;)Ue(t,(e>Pr?gt:0)|Pr&e),e=tn(e/128)},jd=new Uint8Array(3e4),JB=jd.length/3,GB=(t,e)=>{if(e.length<JB){const n=so.encodeInto(e,jd).written||0;de(t,n);for(let r=0;r<n;r++)Ue(t,jd[r])}else At(t,VB(e))},YB=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;de(t,r);for(let s=0;s<r;s++)Ue(t,n.codePointAt(s))},ys=so&&so.encodeInto?GB:YB,ac=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Jr(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(pr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},At=(t,e)=>{de(t,e.byteLength),ac(t,e)},hh=(t,e)=>{KB(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},XB=(t,e)=>hh(t,4).setFloat32(0,e,!1),QB=(t,e)=>hh(t,8).setFloat64(0,e,!1),ZB=(t,e)=>hh(t,8).setBigInt64(0,e,!1),Sg=new DataView(new ArrayBuffer(4)),ez=t=>(Sg.setFloat32(0,t),Sg.getFloat32(0)===t),Ds=(t,e)=>{switch(typeof e){case"string":Ue(t,119),ys(t,e);break;case"number":jB(e)&&xl(e)<=LB?(Ue(t,125),fh(t,e)):ez(e)?(Ue(t,124),XB(t,e)):(Ue(t,123),QB(t,e));break;case"bigint":Ue(t,122),ZB(t,e);break;case"object":if(e===null)Ue(t,126);else if(Rs(e)){Ue(t,117),de(t,e.length);for(let n=0;n<e.length;n++)Ds(t,e[n])}else if(e instanceof Uint8Array)Ue(t,116),At(t,e);else{Ue(t,118);const n=Object.keys(e);de(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ys(t,s),Ds(t,e[s])}}break;case"boolean":Ue(t,e?120:121);break;default:Ue(t,127)}};class Cg extends So{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&de(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Eg=t=>{t.count>0&&(fh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&de(t.encoder,t.count-2))};class vl{constructor(){this.encoder=new So,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Eg(this),this.count=1,this.s=e)}toUint8Array(){return Eg(this),Yt(this.encoder)}}const Tg=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);fh(t.encoder,e),t.count>1&&de(t.encoder,t.count-2)}};class mu{constructor(){this.encoder=new So,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Tg(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Tg(this),Yt(this.encoder)}}class tz{constructor(){this.sarr=[],this.s="",this.lensE=new vl}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new So;return this.sarr.push(this.s),this.s="",ys(e,this.sarr.join("")),ac(e,this.lensE.toUint8Array()),Yt(e)}}const wn=t=>new Error(t),Ht=()=>{throw wn("Method unimplemented")},wt=()=>{throw wn("Unexpected case")},Tv=wn("Unexpected end of array"),Mv=wn("Integer out of Range");class cc{constructor(e){this.arr=e,this.pos=0}}const ph=t=>new cc(t),nz=t=>t.pos!==t.arr.length,rz=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Lt=t=>rz(t,Ee(t)),io=t=>t.arr[t.pos++],Ee=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Pr)*n,n*=128,s<gt)return e;if(e>xa)throw Mv}throw Tv},mh=t=>{let e=t.arr[t.pos++],n=e&Dd,r=64;const s=(e&jn)>0?-1:1;if(!(e>))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Pr)*r,r*=128,e<gt)return s*n;if(n>xa)throw Mv}throw Tv},sz=t=>{let e=Ee(t);if(e===0)return"";{let n=String.fromCodePoint(io(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(io(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},iz=t=>zi.decode(Lt(t)),Pd=zi?iz:sz,gh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},oz=t=>gh(t,4).getFloat32(0,!1),lz=t=>gh(t,8).getFloat64(0,!1),az=t=>gh(t,8).getBigInt64(0,!1),cz=[t=>{},t=>null,mh,oz,lz,az,t=>!1,t=>!0,Pd,t=>{const e=Ee(t),n={};for(let r=0;r<e;r++){const s=Pd(t);n[s]=va(t)}return n},t=>{const e=Ee(t),n=[];for(let r=0;r<e;r++)n.push(va(t));return n},Lt],va=t=>cz[127-io(t)](t);class Mg extends cc{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),nz(this)?this.count=Ee(this)+1:this.count=-1),this.count--,this.s}}class kl extends cc{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=mh(this);const e=Cv(this.s);this.count=1,e&&(this.s=-this.s,this.count=Ee(this)+2)}return this.count--,this.s}}class gu extends cc{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=mh(this),n=e&1;this.diff=tn(e/2),this.count=1,n&&(this.count=Ee(this)+2)}return this.s+=this.diff,this.count--,this.s}}class uz{constructor(e){this.decoder=new kl(e),this.str=Pd(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const dz=crypto.getRandomValues.bind(crypto),fz=Math.random,Av=()=>dz(new Uint32Array(1))[0],hz=t=>t[tn(fz()*t.length)],pz="10000000-1000-4000-8000"+-1e11,mz=()=>pz.replace(/[018]/g,t=>(t^Av()&15>>t/4).toString(16)),gz=Date.now,Ag=t=>new Promise(t);Promise.all.bind(Promise);const _g=t=>t===void 0?null:t;class yz{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let _v=new yz,bz=!0;try{typeof localStorage<"u"&&localStorage&&(_v=localStorage,bz=!1)}catch{}const wz=_v,oo=Symbol("Equality"),Nv=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[oo])!=null&&n.call(t,e))||!1},xz=t=>typeof t=="object",vz=Object.assign,Ov=Object.keys,kz=(t,e)=>{for(const n in t)e(t[n],n)},ka=t=>Ov(t).length,Sz=t=>{for(const e in t)return!1;return!0},Ws=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},yh=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Cz=(t,e)=>t===e||ka(t)===ka(e)&&Ws(t,(n,r)=>(n!==void 0||yh(e,r))&&Nv(e[r],n)),Ez=Object.freeze,Iv=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Iv(t[e])}return Ez(t)},bh=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&bh(t,e,n+1)}},Sl=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[oo]!=null)return t[oo](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Sl(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ka(t)!==ka(e))return!1;for(const n in t)if(!yh(t,n)||!Sl(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Sl(t[n],e[n]))return!1;break;default:return!1}return!0},Tz=(t,e)=>e.includes(t),Ls=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Rv=typeof window<"u"&&typeof document<"u"&&!Ls;let an;const Mz=()=>{if(an===void 0)if(Ls){an=Qt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&an.set(e,""),e=r):e!==null&&(an.set(e,r),e=null)}e!==null&&an.set(e,"")}else typeof location=="object"?(an=Qt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");an.set(`--${kg(e,"-")}`,n),an.set(`-${kg(e,"-")}`,n)}})):an=Qt();return an},Bd=t=>Mz().has(t),Sa=t=>_g(Ls?process.env[t.toUpperCase().replaceAll("-","_")]:wz.getItem(t)),Dv=t=>Bd("--"+t)||Sa(t)!==null,Az=Dv("production"),_z=Ls&&Tz(process.env.FORCE_COLOR,["true","1","2"]),Nz=_z||!Bd("--no-colors")&&!Dv("no-color")&&(!Ls||process.stdout.isTTY)&&(!Ls||Bd("--color")||Sa("COLORTERM")!==null||(Sa("TERM")||"").includes("color")),Oz=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Ev(t[n]);return btoa(e)},Iz=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Rz=Rv?Oz:Iz,Dz=t=>WB(e=>Ds(e,t));class Lz{constructor(e,n){this.left=e,this.right=n}}const Mn=(t,e)=>new Lz(t,e),Ng=t=>t.next()>=.5,yu=(t,e,n)=>tn(t.next()*(n+1-e)+e),Lv=(t,e,n)=>tn(t.next()*(n+1-e)+e),wh=(t,e,n)=>Lv(t,e,n),jz=t=>Ev(wh(t,97,122)),Pz=(t,e=0,n=20)=>{const r=wh(t,e,n);let s="";for(let i=0;i<r;i++)s+=jz(t);return s},bu=(t,e)=>e[wh(t,0,e.length-1)],Bz=Symbol("0schema");class zz{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(UB(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
383
383
|
`)}}const zd=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[oo]?Nv(t,e):Rs(t)?uh(t,n=>dh(e,r=>zd(n,r))):xz(t)?Ws(t,(n,r)=>zd(n,e[r])):!1;class ut{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),zd(n,r)}equals(e){return this.constructor===e.constructor&&Sl(this.shape,e.shape)}[Bz](){return!0}[oo](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Ht()}get nullable(){return qs(this,pc)}get optional(){return new Bv(this)}cast(e){return Og(e,this),e}expect(e){return Og(e,this),e}}_o(ut,"_dilutes",!1);class xh extends ut{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const Be=(t,e=null)=>new xh(t,e);Be(xh);class vh extends ut{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const Ge=t=>new vh(t);Be(vh);class uc extends ut{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(s=>s===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const dc=(...t)=>new uc(t),jv=Be(uc),$z=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Pv=t=>{if(js.check(t))return[$z(t)];if(jv.check(t))return t.shape.map(e=>e+"");if(Kv.check(t))return["[+-]?\\d+.?\\d*"];if(Jv.check(t))return[".*"];if(Ea.check(t))return t.shape.map(Pv).flat(1);wt()};class Hz extends ut{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Pv).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}Be(Hz);const Fz=Symbol("optional");class Bv extends ut{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[Fz](){return!0}}const Vz=Be(Bv);class Uz extends ut{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}Be(Uz);const za=class za extends ut{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new za(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):Ws(this.shape,(r,s)=>{const i=this._isPartial&&!yh(e,s)||r.check(e[s],n);return!i&&(n==null||n.extend(s.toString(),r.toString(),typeof e[s],"Object property does not match")),i})}};_o(za,"_dilutes",!0);let Ca=za;const Wz=t=>new Ca(t),qz=Be(Ca),Kz=Ge(t=>t!=null&&(t.constructor===Object||t.constructor==null));class zv extends ut{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ws(e,(r,s)=>{const i=this.shape.keys.check(s,n);return!i&&(n==null||n.extend(s+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value")),i&&this.shape.values.check(r,n)})}}const $v=(t,e)=>new zv(t,e),Jz=Be(zv);class Hv extends ut{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ws(this.shape,(r,s)=>{const i=r.check(e[s],n);return!i&&(n==null||n.extend(s.toString(),"Tuple",typeof r)),i})}}const Gz=(...t)=>new Hv(t);Be(Hv);class Fv extends ut{constructor(e){super(),this.shape=e.length===1?e[0]:new fc(e)}check(e,n){const r=Rs(e)&&uh(e,s=>this.shape.check(s));return!r&&(n==null||n.extend(null,"Array","")),r}}const Vv=(...t)=>new Fv(t),Yz=Be(Fv),Xz=Ge(t=>Rs(t));class Uv extends ut{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const Qz=(t,e=null)=>new Uv(t,e);Be(Uv);const Zz=Qz(ut);class e$ extends ut{constructor(e){super(),this.len=e.length-1,this.args=Gz(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const t$=Be(e$),n$=Ge(t=>typeof t=="function");class r$ extends ut{constructor(e){super(),this.shape=e}check(e,n){const r=uh(this.shape,s=>s.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}Be(r$,t=>t.shape.length>0);class fc extends ut{constructor(e){super(),this.shape=e}check(e,n){const r=dh(this.shape,s=>s.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}_o(fc,"_dilutes",!0);const qs=(...t)=>t.findIndex(e=>Ea.check(e))>=0?qs(...t.map(e=>lo(e)).map(e=>Ea.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new fc(t),Ea=Be(fc),Wv=()=>!0,Ta=Ge(Wv),s$=Be(vh,t=>t.shape===Wv),kh=Ge(t=>typeof t=="bigint"),i$=Ge(t=>t===kh),qv=Ge(t=>typeof t=="symbol");Ge(t=>t===qv);const bs=Ge(t=>typeof t=="number"),Kv=Ge(t=>t===bs),js=Ge(t=>typeof t=="string"),Jv=Ge(t=>t===js),hc=Ge(t=>typeof t=="boolean"),o$=Ge(t=>t===hc),Gv=dc(void 0);Be(uc,t=>t.shape.length===1&&t.shape[0]===void 0);dc(void 0);const pc=dc(null),l$=Be(uc,t=>t.shape.length===1&&t.shape[0]===null);Be(Uint8Array);Be(xh,t=>t.shape===Uint8Array);const a$=qs(bs,js,pc,Gv,kh,hc,qv);(()=>{const t=Vv(Ta),e=$v(js,Ta),n=qs(bs,js,pc,hc,t,e);return t.shape=n,e.shape.values=n,n})();const lo=t=>{if(Zz.check(t))return t;if(Kz.check(t)){const e={};for(const n in t)e[n]=lo(t[n]);return Wz(e)}else{if(Xz.check(t))return qs(...t.map(lo));if(a$.check(t))return dc(t);if(n$.check(t))return Be(t)}wt()},Og=Az?()=>{}:(t,e)=>{const n=new zz;if(!e.check(t,n))throw wn(`Expected value to be of type ${e.constructor.name}.
|
|
384
384
|
${n.toString()}`)};class c${constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:lo(e),h:n}),this}else(e){return this.if(Ta,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw wn("Unhandled pattern")}}}const u$=t=>new c$(t),Yv=u$(Ta).if(Kv,(t,e)=>yu(e,vg,xa)).if(Jv,(t,e)=>Pz(e)).if(o$,(t,e)=>Ng(e)).if(i$,(t,e)=>BigInt(yu(e,vg,xa))).if(Ea,(t,e)=>ss(e,bu(e,t.shape))).if(qz,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(Vz.check(s)){if(Ng(e))continue;s=s.shape}n[r]=Yv(s,e)}return n}).if(Yz,(t,e)=>{const n=[],r=Lv(e,0,42);for(let s=0;s<r;s++)n.push(ss(e,t.shape));return n}).if(jv,(t,e)=>bu(e,t.shape)).if(l$,(t,e)=>null).if(t$,(t,e)=>{const n=ss(e,t.res);return()=>n}).if(s$,(t,e)=>ss(e,bu(e,[bs,js,pc,Gv,kh,hc,Vv(bs),$v(qs("a","b","c"),bs)]))).if(Jz,(t,e)=>{const n={},r=yu(e,0,3);for(let s=0;s<r;s++){const i=ss(e,t.shape.keys),o=ss(e,t.shape.values);n[i]=o}return n}).done(),ss=(t,e)=>Yv(lo(e),t),Eo=typeof document<"u"?document:{};Ge(t=>t.nodeType===m$);typeof DOMParser<"u"&&new DOMParser;Ge(t=>t.nodeType===f$);Ge(t=>t.nodeType===h$);const d$=t=>NB(t,(e,n)=>`${n}:${e};`).join(""),f$=Eo.ELEMENT_NODE,h$=Eo.TEXT_NODE,p$=Eo.DOCUMENT_NODE,m$=Eo.DOCUMENT_FRAGMENT_NODE;Ge(t=>t.nodeType===p$);const g$=t=>class{constructor(n){this._=n}destroy(){t(this._)}},y$=g$(clearTimeout),Xv=(t,e)=>new y$(setTimeout(e,t)),Wn=Symbol,Qv=Wn(),Zv=Wn(),b$=Wn(),w$=Wn(),x$=Wn(),ek=Wn(),v$=Wn(),Sh=Wn(),k$=Wn(),S$=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const i=t[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const i=t[r];i instanceof Symbol||n.push(i)}return n},C$={[Qv]:Mn("font-weight","bold"),[Zv]:Mn("font-weight","normal"),[b$]:Mn("color","blue"),[x$]:Mn("color","green"),[w$]:Mn("color","grey"),[ek]:Mn("color","red"),[v$]:Mn("color","purple"),[Sh]:Mn("color","orange"),[k$]:Mn("color","black")},E$=t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Qt();let s=[],i=0;for(;i<t.length;i++){const l=t[i],a=C$[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=d$(r);i>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const l=t[i];l instanceof Symbol||s.push(l)}return s},tk=Nz?E$:S$,T$=(...t)=>{console.log(...tk(t)),rk.forEach(e=>e.print(t))},nk=(...t)=>{console.warn(...tk(t)),t.unshift(Sh),rk.forEach(e=>e.print(t))},rk=qr(),sk=t=>({[Symbol.iterator](){return this},next:t}),M$=(t,e)=>sk(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),wu=(t,e)=>sk(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class mc{constructor(e,n){this.clock=e,this.len=n}}class Ks{constructor(){this.clients=new Map}}const mr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])hk(t,i,c.clock,c.len,n)}}),A$=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=tn((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Js=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&A$(n,e.clock)!==null},Ch=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?e[r-1]=new mc(s.clock,pr(s.len,i.clock+i.len-s.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},$d=t=>{const e=new Ks;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)IB(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return Ch(e),e},ao=(t,e,n,r)=>{Un(t.clients,e,()=>[]).push(new mc(n,r))},ik=()=>new Ks,_$=t=>{const e=ik();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new mc(l,a))}}s.length>0&&e.clients.set(r,s)}),e},Eh=(t,e)=>{de(t.restEncoder,e.clients.size),Kr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),de(t.restEncoder,n);const s=r.length;de(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},N$=t=>{const e=new Ks,n=Ee(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Ee(t.restDecoder),i=Ee(t.restDecoder);if(i>0){const o=Un(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new mc(t.readDsClock(),t.readDsLen()))}}return e},Ig=(t,e,n)=>{const r=new Ks,s=Ee(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Ee(t.restDecoder),l=Ee(t.restDecoder),a=n.clients.get(o)||[],c=Re(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&ao(r,o,c,f-c);let h=nn(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,Ra(e,p,d-p.id.clock)),h++);h<a.length&&(p=a[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&a.splice(h,0,Ra(e,p,f-p.id.clock)),p.delete(e))}else ao(r,o,d,f-d)}}if(r.clients.size>0){const i=new gc;return de(i.restEncoder,0),Eh(i,r),i.toUint8Array()}return null},ok=Av;class Zr extends Sv{constructor({guid:e=mz(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ok(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new dk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ag(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>Ag(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ve(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Kr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ve(this,e,n)}get(e,n=Je){const r=Un(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==Je&&s!==n)if(s===Je){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,vs)}getText(e=""){return this.get(e,gr)}getMap(e=""){return this.get(e,Ps)}getXmlElement(e=""){return this.get(e,tt)}getXmlFragment(e=""){return this.get(e,Gr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Kr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Zr({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ve(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class O${constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Ee(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Ee(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ma extends O${constructor(e){super(e),this.keys=[],Ee(e),this.keyClockDecoder=new gu(Lt(e)),this.clientDecoder=new kl(Lt(e)),this.leftClockDecoder=new gu(Lt(e)),this.rightClockDecoder=new gu(Lt(e)),this.infoDecoder=new Mg(Lt(e),io),this.stringDecoder=new uz(Lt(e)),this.parentInfoDecoder=new Mg(Lt(e),io),this.typeRefDecoder=new kl(Lt(e)),this.lenDecoder=new kl(Lt(e))}readLeftID(){return new ws(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ws(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return va(this.restDecoder)}readBuf(){return Lt(this.restDecoder)}readJSON(){return va(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class I${constructor(){this.restEncoder=Co()}toUint8Array(){return Yt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){de(this.restEncoder,e)}writeDsLen(e){de(this.restEncoder,e)}}class R$ extends I${writeLeftID(e){de(this.restEncoder,e.client),de(this.restEncoder,e.clock)}writeRightID(e){de(this.restEncoder,e.client),de(this.restEncoder,e.clock)}writeClient(e){de(this.restEncoder,e)}writeInfo(e){Ld(this.restEncoder,e)}writeString(e){ys(this.restEncoder,e)}writeParentInfo(e){de(this.restEncoder,e?1:0)}writeTypeRef(e){de(this.restEncoder,e)}writeLen(e){de(this.restEncoder,e)}writeAny(e){Ds(this.restEncoder,e)}writeBuf(e){At(this.restEncoder,e)}writeJSON(e){ys(this.restEncoder,JSON.stringify(e))}writeKey(e){ys(this.restEncoder,e)}}class D${constructor(){this.restEncoder=Co(),this.dsCurrVal=0}toUint8Array(){return Yt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,de(this.restEncoder,n)}writeDsLen(e){e===0&&wt(),de(this.restEncoder,e-1),this.dsCurrVal+=e}}class gc extends D${constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new mu,this.clientEncoder=new vl,this.leftClockEncoder=new mu,this.rightClockEncoder=new mu,this.infoEncoder=new Cg(Ld),this.stringEncoder=new tz,this.parentInfoEncoder=new Cg(Ld),this.typeRefEncoder=new vl,this.lenEncoder=new vl}toUint8Array(){const e=Co();return de(e,0),At(e,this.keyClockEncoder.toUint8Array()),At(e,this.clientEncoder.toUint8Array()),At(e,this.leftClockEncoder.toUint8Array()),At(e,this.rightClockEncoder.toUint8Array()),At(e,Yt(this.infoEncoder)),At(e,this.stringEncoder.toUint8Array()),At(e,Yt(this.parentInfoEncoder)),At(e,this.typeRefEncoder.toUint8Array()),At(e,this.lenEncoder.toUint8Array()),ac(e,Yt(this.restEncoder)),Yt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ds(this.restEncoder,e)}writeBuf(e){At(this.restEncoder,e)}writeJSON(e){Ds(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const L$=(t,e,n,r)=>{r=pr(r,e[0].id.clock);const s=nn(e,r);de(t.restEncoder,e.length-s),t.writeClient(n),de(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},lk=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Re(e,i)>s&&r.set(i,s)}),yc(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),de(t.restEncoder,r.size),Kr(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{L$(t,e.clients.get(s),s,i)})},j$=(t,e)=>{const n=Qt(),r=Ee(t.restDecoder);for(let s=0;s<r;s++){const i=Ee(t.restDecoder),o=new Array(i),l=t.readClient();let a=Ee(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const u=t.readInfo();switch(lc&u){case 0:{const d=t.readLen();o[c]=new Bt(se(l,a),d),a+=d;break}case 10:{const d=Ee(t.restDecoder);o[c]=new Gt(se(l,a),d),a+=d;break}default:{const d=(u&(jn|gt))===0,f=new me(se(l,a),null,(u>)===gt?t.readLeftID():null,null,(u&jn)===jn?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&ro)===ro?t.readString():null,Lk(t,u));o[c]=f,a+=f.length}}}}return n},P$=(t,e,n)=>{const r=[];let s=Kr(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const l=new dk,a=new Map,c=(h,p)=>{const g=a.get(h);(g==null||g>p)&&a.set(h,p)};let u=o.refs[o.i++];const d=new Map,f=()=>{for(const h of r){const p=h.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==Gt){const p=Un(d,u.id.client,()=>Re(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Re(e,g)),f();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const h=new gc;return lk(h,l,new Map),de(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},B$=(t,e)=>lk(t,e.doc.store,e.beforeState),z$=(t,e,n,r=new Ma(t))=>ve(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=j$(r,o),c=P$(s,l,a),u=l.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<Re(l,f)){i=!0;break}if(c){for(const[f,h]of c.missing){const p=u.missing.get(f);(p==null||p>h)&&u.missing.set(f,h)}u.update=Hg([u.update,c.update])}}else l.pendingStructs=c;const d=Ig(r,s,l);if(l.pendingDs){const f=new Ma(ph(l.pendingDs));Ee(f.restDecoder);const h=Ig(f,s,l);d&&h?l.pendingDs=Hg([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(i){const f=l.pendingStructs.update;l.pendingStructs=null,Hd(s.doc,f)}},n,!1),Hd=(t,e,n,r=Ma)=>{const s=ph(e);z$(s,t,n,new r(s))};class $${constructor(){this.l=[]}}const Rg=()=>new $$,Dg=(t,e)=>t.l.push(e),Lg=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ak=(t,e,n)=>bh(t.l,[e,n]);class ws{constructor(e,n){this.client=e,this.clock=n}}const Zo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,se=(t,e)=>new ws(t,e),co=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw wt()},uo=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Aa{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class H${constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const F$=(t,e,n=0)=>new H$(t,e,n),el=(t,e,n)=>{let r=null,s=null;return t._item===null?s=co(t):r=se(t._item.id.client,t._item.id.clock),new Aa(r,s,e,n)},xu=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return el(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return el(t,se(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return el(t,r.lastId,n);r=r.right}return el(t,null,n)},V$=(t,e)=>{const n=xs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},ck=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Re(r,s.client)<=s.clock)return null;const u=n?Wd(r,s):V$(r,s),d=u.item;if(!(d instanceof me))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Re(r,i.client)<=i.clock)return null;const{item:u}=n?Wd(r,i):{item:xs(r,i)};if(u instanceof me&&u.content instanceof on)a=u.content.type;else return null}else throw wt();l>=0?c=a._length:c=0}return F$(a,c,t.assoc)};class Th{constructor(e,n){this.ds=e,this.sv=n}}const uk=(t,e)=>new Th(t,e),vu=t=>uk(_$(t.store),yc(t.store)),Tr=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Js(e.ds,t.id),Fd=(t,e)=>{const n=Un(t.meta,Fd,qr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Re(r,i)&&kt(t,se(i,s))}),mr(t,e.ds,s=>{}),n.add(e))};class dk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const yc=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Re=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},fk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw wt()}n.push(e)},nn=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=tn(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=tn((n+r)/2)}throw wt()},U$=(t,e)=>{const n=t.clients.get(e.client);return n[nn(n,e.clock)]},xs=U$,Vd=(t,e,n)=>{const r=nn(e,n),s=e[r];return s.id.clock<n&&s instanceof me?(e.splice(r+1,0,Ra(t,s,n-s.id.clock)),r+1):r},kt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Vd(t,n,e.clock)]},jg=(t,e,n)=>{const r=e.clients.get(n.client),s=nn(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Bt&&r.splice(s+1,0,Ra(t,i,n.clock-i.id.clock+1)),i},W$=(t,e,n)=>{const r=t.clients.get(e.id.client);r[nn(r,e.id.clock)]=n},hk=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Vd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Vd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class q${constructor(e,n,r){this.doc=e,this.deleteSet=new Ks,this.beforeState=yc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Pg=(t,e)=>e.deleteSet.clients.size===0&&!OB(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Ch(e.deleteSet),B$(t,e),Eh(t,e.deleteSet),!0),Bg=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Un(t.changed,e,qr).add(n)},Cl=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof me&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},K$=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=nn(i,l.clock),u=i[c];c<i.length&&u.id.clock<a;u=i[++c]){const d=i[c];if(l.clock+l.len<=d.id.clock)break;d instanceof me&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},J$=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=Jr(s.length-1,1+nn(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Cl(s,a)}})},pk=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Ch(i),n.afterState=yc(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),l.push(()=>{ak(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&pH(n)})}),bh(l,[])}finally{r.gc&&K$(i,s,r.gcFilter),J$(i,s),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=s.clients.get(d),p=pr(nn(h,f),1);for(let g=h.length-1;g>=p;)g-=1+Cl(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:f}=o[u].id,h=s.clients.get(d),p=nn(h,f);p+1<h.length&&Cl(h,p+1)>1||p>0&&Cl(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(T$(Sh,Qv,"[yjs] ",Zv,ek,"Changed the client-id because another client seems to be using it."),r.clientID=ok()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new R$;Pg(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new gc;Pg(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):pk(t,e+1)}}},ve=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new q$(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&pk(s,0)}}return o};class G${constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const zg=(t,e,n)=>{mr(t,n.deletions,r=>{r instanceof me&&e.scope.some(s=>s===t.doc||uo(s,r))&&Oh(r,!1)})},$g=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;ve(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let f=!1;mr(l,c.insertions,h=>{if(h instanceof me){if(h.redone!==null){let{item:p,diff:g}=Wd(a,h.id);g>0&&(p=kt(l,se(p.id.client,p.id.clock+g))),h=p}!h.deleted&&i.some(p=>p===l.doc||uo(p,h))&&d.push(h)}}),mr(l,c.deletions,h=>{h instanceof me&&i.some(p=>p===l.doc||uo(p,h))&&!Js(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=Dk(l,h,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||f});for(let h=d.length-1;h>=0;h--){const p=d[h];t.deleteFilter(p)&&(p.delete(l),f=!0)}t.currStackItem=f?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class mk extends Sv{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Rs(e)?e[0].doc:e instanceof Zr?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const f=new Ks;a.afterState.forEach((y,b)=>{const x=a.beforeState.get(b)||0,w=y-x;w>0&&ao(f,b,x,w)});const h=gz();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=$d([y.deletions,a.deleteSet]),y.insertions=$d([y.insertions,f])}else d.push(new G$(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),mr(a,a.deleteSet,y=>{y instanceof me&&this.scope.some(b=>b===a.doc||uo(b,y))&&Oh(y,!0)});const g=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){const n=new Set(this.scope);e=Rs(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof Je?r.doc!==this.doc:r!==this.doc)&&nk("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>zg(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>zg(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=$g(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=$g(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Y$(t){const e=Ee(t.restDecoder);for(let n=0;n<e;n++){const r=Ee(t.restDecoder),s=t.readClient();let i=Ee(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Ee(t.restDecoder);yield new Gt(se(s,i),a),i+=a}else if(lc&l){const a=(l&(jn|gt))===0,c=new me(se(s,i),null,(l>)===gt?t.readLeftID():null,null,(l&jn)===jn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&ro)===ro?t.readString():null,Lk(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Bt(se(s,i),a),i+=a}}}}class X${constructor(e,n){this.gen=Y$(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Gt);return this.curr}}class Q${constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Z$=(t,e)=>{if(t.constructor===Bt){const{client:n,clock:r}=t.id;return new Bt(se(n,r+e),t.length-e)}else if(t.constructor===Gt){const{client:n,clock:r}=t.id;return new Gt(se(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new me(se(r,s+e),null,se(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Hg=(t,e=Ma,n=gc)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(ph(u)));let s=r.map(u=>new X$(u,!0)),i=null;const o=new n,l=new Q$(o);for(;s=s.filter(f=>f.curr!==null),s.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===Gt?1:-1:p}else return h.curr.id.client-f.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(i!==null){let f=u.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=i.struct.id.clock+i.struct.length&&f.id.client>=i.struct.id.client;)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)si(l,i.struct,i.offset),i={struct:f,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<f.id.clock)if(i.struct.constructor===Gt)i.struct.length=f.id.clock+f.length-i.struct.id.clock;else{si(l,i.struct,i.offset);const p=f.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Gt(se(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-f.id.clock;p>0&&(i.struct.constructor===Gt?i.struct.length-=p:f=Z$(f,p)),i.struct.mergeWith(f)||(si(l,i.struct,i.offset),i={struct:f,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===i.struct.id.clock+i.struct.length&&f.constructor!==Gt;f=u.next())si(l,i.struct,i.offset),i={struct:f,offset:0}}i!==null&&(si(l,i.struct,i.offset),i=null),eH(l);const a=r.map(u=>N$(u)),c=$d(a);return Eh(o,c),o.toUint8Array()},gk=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Yt(t.encoder.restEncoder)}),t.encoder.restEncoder=Co(),t.written=0)},si=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&gk(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),de(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},eH=t=>{gk(t);const e=t.encoder.restEncoder;de(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];de(e,r.written),ac(e,r.restEncoder)}},Fg="You must not compute changes after the event-handler fired.";class bc{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=tH(this.currentTarget,this.target))}deletes(e){return Js(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw wn(Fg);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=fu(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=fu(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=fu(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw wn(Fg);const n=this.target,r=qr(),s=qr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const tH=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},st=()=>{nk("Invalid access: Add Yjs type to a document before reading data.")},yk=80;let Mh=0;class nH{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Mh++}}const rH=t=>{t.timestamp=Mh++},bk=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Mh++},sH=(t,e,n)=>{if(t.length>=yk){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return bk(r,e,n),r}else{const r=new nH(e,n);return t.push(r),r}},wc=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>xl(e-i.index)<xl(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,rH(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&xl(n.index-s)<r.parent.length/yk?(bk(n,r,s),n):sH(t._searchMarker,r,s)},fo=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=pr(e,s.index+n))}},xc=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;Un(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ak(r._eH,n,e)};class Je{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Rg(),this._dEH=Rg(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Ht()}clone(){throw Ht()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Dg(this._eH,e)}observeDeep(e){Dg(this._dEH,e)}unobserve(e){Lg(this._eH,e)}unobserveDeep(e){Lg(this._dEH,e)}toJSON(){}}const wk=(t,e,n)=>{t.doc??st(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},xk=t=>{t.doc??st();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},vk=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Tr(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},ho=(t,e)=>{let n=0,r=t._start;for(t.doc??st();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},kk=(t,e)=>{const n=[];return ho(t,(r,s)=>{n.push(e(r,s,t))}),n},iH=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Sk=(t,e)=>{t.doc??st();const n=wc(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},_a=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new me(se(o,Re(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Yr(c)),s.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new me(se(o,Re(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new To(new Uint8Array(d))),s.integrate(t,0);break;case Zr:s=new me(se(o,Re(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Mo(d)),s.integrate(t,0);break;default:if(d instanceof Je)s=new me(se(o,Re(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new on(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Ck=()=>wn("Length exceeded!"),Ek=(t,e,n,r)=>{if(n>e._length)throw Ck();if(n===0)return e._searchMarker&&fo(e._searchMarker,n,r.length),_a(t,e,null,r);const s=n,i=wc(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&kt(t,se(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&fo(e._searchMarker,s,r.length),_a(t,e,o,r)},oH=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return _a(t,e,s,n)},Tk=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=wc(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&kt(t,se(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&kt(t,se(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Ck();e._searchMarker&&fo(e._searchMarker,s,-i+r)},Na=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Ah=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Yr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Yr([r]);break;case Uint8Array:l=new To(r);break;case Zr:l=new Mo(r);break;default:if(r instanceof Je)l=new on(r);else throw new Error("Unexpected content type")}new me(se(o,Re(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},_h=(t,e)=>{t.doc??st();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Mk=t=>{const e={};return t.doc??st(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Ak=(t,e)=>{t.doc??st();const n=t._map.get(e);return n!==void 0&&!n.deleted},lH=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Tr(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},tl=t=>(t.doc??st(),M$(t._map.entries(),e=>!e[1].deleted));class aH extends bc{}class vs extends Je{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new vs;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new vs}clone(){const e=new vs;return e.insert(0,this.toArray().map(n=>n instanceof Je?n.clone():n)),e}get length(){return this.doc??st(),this._length}_callObserver(e,n){super._callObserver(e,n),xc(this,e,new aH(this,e))}insert(e,n){this.doc!==null?ve(this.doc,r=>{Ek(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ve(this.doc,n=>{oH(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ve(this.doc,r=>{Tk(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Sk(this,e)}toArray(){return xk(this)}slice(e=0,n=this.length){return wk(this,e,n)}toJSON(){return this.map(e=>e instanceof Je?e.toJSON():e)}map(e){return kk(this,e)}forEach(e){ho(this,e)}[Symbol.iterator](){return iH(this)}_write(e){e.writeTypeRef(RH)}}const cH=t=>new vs;class uH extends bc{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ps extends Je{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Ps}clone(){const e=new Ps;return this.forEach((n,r)=>{e.set(r,n instanceof Je?n.clone():n)}),e}_callObserver(e,n){xc(this,e,new uH(this,e,n))}toJSON(){this.doc??st();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof Je?s.toJSON():s}}),e}get size(){return[...tl(this)].length}keys(){return wu(tl(this),e=>e[0])}values(){return wu(tl(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return wu(tl(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??st(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ve(this.doc,n=>{Na(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ve(this.doc,r=>{Ah(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return _h(this,e)}has(e){return Ak(this,e)}clear(){this.doc!==null?ve(this.doc,e=>{this.forEach(function(n,r,s){Na(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(DH)}}const dH=t=>new Ps,ir=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Cz(t,e);class Ud{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&wt(),this.right.content.constructor){case Pe:this.right.deleted||Gs(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Vg=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Pe:e.right.deleted||Gs(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&kt(t,se(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},nl=(t,e,n,r)=>{const s=new Map,i=r?wc(e,n):null;if(i){const o=new Ud(i.p.left,i.p,i.index,s);return Vg(t,o,n-i.index)}else{const o=new Ud(null,e._start,0,s);return Vg(t,o,n)}},_k=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Pe&&ir(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new me(se(i,Re(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Pe(l,o));u.integrate(t,0),n.right=u,n.forward()})},Gs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Nk=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Pe&&ir(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Ok=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!ir(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new me(se(i,Re(s.store,i)),u,u&&u.lastId,d,d&&d.id,e,null,new Pe(l,a)),n.right.integrate(t,0),n.forward()}}return o},ku=(t,e,n,r,s)=>{n.currentAttributes.forEach((f,h)=>{s[h]===void 0&&(s[h]=null)});const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s),a=r.constructor===String?new rn(r):r instanceof Je?new on(r):new es(r);let{left:c,right:u,index:d}=n;e._searchMarker&&fo(e._searchMarker,n.index,a.getLength()),u=new me(se(o,Re(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),_k(t,e,n,l)},Ug=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Pe));){if(!n.right.deleted)switch(n.right.content.constructor){case Pe:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(ir(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&kt(t,se(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
385
385
|
`;n.right=new me(se(o,Re(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new rn(a)),n.right.integrate(t,0),n.forward()}_k(t,e,n,l)},Ik=(t,e,n,r,s)=>{let i=e;const o=Qt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Pe){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case Pe:{const{key:u,value:d}=c,f=r.get(u)??null;(o.get(u)!==c||f===d)&&(e.delete(t),l++,!a&&(s.get(u)??null)===d&&f!==d&&(f===null?s.delete(u):s.set(u,f))),!a&&!e.deleted&&Gs(s,c);break}}}e=e.right}return l},fH=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Pe){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},hH=t=>{let e=0;return ve(t.doc,n=>{let r=t._start,s=t._start,i=Qt();const o=Rd(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Pe:Gs(o,s.content);break;default:e+=Ik(n,r,s,i,o),i=Rd(o),r=s;break}s=s.right}}),e},pH=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&hk(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Pe&&o.constructor!==Bt&&e.add(o.parent)})}ve(n,r=>{mr(t,t.deleteSet,s=>{if(s instanceof Bt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Pe?e.add(i):fH(r,s)});for(const s of e)hH(s)})},Wg=(t,e,n)=>{const r=n,s=Rd(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case on:case es:case rn:n<e.right.length&&kt(t,se(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Ik(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&fo(o._searchMarker,e.index,-r+n),e};class mH extends bc{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];ve(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const f=()=>{if(l!==null){let h=null;switch(l){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},s.size>0&&(h.attributes={},s.forEach((p,g)=>{p!==null&&(h.attributes[g]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},Sz(a)||(h.attributes=vz({},a))),u=0;break}h&&n.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case on:case es:this.adds(o)?this.deletes(o)||(f(),l="insert",c=o.content.getContent()[0],f()):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=1);break;case rn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(f(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=o.length);break;case Pe:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=s.get(h)??null;ir(g,p)?p!==null&&o.delete(r):(l==="retain"&&f(),ir(p,i.get(h)??null)?delete a[h]:a[h]=p)}}else if(this.deletes(o)){i.set(h,p);const g=s.get(h)??null;ir(g,p)||(l==="retain"&&f(),a[h]=g)}else if(!o.deleted){i.set(h,p);const g=a[h];g!==void 0&&(ir(g,p)?g!==null&&o.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}o.deleted||(l==="insert"&&f(),Gs(s,o.content));break}}o=o.right}for(f();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class gr extends Je{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??st(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new gr}clone(){const e=new gr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new mH(this,e,n);xc(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??st();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===rn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ve(this.doc,r=>{const s=new Ud(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
|