reactjs-tiptap-editor 0.0.3 → 0.0.4

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.
@@ -1 +1 @@
1
- "use strict";var vt=Object.defineProperty;var wt=(e,t,n)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Be=(e,t,n)=>wt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./vendor-D85xV5eE.js"),i=require("react/jsx-runtime"),f=require("react"),Ee=require("react-dom");function yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const R=yt(f);function Ct(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M11 7c-1.1 0-2 .9-2 2v2a2 2 0 0 0 2 2h2v2H9v2h4c1.11 0 2-.89 2-2v-2a2 2 0 0 0-2-2h-2V9h4V7z"})})}function jt(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function pt(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function kt(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M19 12h-2v3h-3v2h5zM7 9h3V7H5v5h2zm14-6H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 16H3V5h18z"})})}function Nt(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M21 22H3v-2h18zm0-18H3V2h18zm-11 9.7h4l-2-5.4zM11.2 6h1.7l4.7 12h-2l-.9-2.6H9.4L8.5 18h-2z"})})}function Lt(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}function Ye(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 48 48",...e,children:i.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function St(e){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:i.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 15h15m0 4H6m9-8h6m0-4h-6M9 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2M3 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2"})})}const re={Bold:l.Bold,LoaderCircle:l.LoaderCircle,Italic:l.Italic,Underline:l.Underline,Quote:l.Quote,TextQuote:St,Strikethrough:l.Strikethrough,Minus:l.Minus,Eraser:l.Eraser,PaintRoller:l.PaintRoller,Redo2:l.Redo2,Undo2:l.Undo2,AlignCenter:l.TextAlignCenterIcon,AlignJustify:l.TextAlignJustifyIcon,AlignLeft:l.TextAlignLeftIcon,AlignRight:l.TextAlignRightIcon,ChevronDown:l.ChevronDown,Subscript:l.Subscript,Superscript:l.Superscript,Code:l.Code,Code2:l.CodeXml,Type:l.Type,IndentIncrease:l.IndentIncrease,IndentDecrease:l.IndentDecrease,List:l.List,ListOrdered:l.ListOrdered,ListTodo:l.ListTodo,Link:l.Link,ImageUp:l.ImageUp,Video:l.Video,Maximize:l.Maximize,Minimize:l.Minimize,Table:l.Table,Sparkles:l.Sparkles,Pencil:l.Pencil,Unlink:l.Unlink,BetweenHorizonalEnd:l.BetweenHorizontalEnd,BetweenHorizonalStart:l.BetweenHorizontalStart,BetweenVerticalStart:l.BetweenVerticalStart,BetweenVerticalEnd:l.BetweenVerticalEnd,TableCellsMerge:l.TableCellsMerge,TableCellsSplit:l.TableCellsSplit,Trash2:l.Trash2,Trash:l.Trash,Replace:l.Replace,ChevronsUpDown:l.ChevronsUpDown,LineHeight:Nt,Word:Lt,Heading1:l.Heading1,Heading2:l.Heading2,Heading3:l.Heading3,Columns2:l.Columns2,Columns3:l.Columns3,Columns4:l.Columns4,Plus:l.Plus,Grip:l.GripVertical,Copy:l.Copy,Clipboard:l.Clipboard,PanelLeft:l.PanelLeft,PanelRight:l.PanelRight,Columns:l.Columns2,Iframe:l.Frame,MenuDown:Ye,SizeS:Ct,SizeM:jt,SizeL:pt,AspectRatio:kt,Emoji:l.SmilePlus};function M(...e){return l.twMerge(l.clsx(e))}const Tt=l.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),ve=R.forwardRef(({className:e,variant:t,size:n,...o},a)=>i.jsx(l.Root,{ref:a,className:M(Tt({variant:t,size:n,className:e})),...o}));ve.displayName=l.Root.displayName;const Mt=l.Provider,de=l.Root3,ce=l.Trigger,oe=R.forwardRef(({className:e,sideOffset:t=4,...n},o)=>i.jsx(l.Content2,{ref:o,sideOffset:t,className:M("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));oe.displayName=l.Content2.displayName;let ke;function Ne(){return ke===void 0&&(ke=navigator.platform.includes("Mac")),ke}function De(e){return`${e}`.toLowerCase()==="mod"?Ne()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?Ne()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?Ne()?"⇧":"Shift":e}function we(e){return e.map(De).join(" ")}const b=e=>{var v;const{icon:t=void 0,title:n=void 0,tooltip:o=void 0,disabled:a=!1,customClass:r="",color:d=void 0,loading:s=!1,shortcutKeys:c=void 0,tooltipOptions:u={},action:h=void 0,isActive:m=void 0,children:g}=e,x=re[t];return i.jsxs(de,{children:[i.jsx(ce,{children:i.jsxs(ve,{size:"sm",className:"w-[32px] h-[32px] "+r,onClick:h,"data-state":m!=null&&m()?"on":"off",children:[x&&i.jsx(x,{className:"w-4 h-4"}),g&&i.jsx(i.Fragment,{children:g})]})}),o&&i.jsx(oe,{...u,children:i.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[i.jsx("div",{children:o}),!!((v=e==null?void 0:e.shortcutKeys)!=null&&v.length)&&i.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})]})})]})},Je=l.Bold$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleBold(),isActive:()=>t.isActive("bold")||!1,disabled:!t.can().toggleBold(),icon:"Bold",shortcutKeys:["mod","B"],tooltip:n("editor.bold.tooltip")}})}}}),Qe=l.Italic$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:n}){return{component:b,componentProps:{action:()=>t.commands.toggleItalic(),isActive:()=>t.isActive("italic")||!1,disabled:!t.can().toggleItalic(),shortcutKeys:["mod","I"],icon:"Italic",tooltip:n("editor.italic.tooltip")}}}}}}),et=l.Underline$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:n}){return{component:b,componentProps:{action:()=>t.commands.toggleUnderline(),isActive:()=>t.isActive("underline")||!1,disabled:!t.can().toggleUnderline(),icon:"Underline",shortcutKeys:["mod","U"],tooltip:n("editor.underline.tooltip")}}}}}}),tt=l.Strike.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleStrike(),isActive:()=>t.isActive("strike")||!1,disabled:!t.can().toggleStrike(),icon:"Strikethrough",shortcutKeys:["shift","mod","X"],tooltip:n("editor.strike.tooltip")}})}}}),nt=l.Code$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleCode(),isActive:()=>t.isActive("code")||!1,disabled:!t.can().toggleCode(),icon:"Code",shortcutKeys:["mod","E"],tooltip:n("editor.code.tooltip")}})}}}),At=l.CodeBlockLowlight.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),defaultLanguage:null,button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleCodeBlock(),isActive:()=>t.isActive("codeBlock")||!1,disabled:!t.can().toggleCodeBlock(),icon:"Code2",tooltip:n("editor.codeblock.tooltip")}})}}}),Rt=l.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),O=R.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...a},r)=>{const d=o?l.Slot:"button";return i.jsx(d,{className:M(Rt({variant:t,size:n,className:e})),ref:r,...a})});O.displayName="Button";const He=e=>{var n;const t=re[e.icon];return i.jsxs(de,{children:[i.jsx(ce,{children:i.jsx(O,{className:"h-[32px] px-[5px] py-0 min-w-24 max-w-32 overflow-hidden",variant:"ghost",disabled:e==null?void 0:e.disabled,children:i.jsxs("div",{className:"flex items-center h-full font-normal",children:[(e==null?void 0:e.title)&&i.jsx("div",{className:"text-left truncate text-sm flex-grow",children:e==null?void 0:e.title}),t&&i.jsx(t,{className:"w-3 h-3 ml-1 text-zinc-500 flex-shrink-0"})]})})}),i.jsx(oe,{children:i.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[(e==null?void 0:e.tooltip)&&i.jsx("div",{children:e==null?void 0:e.tooltip}),i.jsx("div",{className:"flex",children:!!((n=e==null?void 0:e.shortcutKeys)!=null&&n.length)&&i.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})})]})})]})},Z=l.Root2,Y=l.Trigger$1,_e=l.Portal2,$e=l.Sub2,Le=R.forwardRef(({className:e,inset:t,children:n,...o},a)=>i.jsxs(l.SubTrigger2,{ref:a,className:M("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...o,children:[n,i.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Le.displayName=l.SubTrigger2.displayName;const Se=R.forwardRef(({className:e,...t},n)=>i.jsx(l.SubContent2,{ref:n,className:M("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Se.displayName=l.SubContent2.displayName;const U=R.forwardRef(({className:e,sideOffset:t=4,...n},o)=>i.jsx(l.Portal2,{children:i.jsx(l.Content2$1,{ref:o,sideOffset:t,className:M("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));U.displayName=l.Content2$1.displayName;const E=R.forwardRef(({className:e,inset:t,...n},o)=>i.jsx(l.Item2,{ref:o,className:M("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));E.displayName=l.Item2.displayName;const J=R.forwardRef(({className:e,children:t,checked:n,...o},a)=>i.jsxs(l.CheckboxItem2,{ref:a,className:M("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...o,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(l.ItemIndicator2,{children:i.jsx(l.Check,{className:"h-4 w-4"})})}),t]}));J.displayName=l.CheckboxItem2.displayName;const Dt=R.forwardRef(({className:e,children:t,...n},o)=>i.jsxs(l.RadioItem2,{ref:o,className:M("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(l.ItemIndicator2,{children:i.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Dt.displayName=l.RadioItem2.displayName;const Ht=R.forwardRef(({className:e,inset:t,...n},o)=>i.jsx(l.Label2,{ref:o,className:M("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ht.displayName=l.Label2.displayName;const ye=R.forwardRef(({className:e,...t},n)=>i.jsx(l.Separator2,{ref:n,className:M("-mx-1 my-1 h-px bg-muted",e),...t}));ye.displayName=l.Separator2.displayName;const it=({className:e,...t})=>i.jsx("span",{className:M("ml-auto text-xs tracking-widest opacity-60",e),...t});it.displayName="DropdownMenuShortcut";const Ft="en",It=200,Ot=It-80,Pt=20,Ue=1e5,Ve=16,ue=10,me=10,he=2,zt="#262626",Bt=["#000000","#262626","#595959","#8C8C8C","#BFBFBF","#D9D9D9","#E9E9E9","#F5F5F5","#FAFAFA","#FFFFFF","#F5222D","#FA541C","#FA8C16","#FADB14","#52C41A","#13C2C2","#1890FF","#2F54EB","#722ED1","#EB2F96","#FFE8E6","#FFECE0","#FFEFD1","#FCFCCA","#E4F7D2","#D3F5F0","#D4EEFC","#DEE8FC","#EFE1FA","#FAE1EB","#FFA39E","#FFBB96","#FFD591","#FFFB8F","#B7EB8F","#87E8DE","#91D5FF","#ADC6FF","#D3ADF7","#FFADD2","#FF4D4F","#FF7A45","#FFA940","#FFEC3D","#73D13D","#36CFC9","#40A9FF","#597EF7","#9254DE","#F759AB","#CF1322","#D4380D","#D46B08","#D4B106","#389E0D","#08979C","#096DD9","#1D39C4","#531DAB","#C41D7F","#820014","#871400","#873800","#614700","#135200","#00474F","#003A8C","#061178","#22075E","#780650"],Et=["10px","11px","12px","14px","16px","18px","20px","22px","24px","26px","28px","36px","48px","72px"],te="defaut";var Te=(e=>(e[e["size-small"]=200]="size-small",e[e["size-medium"]=500]="size-medium",e["size-large"]="100%",e))(Te||{}),be=(e=>(e[e["size-small"]=480]="size-small",e[e["size-medium"]=640]="size-medium",e["size-large"]="100%",e))(be||{});const ot="1";function _t(e){return e=e||new Map,{all:e,on(t,n){const o=e.get(t);o?o.push(n):e.set(t,[n])},off(t,n){const o=e.get(t);o&&(n?o.splice(o.indexOf(n)>>>0,1):e.set(t,[]))},emit(t,n){let o=e.get(t);o&&[...o].map(a=>{a(n)}),o=e.get("*"),o&&[...o].map(a=>{a(t,n)})}}}const $t={"editor.remove":"Remove","editor.copy":"Copy","editor.words":"WORDS","editor.characters":"CHARACTERS","editor.default":"Default","editor.recent":"Recently Used","editor.nofill":"No Fill","editor.format":"Format Painter","editor.draghandle.tooltip":"Modify","editor.copyToClipboard":"CopyToClipboard","editor.importWrod.tooltip":"Import Word","editor.slash":"Press '/' for commands","editor.slash.empty":"No Result","editor.slash.format":"Format","editor.slash.insert":"Insert","editor.slash.embed":"Embed Services","editor.content":"Please input content","editor.fontFamily.tooltip":"Font Family","editor.fontFamily.default.tooltip":"Default","editor.moremark":"More Text Styles","editor.size.small.tooltip":"Small","editor.size.medium.tooltip":"Medium","editor.size.large.tooltip":"Cover","editor.bold.tooltip":"Bold","editor.italic.tooltip":"Italic","editor.underline.tooltip":"Underline","editor.strike.tooltip":"Strike","editor.color.tooltip":"Color","editor.color.more":"More Colors","editor.highlight.tooltip":"Highlight","editor.lineheight.tooltip":"Line Height","editor.heading.tooltip":"Headings","editor.heading.h1.tooltip":"Heading 1","editor.heading.h2.tooltip":"Heading 2","editor.heading.h3.tooltip":"Heading 3","editor.heading.h4.tooltip":"Heading 4","editor.heading.h5.tooltip":"Heading 5","editor.heading.h6.tooltip":"Heading 6","editor.paragraph.tooltip":"Paragraph","editor.textalign.tooltip":"Align","editor.textalign.left.tooltip":"Left","editor.textalign.center.tooltip":"Center","editor.textalign.right.tooltip":"Right","editor.textalign.justify.tooltip":"Justify","editor.indent":"Indent","editor.indent.indent":"Increase Indent","editor.indent.outdent":"Decrease Indent","editor.fontSize.tooltip":"Font size","editor.fontSize.default.tooltip":"Default","editor.superscript.tooltip":"Superscript","editor.subscript.tooltip":"Subscript","editor.bulletlist.tooltip":"Bullet List","editor.orderedlist.tooltip":"Ordered List","editor.tasklist.tooltip":"Task List","editor.indent.tooltip":"Indent","editor.outdent.tooltip":"Outdent","editor.columns.tooltip":"Columns","editor.link.tooltip":"Link","editor.link.unlink.tooltip":"UnLink","editor.link.open.tooltip":"Open Link","editor.link.edit.tooltip":"Edit Link","editor.link.dialog.title":"Insert Link","editor.link.dialog.link":"Link","editor.link.dialog.text":"Text","editor.link.dialog.openInNewTab":"Open In New Tab","editor.link.dialog.link.placeholder":"Link Address","editor.link.dialog.text.placeholder":"Add Description","editor.link.dialog.button.apply":"Apply","editor.image.tooltip":"Image","editor.image.dragger.tooltip":"Click or drag the image to the area to upload","editor.image.float.left.tooltip":"Float left","editor.image.float.none.tooltip":"Float none","editor.image.float.right.tooltip":"Float right","editor.image.dialog.title":"Add an image","editor.image.dialog.tab.url":"Url","editor.image.dialog.tab.upload":"Upload","editor.image.dialog.uploading":"Uploading","editor.image.dialog.form.link":"Link","editor.image.dialog.placeholder":"Link","editor.image.dialog.form.alt":"Alt","editor.image.dialog.form.aspectRatio":"Lock original aspect ratio","editor.image.dialog.form.file":"File","editor.image.dialog.button.apply":"apply","editor.video.tooltip":"Video","editor.video.dialog.tab.upload":"Upload","editor.video.dialog.uploading":"Uploading","editor.video.dialog.title":"Embed or upload a video","editor.video.dialog.link":"link","editor.video.dialog.placeholder":"Link","editor.video.dialog.button.apply":"apply","editor.table.tooltip":"Table","editor.table.menu.insert_table":"Insert Table","editor.table.menu.insert_table.with_header_row":"With header row","editor.table.menu.add_column_before":"Add Column Before","editor.table.menu.add_column_after":"Add Column After","editor.table.menu.delete_column":"Delete Column","editor.table.menu.add_row_before":"Add Row Before","editor.table.menu.add_row_after":"Add Row After","editor.table.menu.delete_row":"Delete Row","editor.table.menu.merge_or_split_cells":"Merge Or Split Cells","editor.table.menu.delete_table":"Delete Table","editor.blockquote.tooltip":"Blockquote","editor.horizontalrule.tooltip":"Horizontal Rule","editor.code.tooltip":"Code","editor.codeblock.tooltip":"Code Block","editor.clear.tooltip":"Clear Format","editor.undo.tooltip":"Undo","editor.redo.tooltip":"Redo","editor.fullscreen.tooltip.fullscreen":"Fullscreen","editor.fullscreen.tooltip.exit":"Fullscreen Exit","editor.imageUpload.fileTypeNotSupported":"File type not supported","editor.imageUpload.fileSizeTooBig":"File size too big, Maximum size is","editor.table.mergeCells":"Merge Cells","editor.table.splitCells":"Split Cells","editor.table.delete":"Delete Table","editor.table.setCellsBgColor":"Set Cells Background Color","editor.table.insertColumnLeft":"Insert Column Left","editor.table.insertColumnRight":"Insert Column Right","editor.table.deleteColumn":"Delete Column","editor.table.insertRowAbove":"Insert Row Above","editor.table.insertRowBelow":"Insert Row Below","editor.table.deleteRow":"Delete Row","editor.emoji.tooltip":"Emoji","editor.iframe.tooltip":"Iframe"},Ut={"editor.remove":"Xóa","editor.copy":"Sao chép","editor.words":"TỪ","editor.characters":"KÝ TỰ","editor.default":"Mặc định","editor.recent":"Đã sử dụng gần đây","editor.nofill":"Không tô","editor.format":"Format Painter","editor.draghandle.tooltip":"Sửa đổi","editor.copyToClipboard":"CopyToClipboard","editor.importWrod.tooltip":"Nhập Word","editor.slash":"Nhấn '/' để biết lệnh","editor.slash.empty":"Không có kết quả","editor.slash.format":"Định dạng","editor.slash.insert":"Chèn","editor.slash.embed":"Dịch vụ nhúng","editor.content":"Vui lòng nhập nội dung","editor.moremark":"Nhiều kiểu văn bản hơn","editor.size.small.tooltip":"Nhỏ","editor.fontFamily.tooltip":"Phông chữ","editor.fontFamily.default.tooltip":"Mặc định","editor.size.medium.tooltip":"Trung bình","editor.size.large.tooltip":"Lớn","editor.bold.tooltip":"Đậm","editor.italic.tooltip":"In nghiêng","editor.underline.tooltip":"Gạch chân","editor.strike.tooltip":"Gạch","editor.color.tooltip":"Màu","editor.color.more":"Nhiều màu hơn","editor.highlight.tooltip":"Đánh dấu","editor.lineheight.tooltip":"Chiều cao dòng","editor.heading.tooltip":"Tiêu đề","editor.heading.h1.tooltip":"Tiêu đề 1","editor.heading.h2.tooltip":"Tiêu đề 2","editor.heading.h3.tooltip":"Tiêu đề 3","editor.heading.h4.tooltip":"Tiêu đề 4","editor.heading.h5.tooltip":"Tiêu đề 5","editor.heading.h6.tooltip":"Tiêu đề 6","editor.paragraph.tooltip":"Đoạn văn","editor.textalign.tooltip":"Căn chỉnh","editor.textalign.left.tooltip":"Trái","editor.textalign.center.tooltip":"Giữa","editor.textalign.right.tooltip":"Phải","editor.textalign.justify.tooltip":"Căn đều","editor.indent":"Thụt lề","editor.indent.indent":"Tăng thụt lề","editor.indent.outdent":"Giảm thụt lề","editor.fontSize.tooltip":"Kích thước phông chữ","editor.fontSize.default.tooltip":"Mặc định","editor.superscript.tooltip":"Chỉ số trên","editor.subscript.tooltip":"Chỉ số dưới","editor.bulletlist.tooltip":"Danh sách dấu đầu dòng","editor.orderedlist.tooltip":"Danh sách có thứ tự","editor.tasklist.tooltip":"Danh sách tác vụ","editor.indent.tooltip":"Tăng thụt lề","editor.outdent.tooltip":"Giảm thụt lề","editor.columns.tooltip":"Cột","editor.link.tooltip":"Liên kết","editor.link.unlink.tooltip":"Hủy liên kết","editor.link.open.tooltip":"Mở liên kết","editor.link.edit.tooltip":"Chỉnh sửa liên kết","editor.link.dialog.title":"Chèn liên kết","editor.link.dialog.link":"Liên kết","editor.link.dialog.text":"Văn bản","editor.link.dialog.openInNewTab":"Mở trong tab mới","editor.link.dialog.link.placeholder":"Địa chỉ liên kết","editor.link.dialog.text.placeholder":"Thêm mô tả","editor.link.dialog.button.apply":"Áp dụng","editor.image.tooltip":"Hình ảnh","editor.image.dragger.tooltip":"Nhấp hoặc kéo hình ảnh đến khu vực để tải lên","editor.image.float.left.tooltip":"Trôi sang trái","editor.image.float.none.tooltip":"Trôi không","editor.image.float.right.tooltip":"Trôi sang phải","editor.image.dialog.title":"Thêm hình ảnh","editor.image.dialog.tab.url":"Url","editor.image.dialog.tab.upload":"Tải lên","editor.image.dialog.uploading":"Đang tải lên","editor.image.dialog.form.link":"Liên kết","editor.image.dialog.placeholder":"Liên kết","editor.image.dialog.form.alt":"Alt","editor.image.dialog.form.aspectRatio":"Khóa tỷ lệ khung hình gốc","editor.image.dialog.form.file":"Tệp","editor.image.dialog.button.apply":"áp dụng","editor.video.tooltip":"Video","editor.video.dialog.tab.upload":"Tải lên","editor.video.dialog.uploading":"Đang tải lên","editor.video.dialog.title":"Nhúng hoặc tải lên video","editor.video.dialog.link":"liên kết","editor.video.dialog.placeholder":"Liên kết","editor.video.dialog.button.apply":"áp dụng","editor.table.tooltip":"Bảng","editor.table.menu.insert_table":"Chèn Bảng","editor.table.menu.insert_table.with_header_row":"Có hàng tiêu đề","editor.table.menu.add_column_before":"Thêm Cột Trước","editor.table.menu.add_column_after":"Thêm Cột Sau","editor.table.menu.delete_column":"Xóa Cột","editor.table.menu.add_row_before":"Thêm Hàng Trước","editor.table.menu.add_row_after":"Thêm Hàng Sau","editor.table.menu.delete_row":"Xóa Hàng","editor.table.menu.merge_or_split_cells":"Gộp Hoặc Tách Ô","editor.table.menu.delete_table":"Xóa Bảng","editor.blockquote.tooltip":"Blockquote","editor.horizontalrule.tooltip":"Quy tắc ngang","editor.code.tooltip":"Mã","editor.codeblock.tooltip":"Khối mã","editor.clear.tooltip":"Xóa định dạng","editor.undo.tooltip":"Hoàn tác","editor.redo.tooltip":"Làm lại","editor.fullscreen.tooltip.fullscreen":"Toàn màn hình","editor.fullscreen.tooltip.exit":"Thoát toàn màn hình","editor.imageUpload.fileTypeNotSupported":"Loại tệp không được hỗ trợ","editor.imageUpload.fileSizeTooBig":"Kích thước tệp quá lớn, Kích thước tối đa là","editor.table.mergeCells":"Gộp các ô","editor.table.splitCells":"Tách các ô","editor.table.delete":"Xóa bảng","editor.table.setCellsBgColor":"Đặt màu nền cho ô","editor.table.insertColumnLeft":"Chèn cột bên trái","editor.table.insertColumnRight":"Chèn cột bên phải","editor.table.deleteColumn":"Xóa cột","editor.table.insertRowAbove":"Chèn hàng phía trên","editor.table.insertRowBelow":"Chèn hàng phía dưới","editor.table.deleteRow":"Xóa hàng","editor.emoji.tooltip":"Biểu tượng","editor.iframe.tooltip":"Iframe"},ne={lang:Ft,message:{en:$t,vi:Ut}};class Vt{constructor(){Be(this,"emitter");this.emitter=_t()}get lang(){return ne.lang}set lang(t){if(!this.isLangSupported(t)){console.warn(`Can't find the current language "${t}", Using language "${ne.lang}" by default`);return}ne.lang=t,this.emitter.emit("lang",t)}get message(){return ne.message}set message(t){ne.message=t}loadLangMessage(t){return this.message[t]}isLangSupported(t){return Object.keys(this.message).includes(t)}setLang(t){this.lang=t}registerWatchLang(t){return this.emitter.on("lang",t),{unsubscribe:()=>{this.emitter.off("lang",t)}}}setMessage(t,n){this.message[t]=n}buildLocalesHandler(t){t||(t=this.lang);const n=this.loadLangMessage(t);return function(a){return n[a]||a}}}const xe=new Vt,Me=l.proxy({lang:ne.lang}),A=()=>{const e=l.useSnapshot(Me),t=f.useMemo(()=>xe.buildLocalesHandler(e.lang),[e.lang]);return f.useEffect(()=>{const n=xe.registerWatchLang(o=>{Me.lang=o});return()=>{n.unsubscribe()}},[]),{lang:e.lang,t}},S={t:e=>xe.buildLocalesHandler(Me.lang)(e)},Kt=xe,qt=e=>{var a,r,d;const{t,lang:n}=A(),o=f.useMemo(()=>{var u;const s=(u=e==null?void 0:e.items)==null?void 0:u.find(h=>h.isActive());return s&&!s.default?{...s}:{title:e.tooltip,font:t("editor.fontFamily.default.tooltip"),isActive:()=>!1,disabled:!1,action:()=>e.editor.chain().focus().unsetFontFamily().run()}},[t,n,e]);return i.jsxs(Z,{children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsx(He,{title:((a=o==null?void 0:o.font)==null?void 0:a.length)>7?`${(r=o==null?void 0:o.font)==null?void 0:r.slice(0,6)}...`:o==null?void 0:o.font,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),i.jsx(U,{className:"w-full",children:(d=e==null?void 0:e.items)==null?void 0:d.map((s,c)=>{const u=s.font===t("editor.fontFamily.default.tooltip")?{}:{fontFamily:s.font};return i.jsxs(f.Fragment,{children:[i.jsx(J,{checked:(o==null?void 0:o.font)===s.font,onClick:s.action,children:i.jsx("div",{className:"ml-1 h-full",style:u,children:s.font})}),s.font===t("editor.fontFamily.default.tooltip")&&i.jsx(ye,{})]},c)})})]})},Wt=l.FontFamily.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),fonts:["Inter","Comic Sans MS, Comic Sans","serif","monospace","cursive"],button({editor:t,extension:n,t:o}){var u;const{extensions:a=[]}=t.extensionManager??[],r=((u=n.options)==null?void 0:u.fonts)||[],d=a.find(h=>h.name==="base-kit"),s=r.map(h=>({action:()=>{t.chain().focus().setFontFamily(h).run()},isActive:()=>t.isActive("textStyle",{fontFamily:h})||!1,disabled:!t.can().setFontFamily(h),title:h,font:h}));d&&d.options.textStyle!==!1&&s.unshift({action:()=>t.chain().focus().unsetFontFamily().run(),isActive:()=>!1,disabled:!1,font:o("editor.fontFamily.default.tooltip"),title:o("editor.fontFamily.tooltip")});const c=s.filter(h=>h.disabled).length===s.length;return{component:qt,componentProps:{tooltip:o("editor.fontFamily.tooltip"),disabled:c,items:s,editor:t}}}}}}),Gt=e=>{var n;const t=f.useMemo(()=>{var r;const o=(r=e==null?void 0:e.items)==null?void 0:r.find(d=>d.isActive());return o&&!o.default?{...o}:{title:e.tooltip,level:0,isActive:()=>!1}},[e]);return i.jsxs(Z,{children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsx(He,{title:t==null?void 0:t.title,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),i.jsx(U,{className:"w-full",children:(n=e==null?void 0:e.items)==null?void 0:n.map((o,a)=>{var r,d;return i.jsxs(f.Fragment,{children:[i.jsxs(J,{checked:(t==null?void 0:t.title)===o.title,onClick:o.action,children:[i.jsx("div",{className:`ml-1 h-full heading-${o.level}`,children:o.title}),!!((r=o==null?void 0:o.shortcutKeys)!=null&&r.length)&&i.jsx(it,{className:"pl-4",children:(d=o==null?void 0:o.shortcutKeys)==null?void 0:d.map(s=>De(s)).join(" ")})]}),o.level===0&&i.jsx(ye,{})]},a)})})]})},Xt=l.Heading.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),levels:[1,2,3,4,5,6],button({editor:t,extension:n,t:o}){var u;const{extensions:a=[]}=t.extensionManager??[],r=((u=n.options)==null?void 0:u.levels)||[],d=a.find(h=>h.name==="base-kit"),s=r.map(h=>({action:()=>t.commands.toggleHeading({level:h}),isActive:()=>t.isActive("heading",{level:h})||!1,disabled:!t.can().toggleHeading({level:h}),title:o(`editor.heading.h${h}.tooltip`),level:h,shortcutKeys:["alt","mod",`${h}`]}));d&&d.options.paragraph!==!1&&s.unshift({action:()=>t.commands.setParagraph(),isActive:()=>t.isActive("paragraph")||!1,disabled:!t.can().setParagraph(),level:0,title:o("editor.paragraph.tooltip"),shortcutKeys:["alt","mod","0"]});const c=s.filter(h=>h.disabled).length===s.length;return{component:Gt,componentProps:{tooltip:o("editor.heading.tooltip"),disabled:c,items:s,editor:t}}}}}}),p=e=>{const t=re[e.name];return i.jsx(i.Fragment,{children:t&&i.jsx(t,{onClick:e==null?void 0:e.onClick,className:`w-4 h-4 ${(e==null?void 0:e.className)||""}`})})},Q=l.Root2$1,ee=l.Trigger$2,V=R.forwardRef(({className:e,align:t="center",sideOffset:n=4,...o},a)=>i.jsx(l.Portal,{children:i.jsx(l.Content2$2,{ref:a,align:t,sideOffset:n,className:M("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));V.displayName=l.Content2$2.displayName;const Zt=e=>{var n;const t=f.useMemo(()=>{var r;const o=(r=e==null?void 0:e.items)==null?void 0:r.find(d=>d.isActive());return o&&!o.default?{...o,icon:o.icon?o.icon:e.icon}:{title:e==null?void 0:e.tooltip,icon:e.icon,isActive:()=>!1}},[e]);return i.jsxs(Q,{children:[i.jsx(ee,{disabled:e==null?void 0:e.disabled,children:i.jsx("div",{className:"flex",children:i.jsx(b,{customClass:"w-12","enable-tooltip":!0,icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:i.jsx(p,{className:"w-3 h-3 ml-1 text-zinc-500",name:"MenuDown"})})})}),i.jsx(V,{className:"min-w-4 w-full !p-[4px] flex flex-row gap-1",align:"start",side:"bottom",children:(n=e==null?void 0:e.items)==null?void 0:n.map((o,a)=>{var r,d;return i.jsxs(de,{children:[i.jsx(ce,{children:i.jsx(ve,{size:"sm",onClick:o==null?void 0:o.action,className:"w-7 h-7 p-1",pressed:t.title===o.title,"data-state":t.title===o.title?"on":"off",children:(o==null?void 0:o.icon)&&i.jsx(p,{name:o.icon})})}),i.jsxs(oe,{className:"flex flex-col items-center",children:[i.jsx("span",{children:o.title}),!!((r=o.shortcutKeys)!=null&&r.length)&&i.jsx("span",{children:(d=o.shortcutKeys)==null?void 0:d.map(s=>De(s)).join(" ")})]})]},`text-align-${a}`)})})]})},Yt=l.TextAlign.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["heading","paragraph","list_item","title"],button({editor:t,extension:n,t:o}){var u;const a=((u=n.options)==null?void 0:u.alignments)||[],r={left:["mod","Shift","L"],center:["mod","Shift","E"],right:["mod","Shift","R"],justify:["mod","Shift","J"]},d={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},s=a.map(h=>({title:o(`editor.textalign.${h}.tooltip`),icon:d[h],shortcutKeys:r[h],isActive:()=>t.isActive({textAlign:h})||!1,action:()=>t.commands.setTextAlign(h),disabled:!t.can().setTextAlign(h)})),c=s.filter(h=>h.disabled).length===s.length;return{component:Zt,componentProps:{icon:"AlignJustify",tooltip:o("editor.textalign.tooltip"),disabled:c,items:s}}}}}}),Jt=e=>{var o;const{t}=A(),n=f.useMemo(()=>{const a=(e.items||[]).find(d=>d.isActive());return a||{title:t("editor.fontSize.default.tooltip"),isActive:()=>!1}},[e]);return i.jsxs(Z,{children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsx(He,{title:n==null?void 0:n.title,tooltip:`${e==null?void 0:e.tooltip}`,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),i.jsx(U,{className:"w-32 overflow-y-auto max-h-96",children:(o=e==null?void 0:e.items)==null?void 0:o.map((a,r)=>i.jsx(J,{checked:n.title===a.title,onClick:a.action,children:i.jsx("div",{className:"ml-1 h-full",children:a.title})},r))})]})},Qt=l.Extension.create({name:"fontSize",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["textStyle"],fontSizes:[...Et],button({editor:t,extension:n,t:o}){var s;const a=((s=n.options)==null?void 0:s.fontSizes)||[],r=[te,...a].map(c=>({title:c===te?o("editor.fontSize.default.tooltip"):String(c),isActive:()=>{const{fontSize:u}=t.getAttributes("textStyle");return c===te&&u===void 0?!0:t.isActive({fontSize:String(c)})||!1},action:()=>{if(c===te){t.commands.unsetFontSize();return}t.commands.setFontSize(String(c))},disabled:!t.can().setFontSize(String(c)),divider:c===te||!1,default:c===te||!1})),d=r.filter(c=>c.disabled).length===r.length;return{component:Jt,componentProps:{editor:t,tooltip:o("editor.fontSize.tooltip"),disabled:d,items:r,maxHeight:280}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replaceAll(/["']+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),G=R.forwardRef(({className:e,type:t,...n},o)=>i.jsx("input",{type:t,className:M("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...n}));G.displayName="Input";const X=R.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...o},a)=>i.jsx(l.Root$1,{ref:a,decorative:n,orientation:t,className:M("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));X.displayName=l.Root$1.displayName;const Ke=Bt,at=[];for(let e=0;e<Ke.length;e+=10)at.push(Ke.slice(e,e+10));const en=({setColor:e})=>{const[t,n]=f.useState("#000000"),[o,a]=f.useState(!1),{t:r}=A();return f.useEffect(()=>()=>{a(!1)},[]),i.jsxs(Q,{open:o,children:[i.jsx(ee,{asChild:!0,children:i.jsxs("div",{onClick:d=>{d.preventDefault(),a(!0)},className:"text-sm hover:cursor-pointer hover:bg-accent py-1.5 px-1.5",children:[r("editor.color.more"),"..."]})}),i.jsxs(V,{children:[i.jsxs("div",{className:"flex flex-col items-center justify-center",children:[i.jsx(l.Z,{color:t,onChange:n}),i.jsx(G,{className:"mt-[8px] w-full",type:"text",onChange:d=>{d.preventDefault(),n(`#${d.target.value}`)},value:t.slice(1)})]}),i.jsx(X,{className:"my-[10px]"}),i.jsx(O,{onClick:d=>{d.preventDefault(),e(t),a(!1)},className:"w-full",children:i.jsx(l.Plus,{size:16})})]})]})},lt=e=>{const{t}=A(),{highlight:n=!1,disabled:o=!1,selectedColor:a,setSelectedColor:r,onChange:d}=e,[s,c]=f.useState([]),u=m=>{const g=[...s],x=g.indexOf(m);x!==-1&&g.splice(x,1),g.unshift(m),g.length>10&&g.pop(),c(g)};function h(m){if(m===void 0){r==null||r(m),d==null||d(m);return}/^#([\da-f]{3}){1,2}$/i.test(m)&&(r==null||r(m),d==null||d(m),u(m))}return i.jsxs(Q,{children:[i.jsx(ee,{disabled:o,children:e==null?void 0:e.children}),i.jsx(V,{hideWhenDetached:!0,className:"p-2 w-full h-full",align:"start",side:"bottom",children:i.jsxs("div",{className:"flex flex-col",children:[n?i.jsxs("div",{className:"flex items-center p-1 rd-1 cursor-pointer hover:bg-accent",onClick:()=>h(void 0),children:[i.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border cursor-pointer hover:border-border hover:shadow-sm relative after:border-b-2 after:border-b-red-500 after:top-[10px] after:h-0 after:left-0 after:w-6 after:absolute after:block after:rotate-[45deg]",children:i.jsx("span",{style:{backgroundColor:"transparent"},children:i.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgba(0, 0, 0, 0.4)",display:"none"},children:i.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})}),i.jsx("span",{className:"text-sm ml-1",children:t("editor.nofill")})]}):i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex items-center p-1 rd-1 cursor-pointer hover:bg-accent",onClick:()=>{h(void 0)},children:[i.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent cursor-pointer",children:i.jsx("span",{style:{backgroundColor:zt},className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",children:i.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:i.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})}),i.jsx("span",{className:"text-sm ml-1",children:t("editor.default")})]})}),at.map((m,g)=>i.jsx("span",{className:"flex p-0 w-full h-auto relative last:pb-2",children:m.map((x,v)=>i.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent flex-[0 0 auto] cursor-pointer hover:border-border hover:shadow-sm",onClick:()=>h(x),children:i.jsx("span",{style:{backgroundColor:x},className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",children:x===a?i.jsx("svg",{className:"absolute top-[-1px] left-[1px] w-3 h-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"block"},children:i.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):i.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:i.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${v}`))},g)),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm my-1",children:t("editor.recent")}),i.jsx("span",{className:"flex p-0 w-full h-auto relative last:pb-2",children:s==null?void 0:s.map((m,g)=>i.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent flex-[0 0 auto] cursor-pointer hover:border-border hover:shadow-sm",onClick:()=>h(m),children:i.jsx("span",{className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",style:{backgroundColor:m},children:i.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:i.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},g))})]}),i.jsx(en,{setColor:h})]})})]})},tn=({fill:e})=>i.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 240 240",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:i.jsx("g",{transform:"translate(0.000000, 0.500000)",children:i.jsxs("g",{transform:"translate(39.000000, 17.353553)",children:[i.jsx("path",{d:"M11,201.146447 L167,201.146447 C173.075132,201.146447 178,206.071314 178,212.146447 C178,218.221579 173.075132,223.146447 167,223.146447 L11,223.146447 C4.92486775,223.146447 7.43989126e-16,218.221579 0,212.146447 C-7.43989126e-16,206.071314 4.92486775,201.146447 11,201.146447 Z",id:"矩形",fill:e||"#DF2A3F",fillRule:"evenodd"}),i.jsx("path",{d:"M72.3425855,16.8295583 C75.799482,7.50883712 86.1577877,2.75526801 95.4785089,6.21216449 C100.284516,7.99463061 104.096358,11.7387855 105.968745,16.4968188 L106.112518,16.8745422 L159.385152,161.694068 C161.291848,166.877345 158.635655,172.624903 153.452378,174.531599 C148.358469,176.405421 142.719567,173.872338 140.716873,168.864661 L140.614848,168.598825 L89.211,28.86 L37.3759214,168.623816 C35.4885354,173.712715 29.8981043,176.351047 24.7909589,174.617647 L24.5226307,174.522368 C19.4337312,172.634982 16.7953993,167.044551 18.5287999,161.937406 L18.6240786,161.669077 L72.3425855,16.8295583 Z",id:"路径-21",fill:"currentColor",fillRule:"nonzero"}),i.jsx("path",{d:"M121,103.146447 C126.522847,103.146447 131,107.623599 131,113.146447 C131,118.575687 126.673329,122.994378 121.279905,123.142605 L121,123.146447 L55,123.146447 C49.4771525,123.146447 45,118.669294 45,113.146447 C45,107.717207 49.3266708,103.298515 54.7200952,103.150288 L55,103.146447 L121,103.146447 Z",id:"路径-22",fill:"currentColor",fillRule:"nonzero"})]})})})}),nn=e=>{const[t,n]=f.useState(void 0);function o(d){var s;(s=e.action)==null||s.call(e,d)}function a(){var d;(d=e.action)==null||d.call(e,t)}const r=f.useCallback(l.debounce(d=>{n(d)},350),[]);return i.jsxs("div",{className:"flex items-center h-[32px]",children:[i.jsx(b,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:a,children:i.jsx("span",{className:"text-sm flex justify-center items-center",children:i.jsx(tn,{fill:t})})}),i.jsx(lt,{selectedColor:t,setSelectedColor:r,onChange:o,disabled:e==null?void 0:e.disabled,children:i.jsx(O,{variant:"ghost",size:"icon",className:"h-[32px] w-3",disabled:e==null?void 0:e.disabled,children:i.jsx(p,{className:"w-3 h-3 text-zinc-500",name:"MenuDown"})})})]})},st=l.Color.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:n}){return{component:nn,componentProps:{action:o=>{o===void 0&&t.chain().focus().unsetColor().run(),typeof o=="string"&&t.chain().focus().setColor(o).run()},isActive:()=>{const{color:o}=t.getAttributes("textStyle");return o&&t.isActive({color:o})||!1},editor:t,disabled:!t.can().setColor(""),tooltip:n("editor.color.tooltip")}}}}}}),on=({fill:e})=>i.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:i.jsxs("g",{id:"icon/背景颜色",children:[i.jsx("g",{id:"编组",fill:"currentColor",children:i.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[i.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),i.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),i.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),i.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",id:"矩形",fill:e||"#FBDE28"})]})})}),Ce=e=>{const[t,n]=f.useState(void 0);function o(d){var s;(s=e.action)==null||s.call(e,d)}function a(){var d;(d=e.action)==null||d.call(e,t)}const r=f.useCallback(l.debounce(d=>{n(d)},350),[]);return i.jsxs("div",{className:"flex items-center h-[32px]",children:[i.jsx(b,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:a,tooltipOptions:e==null?void 0:e.tooltipOptions,shortcutKeys:e==null?void 0:e.shortcutKeys,children:i.jsx("span",{className:"text-sm flex items-center justify-center",children:i.jsx(on,{fill:t})})}),i.jsx(lt,{selectedColor:t,setSelectedColor:r,onChange:o,highlight:!0,disabled:e==null?void 0:e.disabled,children:i.jsx(O,{variant:"ghost",size:"icon",className:"w-3 h-[32px]",disabled:e==null?void 0:e.disabled,children:i.jsx(p,{className:"w-3 h-3 text-zinc-500",name:"MenuDown"})})})]})},rt=l.Highlight.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),multicolor:!0,button:({editor:t,t:n})=>({component:Ce,componentProps:{action:o=>{typeof o=="string"&&t.chain().focus().setHighlight({color:o}).run(),o===void 0&&t.chain().focus().unsetHighlight().run()},editor:t,isActive:()=>t.isActive("highlight")||!1,disabled:!t.can().setHighlight(),shortcutKeys:["⇧","mod","H"],tooltip:n("editor.highlight.tooltip")}})}}}),an=l.BulletList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleBulletList(),isActive:()=>t.isActive("bulletList")||!1,disabled:!t.can().toggleBulletList(),shortcutKeys:["shift","mod","8"],icon:"List",tooltip:n("editor.bulletlist.tooltip")}})}}}),ln=l.Node.create({name:"clear",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.chain().focus().clearNodes().unsetAllMarks().run(),disabled:!t.can().chain().focus().clearNodes().unsetAllMarks().run(),icon:"Eraser",tooltip:n("editor.clear.tooltip")}})}}}),sn=l.OrderedList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleOrderedList(),isActive:()=>t.isActive("orderedList")||!1,disabled:!t.can().toggleOrderedList(),icon:"ListOrdered",shortcutKeys:["mod","shift","7"],tooltip:n("editor.orderedlist.tooltip")}})}}}),rn=l.TaskList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleTaskList(),isActive:()=>t.isActive("taskList")||!1,disabled:!t.can().toggleTaskList(),icon:"ListTodo",shortcutKeys:["shift","mod","9"],tooltip:n("editor.tasklist.tooltip")}})}},addExtensions(){return[l.TaskItem.configure(this.options.taskItem)]}}),dn=l.Blockquote.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"blockquote"},button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.toggleBlockquote(),isActive:()=>t.isActive("blockquote")||!1,disabled:!t.can().toggleBlockquote(),icon:"TextQuote",shortcutKeys:["shift","mod","B"],tooltip:n("editor.blockquote.tooltip")}})}}}),cn=l.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ge=R.forwardRef(({className:e,...t},n)=>i.jsx(l.Root$2,{ref:n,className:M(cn(),e),...t}));ge.displayName=l.Root$2.displayName;const dt=R.forwardRef(({className:e,...t},n)=>i.jsx(l.Root$3,{className:M("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:i.jsx(l.Thumb,{className:M("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dt.displayName=l.Root$3.displayName;const ct=e=>{const{t}=A(),[n,o]=f.useState({text:"",link:""}),[a,r]=f.useState(!1);f.useEffect(()=>{var s;if(e!=null&&e.editor){const{href:c,target:u}=(s=e.editor)==null?void 0:s.getAttributes("link"),{from:h,to:m}=e.editor.state.selection,g=e.editor.state.doc.textBetween(h,m," ");o({link:c,text:g}),r(u==="_blank")}},[e==null?void 0:e.editor]);function d(s){s.preventDefault(),e==null||e.onSetLink(n.link,n.text,a)}return i.jsx("div",{className:"p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:i.jsxs("form",{className:"flex flex-col gap-2",onSubmit:d,children:[i.jsxs(ge,{children:[" ",t("editor.link.dialog.text")," "]}),i.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:i.jsx("div",{className:"relative w-full max-w-sm items-center",children:i.jsx(G,{type:"text",value:n.text,required:!0,className:"w-80",placeholder:"Text",onChange:s=>o({...n,text:s.target.value})})})}),i.jsx(ge,{children:t("editor.link.dialog.link")}),i.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:i.jsxs("div",{className:"relative w-full max-w-sm items-center",children:[i.jsx(G,{type:"url",value:n.link,required:!0,className:"pl-10",onChange:s=>o({...n,link:s.target.value})}),i.jsx("span",{className:"absolute start-0 inset-y-0 flex items-center justify-center px-2",children:i.jsx(p,{className:"size-5 text-muted-foreground",name:"Link"})})]})}),i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(ge,{children:t("editor.link.dialog.openInNewTab")}),i.jsx(dt,{checked:a,onCheckedChange:s=>{r(s)}})]}),i.jsx(O,{type:"submit",className:"mt-2 self-end",children:t("editor.link.dialog.button.apply")})]})})},un=e=>{function t(n,o,a){e.action&&e.action({link:n,text:o,openInNewTab:a})}return i.jsxs(Q,{children:[i.jsx(ee,{disabled:e==null?void 0:e.disabled,children:i.jsx(f.Fragment,{children:i.jsx(b,{tooltip:e==null?void 0:e.tooltip,isActive:e==null?void 0:e.isActive,disabled:e==null?void 0:e.disabled,children:i.jsx(p,{name:e==null?void 0:e.icon})})})}),i.jsx(V,{hideWhenDetached:!0,className:"w-full",align:"start",side:"bottom",children:i.jsx(ct,{editor:e.editor,onSetLink:t})})]})},ut=l.Link$1.extend({inclusive:!1,parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){return["a",l.mergeAttributes(this.options.HTMLAttributes,e,{class:"link"}),0]},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),openOnClick:!0,button:({editor:t,t:n})=>({component:un,componentProps:{editor:t,action:o=>{const{link:a,text:r,openInNewTab:d}=o;t.chain().extendMarkRange("link").insertContent({type:"text",text:r,marks:[{type:"link",attrs:{href:a,target:d?"_blank":""}}]}).setLink({href:a}).focus().run()},id:"linkk",isActive:()=>t.isActive("link")||!1,disabled:!t.can().setLink({href:""}),icon:"Link",tooltip:n("editor.link.tooltip")}})}},addProseMirrorPlugins(){return[new l.Plugin({props:{handleClick:(e,t)=>{const{schema:n,doc:o,tr:a}=e.state,r=l.getMarkRange(o.resolve(t),n.marks.link);if(!r)return!1;const d=o.resolve(r.from),s=o.resolve(r.to),c=a.setSelection(new l.TextSelection(d,s));e.dispatch(c)}}})]}}),mn=l.HorizontalRule.extend({renderHTML(){return["div",l.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.setHorizontalRule(),disabled:!t.can().setHorizontalRule(),icon:"Minus",shortcutKeys:["mod","alt","S"],tooltip:n("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}}}),hn=e=>{var v;const{icon:t=void 0,title:n=void 0,tooltip:o=void 0,disabled:a=!1,customClass:r="",color:d=void 0,loading:s=!1,shortcutKeys:c=void 0,tooltipOptions:u={},action:h=void 0,isActive:m=void 0,children:g}=e,x=re[t];return i.jsxs(de,{children:[i.jsx(ce,{children:i.jsxs(ve,{size:"sm",className:"w-[32px] h-[32px] "+r,disabled:m==null?void 0:m(),onClick:h,children:[x&&i.jsx(x,{className:"w-4 h-4"}),g&&i.jsx(i.Fragment,{children:g})]})}),o&&i.jsx(oe,{...u,children:i.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[i.jsx("div",{children:o}),!!((v=e==null?void 0:e.shortcutKeys)!=null&&v.length)&&i.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})]})})]})},fn=["undo","redo"],gn=l.History.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),depth:100,newGroupDelay:500,button:({editor:t,t:n})=>fn.map(o=>({component:hn,componentProps:{action:()=>{o==="undo"&&t.chain().focus().undo().run(),o==="redo"&&t.chain().focus().redo().run()},shortcutKeys:o==="undo"?["mod","Z"]:["shift","mod","Z"],disabled:o==="undo"?!t.can().undo():!t.can().redo(),isActive:()=>o==="undo"?!t.can().undo():!t.can().redo(),icon:o==="undo"?"Undo2":"Redo2",tooltip:n(`editor.${o}.tooltip`)}}))}}}),bn=l.Document.extend({content:"(block|columns)+"}),xn=l.Node.create({name:"column",content:"block+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:e=>e.dataset.position,renderHTML:e=>({"data-position":e.position})}}},renderHTML({HTMLAttributes:e}){return["div",l.mergeAttributes(e,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}});var q=(e=>(e.SidebarLeft="sidebar-left",e.SidebarRight="sidebar-right",e.TwoColumn="two-column",e))(q||{});const mt=l.Node.create({name:"columns",group:"columns",content:"column+",defining:!0,isolating:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),layout:"two-column"}},addAttributes(){return{layout:{default:"two-column"}}},addCommands(){return{setColumns:()=>({commands:e})=>(e.insertContent('<div data-type="columns"><div data-type="column" data-position="left"><p></p></div><div data-type="column" data-position="right"><p></p></div></div>'),!0),setLayout:e=>({commands:t})=>t.updateAttributes("columns",{layout:e})}},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"columns",class:`layout-${e.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]},addExtensions(){return[xn.configure(this.options.columnOptions)]}}),vn=l.Extension.create({name:"columnToolbar",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>{t.chain().setColumns().focus(t.state.selection.head-1).run()},icon:"Columns",tooltip:n("editor.columns.tooltip")}})}}}),wn=l.Extension.create({name:"selection",addProseMirrorPlugins(){const{editor:e}=this;return[new l.Plugin({key:new l.PluginKey("selection"),props:{decorations(t){return t.selection.empty||e.isFocused===!0?null:l.DecorationSet.create(t.doc,[l.Decoration.inline(t.selection.from,t.selection.to,{class:"selection"})])}}})]}}),yn=e=>{const{t}=A(),n=f.useMemo(()=>[{name:"paragraph",label:t("editor.paragraph.tooltip"),iconName:"Heading1",isActive:()=>e.editor.isActive("paragraph")&&!e.editor.isActive("orderedList")&&!e.editor.isActive("bulletList")&&!e.editor.isActive("taskList"),action:()=>e.editor.chain().focus().clearNodes().run()},{name:"heading1",label:t("editor.heading.h1.tooltip"),isActive:()=>e.editor.isActive("heading",{level:1}),iconName:"Heading1",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:1}).run()},{name:"heading2",label:t("editor.heading.h2.tooltip"),isActive:()=>e.editor.isActive("heading",{level:2}),iconName:"Heading2",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:2}).run()},{name:"heading3",label:t("editor.heading.h3.tooltip"),isActive:()=>e.editor.isActive("heading",{level:3}),iconName:"Heading3",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:3}).run()},{name:"bulletList",label:t("editor.bulletlist.tooltip"),isActive:()=>e.editor.isActive("bulletList"),iconName:"List",action:()=>e.editor.chain().focus().clearNodes().toggleBulletList().run()},{name:"numberedList",label:t("editor.orderedlist.tooltip"),isActive:()=>e.editor.isActive("orderedList"),iconName:"ListOrdered",action:()=>e.editor.chain().focus().clearNodes().toggleOrderedList().run()},{name:"taskList",label:t("editor.tasklist.tooltip"),isActive:()=>e.editor.isActive("taskList"),iconName:"ListTodo",action:()=>e.editor.chain().focus().clearNodes().toggleTaskList().run()},{name:"blockquote",label:t("editor.blockquote.tooltip"),isActive:()=>e.editor.isActive("blockquote"),iconName:"TextQuote",action:()=>e.editor.chain().focus().clearNodes().toggleBlockquote().run()},{name:"codeBlock",label:t("editor.codeblock.tooltip"),isActive:()=>e.editor.isActive("codeBlock"),iconName:"Code2",action:()=>e.editor.chain().focus().clearNodes().toggleCodeBlock().run()}],[e.editor,t]),o=f.useMemo(()=>n.filter(a=>a.isActive()).pop()??{label:"Empty"},[n]);return i.jsx(i.Fragment,{children:i.jsxs(Z,{children:[i.jsx(Y,{children:i.jsxs(O,{variant:"ghost",className:"h-[32px] flex gap-1 px-1.5",children:[i.jsxs("span",{className:"whitespace-nowrap text-sm font-normal",children:[" ",o==null?void 0:o.label]}),i.jsx(l.ChevronDown,{className:"w-4 h-4"})]})}),i.jsx(U,{hideWhenDetached:!0,className:"w-full p-1",align:"start",sideOffset:5,children:n.map((a,r)=>{var s;const d=re[a.iconName];return i.jsx(J,{checked:((s=a.isActive)==null?void 0:s.call(a))||!1,onClick:()=>a.action(),className:"cursor-pointer",children:i.jsxs("div",{className:"flex items-center gap-2 px-2",children:[i.jsx(d,{className:"h3 w-3"}),i.jsxs("span",{children:[" ",a.label]})]})},r)})})]})})},Cn=l.Extension.create({name:"text-bubble",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),toolbar:!1,button:()=>({component:yn,componentProps:{}})}}});function qe({types:e,node:t}){return Array.isArray(e)&&e.includes(t.type)||t.type===e}const jn=l.Extension.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const e=new l.PluginKey(this.name),t=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>this.options.notAfter.includes(n.name));return[new l.Plugin({key:e,appendTransaction:(n,o,a)=>{const{doc:r,tr:d,schema:s}=a,c=e.getState(a),u=r.content.size,h=s.nodes[this.options.node];if(c)return d.insert(u,h.create())},state:{init:(n,o)=>{const a=o.tr.doc.lastChild;return!qe({node:a,types:t})},apply:(n,o)=>{if(!n.docChanged)return o;const a=n.doc.lastChild;return!qe({node:a,types:t})}}})]}}),pn=l.Extension.create({name:"base-kit",addExtensions(){const e=[];return this.options.multiColumn?(e.push(bn.configure()),e.push(mt)):e.push(l.Document),this.options.placeholder!==!1&&e.push(l.Placeholder.configure({placeholder:({node:t,pos:n})=>{var o,a;return((o=t==null?void 0:t.type)==null?void 0:o.name)==="heading"?`${S.t(`editor.heading.h${t.attrs.level}.tooltip`)}`:((a=t==null?void 0:t.type)==null?void 0:a.name)==="codeBlock"?"":n===0?S.t("editor.content"):S.t("editor.slash")},...this.options.placeholder})),this.options.focus!==!1&&e.push(l.FocusClasses.configure({className:"focus",...this.options.focus})),this.options.text!==!1&&e.push(l.Text.configure()),this.options.textBubble!==!1&&e.push(Cn.configure()),this.options.gapcursor!==!1&&e.push(l.Gapcursor.configure()),this.options.dropcursor!==!1&&e.push(l.Dropcursor.configure({...this.options.dropcursor,width:2,class:"ProseMirror-dropcursor border-black"})),this.options.characterCount!==!1&&e.push(l.CharacterCount.configure(this.options.characterCount)),this.options.paragraph!==!1&&e.push(l.Paragraph.configure(this.options.paragraph)),this.options.hardBreak!==!1&&e.push(l.HardBreak.configure(this.options.hardBreak)),this.options.listItem!==!1&&e.push(l.ListItem.configure(this.options.listItem)),this.options.textStyle!==!1&&e.push(l.TextStyle.configure(this.options.textStyle)),this.options.trailingNode!==!1&&e.push(jn.configure(this.options.trailingNode)),this.options.selection!==!1&&e.push(wn),e}}),kn=l.Extension.create({name:"subAndSuperScript",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,extension:n,t:o})=>{const a=n.options.subscript,r=n.options.superscript,d={component:b,componentProps:{action:()=>t.commands.toggleSubscript(),isActive:()=>t.isActive("subscript")||!1,disabled:!t.can().toggleSubscript(),icon:"Subscript",tooltip:o("editor.subscript.tooltip")}},s={component:b,componentProps:{action:()=>t.commands.toggleSuperscript(),isActive:()=>t.isActive("superscript")||!1,disabled:!t.can().toggleSuperscript(),icon:"Superscript",tooltip:o("editor.superscript.tooltip")}},c=[];return a!==!1&&c.push(d),r!==!1&&c.push(s),c}}},addExtensions(){const e=[];return this.options.subscript!==!1&&e.push(l.Subscript$1.configure(this.options.subscript)),this.options.superscript!==!1&&e.push(l.Superscript$1.configure(this.options.superscript)),e}}),Nn=e=>{var n;const t=f.useMemo(()=>{var r;const o=(r=e==null?void 0:e.items)==null?void 0:r.find(d=>d.isActive());return o&&!o.default?{...o,icon:o!=null&&o.icon?o==null?void 0:o.icon:e==null?void 0:e.icon}:{title:e.tooltip,icon:e.icon,isActive:()=>!1}},[e]);return i.jsxs(Z,{children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsx(b,{customClass:"w-12",icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:i.jsx(Ye,{className:"w-3 h-3 text-gray-500"})})}),i.jsx(U,{className:"w-full",children:(n=e==null?void 0:e.items)==null?void 0:n.map((o,a)=>i.jsxs(J,{checked:t.title===o.title,onClick:o.action,className:"flex gap-3 items-center",children:[i.jsx(p,{name:o==null?void 0:o.icon}),i.jsx("span",{className:"ml-1",children:o.title}),!!(o!=null&&o.shortcutKeys)&&i.jsx("span",{className:"text-xs tracking-widest opacity-60 ml-auto",children:we(o.shortcutKeys)})]},a))})]})},Ln=l.Extension.create({name:"moreMark",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,extension:n,t:o}){const a=n.options.subscript,r=n.options.superscript,d={action:()=>t.commands.toggleSubscript(),isActive:()=>t.isActive("subscript")||!1,disabled:!t.can().toggleSubscript(),icon:"Subscript",title:o("editor.subscript.tooltip"),shortcutKeys:["mod","."]},s={action:()=>t.commands.toggleSuperscript(),isActive:()=>t.isActive("superscript")||!1,disabled:!t.can().toggleSuperscript(),icon:"Superscript",title:o("editor.superscript.tooltip"),shortcutKeys:["mod",","]},c=[];return a!==!1&&c.push(d),r!==!1&&c.push(s),{component:Nn,componentProps:{icon:"Type",tooltip:o("editor.moremark"),disabled:!t.isEditable,items:c}}}}},addExtensions(){const e=[];return this.options.subscript!==!1&&e.push(l.Subscript$1.configure(this.options.subscript)),this.options.superscript!==!1&&e.push(l.Superscript$1.configure(this.options.superscript)),e}});var W=(e=>(e[e.max=7]="max",e[e.min=0]="min",e[e.more=1]="more",e[e.less=-1]="less",e))(W||{});function Sn(e,t,n){return e<t?t:e>n?n:e}function Tn(e,t,n,o){const{doc:a,selection:r}=e;if(!a||!r||!(r instanceof l.TextSelection||r instanceof l.AllSelection))return e;const{from:d,to:s}=r;return a.nodesBetween(d,s,(c,u)=>{const h=c.type;return n.includes(h.name)?(e=Ae(e,u,t),!1):!l.isList(c.type.name,o.extensionManager.extensions)}),e}function Ae(e,t,n){if(!e.doc)return e;const o=e.doc.nodeAt(t);if(!o)return e;const d=Sn((o.attrs.indent||0)+n,0,7);if(d===o.attrs.indent)return e;const s={...o.attrs,indent:d};return e.setNodeMarkup(t,o.type,s,o.marks)}function We({delta:e,types:t}){return({state:n,dispatch:o,editor:a})=>{const{selection:r}=n;let{tr:d}=n;return d=d.setSelection(r),d=Tn(d,e,t,a),d.docChanged?(o&&o(d),!0):!1}}const Mn=l.Extension.create({name:"indent",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","blockquote"],minIndent:W.min,maxIndent:W.max,button({editor:t,t:n}){return[{component:b,componentProps:{action:()=>{t.commands.indent()},shortcutKeys:["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")}},{component:b,componentProps:{action:()=>{t.commands.outdent()},shortcutKeys:["Shift","Tab"],icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}]}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>{const t=e.dataset.indent;return(t?Number.parseInt(t,10):0)||0},renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}}]},addCommands(){return{indent:()=>We({delta:W.more,types:this.options.types}),outdent:()=>We({delta:W.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});function An(e){return Number.parseFloat(e.replace("%",""))/100}const Rn=e=>{const{t}=A(),[n,o]=f.useState("default");function a(d){d==="default"?e.editor.commands.unsetLineHeight():e.editor.commands.setLineHeight(d),o(d)}const r=f.useMemo(()=>{const c=e.editor.extensionManager.extensions.find(u=>u.name==="lineHeight").options.lineHeights.map(u=>({label:An(u),value:u}));return c.unshift({label:t("editor.default"),value:"default"}),c},[e]);return i.jsxs(Z,{children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsx(b,{customClass:"w-12",icon:"LineHeight",tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:i.jsx(p,{className:"w-3 h-3 text-zinc-500 ml-1",name:"MenuDown"})})}),i.jsx(U,{className:"min-w-24",children:r==null?void 0:r.map((d,s)=>i.jsx(J,{checked:d.value===n,onClick:()=>a(d.value),children:d.label},`lineHeight-${s}`))})]})},Dn=["paragraph","heading","list_item","todo_item"];function Hn(e,t){const{selection:n,doc:o}=e;if(!n||!o||!(n instanceof l.TextSelection||n instanceof l.AllSelection))return e;const{from:a,to:r}=n,d=[],s=t&&t!==ot?t:null;if(o.nodesBetween(a,r,(c,u)=>{const h=c.type;return Dn.includes(h.name)?((c.attrs.lineHeight||null)!==s&&d.push({node:c,pos:u,nodeType:h}),h.name!=="list_item"&&h.name!=="todo_item"):!0}),d.length===0)return e;for(const c of d){const{node:u,pos:h,nodeType:m}=c;let{attrs:g}=u;g={...g,lineHeight:s},e=e.setNodeMarkup(h,m,g,u.marks)}return e}function Fn(e){return({state:t,dispatch:n})=>{const{selection:o}=t;let{tr:a}=t;return a=a.setSelection(o),a=Hn(a,e),a.docChanged?(n&&n(a),!0):!1}}const In=l.Extension.create({name:"lineHeight",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","list_item","todo_item"],lineHeights:["100%","115%","150%","200%","250%","300%"],defaultHeight:ot,button({editor:t,t:n}){return{component:Rn,componentProps:{editor:t,tooltip:n("editor.lineheight.tooltip")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||this.options.defaultHeight,renderHTML:e=>e.lineHeight===this.options.defaultHeight||!e.lineHeight?{}:{style:`line-height: ${e.lineHeight}`}}}}]},addCommands(){return{setLineHeight:e=>Fn(e),unsetLineHeight:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"lineHeight"))}}}),On=(e,t)=>{var H,P;const[n,o]=f.useState(0),[a,r]=f.useState(0),d=f.useRef(null),{t:s}=A(),c=f.useRef([]);f.useImperativeHandle(t,()=>({onKeyDown:u})),f.useEffect(()=>{if(!d.current)return;const y=a*1e3+n,C=c.current[y];C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})},[n,a]);function u({event:y}){return y.key==="ArrowUp"?(h(),!0):y.key==="ArrowDown"?(m(),!0):y.key==="Enter"?(g(),!0):!1}function h(){var L;if(e.items.length===0)return!1;let y=n-1,C=a;y<0&&(C=a-1,y=((L=e.items[C])==null?void 0:L.commands.length)-1||0),C<0&&(C=e.items.length-1,y=e.items[C].commands.length-1),o(y),r(C)}function m(){if(e.items.length===0)return!1;const y=e.items[a].commands;let C=n+1,L=a;y.length-1<C&&(C=0,L=a+1),e.items.length-1<L&&(L=0),o(C),r(L)}function g(){if(e.items.length===0||a===-1||n===-1)return!1;x(a,n)}function x(y,C){const L=e.items[y].commands[C];e.command(L)}function v(y,C){x(y,C)}function T(y,C,L){c.current[y*1e3+C]=L}return i.jsx("div",{className:"bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800 text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-1",ref:d,children:(H=e==null?void 0:e.items)!=null&&H.length?i.jsx("div",{className:"grid grid-cols-1 gap-0.5 min-w-48",children:(P=e==null?void 0:e.items)==null?void 0:P.map((y,C)=>i.jsxs(f.Fragment,{children:[i.jsx("div",{className:"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-2 font-semibold tracking-wider select-none uppercase first:mt-0.5",children:y.title}),y.commands.map((L,z)=>i.jsxs("button",{className:`flex items-center gap-3 px-2 py-1.5 text-sm text-neutral-800 dark:text-neutral-200 text-left w-full rounded-sm outline-none transition-colors ${a===C&&n===z?"bg-accent text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200":"hover:bg-accent hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200"}`,ref:k=>T(C,z,k),onClick:()=>v(C,z),children:[L.iconUrl&&i.jsx("img",{className:"w-6 h-6",src:L.iconUrl,alt:""}),L.iconName&&i.jsx(p,{name:L.iconName,className:"mr-1 text-lg"}),L.label]},`command-${z}`))]},y.title))}):i.jsx("div",{className:"p-3",children:i.jsx("span",{className:"text-xs text-gray-800 dark:text-gray-100",children:s("editor.slash.empty")})})})},Pn=f.forwardRef(On);function zn(e){return[{name:"format",title:S.t("editor.slash.format"),commands:[{name:"heading1",label:S.t("editor.heading.h1.tooltip"),aliases:["h1","bt","bt1"],iconName:"Heading1",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setHeading({level:1}).run()}},{name:"heading2",label:S.t("editor.heading.h2.tooltip"),aliases:["h2","bt","bt2"],iconName:"Heading2",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setNode("heading",{level:2}).run()}},{name:"heading3",label:S.t("editor.heading.h3.tooltip"),aliases:["h3","bt","bt3"],iconName:"Heading3",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setNode("heading",{level:3}).run()}},{name:"bulletList",label:S.t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).toggleBulletList().run()}},{name:"numberedList",label:S.t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).toggleOrderedList().run()}},{name:"taskList",label:S.t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).toggleTaskList().run()}},{name:"blockquote",label:S.t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setBlockquote().run()}},{name:"codeBlock",label:S.t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:n=>n.isActive("columns"),action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setCodeBlock().run()}}]},{name:"insert",title:S.t("editor.slash.insert"),commands:[{name:"image",label:S.t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:n=>n.isActive("columns"),action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setImageUpload().run()}},{name:"video",label:S.t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:n=>n.isActive("columns"),action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setVideoUpload().run()}},{name:"table",label:S.t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:n=>n.isActive("columns"),action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},{name:"horizontalRule",label:S.t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:n,range:o})=>{n.chain().focus().deleteRange(o).setHorizontalRule().run()}}]}]}const K="slashCommand";let j;const Bn=l.Extension.create({name:K,priority:200,onCreate(){j=l.tippy("body",{interactive:!0,trigger:"manual",placement:"bottom-start",theme:"slash-command",maxWidth:"16rem",offset:[16,8],popperOptions:{strategy:"fixed",modifiers:[{name:"flip",enabled:!1}]}})},addProseMirrorPlugins(){return[l.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new l.PluginKey(K),allow:({state:e,range:t})=>{var u,h,m;const n=e.doc.resolve(t.from),o=n.depth===1,a=n.parent.type.name==="paragraph",r=((u=n.parent.textContent)==null?void 0:u.charAt(0))==="/",d=this.editor.isActive("column"),s=(m=n.parent.textContent)==null?void 0:m.slice(Math.max(0,(h=n.parent.textContent)==null?void 0:h.indexOf("/"))),c=!(s!=null&&s.endsWith(" "));return(o&&a&&r||d&&a&&r)&&c},command:({editor:e,range:t,props:n})=>{const{view:o}=e;n.action({editor:e,range:t}),o.focus()},items:({query:e})=>(console.log(this),zn(this.editor).map(r=>({...r,commands:r.commands.filter(d=>{const s=d.label.toLowerCase().trim(),c=e.toLowerCase().trim();if(d.aliases){const u=d.aliases.map(g=>g.toLowerCase().trim()),h=s.match(c),m=u.some(g=>g.match(c));return h||m}return s.match(c)}).filter(d=>d.shouldBeHidden?!d.shouldBeHidden(this.editor):!0)})).filter(r=>r.commands.length>0).map(r=>({...r,commands:r.commands.map(d=>({...d,isEnabled:!0}))}))),render:()=>{let e,t=null;return{onStart:n=>{var r;e=new l.ReactRenderer(Pn,{props:n,editor:n.editor});const{view:o}=n.editor,a=()=>{if(!n.clientRect)return n.editor.storage[K].rect;const d=n.clientRect();if(!d)return n.editor.storage[K].rect;let s=d.y;if(d.top+e.element.offsetHeight+40>window.innerHeight){const c=d.top+e.element.offsetHeight-window.innerHeight+40;s=d.y-c}return new DOMRect(d.x,s,d.width,d.height)};t=()=>{j==null||j[0].setProps({getReferenceClientRect:a})},(r=o.dom.parentElement)==null||r.addEventListener("scroll",t),j==null||j[0].setProps({getReferenceClientRect:a,appendTo:()=>document.body,content:e.element}),j==null||j[0].show()},onUpdate(n){var d;e.updateProps(n);const{view:o}=n.editor,a=()=>{if(!n.clientRect)return n.editor.storage[K].rect;const s=n.clientRect();return s?new DOMRect(s.x,s.y,s.width,s.height):n.editor.storage[K].rect},r=()=>{j==null||j[0].setProps({getReferenceClientRect:a})};(d=o.dom.parentElement)==null||d.addEventListener("scroll",r),n.editor.storage[K].rect=n.clientRect?a():{width:0,height:0,left:0,top:0,right:0,bottom:0},j==null||j[0].setProps({getReferenceClientRect:a})},onKeyDown(n){var o;return n.event.key==="Escape"?(j==null||j[0].hide(),!0):(j!=null&&j[0].state.isShown||j==null||j[0].show(),(o=e.ref)==null?void 0:o.onKeyDown(n))},onExit(n){var o;if(j==null||j[0].hide(),t){const{view:a}=n.editor;(o=a.dom.parentElement)==null||o.removeEventListener("scroll",t)}e.destroy()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}}),En=(e,t="px")=>{if(!e)return e;const n=Re(e)?String(e):e,o=Number.parseFloat(n),a=n.match(/[%A-Za-z]+$/),r=a?a[0]:t;return Number.isNaN(o)?e:o+r};function _n(e,t,n){return e<t?t:e>n?n:e}const Re=e=>typeof e=="number",$n=e=>typeof e=="function";function Un(e,t){if(!e)return!1;const{extensions:n=[]}=(e==null?void 0:e.extensionManager)??{};return!!n.find(a=>a.name===t)}const fe={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"},Vn=e=>{var k;const[t,n]=f.useState({width:Ue,height:Ue}),[o,a]=f.useState({width:0,height:0}),[r,d]=f.useState([fe.TOP_LEFT,fe.TOP_RIGHT,fe.BOTTOM_LEFT,fe.BOTTOM_RIGHT]),[s,c]=f.useState(!1),[u,h]=f.useState({x:0,y:0,w:0,h:0,dir:""}),m=f.useMemo(()=>{var D;const{src:w,alt:F,width:I,height:_}=(D=e==null?void 0:e.node)==null?void 0:D.attrs,$=Re(I)?I+"px":I,N=Re(_)?_+"px":_;return{src:w||void 0,alt:F||void 0,style:{width:$||void 0,height:N||void 0}}},[(k=e==null?void 0:e.node)==null?void 0:k.attrs]),g=f.useMemo(()=>{const{style:{width:w}}=m;return{width:w==="100%"?w:void 0}},[m]);function x(w){a({width:w.target.width,height:w.target.height})}function v(){const{editor:w,getPos:F}=e;w.commands.setNodeSelection(F())}const T=f.useCallback(l.throttle(function(){const{editor:w}=e,{width:F}=getComputedStyle(w.view.dom);n(I=>({...I,width:Number.parseInt(F,10)}))},Ve),[e==null?void 0:e.editor]);function H(w,F){w.preventDefault(),w.stopPropagation();const I=o.width,_=o.height,$=I/_;let N=Number(e.node.attrs.width),D=Number(e.node.attrs.height);const B=t.width;N&&!D?(N=N>B?B:N,D=Math.round(N/$)):D&&!N?(N=Math.round(D*$),N=N>B?B:N):!N&&!D?(N=I>B?B:I,D=Math.round(N/$)):N=N>B?B:N,Ee.flushSync(()=>{c(!0),h({x:w.clientX,y:w.clientY,w:N,h:D,dir:F})})}const P=f.useCallback(l.throttle(function(w){if(w.preventDefault(),w.stopPropagation(),!s)return;const{x:F,y:I,w:_,h:$,dir:N}=u,D=(w.clientX-F)*(/l/.test(N)?-1:1);(w.clientY-I)*(/t/.test(N)?-1:1);const B=_n(_+D,Pt,t.width);e.updateAttributes({width:B,height:null})},Ve),[s,u,t,e.updateAttributes]),y=f.useCallback(w=>{w.preventDefault(),w.stopPropagation(),s&&(Ee.flushSync(()=>{h({x:0,y:0,w:0,h:0,dir:""}),c(!1)}),v())},[s,v]),C=f.useCallback(()=>{document==null||document.addEventListener("mousemove",P,!0),document==null||document.addEventListener("mouseup",y,!0)},[P,y]),L=f.useCallback(()=>{document==null||document.removeEventListener("mousemove",P,!0),document==null||document.removeEventListener("mouseup",y,!0)},[P,y]);f.useEffect(()=>(s?C():L(),()=>{L()}),[s,C,L]);const z=f.useMemo(()=>new ResizeObserver(()=>T()),[T]);return f.useEffect(()=>(z.observe(e.editor.view.dom),()=>{z.disconnect()}),[e.editor.view.dom,z]),i.jsx(l.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%"},children:i.jsxs("div",{draggable:"true","data-drag-handle":!0,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,style:g,children:[i.jsx("img",{src:m.src,alt:m.alt,style:m.style,height:"auto",className:"image-view__body__image block",onLoad:x,onClick:v}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||s)&&i.jsx("div",{className:"image-resizer",children:r==null?void 0:r.map(w=>i.jsx("span",{className:`image-resizer__handler image-resizer__handler--${w}`,onMouseDown:F=>H(F,w)},w))})]})})},Kn=l.Image.extend({inline(){return!0},group(){return"inline"},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||null;return n==null?null:Number.parseInt(n,10)},renderHTML:t=>({width:t.width})}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!0,upload:null}},addNodeView(){return l.ReactNodeViewRenderer(Vn)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),updateImage:t=>({commands:n})=>n.updateAttributes(this.name,t)}},renderHTML({HTMLAttributes:e}){return["img",l.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]},parseHTML(){return[{tag:"img[src]"}]}}),ht=l.Root2$2,Fe=R.forwardRef(({className:e,...t},n)=>i.jsx(l.List$1,{ref:n,className:M("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Fe.displayName=l.List$1.displayName;const le=R.forwardRef(({className:e,...t},n)=>i.jsx(l.Trigger$3,{ref:n,className:M("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));le.displayName=l.Trigger$3.displayName;const se=R.forwardRef(({className:e,...t},n)=>i.jsx(l.Content,{ref:n,className:M("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));se.displayName=l.Content.displayName;const ie=new l.PluginKey("upload-image"),qn=()=>new l.Plugin({key:ie,state:{init(){return l.DecorationSet.empty},apply(e,t){t=t.map(e.mapping,e.doc);const n=e.getMeta(ie);if(n!=null&&n.add)for(const{id:o,pos:a,src:r}of n.add){const d=Wn(r),s=l.Decoration.widget(a,d,{id:o});t=t.add(e.doc,[s])}else if(n!=null&&n.remove)for(const o of n.remove)t=t.remove(t.find(void 0,void 0,a=>a.id===o));return t}},props:{decorations(e){return this.getState(e)}}});function Wn(e){const t=document.createElement("div"),n=document.createElement("img");return n.setAttribute("class","opacity-50"),n.src=e,n.addEventListener("load",()=>{t.setAttribute("class","img-placeholder")}),t.append(n),t}function Gn(e,t){var a;const o=ie.getState(e).find(void 0,void 0,r=>r.id===t);return o.length>0?(a=o[0])==null?void 0:a.from:null}const ft=({validateFn:e,onUpload:t})=>(n,o,a)=>{for(const r of n){if(e&&!e(r))continue;const d=Date.now().toString(),s=o.state.tr;s.selection.empty||s.deleteSelection();const c=URL.createObjectURL(r);s.setMeta(ie,{add:[{id:d,pos:a,src:c}]}),o.dispatch(s),t(r).then(u=>{var T;const{schema:h}=o.state,m=Gn(o.state,d);if(m===null)return;const g=typeof u=="object"?c:u,x=(T=h.nodes.image)==null?void 0:T.create({src:g});if(!x)return;const v=o.state.tr.replaceWith(m,m,x).setMeta(ie,{remove:[d]});o.dispatch(v)},()=>{const u=o.state.tr.delete(a,a).setMeta(ie,{remove:[d]});o.dispatch(u)})}},Xn=(e,t,n)=>{var a;const o=[...((a=t.clipboardData)==null?void 0:a.files)||[]];if(o.length>0){t.preventDefault();const r=e.state.selection.from;return n(o,e,r+1),!0}return!1},Zn=(e,t,n,o)=>{var r;const a=[...((r=t.dataTransfer)==null?void 0:r.files)||[]];if(!n&&a.length>0){t.preventDefault();const d=e.posAtCoords({left:t.clientX,top:t.clientY});if(d)return o(a,e,d.pos+1),!0}return!1},Yn=e=>{const{t}=A(),[n,o]=f.useState(""),a=f.useRef(null);function r(u){var v,T;const h=(v=u==null?void 0:u.target)==null?void 0:v.files;if(!e.editor||e.editor.isDestroyed||h.length===0)return;const m=h[0],g=(T=e.editor.extensionManager.extensions.find(H=>H.name==="imageUpload"))==null?void 0:T.options;ft({validateFn:()=>!0,onUpload:g.upload})([m],e.editor.view,e.getPos())}function d(u){u.preventDefault(),e.editor.chain().setImage({src:n}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run()}function s(u){u==null||u.preventDefault(),e.deleteNode()}function c(u){var h;u.preventDefault(),(h=a.current)==null||h.click()}return i.jsx(l.NodeViewWrapper,{className:"p-0 m-0","data-drag-handle":!0,children:i.jsxs(Q,{defaultOpen:!0,modal:!0,children:[i.jsx(ee,{asChild:!0,children:i.jsx("div",{className:"flex items-center w-full p-3 my-3 hover:bg-accent border border-border text-muted-foreground cursor-pointer rounded-sm transition-all",children:i.jsxs("div",{className:"flex justify-between items-center w-full",children:[i.jsxs("div",{className:"flex justify-center items-center gap-3",children:[i.jsx(p,{name:"ImageUp",className:"w-6 h-6"}),i.jsx("span",{className:"text-sm",children:t("editor.image.dialog.title")})]}),i.jsx(p,{name:"Trash2",className:"hover:text-foreground",onClick:s})]})})}),i.jsx(V,{className:"w-full",onOpenAutoFocus:u=>u.preventDefault(),children:i.jsxs(ht,{defaultValue:"upload",className:"w-[400px]",activationMode:"manual",children:[i.jsxs(Fe,{className:"grid w-full grid-cols-2",children:[i.jsxs(le,{value:"upload",children:[t("editor.image.dialog.tab.upload")," "]}),i.jsxs(le,{value:"link",children:[" ",t("editor.image.dialog.tab.url")," "]})]}),i.jsxs(se,{value:"upload",children:[i.jsx(O,{className:"w-full mt-1",size:"sm",onClick:c,children:t("editor.image.dialog.tab.upload")}),i.jsx("input",{type:"file",accept:"image/*",ref:a,multiple:!0,style:{display:"none"},onChange:r})]}),i.jsx(se,{value:"link",children:i.jsx("form",{onSubmit:d,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(G,{type:"url",autoFocus:!0,value:n,onChange:u=>o(u.target.value),required:!0,placeholder:t("editor.image.dialog.placeholder")}),i.jsx(O,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})})]})})},Jn={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5},Qn=l.Node.create({name:"imageUpload",isolating:!0,defining:!0,group:"block",draggable:!1,selectable:!0,inline:!1,onCreate(){if(typeof this.options.upload!="function")throw new TypeError("Image upload function should be a function")},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addCommands(){return{setImageUpload:()=>({commands:e})=>e.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return l.ReactNodeViewRenderer(Yn)},addOptions(){var e;return{...Jn,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:n,t:o})=>({component:b,componentProps:{action:()=>t.commands.setImageUpload(),upload:n.options.upload,disabled:!t.can().setImage({}),icon:"ImageUp",tooltip:o("editor.image.tooltip")}})}},addProseMirrorPlugins(){const t=ft({validateFn:n=>!(!this.options.acceptMimes.includes(n.type)||n.size>this.options.maxSize),onUpload:this.options.upload});return[new l.Plugin({props:{handlePaste:(n,o)=>!o.clipboardData||[...o.clipboardData.items||[]].some(r=>r.type==="text/html")?!1:Xn(n,o,t),handleDrop:(n,o,a,r)=>(!(o instanceof DragEvent)||!o.dataTransfer||Zn(n,o,r,t),!1)}}),qn()]}});function ei(e){return e=e.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/"),e=e.replace("https://vimeo.com/","https://player.vimeo.com/video/"),/^https?:\/\/www.bilibili.com\/video\/.*/i.test(e)&&(e=e.replace(/\?.*$/i,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),e.includes("drive.google.com")&&(e=e.replace("/view","/preview")),e}const ti=l.Node.create({name:"video",group:"block",atom:!0,draggable:!0,addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?ei(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:En(e)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"div[data-video] iframe"}]},renderHTML({HTMLAttributes:e}){const{width:t="100%"}=e??{},n={...e,width:"100%",height:"100%"},o=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`,a=`flex: 1;padding-bottom: ${9/16*100}%;`,s=["div",{style:o},["div",{style:a}],["iframe",n]];return["div",{...this.options.HTMLAttributes,"data-video":""},s]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}},addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,width:be["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"}}}}),ni=e=>{const{t}=A(),[n,o]=f.useState(""),[a,r]=f.useState(!1),d=f.useRef(null);function s(m){var T,H;r(!0);const g=(T=m==null?void 0:m.target)==null?void 0:T.files;if(!e.editor||e.editor.isDestroyed||g.length===0)return;const x=g[0],v=(H=e.editor.extensionManager.extensions.find(P=>P.name==="videoUpload"))==null?void 0:H.options;v==null||v.upload([x]).then(P=>{e.editor.chain().setVideo({src:P[0].src,width:"100%"}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run(),r(!1)})}function c(m){m.preventDefault(),e.editor.chain().setVideo({src:n,width:"100%"}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run()}function u(m){m.preventDefault(),e.deleteNode()}function h(m){var g;m.preventDefault(),(g=d.current)==null||g.click()}return i.jsx(l.NodeViewWrapper,{as:"div","data-drag-handle":!0,children:i.jsxs(Q,{defaultOpen:!0,modal:!0,children:[i.jsx(ee,{asChild:!0,children:i.jsx("div",{className:"flex items-center w-full p-3 my-3 hover:bg-accent border border-border text-muted-foreground cursor-pointer rounded-sm transition-all",children:a?i.jsxs("div",{className:"flex justify-center items-center gap-3 text-s",children:[i.jsx(p,{className:"animate-spin w-6 h-6",name:"LoaderCircle"}),i.jsxs("span",{children:[t("editor.video.dialog.uploading"),"..."]})]}):i.jsxs("div",{className:"flex justify-between items-center w-full",children:[i.jsxs("div",{className:"flex justify-center items-center gap-3",children:[i.jsx(p,{name:"Video",className:"w-6 h-6"}),i.jsx("span",{className:"text-sm",children:t("editor.video.dialog.title")})]}),i.jsx(p,{name:"Trash2",className:"hover:text-foreground",onClick:u})]})})}),i.jsx(V,{className:"w-full",onOpenAutoFocus:m=>m.preventDefault(),children:i.jsxs(ht,{defaultValue:"upload",className:"w-[400px]",activationMode:"manual",children:[i.jsxs(Fe,{className:"grid w-full grid-cols-2",children:[i.jsxs(le,{value:"upload",children:[t("editor.video.dialog.tab.upload")," "]}),i.jsxs(le,{value:"link",children:[" ",t("editor.video.dialog.link")," "]})]}),i.jsxs(se,{value:"upload",children:[i.jsx(O,{className:"w-full mt-1",size:"sm",onClick:h,children:t("editor.video.dialog.tab.upload")}),i.jsx("input",{type:"file",accept:"video/*",ref:d,multiple:!0,style:{display:"none"},onChange:s})]}),i.jsx(se,{value:"link",children:i.jsx("form",{onSubmit:c,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(G,{type:"url",autoFocus:!0,required:!0,placeholder:t("editor.video.dialog.placeholder"),value:n,onChange:m=>o(m.target.value)}),i.jsx(O,{type:"submit",children:t("editor.video.dialog.button.apply")})]})})})]})})]})})},ii=l.Node.create({name:"videoUpload",isolating:!0,defining:!0,group:"block",draggable:!0,selectable:!0,inline:!1,parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addCommands(){return{setVideoUpload:()=>({commands:e})=>e.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return l.ReactNodeViewRenderer(ni)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),upload:void 0,button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>t.commands.setVideoUpload(),isActive:()=>t.isActive("video")||!1,disabled:!t.can().setVideo({}),icon:"Video",tooltip:n("editor.video.tooltip")}})}}}),oi=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ai=/CrOS/,li=/android|ipad|playbook|silk/i;function Ge(e={}){let t=e.ua||typeof navigator<"u"&&navigator.userAgent;return t&&typeof t=="object"&&t.headers&&typeof t.headers["user-agent"]=="string"&&(t=t.headers["user-agent"]),typeof t!="string"?!1:!!(oi.test(t)&&!ai.test(t)||e.tablet&&li.test(t)||e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.includes("Macintosh")&&t.includes("Safari"))}const Xe=e=>Array.from({length:e}).map((t,n)=>n+1),si=e=>{var h;const[t,n]=f.useState(!0),[o,a]=f.useState({rows:Ge()?me:ue,cols:Ge()?me:ue}),[r,d]=f.useState({rows:he,cols:he});function s(m,g){m===o.rows&&a(x=>({...x,rows:Math.min(m+1,me)})),g===o.cols&&a(x=>({...x,cols:Math.min(g+1,me)})),d({rows:m,cols:g})}function c(m,g){e==null||e.createTable({rows:m,cols:g,withHeaderRow:t}),u()}function u(){n(!1),a({rows:ue,cols:ue}),d({rows:he,cols:he})}return i.jsxs(Q,{children:[i.jsx(ee,{asChild:!0,children:i.jsx("button",{disabled:e==null?void 0:e.disabled,className:"m-0 p-0",children:e==null?void 0:e.children})}),i.jsx(V,{className:"w-full !p-2",align:"start",side:"bottom",children:i.jsxs("div",{className:"table-grid-size-editor p-0",children:[i.jsx("div",{className:"flex flex-col flex-wrap gap-1 justify-between",children:(h=Xe(o==null?void 0:o.rows))==null?void 0:h.map(m=>{var g;return i.jsx("div",{className:"flex gap-1",children:(g=Xe(o==null?void 0:o.cols))==null?void 0:g.map(x=>i.jsx("div",{className:`pa-1 cursor-pointer border-border ${x<=r.cols&&m<=r.rows&&"bg-foreground"}`,onMouseOver:()=>s(m,x),onMouseDown:()=>c(m,x),children:i.jsx("div",{className:"w-4 h-4 p-1 border rounded-[2px] box-border border-solid"})},`c-${x}`))},`r-${m}`)})}),i.jsxs("div",{className:"text-center text-sm text-zinc-600 mt-2",children:[r.rows," x ",r.cols]})]})})]})},ri=e=>{function t(n){e.disabled||e.editor.chain().focus().insertTable({...n,withHeaderRow:!1}).run()}return i.jsx(si,{createTable:t,disabled:e==null?void 0:e.disabled,children:i.jsx("div",{className:"flex",children:i.jsx(b,{icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,color:e==null?void 0:e.color,action:e==null?void 0:e.action,isActive:e==null?void 0:e.isActive})})})},di=(e,t,n)=>{if(!e.doc)return e;const o=e.doc.nodeAt(t);if(!o||n===o.attrs.backgroundColor)return e;const a={...o.attrs,backgroundColor:n};return e.setNodeMarkup(t,o.type,a,o.marks)},ci=(e,t,n)=>{const{doc:o,selection:a}=e;return!o||!a||!(a instanceof l.CellSelection)||a.forEachCell((r,d)=>{e=di(e,d,n)}),e},Ze=(e,t)=>({tr:n,state:o,dispatch:a})=>{const{selection:r}=o;return n=n.setSelection(r),n=ci(n,t,e),n.docChanged?(a==null||a(n),!0):!1},ui=l.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:e=>e.style.backgroundColor||"",renderHTML:e=>!e.backgroundColor||e.backgroundColor===""?{}:{style:`background-color: ${e.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:e=>Ze(e,this.options),unsetTableCellBackground:()=>Ze("",this.options)}}}),mi=l.TableHeader.extend({addAttributes(){return{HTMLAttributes:{},colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(o=>Number.parseInt(o,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:e}=this.editor;return[new l.Plugin({props:{decorations:t=>{if(!e)return l.DecorationSet.empty;const{doc:n,selection:o}=t,a=[],r=xi(0)(o);return r&&r.forEach(({pos:d},s)=>{a.push(l.Decoration.widget(d+1,()=>{const c=fi(s)(o);let u="grip-column";c&&(u+=" selected"),s===0&&(u+=" first"),s===r.length-1&&(u+=" last");const h=document.createElement("a");return h.className=u,h.addEventListener("mousedown",m=>{m.preventDefault(),m.stopImmediatePropagation(),this.editor.view.dispatch(vi(s)(this.editor.state.tr))}),h}))}),l.DecorationSet.create(n,a)}}})]}}),hi=l.TableRow.extend({allowGapCursor:!1,content:"tableCell*"}),je=l.Table$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:t,t:n})=>({component:ri,componentProps:{disabled:t.isActive("table")||!1,icon:"Table",tooltip:n("editor.table.tooltip"),editor:t}})}},addProseMirrorPlugins(){return[...this.options.resizable?[l.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],l.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addExtensions(){return[hi.configure(this.options.tableRow),mi.configure(this.options.tableHeader),pi.configure(this.options.tableCell),ui.configure(this.options.tableCellBackground)]}}),Ie=e=>t=>{const n=l.TableMap.get(t.$anchorCell.node(-1)),o=t.$anchorCell.start(-1),a=n.cellsInRect(e),r=n.cellsInRect(n.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o));for(let d=0,s=a.length;d<s;d+=1)if(!r.includes(a[d]))return!1;return!0},Oe=e=>l.findParentNode(t=>t.type.spec.tableRole&&t.type.spec.tableRole==="table")(e),Pe=e=>e instanceof l.CellSelection,fi=e=>t=>{if(Pe(t)){const n=l.TableMap.get(t.$anchorCell.node(-1));return Ie({left:e,right:e+1,top:0,bottom:n.height})(t)}return!1},gi=e=>t=>{if(Pe(t)){const n=l.TableMap.get(t.$anchorCell.node(-1));return Ie({left:0,right:n.width,top:e,bottom:e+1})(t)}return!1},pe=e=>{if(Pe(e)){const t=l.TableMap.get(e.$anchorCell.node(-1));return Ie({left:0,right:t.width,top:0,bottom:t.height})(e)}return!1},bi=e=>t=>{const n=Oe(t);if(n){const o=l.TableMap.get(n.node);return(Array.isArray(e)?e:[e]).reduce((r,d)=>{if(d>=0&&d<=o.width-1){const s=o.cellsInRect({left:d,right:d+1,top:0,bottom:o.height});return r.concat(s.map(c=>{const u=n.node.nodeAt(c),h=c+n.start;return{pos:h,start:h+1,node:u}}))}return r},[])}return null},xi=e=>t=>{const n=Oe(t);if(n){const o=l.TableMap.get(n.node);return(Array.isArray(e)?e:[e]).reduce((r,d)=>{if(d>=0&&d<=o.height-1){const s=o.cellsInRect({left:0,right:o.width,top:d,bottom:d+1});return r.concat(s.map(c=>{const u=n.node.nodeAt(c),h=c+n.start;return{pos:h,start:h+1,node:u}}))}return r},[])}return null},gt=e=>t=>n=>{const o=Oe(n.selection),a=e==="row";if(o){const r=l.TableMap.get(o.node);if(t>=0&&t<(a?r.height:r.width)){const d=a?0:t,s=a?t:0,c=a?r.width:t+1,u=a?t+1:r.height,h=r.cellsInRect({left:d,top:s,right:a?c:d+1,bottom:a?s+1:u}),m=u-s===1?h:r.cellsInRect({left:a?d:c-1,top:a?u-1:s,right:c,bottom:u}),g=o.start+h[0],x=o.start+m.at(-1),v=n.doc.resolve(g),T=n.doc.resolve(x);return n.setSelection(new l.CellSelection(T,v))}}return n},vi=gt("column"),wi=gt("row"),ze=e=>{const t=e.state.selection;let n=0,o=0;return t.forEachCell(a=>{n++,(a.attrs.colspan>1||a.attrs.rowspan>1)&&o++}),{isRowSelection:t.isRowSelection(),isColSelection:t.isColSelection(),cellCount:n,mergedCellCount:o}},yi=({editor:e,view:t,state:n,from:o})=>{const a=t.domAtPos(o).node,d=t.nodeDOM(o)||a;if(!e.isActive(je.name)||!d)return!1;if(pe(n.selection))return!0;let s=d;for(;s&&!["TD","TH"].includes(s.tagName);)s=s.parentElement;if(s&&s.querySelector&&s.querySelector("a.grip-column.selected")||s&&s.querySelector&&s.querySelector("a.grip-row.selected"))return!1;const h=n.selection;if(h instanceof l.CellSelection){let m=0;return h.forEachCell(()=>{m++}),m>0}return!1},Ci=({editor:e,view:t,state:n,from:o})=>{const a=t.domAtPos(o).node,d=t.nodeDOM(o)||a;if(!e.isActive(je.name)||!d||pe(n.selection))return!1;let s=d;for(;s&&!["TD","TH"].includes(s.tagName);)s=s.parentElement;return!!(s&&s.querySelector&&s.querySelector("a.grip-column.selected"))},ji=({editor:e,view:t,state:n,from:o})=>{const a=t.domAtPos(o).node,d=t.nodeDOM(o)||a;if(!e.isActive(je.name)||!d||pe(n.selection))return!1;let s=d;for(;s&&!["TD","TH"].includes(s.tagName);)s=s.parentElement;return!!(s&&s.querySelector&&s.querySelector("a.grip-row.selected"))},pi=l.Node.create({name:"tableCell",content:"block+",tableRole:"cell",isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",l.mergeAttributes(this.options.HTMLAttributes,e),0]},addAttributes(){return{colspan:{default:1,parseHTML:e=>{const t=e.getAttribute("colspan");return t?Number.parseInt(t,10):1}},rowspan:{default:1,parseHTML:e=>{const t=e.getAttribute("rowspan");return t?Number.parseInt(t,10):1}},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?[Number.parseInt(t,10)]:null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:e}=this.editor;return[new l.Plugin({props:{decorations:t=>{if(!e)return l.DecorationSet.empty;const{doc:n,selection:o}=t,a=[],r=bi(0)(o);return r&&r.forEach(({pos:d},s)=>{a.push(l.Decoration.widget(d+1,()=>{const c=gi(s)(o);let u="grip-row";c&&(u+=" selected"),s===0&&(u+=" first"),s===r.length-1&&(u+=" last");const h=document.createElement("a");return h.className=u,h.addEventListener("mousedown",m=>{m.preventDefault(),m.stopImmediatePropagation(),this.editor.view.dispatch(wi(s)(this.editor.state.tr))}),h}))}),l.DecorationSet.create(n,a)}}})]}}),ki=l.Extension.create({name:"painter",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:n})=>({component:b,componentProps:{action:()=>{t.commands.setPainter(t==null?void 0:t.state.selection.$head.marks())},icon:"PaintRoller",tooltip:n("editor.format")}})}},addCommands(){return{setPainter:e=>({view:{dispatch:t,state:{tr:n},dom:o}})=>{const d=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#000" d="M9 22v-6H4V7q0-1.65 1.175-2.825T8 3h12v13h-5v6zM6 10h12V5h-1v4h-2V5h-1v2h-2V5H8q-.825 0-1.412.588T6 7zm0 4h12v-2H6zm0 0v-2z"/></svg>')}"), auto`;return o.style.cursor=d,t(n.setMeta("painterAction",{type:"start",marks:e})),!0}}},addProseMirrorPlugins(){return[new l.Plugin({key:new l.PluginKey("format-painter"),state:{init:()=>[],apply:(e,t)=>{const n=e.getMeta("painterAction");return n&&n.type==="start"?t=n.marks:n&&n.type==="end"&&(t=[]),t}},props:{handleDOMEvents:{mousedown(e,t){const n=this.getState(e.state);if(!n||n.length===0)return e.dom.style.cursor="",!1;const o=()=>{document.removeEventListener("mouseup",o);let{dispatch:a,state:{tr:r,selection:d},dom:s}=e;s.style.cursor="",r=r.removeMark(d.from,d.to);for(const c of n)c.type.name!="link"&&(r=r.addMark(d.from,d.to,c));a(r.setMeta("painterAction",{type:"end"}))};return document.addEventListener("mouseup",o),!0}}}})]}}),ae={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:["v.youku.com\\/v_show\\/id_\\w+\\=*"],idRule:"id_\\w+\\=*"},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:["www.bilibili.com\\/video\\/\\w+"]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:["v.qq.com\\/x\\/cover\\/\\w+\\/\\w+"]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:["\\.amap\\.com"]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:["map\\.baidu\\.com"]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:["https:\\/\\/\\w+.modao.cc\\/app\\/\\w+\\/embed\\/v2"],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:["https:\\/\\/lanhuapp.com\\/url\\/\\w+"],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:["https:\\/\\/www.figma.com\\/file\\/\\w+"]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:["https:\\/\\/www.canva.cn\\/design\\/.+\\/view"]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:["https:\\/\\/www.processon.com\\/embed\\/\\w+"]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:["https:\\/\\/codepen.io\\/.+\\/embed\\/\\w+"]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:["https:\\/\\/jinshuju.net\\/f\\/\\w+"]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:["https:\\/\\/goo.gl\\/maps\\/\\w+"]}};function Ni(e,t){const n=ae.youtube,o=t.matchedUrl;t.validLink=!0;const a=o.split("="),r=a.length;if(r>0){const d=a[r-1];t.src=`${n.srcPrefix}/${d}`,t.validId=!0}return t}function Li(e,t){const n=ae.youku,o=t.matchedUrl,a=n.idRule,r=new RegExp(a),d=o.match(r);if(d&&d.length>0){const s=d[0].slice(3);t.validId=!0,t.src=`${n.srcPrefix}/${s}`}else t.validId=!1;return t}function Si(e,t){const n=ae.bilibili,a=t.matchedUrl.split("/"),r=a.length;if(r>0){const d=a[r-1];t.src=`${n.srcPrefix}=${d}`,t.validId=!0}return t}function Ti(e,t){const n=ae.qqvideo,a=t.matchedUrl.split("/"),r=a.length;if(r>0){const d=a[r-1];t.src=`${n.srcPrefix}=${d}`,t.validId=!0}return t}function Mi(e,t){return t.src=e,t.validId=!0,t}function Ai(e,t){return t.src=e,t.validId=!0,t}function Ri(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function Di(e,t){return t.src=t.matchedUrl,t.validId=!0,t.originalLink=t.src,t}function Hi(e,t){return t.src=t.matchedUrl,t.validId=!0,t.originalLink=t.src,t}function Fi(e,t){const n=ae.figma;return t.src=`${n.srcPrefix}=${encodeURIComponent(t.matchedUrl)}`,t.validId=!0,t.originalLink=t.matchedUrl,t}function Ii(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function Oi(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function Pi(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=t.src,t}function zi(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function Bi(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function Ei(e,t,n){if(e==="googlemaps")return n.validLink=!0,n.matchedUrl=t,n;const a=ae[e].linkRule;for(const r of a){const d=new RegExp(r),s=t.match(d);if(s&&s.length>0)return n.validLink=!0,n.matchedUrl=e==="youtube"?s[1]:s[0],n}return n}const _i=e=>{var n,o;let t="iframe";return((n=e.includes)!=null&&n.call(e,"youtube")||(o=e.includes)!=null&&o.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t},$i=e=>{let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const n=_i(e);if(t=Ei(n,e,t),!t.validLink)return t;switch(n){case"youtube":return Ni(e,t);case"youku":return Li(e,t);case"bilibili":return Si(e,t);case"qqvideo":return Ti(e,t);case"amap":return Mi(e,t);case"baidu_map":return Ai(e,t);case"googlemaps":return Ri(e,t);case"modao":return Di(e,t);case"lanhu":return Hi(e,t);case"figma":return Fi(e,t);case"canva":return Ii(e,t);case"processon":return Oi(e,t);case"codepen":return Pi(e,t);case"jinshuju":return zi(e,t);case"iframe":return Bi(e,t)}return t},Ui=e=>{var a,r,d,s,c,u,h,m;const[t,n]=f.useState("");function o(){if(!t)return;const g=$i(t);g.validLink&&g.validId&&e.updateAttributes({src:g.src})}return i.jsx(i.Fragment,{children:i.jsxs(l.NodeViewWrapper,{as:"section",children:[!((r=(a=e==null?void 0:e.node)==null?void 0:a.attrs)!=null&&r.src)&&i.jsxs("div",{className:"max-w-[600px] mx-[auto] my-[12px] flex items-center justify-center gap-[10px] p-[10px] border-[1px] border-solid border-[#ccc] rounded-[12px]",children:[i.jsx(G,{value:t,onInput:g=>n(g.target.value),type:"url",className:"flex-1",autoFocus:!0,placeholder:"Enter link"}),i.jsx(O,{className:"w-[60px]",onClick:o,children:"OK"})]}),((s=(d=e==null?void 0:e.node)==null?void 0:d.attrs)==null?void 0:s.src)&&i.jsx("iframe",{src:(u=(c=e==null?void 0:e.node)==null?void 0:c.attrs)==null?void 0:u.src,frameBorder:"0",allowFullScreen:!0,title:(m=(h=e==null?void 0:e.node)==null?void 0:h.attrs)==null?void 0:m.src,className:"my-[12px]"})]})})},Vi=l.Node.create({name:"iframes",group:"block",atom:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"},button:({editor:t,extension:n,t:o})=>({component:b,componentProps:{action:a=>t.commands.setIframe(a),upload:n.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:o("editor.iframe.tooltip")}})}},addAttributes(){return{src:{default:null},service:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["div",this.options.HTMLAttributes,["iframe",e]]},addNodeView(){return l.ReactNodeViewRenderer(Ui)},addCommands(){return{setIframe:e=>({tr:t,dispatch:n})=>{const{selection:o}=t,a=this.type.create(e);return n&&t.replaceRangeWith(o.from,o.to,a),!0}}}}),Ki=e=>{const{t}=A();return i.jsxs("div",{className:"flex items-center gap-2 p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:[i.jsx("a",{href:e==null?void 0:e.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline break-all",children:l.truncate(e==null?void 0:e.link,{length:50,omission:"…"})}),(e==null?void 0:e.link)&&i.jsx(X,{orientation:"vertical",className:"h-4"}),i.jsxs("div",{className:"flex flex-nowrap",children:[i.jsx(b,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),action:()=>{e==null||e.onEdit()},tooltipOptions:{sideOffset:15}}),i.jsx(b,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),action:()=>{e==null||e.onClear()},tooltipOptions:{sideOffset:15}})]})]})},qi=e=>{const[t,n]=f.useState(!1),o=f.useMemo(()=>{const{href:s}=e.editor.getAttributes("link");return s},[e]),a=f.useCallback(({editor:s})=>s.isActive("link"),[]),r=(s,c,u)=>{e.editor.chain().extendMarkRange("link").insertContent({type:"text",text:c,marks:[{type:"link",attrs:{href:s,target:u?"_blank":""}}]}).setLink({href:s}).focus().run(),n(!1)},d=f.useCallback(()=>{e.editor.chain().extendMarkRange("link").unsetLink().focus().run(),n(!1)},[e.editor]);return i.jsx(i.Fragment,{children:i.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:a,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{n(!1)}},children:e!=null&&e.disabled?i.jsx(i.Fragment,{}):i.jsx(i.Fragment,{children:t?i.jsx(ct,{onSetLink:r,editor:e==null?void 0:e.editor}):i.jsx(Ki,{editor:e==null?void 0:e.editor,onClear:d,onEdit:()=>{n(!0)},link:o})})})})},Wi=e=>{const t=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return t.map((o,a)=>({type:`image-${o}`,component:b,componentProps:{tooltip:S.t(`editor.${o.replace("-",".")}.tooltip`),icon:n[a],action:()=>e.commands.updateImage({width:Te[o]}),isActive:()=>e.isActive("image",{width:Te[o]})}}))},Gi=e=>{const t=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map((o,a)=>({type:`image-${o}`,component:b,componentProps:{tooltip:S.t(`editor.textalign.${o}.tooltip`),icon:n[o],action:()=>e.commands.setTextAlign(o),isActive:()=>e.isActive({textAlign:o})||!1,disabled:!e.can().setTextAlign(o)}}))},Xi=e=>{const t=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return t.map((o,a)=>({type:`video-${o}`,component:b,componentProps:{tooltip:S.t(`editor.${o.replace("-",".")}.tooltip`),icon:n[a],action:()=>e.commands.updateVideo({width:be[o]}),isActive:()=>e.isActive("video",{width:be[o]})}}))},Zi=e=>[...Wi(e),...Gi(e),{type:"remove",component:b,componentProps:{editor:e,tooltip:S.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;l.deleteSelection(t,n)}}}],Yi=e=>[...Xi(e),{type:"remove",component:b,componentProps:{editor:e,tooltip:S.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;l.deleteSelection(t,n)}}}],Ji=(e,t)=>[Je.configure().options.button({editor:e,t}),Qe.configure().options.button({editor:e,t}),et.configure().options.button({editor:e,t}),tt.configure().options.button({editor:e,t}),nt.configure().options.button({editor:e,t}),ut.configure().options.button({editor:e,t}),{type:"divider",component:void 0,componentProps:{}},st.configure().options.button({editor:e,t}),rt.configure().options.button({editor:e,t})],bt={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"},xt=({item:e,disabled:t,editor:n})=>{var a;const o=e.component;return o?i.jsx(f.Fragment,{children:e.type==="divider"?i.jsx(X,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"}):i.jsx(i.Fragment,{children:i.jsx(o,{...e.componentProps,editor:n,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})})}):i.jsx(i.Fragment,{})},Qi=e=>e.type.name==="image",eo=e=>e.type.name==="video",to=e=>{const{lang:t}=A(),n=({editor:a})=>{const{selection:r}=a.view.state,{$from:d,to:s}=r;let c=!1;return a.view.state.doc.nodesBetween(d.pos,s,u=>{if(Qi(u))return c=!0,!1}),c},o=f.useMemo(()=>e.disabled?[]:Zi(e.editor),[e.disabled,e.editor,t]);return i.jsx(i.Fragment,{children:i.jsx(l.BubbleMenu,{shouldShow:n,editor:e==null?void 0:e.editor,tippyOptions:bt,children:o!=null&&o.length?i.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:i.jsx("div",{className:"flex items-center flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:o==null?void 0:o.map((a,r)=>i.jsx(xt,{item:a,disabled:e.disabled,editor:e.editor},`bubbleMenu-image-${r}`))})}):i.jsx(i.Fragment,{})})})},no=e=>{const{lang:t}=A(),n=({editor:a})=>{const{selection:r}=a.view.state,{$from:d,to:s}=r;let c=!1;return a.view.state.doc.nodesBetween(d.pos,s,u=>{if(eo(u))return c=!0,!1}),c},o=f.useMemo(()=>e.disabled?[]:Yi(e.editor),[e.editor,e.disabled,t]);return i.jsx(i.Fragment,{children:i.jsx(l.BubbleMenu,{shouldShow:n,editor:e==null?void 0:e.editor,tippyOptions:bt,children:o!=null&&o.length?i.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:i.jsx("div",{className:"flex items-center flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:o==null?void 0:o.map((a,r)=>i.jsx(xt,{item:a,disabled:e.disabled,editor:e.editor},`bubbleMenu-video-${r}`))})}):i.jsx(i.Fragment,{})})})},io={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"},oo=({item:e,disabled:t,editor:n})=>{var a;const o=e.component;return o?i.jsx(f.Fragment,{children:i.jsx(o,{...e.componentProps,editor:n,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})}):i.jsx(i.Fragment,{})},ao=e=>{const{t,lang:n}=A(),o=({editor:r})=>{const{selection:d}=r.view.state,{$from:s,to:c}=d;return s.pos===c?!1:d instanceof l.TextSelection},a=f.useMemo(()=>e.disabled||!(e!=null&&e.editor)?[]:Ji(e.editor,t),[e.disabled,e.editor,n,t]);return i.jsx(i.Fragment,{children:i.jsx(l.BubbleMenu,{shouldShow:o,editor:e==null?void 0:e.editor,tippyOptions:io,children:a!=null&&a.length?i.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:i.jsx("div",{className:"flex items-center gap-[4px] flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:a==null?void 0:a.map((r,d)=>(r==null?void 0:r.type)==="divider"?i.jsx(X,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"},`bubbleMenu-divider-${d}`):i.jsx(oo,{item:r,disabled:e.disabled,editor:e.editor},`bubbleMenu-text-${d}`))})}):i.jsx(i.Fragment,{})})})},lo=e=>{var L,z;const{t}=A(),[n,o]=f.useState(null),[a,r]=f.useState(-1),d=f.useRef(null),s=f.useRef(null),[c,u]=f.useState(!1);f.useEffect(()=>{d.current&&!e.editor.isDestroyed&&(s.current=l.DragHandlePlugin({editor:e.editor,element:d.current,pluginKey:"ContentItemMenu",tippyOptions:{offset:[-2,16],zIndex:99,moveTransition:"transform 0.15s ease-out"},onNodeChange:h}),e.editor.registerPlugin(s.current))},[e.editor,d]);function h(k){k.node&&o(k.node),r(k.pos)}function m(){const k=e.editor.chain();k.setNodeSelection(a).unsetAllMarks(),(n==null?void 0:n.type.name)!=="paragraph"&&k.setParagraph(),k.run()}function g(){e.editor.chain().focus().setNodeSelection(a).run(),document.execCommand("copy")}function x(){e.editor.commands.setNodeSelection(a);const{$anchor:k}=e.editor.state.selection,w=k.node(1)||e.editor.state.selection.node;e.editor.chain().setMeta("hideDragHandle",!0).insertContentAt(a+((n==null?void 0:n.nodeSize)||0),w.toJSON()).run()}function v(k){e.editor.commands.setTextAlign(k)}function T(){const k=Ae(e.editor.state.tr,a,1);k.setMeta("hideDragHandle",!0),e.editor.view.dispatch&&e.editor.view.dispatch(k)}function H(){const k=Ae(e.editor.state.tr,a,-1);e.editor.view.dispatch&&e.editor.view.dispatch(k)}function P(){e.editor.chain().setMeta("hideDragHandle",!0).setNodeSelection(a).deleteSelection().run()}const y=k=>{u(k)};f.useEffect(()=>{c?e.editor.commands.setMeta("lockDragHandle",!0):e.editor.commands.setMeta("lockDragHandle",!1)},[c]),f.useEffect(()=>()=>{s.current&&(e.editor.unregisterPlugin(s.current),s.current=null)},[]);function C(){var k;if(a!==-1){const w=(n==null?void 0:n.nodeSize)||0,F=a+w,I=(n==null?void 0:n.type.name)==="paragraph"&&((k=n==null?void 0:n.content)==null?void 0:k.size)===0,_=I?a+2:F+2;e.editor.chain().command(({dispatch:$,tr:N,state:D})=>$?(I?N.insertText("/",a,a+1):N.insert(F,D.schema.nodes.paragraph.create(null,[D.schema.text("/")])),$(N)):!0).focus(_).run()}}return i.jsx(i.Fragment,{children:i.jsx("div",{className:"[transition-property:top,_left] ease-in-out duration-200 "+(e==null?void 0:e.className),style:{opacity:e!=null&&e.disabled?0:1},ref:d,children:i.jsxs("div",{className:"flex items-center gap-0.5 [transition-property:top,_left] ease-in-out duration-200",children:[i.jsx(O,{variant:"ghost",size:"icon",className:"w-7 h-7 cursor-grab",disabled:e==null?void 0:e.disabled,onClick:C,children:i.jsx(p,{name:"Plus",className:"text-lg text-neutral-600 dark:text-neutral-200"})}),i.jsxs(Z,{open:c,onOpenChange:y,children:[i.jsx(Y,{disabled:e==null?void 0:e.disabled,children:i.jsxs(de,{children:[i.jsx(ce,{asChild:!0,disabled:e==null?void 0:e.disabled,children:i.jsx(O,{variant:"ghost",size:"icon",className:"w-7 h-7 cursor-grab",disabled:e==null?void 0:e.disabled,children:i.jsx(p,{name:"Grip",className:"text-sm dark:text-neutral-200 text-neutral-600"})})}),i.jsx(oe,{children:i.jsx("p",{children:t("editor.draghandle.tooltip")})})]})}),i.jsxs(U,{className:"w-48",align:"start",side:"bottom",sideOffset:0,children:[i.jsxs(E,{onClick:P,className:"flex gap-3 focus:text-red-500 focus:bg-red-400 hover:bg-red-400 dark:hover:text-red-500 bg-opacity-10 hover:bg-opacity-20 focus:bg-opacity-30 dark:hover:bg-opacity-20",children:[i.jsx(p,{name:"Trash2"}),i.jsx("span",{children:t("editor.remove")})]}),i.jsxs(E,{className:"flex gap-3",onClick:m,children:[i.jsx(p,{name:"PaintRoller"}),i.jsx("span",{children:t("editor.clear.tooltip")})]}),i.jsxs(E,{className:"flex gap-3",onClick:g,children:[i.jsx(p,{name:"Clipboard"}),i.jsx("span",{children:t("editor.copyToClipboard")})]}),i.jsxs(E,{className:"flex gap-3",onClick:x,children:[i.jsx(p,{name:"Copy"}),i.jsx("span",{children:t("editor.copy")})]}),i.jsx(ye,{}),i.jsxs($e,{children:[i.jsxs(Le,{className:"flex gap-3",children:[i.jsx(p,{name:"AlignCenter"}),i.jsx("span",{children:t("editor.textalign.tooltip")})]}),i.jsx(_e,{children:i.jsxs(Se,{children:[i.jsxs(E,{className:"flex gap-3",onClick:()=>v("left"),children:[i.jsx(p,{name:"AlignLeft"}),i.jsx("span",{children:t("editor.textalign.left.tooltip")})]}),i.jsxs(E,{className:"flex gap-3",onClick:()=>v("center"),children:[i.jsx(p,{name:"AlignCenter"}),i.jsx("span",{children:t("editor.textalign.center.tooltip")})]}),i.jsxs(E,{className:"flex gap-3",onClick:()=>v("right"),children:[i.jsx(p,{name:"AlignRight"}),i.jsx("span",{children:t("editor.textalign.right.tooltip")})]})]})})]}),i.jsxs($e,{children:[i.jsxs(Le,{className:"flex gap-3",children:[i.jsx(p,{name:"IndentIncrease"}),i.jsx("span",{children:t("editor.indent")})]}),i.jsx(_e,{children:i.jsxs(Se,{children:[i.jsxs(E,{className:"flex gap-3",onClick:T,disabled:((L=n==null?void 0:n.attrs)==null?void 0:L.indent)>=W.max,children:[i.jsx(p,{name:"IndentIncrease"}),i.jsx("span",{children:t("editor.indent.tooltip")})]}),i.jsxs(E,{className:"flex gap-3",onClick:H,disabled:((z=n==null?void 0:n.attrs)==null?void 0:z.indent)<=W.min,children:[i.jsx(p,{name:"IndentDecrease"}),i.jsx("span",{children:t("editor.outdent.tooltip")})]})]})})]})]})]})]})})})},so=({editor:e,disabled:t})=>{const{t:n,lang:o}=A(),a=f.useMemo(()=>{const d=[...e.extensionManager.extensions].sort((c,u)=>{const h=c.options.sort??-1,m=u.options.sort??-1;return h-m});let s=[];for(const c of d){const{button:u,divider:h=!1,spacer:m=!1,toolbar:g=!0}=c.options;if(!u||!$n(u)||!g)continue;const x=u({editor:e,extension:c,t:n});if(Array.isArray(x)){const v=x.map((T,H)=>({button:T,divider:H===x.length-1?h:!1,spacer:H===0?m:!1}));s=[...s,...v];continue}s.push({button:x,divider:h,spacer:m})}return s},[e,n,o]);return i.jsx("div",{className:"border-b py-2 px-1",style:{pointerEvents:t?"none":"auto",opacity:t?.5:1},children:i.jsx("div",{className:"flex flex-wrap h-auto relative gap-y-1 gap-x-1",children:a.map((r,d)=>{var c,u;const s=r.button.component;return i.jsxs("div",{className:"flex items-center",children:[(r==null?void 0:r.spacer)&&i.jsx(X,{orientation:"vertical",className:"h-[16px] mx-[10px]"}),i.jsx(s,{...r.button.componentProps,disabled:t||((u=(c=r==null?void 0:r.button)==null?void 0:c.componentProps)==null?void 0:u.disabled)}),(r==null?void 0:r.divider)&&i.jsx(X,{orientation:"vertical",className:"h-auto mx-2"})]},d)})})})},ro=(e,t)=>{const{view:n,state:{selection:{from:o}}}=e,a=document.querySelectorAll(".has-focus"),r=a.length,s=a[r-1];if(s&&s.dataset.type&&s.dataset.type===t||s&&s.classList&&s.classList.contains(t))return s;const c=n.domAtPos(o).node;let u=c;for(u.tagName||(u=c.parentElement);u&&!(u.dataset.type&&u.dataset.type===t)&&!u.classList.contains(t);)u=u.parentElement;return u},co=({editor:e})=>l.isActive(e.view.state,"columns"),uo=e=>{const t=()=>{const r=ro(e.editor,"columns");return(r==null?void 0:r.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},n=()=>{e.editor.chain().focus().setLayout(q.SidebarLeft).run()},o=()=>{e.editor.chain().focus().setLayout(q.SidebarRight).run()},a=()=>{e.editor.chain().focus().setLayout(q.TwoColumn).run()};return i.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,pluginKey:"columns",shouldShow:co,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,plugins:[l.sticky],sticky:"popper"},children:i.jsx("div",{className:"p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:i.jsxs("div",{className:"flex gap-1 items-center",children:[i.jsx(b,{title:"ok",icon:"PanelLeft",tooltip:"Left Sidebar",action:n,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:q.SidebarLeft}),tooltipOptions:{sideOffset:15}}),i.jsx(b,{title:"ok",icon:"Columns",tooltip:"Two-column layout",action:a,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:q.TwoColumn}),tooltipOptions:{sideOffset:15}}),i.jsx(b,{title:"ok",icon:"PanelRight",tooltip:"Right Sidebar",action:o,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:q.SidebarRight}),tooltipOptions:{sideOffset:15}})]})})})},mo=e=>{const{t}=A(),n=({view:a,state:r,from:d})=>r?yi({editor:e.editor,view:a,state:r,from:d||0}):!1,o=f.useMemo(()=>e.editor.state.selection instanceof l.CellSelection?ze(e.editor):null,[e]);return i.jsx(l.BubbleMenu,{editor:e.editor,pluginKey:"tableCellMenu",updateDelay:0,shouldShow:n,tippyOptions:{appendTo:"parent",offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},children:i.jsxs("div",{className:"flex flex-row h-full leading-none gap-0.5 p-2 bg-background rounded-lg shadow-sm border border-border",children:[(o==null?void 0:o.cellCount)>1&&i.jsx(b,{tooltip:t("editor.table.mergeCells"),icon:"TableCellsMerge",action:e==null?void 0:e.onMergeCell,"tooltip-options":{sideOffset:15}}),(o==null?void 0:o.mergedCellCount)>0&&i.jsx(b,{tooltip:t("editor.table.splitCells"),icon:"TableCellsSplit",action:e==null?void 0:e.onSplitCell,tooltipOptions:{sideOffset:15}}),pe(e.editor.state.selection)&&i.jsx(b,{tooltip:t("editor.table.delete"),icon:"Trash2",action:e==null?void 0:e.onDeleteTable,tooltipOptions:{sideOffset:15}}),i.jsx(Ce,{editor:e==null?void 0:e.editor,tooltip:t("editor.table.setCellsBgColor"),action:a=>e==null?void 0:e.onSetCellBackground(a),tooltipOptions:{sideOffset:15}})]})})},ho=e=>{const{t}=A(),n=({view:s,state:c,from:u})=>c?Ci({editor:e.editor,view:s,state:c,from:u||0}):!1,o=f.useMemo(()=>e.editor.state.selection instanceof l.CellSelection?ze(e.editor):null,[e]);function a(){e.editor.chain().focus().addColumnBefore().run()}function r(){e.editor.chain().focus().addColumnAfter().run()}function d(){e.editor.chain().focus().deleteColumn().run()}return i.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,pluginKey:"tableColumnMenu",updateDelay:0,shouldShow:n,tippyOptions:{appendTo:"parent",offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},children:i.jsxs("div",{className:"min-w-32 flex flex-row h-full leading-none gap-0.5 p-2 bg-background rounded-lg shadow-sm border border-border",children:[i.jsx(b,{icon:"BetweenHorizonalEnd",action:a,tooltip:t("editor.table.insertColumnLeft"),tooltipOptions:{sideOffset:15}}),i.jsx(b,{icon:"BetweenHorizonalStart",action:r,tooltip:t("editor.table.insertColumnRight"),tooltipOptions:{sideOffset:15}}),i.jsx(b,{icon:"Trash2",action:d,tooltip:t("editor.table.deleteColumn"),tooltipOptions:{sideOffset:15}}),(o==null?void 0:o.cellCount)>1&&i.jsx(b,{icon:"TableCellsMerge",action:e==null?void 0:e.onMergeCell,tooltip:t("editor.table.mergeCells"),tooltipOptions:{sideOffset:15}}),(o==null?void 0:o.mergedCellCount)>0&&i.jsx(b,{icon:"TableCellsSplit",action:e==null?void 0:e.onSplitCell,tooltip:t("editor.table.splitCells"),tooltipOptions:{sideOffset:15}}),i.jsx(Ce,{editor:"editor",tooltip:t("editor.table.setCellsBgColor"),action:s=>e==null?void 0:e.onSetCellBackground(s),tooltipOptions:{sideOffset:15}})]})})},fo=e=>{const{t}=A(),n=({view:s,state:c,from:u})=>c?ji({editor:e.editor,view:s,state:c,from:u||0}):!1,o=f.useMemo(()=>e.editor.state.selection instanceof l.CellSelection?ze(e.editor):null,[e]);function a(){e.editor.chain().focus().addRowBefore().run()}function r(){e.editor.chain().focus().addRowAfter().run()}function d(){e.editor.chain().focus().deleteRow().run()}return i.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,pluginKey:"tableRowMenu",updateDelay:0,shouldShow:n,tippyOptions:{appendTo:"parent",placement:"left",offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},children:i.jsxs("div",{className:"flex flex-col h-full leading-none gap-0.5 p-2 bg-background rounded-lg shadow-sm border border-border",children:[i.jsx(b,{icon:"BetweenVerticalEnd",action:a,tooltip:t("editor.table.insertRowAbove"),tooltipOptions:{sideOffset:15,side:"right"}}),i.jsx(b,{icon:"BetweenVerticalStart",action:r,tooltip:t("editor.table.insertRowBelow"),tooltipOptions:{sideOffset:15,side:"right"}}),i.jsx(b,{icon:"Trash2",action:d,tooltip:t("editor.table.deleteRow"),tooltipOptions:{sideOffset:15,side:"right"}}),(o==null?void 0:o.cellCount)>1&&i.jsx(b,{icon:"TableCellsMerge",action:e==null?void 0:e.onMergeCell,tooltip:t("editor.table.mergeCells"),tooltipOptions:{sideOffset:15,side:"right"}}),(o==null?void 0:o.mergedCellCount)>0&&i.jsx(b,{icon:"TableCellsSplit",action:e==null?void 0:e.onSplitCell,tooltip:t("editor.table.splitCells"),tooltipOptions:{sideOffset:15,side:"right"}}),i.jsx(Ce,{editor:e==null?void 0:e.editor,tooltip:t("editor.table.setCellsBgColor"),action:s=>e==null?void 0:e.onSetCellBackground(s),tooltipOptions:{sideOffset:15,side:"right"}})]})})},go=e=>{function t(){e.editor.chain().focus().deleteTable().run()}function n(r){e.editor.chain().focus().setTableCellBackground(r).run()}function o(){e.editor.chain().focus().mergeCells().run()}function a(){const r=[];e.editor.state.selection.forEachCell((s,c)=>{(s.attrs.colspan>1||s.attrs.rowspan>1)&&r.push(c)});let d=e.editor.chain();r.sort((s,c)=>c-s).forEach(s=>{d=d.setCellSelection({anchorCell:s}).splitCell()}),d.run()}return i.jsxs(i.Fragment,{children:[i.jsx(mo,{editor:e==null?void 0:e.editor,onDeleteTable:t,onSplitCell:a,onMergeCell:o,onSetCellBackground:n}),i.jsx(ho,{editor:e==null?void 0:e.editor,onSplitCell:a,onMergeCell:o,onSetCellBackground:n}),i.jsx(fo,{editor:e==null?void 0:e.editor,onSplitCell:a,onMergeCell:o,onSetCellBackground:n})]})},bo=l.proxy({theme:"light"}),xo={setTheme:e=>{bo.theme=e}};function vo(e,t){const{content:n,extensions:o,useEditorOptions:a={}}=e,{t:r}=A(),d=f.useMemo(()=>{const m=l.differenceBy(o,o,"name");return[...o.map(x=>{const v=o.find(T=>T.name===x.name);return v?x.configure(v.options):x}),...m].map((x,v)=>x.configure({sort:v}))},[o]),s=l.useEditor({extensions:d,content:n,onUpdate:({editor:m})=>{u(m)},...a});f.useEffect(()=>{document.body.classList.toggle("dark",e.dark),xo.setTheme(e.dark?"dark":"light")},[e.dark]),f.useEffect(()=>{s==null||s.setEditable(!(e!=null&&e.disabled))},[s,e==null?void 0:e.disabled]);function c(m,g){return e!=null&&e.removeDefaultWrapper?g==="html"?m.isEmpty?"":m.getHTML():g==="json"?m.isEmpty?{}:m.getJSON():g==="text"?m.isEmpty?"":m.getText():"":g==="html"?m.getHTML():g==="json"?m.getJSON():g==="text"?m.getText():""}const u=l.throttle(m=>{var x;const g=c(m,e.output);(x=e==null?void 0:e.onChangeContent)==null||x.call(e,g)},Ot);f.useImperativeHandle(t,()=>({editor:s})),f.useEffect(()=>()=>{var m;(m=s==null?void 0:s.destroy)==null||m.call(s)},[]);const h=Un(s,"characterCount");return s?i.jsx(Mt,{delayDuration:0,children:i.jsxs("div",{className:"reactjs-tiptap-editor rounded-[0.5rem] bg-background shadow overflow-hidden outline outline-1",children:[!(e!=null&&e.hideBubble)&&i.jsxs(i.Fragment,{children:[i.jsx(uo,{editor:s}),i.jsx(go,{editor:s}),i.jsx(lo,{editor:s,disabled:e==null?void 0:e.disabled}),i.jsx(qi,{editor:s,disabled:e==null?void 0:e.disabled}),i.jsx(ao,{editor:s,disabled:e==null?void 0:e.disabled}),i.jsx(to,{editor:s,disabled:e==null?void 0:e.disabled}),i.jsx(no,{editor:s,disabled:e==null?void 0:e.disabled})]}),i.jsxs("div",{className:"flex flex-col w-full max-h-full",children:[!(e!=null&&e.hideToolbar)&&i.jsx(so,{editor:s,disabled:e==null?void 0:e.disabled}),i.jsx(l.EditorContent,{className:`relative ${(e==null?void 0:e.contentClass)||""}`,editor:s}),i.jsx("div",{className:"flex justify-between border-t p-3 items-center",children:h&&i.jsx("div",{className:"flex flex-col",children:i.jsx("div",{className:"flex justify-end gap-3 text-sm",children:i.jsxs("span",{children:[s.storage.characterCount.characters()," ",r("editor.characters")]})})})})]})]})}):i.jsx(i.Fragment,{})}const wo=f.forwardRef(vo);exports.BaseKit=pn;exports.Blockquote=dn;exports.Bold=Je;exports.BulletList=an;exports.Clear=ln;exports.Code=nt;exports.CodeBlock=At;exports.Color=st;exports.ColumnToolbar=vn;exports.Columns=mt;exports.FontFamily=Wt;exports.FontSize=Qt;exports.FormatPainter=ki;exports.Heading=Xt;exports.Highlight=rt;exports.History=gn;exports.HorizontalRule=mn;exports.Iframe=Vi;exports.Image=Kn;exports.ImageUpload=Qn;exports.Indent=Mn;exports.Italic=Qe;exports.LineHeight=In;exports.Link=ut;exports.MoreMark=Ln;exports.OrderedList=sn;exports.SlashCommand=Bn;exports.Strike=tt;exports.SubAndSuperScript=kn;exports.Table=je;exports.TaskList=rn;exports.TextAlign=Yt;exports.Underline=et;exports.Video=ti;exports.VideoUpload=ii;exports.default=wo;exports.locale=Kt;
1
+ "use strict";var ut=Object.defineProperty;var mt=(e,t,i)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var He=(e,t,i)=>mt(e,typeof t!="symbol"?t+"":t,i);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./vendor-DlmsfAkr.js"),n=require("react/jsx-runtime"),f=require("react"),Fe=require("react-dom");function ht(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const M=ht(f);function ft(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M11 7c-1.1 0-2 .9-2 2v2a2 2 0 0 0 2 2h2v2H9v2h4c1.11 0 2-.89 2-2v-2a2 2 0 0 0-2-2h-2V9h4V7z"})})}function gt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function xt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function bt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M19 12h-2v3h-3v2h5zM7 9h3V7H5v5h2zm14-6H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 16H3V5h18z"})})}function vt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M21 22H3v-2h18zm0-18H3V2h18zm-11 9.7h4l-2-5.4zM11.2 6h1.7l4.7 12h-2l-.9-2.6H9.4L8.5 18h-2z"})})}function wt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}function Ve(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 48 48",...e,children:n.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function yt(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 15h15m0 4H6m9-8h6m0-4h-6M9 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2M3 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2"})})}const jt=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4 iconify iconify--hugeicons",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M5.5 3c1.404 0 2.107 0 2.611.38c.219.164.406.375.552.62C9 4.568 9 5.358 9 6.938v10.125c0 1.58 0 2.37-.337 2.937a2.1 2.1 0 0 1-.552.621c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C2 19.432 2 18.642 2 17.062V6.938c0-1.58 0-2.37.337-2.938a2.1 2.1 0 0 1 .552-.62C3.393 3 4.096 3 5.5 3M20 11.938v5.124c0 1.58 0 2.37-.337 2.938a2.1 2.1 0 0 1-.552.62c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C13 19.433 13 18.642 13 17.063V6.938c0-1.58 0-2.37.337-2.938M22 9l-6-6m6 0l-6 6",color:"currentColor"})}),kt=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4 iconify iconify--hugeicons",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M21 18.5c0 1.404 0 2.107-.38 2.611a2.1 2.1 0 0 1-.62.552c-.567.337-1.358.337-2.937.337H6.938c-1.58 0-2.37 0-2.938-.337a2.1 2.1 0 0 1-.62-.552C3 20.607 3 19.904 3 18.5s0-2.107.38-2.611c.163-.218.374-.406.62-.552C4.567 15 5.357 15 6.938 15h10.125c1.58 0 2.37 0 2.937.337c.246.146.457.334.62.552c.38.504.38 1.207.38 2.611M12.063 4H6.937C5.358 4 4.568 4 4 4.337a2.1 2.1 0 0 0-.62.552C3 5.393 3 6.096 3 7.5s0 2.107.38 2.611c.163.218.374.406.62.552C4.567 11 5.357 11 6.938 11h10.125c1.58 0 2.37 0 2.937-.337M21 8l-6-6m6 0l-6 6",color:"currentColor"})}),re={Bold:l.Bold,LoaderCircle:l.LoaderCircle,Italic:l.Italic,Underline:l.Underline,Quote:l.Quote,TextQuote:yt,Strikethrough:l.Strikethrough,Minus:l.Minus,Eraser:l.Eraser,PaintRoller:l.PaintRoller,Redo2:l.Redo2,Undo2:l.Undo2,AlignCenter:l.TextAlignCenterIcon,AlignJustify:l.TextAlignJustifyIcon,AlignLeft:l.TextAlignLeftIcon,AlignRight:l.TextAlignRightIcon,ChevronDown:l.ChevronDown,Subscript:l.Subscript,Superscript:l.Superscript,Code:l.Code,Code2:l.CodeXml,Type:l.Type,IndentIncrease:l.IndentIncrease,IndentDecrease:l.IndentDecrease,List:l.List,ListOrdered:l.ListOrdered,ListTodo:l.ListTodo,Link:l.Link,ImageUp:l.ImageUp,Video:l.Video,Maximize:l.Maximize,Minimize:l.Minimize,Table:l.Table,Sparkles:l.Sparkles,Pencil:l.Pencil,Unlink:l.Unlink,BetweenHorizonalEnd:l.BetweenHorizontalEnd,BetweenHorizonalStart:l.BetweenHorizontalStart,BetweenVerticalStart:l.BetweenVerticalStart,BetweenVerticalEnd:l.BetweenVerticalEnd,TableCellsMerge:l.TableCellsMerge,TableCellsSplit:l.TableCellsSplit,Trash2:l.Trash2,Trash:l.Trash,Replace:l.Replace,ChevronsUpDown:l.ChevronsUpDown,LineHeight:vt,Word:wt,Heading1:l.Heading1,Heading2:l.Heading2,Heading3:l.Heading3,Columns2:l.Columns2,Columns3:l.Columns3,Columns4:l.Columns4,Plus:l.Plus,Grip:l.GripVertical,Copy:l.Copy,Clipboard:l.Clipboard,PanelLeft:l.PanelLeft,PanelRight:l.PanelRight,Columns:l.Columns2,Iframe:l.Frame,MenuDown:Ve,SizeS:ft,SizeM:gt,SizeL:xt,AspectRatio:bt,Emoji:l.SmilePlus,DeleteColumn:jt,DeleteRow:kt};function S(...e){return l.twMerge(l.clsx(e))}const Ct=l.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),ve=M.forwardRef(({className:e,variant:t,size:i,...o},a)=>n.jsx(l.Root,{ref:a,className:S(Ct({variant:t,size:i,className:e})),...o}));ve.displayName=l.Root.displayName;const pt=l.Provider,de=l.Root3,ce=l.Trigger,oe=M.forwardRef(({className:e,sideOffset:t=4,...i},o)=>n.jsx(l.Content2,{ref:o,sideOffset:t,className:S("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...i}));oe.displayName=l.Content2.displayName;let je;function ke(){return je===void 0&&(je=navigator.platform.includes("Mac")),je}function Ae(e){return`${e}`.toLowerCase()==="mod"?ke()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?ke()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?ke()?"⇧":"Shift":e}function we(e){return e.map(Ae).join(" ")}const v=e=>{var w;const{icon:t=void 0,title:i=void 0,tooltip:o=void 0,disabled:a=!1,customClass:s="",color:r=void 0,loading:d=!1,shortcutKeys:c=void 0,tooltipOptions:u={},action:h=void 0,isActive:m=void 0,children:g}=e,b=re[t];return n.jsxs(de,{children:[n.jsx(ce,{children:n.jsxs(ve,{size:"sm",className:"w-[32px] h-[32px] "+s,onClick:h,"data-state":m!=null&&m()?"on":"off",children:[b&&n.jsx(b,{className:"w-4 h-4"}),g&&n.jsx(n.Fragment,{children:g})]})}),o&&n.jsx(oe,{...u,children:n.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[n.jsx("div",{children:o}),!!((w=e==null?void 0:e.shortcutKeys)!=null&&w.length)&&n.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})]})})]})},Ke=l.Bold$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleBold(),isActive:()=>t.isActive("bold")||!1,disabled:!t.can().toggleBold(),icon:"Bold",shortcutKeys:["mod","B"],tooltip:i("editor.bold.tooltip")}})}}}),qe=l.Italic$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:i}){return{component:v,componentProps:{action:()=>t.commands.toggleItalic(),isActive:()=>t.isActive("italic")||!1,disabled:!t.can().toggleItalic(),shortcutKeys:["mod","I"],icon:"Italic",tooltip:i("editor.italic.tooltip")}}}}}}),We=l.Underline$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:i}){return{component:v,componentProps:{action:()=>t.commands.toggleUnderline(),isActive:()=>t.isActive("underline")||!1,disabled:!t.can().toggleUnderline(),icon:"Underline",shortcutKeys:["mod","U"],tooltip:i("editor.underline.tooltip")}}}}}}),Ge=l.Strike.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleStrike(),isActive:()=>t.isActive("strike")||!1,disabled:!t.can().toggleStrike(),icon:"Strikethrough",shortcutKeys:["shift","mod","X"],tooltip:i("editor.strike.tooltip")}})}}}),Xe=l.Code$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleCode(),isActive:()=>t.isActive("code")||!1,disabled:!t.can().toggleCode(),icon:"Code",shortcutKeys:["mod","E"],tooltip:i("editor.code.tooltip")}})}}}),Nt=l.CodeBlockLowlight.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),defaultLanguage:null,button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleCodeBlock(),isActive:()=>t.isActive("codeBlock")||!1,disabled:!t.can().toggleCodeBlock(),icon:"Code2",tooltip:i("editor.codeblock.tooltip")}})}}}),Lt=l.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),z=M.forwardRef(({className:e,variant:t,size:i,asChild:o=!1,...a},s)=>{const r=o?l.Slot:"button";return n.jsx(r,{className:S(Lt({variant:t,size:i,className:e})),ref:s,...a})});z.displayName="Button";const Me=e=>{var i;const t=re[e.icon];return n.jsxs(de,{children:[n.jsx(ce,{children:n.jsx(z,{className:"h-[32px] px-[5px] py-0 min-w-24 max-w-32 overflow-hidden",variant:"ghost",disabled:e==null?void 0:e.disabled,children:n.jsxs("div",{className:"flex items-center h-full font-normal",children:[(e==null?void 0:e.title)&&n.jsx("div",{className:"text-left truncate text-sm flex-grow",children:e==null?void 0:e.title}),t&&n.jsx(t,{className:"w-3 h-3 ml-1 text-zinc-500 flex-shrink-0"})]})})}),n.jsx(oe,{children:n.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[(e==null?void 0:e.tooltip)&&n.jsx("div",{children:e==null?void 0:e.tooltip}),n.jsx("div",{className:"flex",children:!!((i=e==null?void 0:e.shortcutKeys)!=null&&i.length)&&n.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})})]})})]})},Z=l.Root2,Y=l.Trigger$1,De=l.Portal2,Ie=l.Sub2,Ce=M.forwardRef(({className:e,inset:t,children:i,...o},a)=>n.jsxs(l.SubTrigger2,{ref:a,className:S("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...o,children:[i,n.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ce.displayName=l.SubTrigger2.displayName;const pe=M.forwardRef(({className:e,...t},i)=>n.jsx(l.SubContent2,{ref:i,className:S("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));pe.displayName=l.SubContent2.displayName;const V=M.forwardRef(({className:e,sideOffset:t=4,...i},o)=>n.jsx(l.Portal2,{children:n.jsx(l.Content2$1,{ref:o,sideOffset:t,className:S("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...i})}));V.displayName=l.Content2$1.displayName;const _=M.forwardRef(({className:e,inset:t,...i},o)=>n.jsx(l.Item2,{ref:o,className:S("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...i}));_.displayName=l.Item2.displayName;const J=M.forwardRef(({className:e,children:t,checked:i,...o},a)=>n.jsxs(l.CheckboxItem2,{ref:a,className:S("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:i,...o,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(l.ItemIndicator2,{children:n.jsx(l.Check,{className:"h-4 w-4"})})}),t]}));J.displayName=l.CheckboxItem2.displayName;const Tt=M.forwardRef(({className:e,children:t,...i},o)=>n.jsxs(l.RadioItem2,{ref:o,className:S("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...i,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(l.ItemIndicator2,{children:n.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Tt.displayName=l.RadioItem2.displayName;const St=M.forwardRef(({className:e,inset:t,...i},o)=>n.jsx(l.Label2,{ref:o,className:S("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...i}));St.displayName=l.Label2.displayName;const ye=M.forwardRef(({className:e,...t},i)=>n.jsx(l.Separator2,{ref:i,className:S("-mx-1 my-1 h-px bg-muted",e),...t}));ye.displayName=l.Separator2.displayName;const Ze=({className:e,...t})=>n.jsx("span",{className:S("ml-auto text-xs tracking-widest opacity-60",e),...t});Ze.displayName="DropdownMenuShortcut";const At="en",Mt=200,Rt=Mt-80,Ht=20,Be=1e5,ze=16,ue=10,me=10,he=2,Ft="#262626",Dt=["#000000","#262626","#595959","#8C8C8C","#BFBFBF","#D9D9D9","#E9E9E9","#F5F5F5","#FAFAFA","#FFFFFF","#F5222D","#FA541C","#FA8C16","#FADB14","#52C41A","#13C2C2","#1890FF","#2F54EB","#722ED1","#EB2F96","#FFE8E6","#FFECE0","#FFEFD1","#FCFCCA","#E4F7D2","#D3F5F0","#D4EEFC","#DEE8FC","#EFE1FA","#FAE1EB","#FFA39E","#FFBB96","#FFD591","#FFFB8F","#B7EB8F","#87E8DE","#91D5FF","#ADC6FF","#D3ADF7","#FFADD2","#FF4D4F","#FF7A45","#FFA940","#FFEC3D","#73D13D","#36CFC9","#40A9FF","#597EF7","#9254DE","#F759AB","#CF1322","#D4380D","#D46B08","#D4B106","#389E0D","#08979C","#096DD9","#1D39C4","#531DAB","#C41D7F","#820014","#871400","#873800","#614700","#135200","#00474F","#003A8C","#061178","#22075E","#780650"],It=["10px","11px","12px","14px","16px","18px","20px","22px","24px","26px","28px","36px","48px","72px"],te="defaut";var Ne=(e=>(e[e["size-small"]=200]="size-small",e[e["size-medium"]=500]="size-medium",e["size-large"]="100%",e))(Ne||{}),xe=(e=>(e[e["size-small"]=480]="size-small",e[e["size-medium"]=640]="size-medium",e["size-large"]="100%",e))(xe||{});const Ye="1";function Bt(e){return e=e||new Map,{all:e,on(t,i){const o=e.get(t);o?o.push(i):e.set(t,[i])},off(t,i){const o=e.get(t);o&&(i?o.splice(o.indexOf(i)>>>0,1):e.set(t,[]))},emit(t,i){let o=e.get(t);o&&[...o].map(a=>{a(i)}),o=e.get("*"),o&&[...o].map(a=>{a(t,i)})}}}const zt={"editor.remove":"Remove","editor.copy":"Copy","editor.words":"WORDS","editor.characters":"CHARACTERS","editor.default":"Default","editor.recent":"Recently Used","editor.nofill":"No Fill","editor.format":"Format Painter","editor.draghandle.tooltip":"Modify","editor.copyToClipboard":"CopyToClipboard","editor.importWrod.tooltip":"Import Word","editor.slash":"Press '/' for commands","editor.slash.empty":"No Result","editor.slash.format":"Format","editor.slash.insert":"Insert","editor.slash.embed":"Embed Services","editor.content":"Please input content","editor.fontFamily.tooltip":"Font Family","editor.fontFamily.default.tooltip":"Default","editor.moremark":"More Text Styles","editor.size.small.tooltip":"Small","editor.size.medium.tooltip":"Medium","editor.size.large.tooltip":"Cover","editor.bold.tooltip":"Bold","editor.italic.tooltip":"Italic","editor.underline.tooltip":"Underline","editor.strike.tooltip":"Strike","editor.color.tooltip":"Color","editor.color.more":"More Colors","editor.highlight.tooltip":"Highlight","editor.lineheight.tooltip":"Line Height","editor.heading.tooltip":"Headings","editor.heading.h1.tooltip":"Heading 1","editor.heading.h2.tooltip":"Heading 2","editor.heading.h3.tooltip":"Heading 3","editor.heading.h4.tooltip":"Heading 4","editor.heading.h5.tooltip":"Heading 5","editor.heading.h6.tooltip":"Heading 6","editor.paragraph.tooltip":"Paragraph","editor.textalign.tooltip":"Align","editor.textalign.left.tooltip":"Left","editor.textalign.center.tooltip":"Center","editor.textalign.right.tooltip":"Right","editor.textalign.justify.tooltip":"Justify","editor.indent":"Indent","editor.indent.indent":"Increase Indent","editor.indent.outdent":"Decrease Indent","editor.fontSize.tooltip":"Font size","editor.fontSize.default.tooltip":"Default","editor.superscript.tooltip":"Superscript","editor.subscript.tooltip":"Subscript","editor.bulletlist.tooltip":"Bullet List","editor.orderedlist.tooltip":"Ordered List","editor.tasklist.tooltip":"Task List","editor.indent.tooltip":"Indent","editor.outdent.tooltip":"Outdent","editor.columns.tooltip":"Columns","editor.link.tooltip":"Link","editor.link.unlink.tooltip":"UnLink","editor.link.open.tooltip":"Open Link","editor.link.edit.tooltip":"Edit Link","editor.link.dialog.title":"Insert Link","editor.link.dialog.link":"Link","editor.link.dialog.text":"Text","editor.link.dialog.openInNewTab":"Open In New Tab","editor.link.dialog.link.placeholder":"Link Address","editor.link.dialog.text.placeholder":"Add Description","editor.link.dialog.button.apply":"Apply","editor.image.tooltip":"Image","editor.image.dragger.tooltip":"Click or drag the image to the area to upload","editor.image.float.left.tooltip":"Float left","editor.image.float.none.tooltip":"Float none","editor.image.float.right.tooltip":"Float right","editor.image.dialog.title":"Add an image","editor.image.dialog.tab.url":"Url","editor.image.dialog.tab.upload":"Upload","editor.image.dialog.uploading":"Uploading","editor.image.dialog.form.link":"Link","editor.image.dialog.placeholder":"Link","editor.image.dialog.form.alt":"Alt","editor.image.dialog.form.aspectRatio":"Lock original aspect ratio","editor.image.dialog.form.file":"File","editor.image.dialog.button.apply":"apply","editor.video.tooltip":"Video","editor.video.dialog.tab.upload":"Upload","editor.video.dialog.uploading":"Uploading","editor.video.dialog.title":"Embed or upload a video","editor.video.dialog.link":"link","editor.video.dialog.placeholder":"Link","editor.video.dialog.button.apply":"apply","editor.table.tooltip":"Table","editor.table.menu.insert_table":"Insert Table","editor.table.menu.insert_table.with_header_row":"With header row","editor.table.menu.add_column_before":"Add Column Before","editor.table.menu.add_column_after":"Add Column After","editor.table.menu.delete_column":"Delete Column","editor.table.menu.add_row_before":"Add Row Before","editor.table.menu.add_row_after":"Add Row After","editor.table.menu.delete_row":"Delete Row","editor.table.menu.merge_or_split_cells":"Merge Or Split Cells","editor.table.menu.delete_table":"Delete Table","editor.blockquote.tooltip":"Blockquote","editor.horizontalrule.tooltip":"Horizontal Rule","editor.code.tooltip":"Code","editor.codeblock.tooltip":"Code Block","editor.clear.tooltip":"Clear Format","editor.undo.tooltip":"Undo","editor.redo.tooltip":"Redo","editor.fullscreen.tooltip.fullscreen":"Fullscreen","editor.fullscreen.tooltip.exit":"Fullscreen Exit","editor.imageUpload.fileTypeNotSupported":"File type not supported","editor.imageUpload.fileSizeTooBig":"File size too big, Maximum size is","editor.table.menu.insertColumnBefore":"Insert Column Before","editor.table.menu.insertColumnAfter":"Insert Column After","editor.table.menu.deleteColumn":"Delete Column","editor.table.menu.insertRowAbove":"Insert Row Above","editor.table.menu.insertRowBelow":"Insert Row Below","editor.table.menu.deleteRow":"Delete Row","editor.table.menu.mergeCells":"Merge Cells","editor.table.menu.splitCells":"Split Cells","editor.table.menu.deleteTable":"Delete Table","editor.table.menu.setCellsBgColor":"Cell Background Color","editor.emoji.tooltip":"Emoji","editor.iframe.tooltip":"Iframe"},Pt={"editor.remove":"Xóa","editor.copy":"Sao chép","editor.words":"TỪ","editor.characters":"KÝ TỰ","editor.default":"Mặc định","editor.recent":"Đã sử dụng gần đây","editor.nofill":"Không tô","editor.format":"Format Painter","editor.draghandle.tooltip":"Sửa đổi","editor.copyToClipboard":"CopyToClipboard","editor.importWrod.tooltip":"Nhập Word","editor.slash":"Nhấn '/' để biết lệnh","editor.slash.empty":"Không có kết quả","editor.slash.format":"Định dạng","editor.slash.insert":"Chèn","editor.slash.embed":"Dịch vụ nhúng","editor.content":"Vui lòng nhập nội dung","editor.moremark":"Nhiều kiểu văn bản hơn","editor.size.small.tooltip":"Nhỏ","editor.fontFamily.tooltip":"Phông chữ","editor.fontFamily.default.tooltip":"Mặc định","editor.size.medium.tooltip":"Trung bình","editor.size.large.tooltip":"Lớn","editor.bold.tooltip":"Đậm","editor.italic.tooltip":"In nghiêng","editor.underline.tooltip":"Gạch chân","editor.strike.tooltip":"Gạch","editor.color.tooltip":"Màu","editor.color.more":"Nhiều màu hơn","editor.highlight.tooltip":"Đánh dấu","editor.lineheight.tooltip":"Chiều cao dòng","editor.heading.tooltip":"Tiêu đề","editor.heading.h1.tooltip":"Tiêu đề 1","editor.heading.h2.tooltip":"Tiêu đề 2","editor.heading.h3.tooltip":"Tiêu đề 3","editor.heading.h4.tooltip":"Tiêu đề 4","editor.heading.h5.tooltip":"Tiêu đề 5","editor.heading.h6.tooltip":"Tiêu đề 6","editor.paragraph.tooltip":"Đoạn văn","editor.textalign.tooltip":"Căn chỉnh","editor.textalign.left.tooltip":"Trái","editor.textalign.center.tooltip":"Giữa","editor.textalign.right.tooltip":"Phải","editor.textalign.justify.tooltip":"Căn đều","editor.indent":"Thụt lề","editor.indent.indent":"Tăng thụt lề","editor.indent.outdent":"Giảm thụt lề","editor.fontSize.tooltip":"Kích thước phông chữ","editor.fontSize.default.tooltip":"Mặc định","editor.superscript.tooltip":"Chỉ số trên","editor.subscript.tooltip":"Chỉ số dưới","editor.bulletlist.tooltip":"Danh sách dấu đầu dòng","editor.orderedlist.tooltip":"Danh sách có thứ tự","editor.tasklist.tooltip":"Danh sách tác vụ","editor.indent.tooltip":"Tăng thụt lề","editor.outdent.tooltip":"Giảm thụt lề","editor.columns.tooltip":"Cột","editor.link.tooltip":"Liên kết","editor.link.unlink.tooltip":"Hủy liên kết","editor.link.open.tooltip":"Mở liên kết","editor.link.edit.tooltip":"Chỉnh sửa liên kết","editor.link.dialog.title":"Chèn liên kết","editor.link.dialog.link":"Liên kết","editor.link.dialog.text":"Văn bản","editor.link.dialog.openInNewTab":"Mở trong tab mới","editor.link.dialog.link.placeholder":"Địa chỉ liên kết","editor.link.dialog.text.placeholder":"Thêm mô tả","editor.link.dialog.button.apply":"Áp dụng","editor.image.tooltip":"Hình ảnh","editor.image.dragger.tooltip":"Nhấp hoặc kéo hình ảnh đến khu vực để tải lên","editor.image.float.left.tooltip":"Trôi sang trái","editor.image.float.none.tooltip":"Trôi không","editor.image.float.right.tooltip":"Trôi sang phải","editor.image.dialog.title":"Thêm hình ảnh","editor.image.dialog.tab.url":"Url","editor.image.dialog.tab.upload":"Tải lên","editor.image.dialog.uploading":"Đang tải lên","editor.image.dialog.form.link":"Liên kết","editor.image.dialog.placeholder":"Liên kết","editor.image.dialog.form.alt":"Alt","editor.image.dialog.form.aspectRatio":"Khóa tỷ lệ khung hình gốc","editor.image.dialog.form.file":"Tệp","editor.image.dialog.button.apply":"áp dụng","editor.video.tooltip":"Video","editor.video.dialog.tab.upload":"Tải lên","editor.video.dialog.uploading":"Đang tải lên","editor.video.dialog.title":"Nhúng hoặc tải lên video","editor.video.dialog.link":"liên kết","editor.video.dialog.placeholder":"Liên kết","editor.video.dialog.button.apply":"áp dụng","editor.table.tooltip":"Bảng","editor.table.menu.insert_table":"Chèn Bảng","editor.table.menu.insert_table.with_header_row":"Có hàng tiêu đề","editor.table.menu.add_column_before":"Thêm Cột Trước","editor.table.menu.add_column_after":"Thêm Cột Sau","editor.table.menu.delete_column":"Xóa Cột","editor.table.menu.add_row_before":"Thêm Hàng Trước","editor.table.menu.add_row_after":"Thêm Hàng Sau","editor.table.menu.delete_row":"Xóa Hàng","editor.table.menu.merge_or_split_cells":"Gộp Hoặc Tách Ô","editor.table.menu.delete_table":"Xóa Bảng","editor.blockquote.tooltip":"Blockquote","editor.horizontalrule.tooltip":"Quy tắc ngang","editor.code.tooltip":"Mã","editor.codeblock.tooltip":"Khối mã","editor.clear.tooltip":"Xóa định dạng","editor.undo.tooltip":"Hoàn tác","editor.redo.tooltip":"Làm lại","editor.fullscreen.tooltip.fullscreen":"Toàn màn hình","editor.fullscreen.tooltip.exit":"Thoát toàn màn hình","editor.imageUpload.fileTypeNotSupported":"Loại tệp không được hỗ trợ","editor.imageUpload.fileSizeTooBig":"Kích thước tệp quá lớn, Kích thước tối đa là","editor.table.menu.insertColumnBefore":"Chèn cột trước","editor.table.menu.insertColumnAfter":"Chèn cột sau","editor.table.menu.deleteColumn":"Xóa cột","editor.table.menu.insertRowAbove":"Chèn hàng ở trên","editor.table.menu.insertRowBelow":"Chèn hàng ở dưới","editor.table.menu.deleteRow":"Xóa hàng","editor.table.menu.mergeCells":"Gộp các ô","editor.table.menu.splitCells":"Chia ô","editor.table.menu.deleteTable":"Xóa bảng","editor.table.menu.setCellsBgColor":"Màu nền ô","editor.emoji.tooltip":"Biểu tượng","editor.iframe.tooltip":"Iframe"},ne={lang:At,message:{en:zt,vi:Pt}};class Et{constructor(){He(this,"emitter");this.emitter=Bt()}get lang(){return ne.lang}set lang(t){if(!this.isLangSupported(t)){console.warn(`Can't find the current language "${t}", Using language "${ne.lang}" by default`);return}ne.lang=t,this.emitter.emit("lang",t)}get message(){return ne.message}set message(t){ne.message=t}loadLangMessage(t){return this.message[t]}isLangSupported(t){return Object.keys(this.message).includes(t)}setLang(t){this.lang=t}registerWatchLang(t){return this.emitter.on("lang",t),{unsubscribe:()=>{this.emitter.off("lang",t)}}}setMessage(t,i){this.message[t]=i}buildLocalesHandler(t){t||(t=this.lang);const i=this.loadLangMessage(t);return function(a){return i[a]||a}}}const be=new Et,Le=l.proxy({lang:ne.lang}),R=()=>{const e=l.useSnapshot(Le),t=f.useMemo(()=>be.buildLocalesHandler(e.lang),[e.lang]);return f.useEffect(()=>{const i=be.registerWatchLang(o=>{Le.lang=o});return()=>{i.unsubscribe()}},[]),{lang:e.lang,t}},T={t:e=>be.buildLocalesHandler(Le.lang)(e)},Ot=be,_t=e=>{var a,s,r;const{t,lang:i}=R(),o=f.useMemo(()=>{var u;const d=(u=e==null?void 0:e.items)==null?void 0:u.find(h=>h.isActive());return d&&!d.default?{...d}:{title:e.tooltip,font:t("editor.fontFamily.default.tooltip"),isActive:()=>!1,disabled:!1,action:()=>e.editor.chain().focus().unsetFontFamily().run()}},[t,i,e]);return n.jsxs(Z,{children:[n.jsx(Y,{disabled:e==null?void 0:e.disabled,children:n.jsx(Me,{title:((a=o==null?void 0:o.font)==null?void 0:a.length)>7?`${(s=o==null?void 0:o.font)==null?void 0:s.slice(0,6)}...`:o==null?void 0:o.font,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),n.jsx(V,{className:"w-full",children:(r=e==null?void 0:e.items)==null?void 0:r.map((d,c)=>{const u=d.font===t("editor.fontFamily.default.tooltip")?{}:{fontFamily:d.font};return n.jsxs(f.Fragment,{children:[n.jsx(J,{checked:(o==null?void 0:o.font)===d.font,onClick:d.action,children:n.jsx("div",{className:"ml-1 h-full",style:u,children:d.font})}),d.font===t("editor.fontFamily.default.tooltip")&&n.jsx(ye,{})]},c)})})]})},$t=l.FontFamily.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),fonts:["Inter","Comic Sans MS, Comic Sans","serif","monospace","cursive"],button({editor:t,extension:i,t:o}){var u;const{extensions:a=[]}=t.extensionManager??[],s=((u=i.options)==null?void 0:u.fonts)||[],r=a.find(h=>h.name==="base-kit"),d=s.map(h=>({action:()=>{t.chain().focus().setFontFamily(h).run()},isActive:()=>t.isActive("textStyle",{fontFamily:h})||!1,disabled:!t.can().setFontFamily(h),title:h,font:h}));r&&r.options.textStyle!==!1&&d.unshift({action:()=>t.chain().focus().unsetFontFamily().run(),isActive:()=>!1,disabled:!1,font:o("editor.fontFamily.default.tooltip"),title:o("editor.fontFamily.tooltip")});const c=d.filter(h=>h.disabled).length===d.length;return{component:_t,componentProps:{tooltip:o("editor.fontFamily.tooltip"),disabled:c,items:d,editor:t}}}}}}),Ut=e=>{var i;const t=f.useMemo(()=>{var s;const o=(s=e==null?void 0:e.items)==null?void 0:s.find(r=>r.isActive());return o&&!o.default?{...o}:{title:e.tooltip,level:0,isActive:()=>!1}},[e]);return n.jsxs(Z,{children:[n.jsx(Y,{disabled:e==null?void 0:e.disabled,children:n.jsx(Me,{title:t==null?void 0:t.title,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),n.jsx(V,{className:"w-full",children:(i=e==null?void 0:e.items)==null?void 0:i.map((o,a)=>{var s,r;return n.jsxs(f.Fragment,{children:[n.jsxs(J,{checked:(t==null?void 0:t.title)===o.title,onClick:o.action,children:[n.jsx("div",{className:`ml-1 h-full heading-${o.level}`,children:o.title}),!!((s=o==null?void 0:o.shortcutKeys)!=null&&s.length)&&n.jsx(Ze,{className:"pl-4",children:(r=o==null?void 0:o.shortcutKeys)==null?void 0:r.map(d=>Ae(d)).join(" ")})]}),o.level===0&&n.jsx(ye,{})]},a)})})]})},Vt=l.Heading.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),levels:[1,2,3,4,5,6],button({editor:t,extension:i,t:o}){var u;const{extensions:a=[]}=t.extensionManager??[],s=((u=i.options)==null?void 0:u.levels)||[],r=a.find(h=>h.name==="base-kit"),d=s.map(h=>({action:()=>t.commands.toggleHeading({level:h}),isActive:()=>t.isActive("heading",{level:h})||!1,disabled:!t.can().toggleHeading({level:h}),title:o(`editor.heading.h${h}.tooltip`),level:h,shortcutKeys:["alt","mod",`${h}`]}));r&&r.options.paragraph!==!1&&d.unshift({action:()=>t.commands.setParagraph(),isActive:()=>t.isActive("paragraph")||!1,disabled:!t.can().setParagraph(),level:0,title:o("editor.paragraph.tooltip"),shortcutKeys:["alt","mod","0"]});const c=d.filter(h=>h.disabled).length===d.length;return{component:Ut,componentProps:{tooltip:o("editor.heading.tooltip"),disabled:c,items:d,editor:t}}}}}}),p=e=>{const t=re[e.name];return n.jsx(n.Fragment,{children:t&&n.jsx(t,{onClick:e==null?void 0:e.onClick,className:`w-4 h-4 ${(e==null?void 0:e.className)||""}`})})},Q=l.Root2$1,ee=l.Trigger$2,K=M.forwardRef(({className:e,align:t="center",sideOffset:i=4,...o},a)=>n.jsx(l.Portal,{children:n.jsx(l.Content2$2,{ref:a,align:t,sideOffset:i,className:S("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));K.displayName=l.Content2$2.displayName;const Kt=e=>{var i;const t=f.useMemo(()=>{var s;const o=(s=e==null?void 0:e.items)==null?void 0:s.find(r=>r.isActive());return o&&!o.default?{...o,icon:o.icon?o.icon:e.icon}:{title:e==null?void 0:e.tooltip,icon:e.icon,isActive:()=>!1}},[e]);return n.jsxs(Q,{children:[n.jsx(ee,{disabled:e==null?void 0:e.disabled,children:n.jsx("div",{className:"flex",children:n.jsx(v,{customClass:"w-12","enable-tooltip":!0,icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:n.jsx(p,{className:"w-3 h-3 ml-1 text-zinc-500",name:"MenuDown"})})})}),n.jsx(K,{className:"min-w-4 w-full !p-[4px] flex flex-row gap-1",align:"start",side:"bottom",children:(i=e==null?void 0:e.items)==null?void 0:i.map((o,a)=>{var s,r;return n.jsxs(de,{children:[n.jsx(ce,{children:n.jsx(ve,{size:"sm",onClick:o==null?void 0:o.action,className:"w-7 h-7 p-1",pressed:t.title===o.title,"data-state":t.title===o.title?"on":"off",children:(o==null?void 0:o.icon)&&n.jsx(p,{name:o.icon})})}),n.jsxs(oe,{className:"flex flex-col items-center",children:[n.jsx("span",{children:o.title}),!!((s=o.shortcutKeys)!=null&&s.length)&&n.jsx("span",{children:(r=o.shortcutKeys)==null?void 0:r.map(d=>Ae(d)).join(" ")})]})]},`text-align-${a}`)})})]})},qt=l.TextAlign.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["heading","paragraph","list_item","title"],button({editor:t,extension:i,t:o}){var u;const a=((u=i.options)==null?void 0:u.alignments)||[],s={left:["mod","Shift","L"],center:["mod","Shift","E"],right:["mod","Shift","R"],justify:["mod","Shift","J"]},r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},d=a.map(h=>({title:o(`editor.textalign.${h}.tooltip`),icon:r[h],shortcutKeys:s[h],isActive:()=>t.isActive({textAlign:h})||!1,action:()=>t.commands.setTextAlign(h),disabled:!t.can().setTextAlign(h)})),c=d.filter(h=>h.disabled).length===d.length;return{component:Kt,componentProps:{icon:"AlignJustify",tooltip:o("editor.textalign.tooltip"),disabled:c,items:d}}}}}}),Wt=e=>{var o;const{t}=R(),i=f.useMemo(()=>{const a=(e.items||[]).find(r=>r.isActive());return a||{title:t("editor.fontSize.default.tooltip"),isActive:()=>!1}},[e]);return n.jsxs(Z,{children:[n.jsx(Y,{disabled:e==null?void 0:e.disabled,children:n.jsx(Me,{title:i==null?void 0:i.title,tooltip:`${e==null?void 0:e.tooltip}`,disabled:e==null?void 0:e.disabled,icon:"MenuDown"})}),n.jsx(V,{className:"w-32 overflow-y-auto max-h-96",children:(o=e==null?void 0:e.items)==null?void 0:o.map((a,s)=>n.jsx(J,{checked:i.title===a.title,onClick:a.action,children:n.jsx("div",{className:"ml-1 h-full",children:a.title})},s))})]})},Gt=l.Extension.create({name:"fontSize",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["textStyle"],fontSizes:[...It],button({editor:t,extension:i,t:o}){var d;const a=((d=i.options)==null?void 0:d.fontSizes)||[],s=[te,...a].map(c=>({title:c===te?o("editor.fontSize.default.tooltip"):String(c),isActive:()=>{const{fontSize:u}=t.getAttributes("textStyle");return c===te&&u===void 0?!0:t.isActive({fontSize:String(c)})||!1},action:()=>{if(c===te){t.commands.unsetFontSize();return}t.commands.setFontSize(String(c))},disabled:!t.can().setFontSize(String(c)),divider:c===te||!1,default:c===te||!1})),r=s.filter(c=>c.disabled).length===s.length;return{component:Wt,componentProps:{editor:t,tooltip:o("editor.fontSize.tooltip"),disabled:r,items:s,maxHeight:280}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replaceAll(/["']+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),X=M.forwardRef(({className:e,type:t,...i},o)=>n.jsx("input",{type:t,className:S("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...i}));X.displayName="Input";const $=M.forwardRef(({className:e,orientation:t="horizontal",decorative:i=!0,...o},a)=>n.jsx(l.Root$1,{ref:a,decorative:i,orientation:t,className:S("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));$.displayName=l.Root$1.displayName;const Pe=Dt,Je=[];for(let e=0;e<Pe.length;e+=10)Je.push(Pe.slice(e,e+10));const Xt=({setColor:e})=>{const[t,i]=f.useState("#000000"),[o,a]=f.useState(!1),{t:s}=R();return f.useEffect(()=>()=>{a(!1)},[]),n.jsxs(Q,{open:o,children:[n.jsx(ee,{asChild:!0,children:n.jsxs("div",{onClick:r=>{r.preventDefault(),a(!0)},className:"text-sm hover:cursor-pointer hover:bg-accent py-1.5 px-1.5",children:[s("editor.color.more"),"..."]})}),n.jsxs(K,{children:[n.jsxs("div",{className:"flex flex-col items-center justify-center",children:[n.jsx(l.Z,{color:t,onChange:i}),n.jsx(X,{className:"mt-[8px] w-full",type:"text",onChange:r=>{r.preventDefault(),i(`#${r.target.value}`)},value:t.slice(1)})]}),n.jsx($,{className:"my-[10px]"}),n.jsx(z,{onClick:r=>{r.preventDefault(),e(t),a(!1)},className:"w-full",children:n.jsx(l.Plus,{size:16})})]})]})},Qe=e=>{const{t}=R(),{highlight:i=!1,disabled:o=!1,selectedColor:a,setSelectedColor:s,onChange:r}=e,[d,c]=f.useState([]),u=m=>{const g=[...d],b=g.indexOf(m);b!==-1&&g.splice(b,1),g.unshift(m),g.length>10&&g.pop(),c(g)};function h(m){if(m===void 0){s==null||s(m),r==null||r(m);return}/^#([\da-f]{3}){1,2}$/i.test(m)&&(s==null||s(m),r==null||r(m),u(m))}return n.jsxs(Q,{children:[n.jsx(ee,{disabled:o,children:e==null?void 0:e.children}),n.jsx(K,{hideWhenDetached:!0,className:"p-2 w-full h-full",align:"start",side:"bottom",children:n.jsxs("div",{className:"flex flex-col",children:[i?n.jsxs("div",{className:"flex items-center p-1 rd-1 cursor-pointer hover:bg-accent",onClick:()=>h(void 0),children:[n.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border cursor-pointer hover:border-border hover:shadow-sm relative after:border-b-2 after:border-b-red-500 after:top-[10px] after:h-0 after:left-0 after:w-6 after:absolute after:block after:rotate-[45deg]",children:n.jsx("span",{style:{backgroundColor:"transparent"},children:n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgba(0, 0, 0, 0.4)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})}),n.jsx("span",{className:"text-sm ml-1",children:t("editor.nofill")})]}):n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center p-1 rd-1 cursor-pointer hover:bg-accent",onClick:()=>{h(void 0)},children:[n.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent cursor-pointer",children:n.jsx("span",{style:{backgroundColor:Ft},className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",children:n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})}),n.jsx("span",{className:"text-sm ml-1",children:t("editor.default")})]})}),Je.map((m,g)=>n.jsx("span",{className:"flex p-0 w-full h-auto relative last:pb-2",children:m.map((b,w)=>n.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent flex-[0 0 auto] cursor-pointer hover:border-border hover:shadow-sm",onClick:()=>h(b),children:n.jsx("span",{style:{backgroundColor:b},className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",children:b===a?n.jsx("svg",{className:"absolute top-[-1px] left-[1px] w-3 h-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"block"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${w}`))},g)),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm my-1",children:t("editor.recent")}),n.jsx("span",{className:"flex p-0 w-full h-auto relative last:pb-2",children:d==null?void 0:d.map((m,g)=>n.jsx("span",{className:"w-6 h-6 p-0.5 inline-block rounded-sm border border-transparent flex-[0 0 auto] cursor-pointer hover:border-border hover:shadow-sm",onClick:()=>h(m),children:n.jsx("span",{className:"relative w-[18px] h-[18px] block rounded-[2px] border-transparent",style:{backgroundColor:m},children:n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},g))})]}),n.jsx(Xt,{setColor:h})]})})]})},Zt=({fill:e})=>n.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 240 240",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:n.jsx("g",{transform:"translate(0.000000, 0.500000)",children:n.jsxs("g",{transform:"translate(39.000000, 17.353553)",children:[n.jsx("path",{d:"M11,201.146447 L167,201.146447 C173.075132,201.146447 178,206.071314 178,212.146447 C178,218.221579 173.075132,223.146447 167,223.146447 L11,223.146447 C4.92486775,223.146447 7.43989126e-16,218.221579 0,212.146447 C-7.43989126e-16,206.071314 4.92486775,201.146447 11,201.146447 Z",id:"矩形",fill:e||"#DF2A3F",fillRule:"evenodd"}),n.jsx("path",{d:"M72.3425855,16.8295583 C75.799482,7.50883712 86.1577877,2.75526801 95.4785089,6.21216449 C100.284516,7.99463061 104.096358,11.7387855 105.968745,16.4968188 L106.112518,16.8745422 L159.385152,161.694068 C161.291848,166.877345 158.635655,172.624903 153.452378,174.531599 C148.358469,176.405421 142.719567,173.872338 140.716873,168.864661 L140.614848,168.598825 L89.211,28.86 L37.3759214,168.623816 C35.4885354,173.712715 29.8981043,176.351047 24.7909589,174.617647 L24.5226307,174.522368 C19.4337312,172.634982 16.7953993,167.044551 18.5287999,161.937406 L18.6240786,161.669077 L72.3425855,16.8295583 Z",id:"路径-21",fill:"currentColor",fillRule:"nonzero"}),n.jsx("path",{d:"M121,103.146447 C126.522847,103.146447 131,107.623599 131,113.146447 C131,118.575687 126.673329,122.994378 121.279905,123.142605 L121,123.146447 L55,123.146447 C49.4771525,123.146447 45,118.669294 45,113.146447 C45,107.717207 49.3266708,103.298515 54.7200952,103.150288 L55,103.146447 L121,103.146447 Z",id:"路径-22",fill:"currentColor",fillRule:"nonzero"})]})})})}),Yt=e=>{const[t,i]=f.useState(void 0);function o(r){var d;(d=e.action)==null||d.call(e,r)}function a(){var r;(r=e.action)==null||r.call(e,t)}const s=f.useCallback(l.debounce(r=>{i(r)},350),[]);return n.jsxs("div",{className:"flex items-center h-[32px]",children:[n.jsx(v,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:a,children:n.jsx("span",{className:"text-sm flex justify-center items-center",children:n.jsx(Zt,{fill:t})})}),n.jsx(Qe,{selectedColor:t,setSelectedColor:s,onChange:o,disabled:e==null?void 0:e.disabled,children:n.jsx(z,{variant:"ghost",size:"icon",className:"h-[32px] w-3",disabled:e==null?void 0:e.disabled,children:n.jsx(p,{className:"w-3 h-3 text-zinc-500",name:"MenuDown"})})})]})},et=l.Color.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:i}){return{component:Yt,componentProps:{action:o=>{o===void 0&&t.chain().focus().unsetColor().run(),typeof o=="string"&&t.chain().focus().setColor(o).run()},isActive:()=>{const{color:o}=t.getAttributes("textStyle");return o&&t.isActive({color:o})||!1},editor:t,disabled:!t.can().setColor(""),tooltip:i("editor.color.tooltip")}}}}}}),Jt=({fill:e})=>n.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:n.jsxs("g",{id:"icon/背景颜色",children:[n.jsx("g",{id:"编组",fill:"currentColor",children:n.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[n.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),n.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),n.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),n.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",id:"矩形",fill:e||"#FBDE28"})]})})}),tt=e=>{const[t,i]=f.useState(void 0);function o(r){var d;(d=e.action)==null||d.call(e,r)}function a(){var r;(r=e.action)==null||r.call(e,t)}const s=f.useCallback(l.debounce(r=>{i(r)},350),[]);return n.jsxs("div",{className:"flex items-center h-[32px]",children:[n.jsx(v,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:a,tooltipOptions:e==null?void 0:e.tooltipOptions,shortcutKeys:e==null?void 0:e.shortcutKeys,children:n.jsx("span",{className:"text-sm flex items-center justify-center",children:n.jsx(Jt,{fill:t})})}),n.jsx(Qe,{selectedColor:t,setSelectedColor:s,onChange:o,highlight:!0,disabled:e==null?void 0:e.disabled,children:n.jsx(z,{variant:"ghost",size:"icon",className:"w-3 h-[32px]",disabled:e==null?void 0:e.disabled,children:n.jsx(p,{className:"w-3 h-3 text-zinc-500",name:"MenuDown"})})})]})},nt=l.Highlight.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),multicolor:!0,button:({editor:t,t:i})=>({component:tt,componentProps:{action:o=>{typeof o=="string"&&t.chain().focus().setHighlight({color:o}).run(),o===void 0&&t.chain().focus().unsetHighlight().run()},editor:t,isActive:()=>t.isActive("highlight")||!1,disabled:!t.can().setHighlight(),shortcutKeys:["⇧","mod","H"],tooltip:i("editor.highlight.tooltip")}})}}}),Qt=l.BulletList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleBulletList(),isActive:()=>t.isActive("bulletList")||!1,disabled:!t.can().toggleBulletList(),shortcutKeys:["shift","mod","8"],icon:"List",tooltip:i("editor.bulletlist.tooltip")}})}}}),en=l.Node.create({name:"clear",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.chain().focus().clearNodes().unsetAllMarks().run(),disabled:!t.can().chain().focus().clearNodes().unsetAllMarks().run(),icon:"Eraser",tooltip:i("editor.clear.tooltip")}})}}}),tn=l.OrderedList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleOrderedList(),isActive:()=>t.isActive("orderedList")||!1,disabled:!t.can().toggleOrderedList(),icon:"ListOrdered",shortcutKeys:["mod","shift","7"],tooltip:i("editor.orderedlist.tooltip")}})}}}),nn=l.TaskList.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleTaskList(),isActive:()=>t.isActive("taskList")||!1,disabled:!t.can().toggleTaskList(),icon:"ListTodo",shortcutKeys:["shift","mod","9"],tooltip:i("editor.tasklist.tooltip")}})}},addExtensions(){return[l.TaskItem.configure(this.options.taskItem)]}}),on=l.Blockquote.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"blockquote"},button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.toggleBlockquote(),isActive:()=>t.isActive("blockquote")||!1,disabled:!t.can().toggleBlockquote(),icon:"TextQuote",shortcutKeys:["shift","mod","B"],tooltip:i("editor.blockquote.tooltip")}})}}}),an=l.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ge=M.forwardRef(({className:e,...t},i)=>n.jsx(l.Root$2,{ref:i,className:S(an(),e),...t}));ge.displayName=l.Root$2.displayName;const it=M.forwardRef(({className:e,...t},i)=>n.jsx(l.Root$3,{className:S("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:i,children:n.jsx(l.Thumb,{className:S("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));it.displayName=l.Root$3.displayName;const ot=e=>{const{t}=R(),[i,o]=f.useState({text:"",link:""}),[a,s]=f.useState(!1);f.useEffect(()=>{var d;if(e!=null&&e.editor){const{href:c,target:u}=(d=e.editor)==null?void 0:d.getAttributes("link"),{from:h,to:m}=e.editor.state.selection,g=e.editor.state.doc.textBetween(h,m," ");o({link:c,text:g}),s(u==="_blank")}},[e==null?void 0:e.editor]);function r(d){d.preventDefault(),e==null||e.onSetLink(i.link,i.text,a)}return n.jsx("div",{className:"p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:r,children:[n.jsxs(ge,{children:[" ",t("editor.link.dialog.text")," "]}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative w-full max-w-sm items-center",children:n.jsx(X,{type:"text",value:i.text,required:!0,className:"w-80",placeholder:"Text",onChange:d=>o({...i,text:d.target.value})})})}),n.jsx(ge,{children:t("editor.link.dialog.link")}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsxs("div",{className:"relative w-full max-w-sm items-center",children:[n.jsx(X,{type:"url",value:i.link,required:!0,className:"pl-10",onChange:d=>o({...i,link:d.target.value})}),n.jsx("span",{className:"absolute start-0 inset-y-0 flex items-center justify-center px-2",children:n.jsx(p,{className:"size-5 text-muted-foreground",name:"Link"})})]})}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ge,{children:t("editor.link.dialog.openInNewTab")}),n.jsx(it,{checked:a,onCheckedChange:d=>{s(d)}})]}),n.jsx(z,{type:"submit",className:"mt-2 self-end",children:t("editor.link.dialog.button.apply")})]})})},ln=e=>{function t(i,o,a){e.action&&e.action({link:i,text:o,openInNewTab:a})}return n.jsxs(Q,{children:[n.jsx(ee,{disabled:e==null?void 0:e.disabled,children:n.jsx(f.Fragment,{children:n.jsx(v,{tooltip:e==null?void 0:e.tooltip,isActive:e==null?void 0:e.isActive,disabled:e==null?void 0:e.disabled,children:n.jsx(p,{name:e==null?void 0:e.icon})})})}),n.jsx(K,{hideWhenDetached:!0,className:"w-full",align:"start",side:"bottom",children:n.jsx(ot,{editor:e.editor,onSetLink:t})})]})},at=l.Link$1.extend({inclusive:!1,parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){return["a",l.mergeAttributes(this.options.HTMLAttributes,e,{class:"link"}),0]},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),openOnClick:!0,button:({editor:t,t:i})=>({component:ln,componentProps:{editor:t,action:o=>{const{link:a,text:s,openInNewTab:r}=o;t.chain().extendMarkRange("link").insertContent({type:"text",text:s,marks:[{type:"link",attrs:{href:a,target:r?"_blank":""}}]}).setLink({href:a}).focus().run()},id:"linkk",isActive:()=>t.isActive("link")||!1,disabled:!t.can().setLink({href:""}),icon:"Link",tooltip:i("editor.link.tooltip")}})}},addProseMirrorPlugins(){return[new l.Plugin({props:{handleClick:(e,t)=>{const{schema:i,doc:o,tr:a}=e.state,s=l.getMarkRange(o.resolve(t),i.marks.link);if(!s)return!1;const r=o.resolve(s.from),d=o.resolve(s.to),c=a.setSelection(new l.TextSelection(r,d));e.dispatch(c)}}})]}}),sn=l.HorizontalRule.extend({renderHTML(){return["div",l.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.setHorizontalRule(),disabled:!t.can().setHorizontalRule(),icon:"Minus",shortcutKeys:["mod","alt","S"],tooltip:i("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}}}),rn=e=>{var w;const{icon:t=void 0,title:i=void 0,tooltip:o=void 0,disabled:a=!1,customClass:s="",color:r=void 0,loading:d=!1,shortcutKeys:c=void 0,tooltipOptions:u={},action:h=void 0,isActive:m=void 0,children:g}=e,b=re[t];return n.jsxs(de,{children:[n.jsx(ce,{children:n.jsxs(ve,{size:"sm",className:"w-[32px] h-[32px] "+s,disabled:m==null?void 0:m(),onClick:h,children:[b&&n.jsx(b,{className:"w-4 h-4"}),g&&n.jsx(n.Fragment,{children:g})]})}),o&&n.jsx(oe,{...u,children:n.jsxs("div",{className:"max-w-24 text-center flex flex-col items-center",children:[n.jsx("div",{children:o}),!!((w=e==null?void 0:e.shortcutKeys)!=null&&w.length)&&n.jsx("span",{children:we(e==null?void 0:e.shortcutKeys)})]})})]})},dn=["undo","redo"],cn=l.History.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),depth:100,newGroupDelay:500,button:({editor:t,t:i})=>dn.map(o=>({component:rn,componentProps:{action:()=>{o==="undo"&&t.chain().focus().undo().run(),o==="redo"&&t.chain().focus().redo().run()},shortcutKeys:o==="undo"?["mod","Z"]:["shift","mod","Z"],disabled:o==="undo"?!t.can().undo():!t.can().redo(),isActive:()=>o==="undo"?!t.can().undo():!t.can().redo(),icon:o==="undo"?"Undo2":"Redo2",tooltip:i(`editor.${o}.tooltip`)}}))}}}),un=l.Document.extend({content:"(block|columns)+"}),mn=l.Node.create({name:"column",content:"block+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:e=>e.dataset.position,renderHTML:e=>({"data-position":e.position})}}},renderHTML({HTMLAttributes:e}){return["div",l.mergeAttributes(e,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}});var W=(e=>(e.SidebarLeft="sidebar-left",e.SidebarRight="sidebar-right",e.TwoColumn="two-column",e))(W||{});const lt=l.Node.create({name:"columns",group:"columns",content:"column+",defining:!0,isolating:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),layout:"two-column"}},addAttributes(){return{layout:{default:"two-column"}}},addCommands(){return{setColumns:()=>({commands:e})=>(e.insertContent('<div data-type="columns"><div data-type="column" data-position="left"><p></p></div><div data-type="column" data-position="right"><p></p></div></div>'),!0),setLayout:e=>({commands:t})=>t.updateAttributes("columns",{layout:e})}},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"columns",class:`layout-${e.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]},addExtensions(){return[mn.configure(this.options.columnOptions)]}}),hn=l.Extension.create({name:"columnToolbar",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>{t.chain().setColumns().focus(t.state.selection.head-1).run()},icon:"Columns",tooltip:i("editor.columns.tooltip")}})}}}),fn=l.Extension.create({name:"selection",addProseMirrorPlugins(){const{editor:e}=this;return[new l.Plugin({key:new l.PluginKey("selection"),props:{decorations(t){return t.selection.empty||e.isFocused===!0?null:l.DecorationSet.create(t.doc,[l.Decoration.inline(t.selection.from,t.selection.to,{class:"selection"})])}}})]}}),gn=e=>{const{t}=R(),i=f.useMemo(()=>[{name:"paragraph",label:t("editor.paragraph.tooltip"),iconName:"Heading1",isActive:()=>e.editor.isActive("paragraph")&&!e.editor.isActive("orderedList")&&!e.editor.isActive("bulletList")&&!e.editor.isActive("taskList"),action:()=>e.editor.chain().focus().clearNodes().run()},{name:"heading1",label:t("editor.heading.h1.tooltip"),isActive:()=>e.editor.isActive("heading",{level:1}),iconName:"Heading1",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:1}).run()},{name:"heading2",label:t("editor.heading.h2.tooltip"),isActive:()=>e.editor.isActive("heading",{level:2}),iconName:"Heading2",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:2}).run()},{name:"heading3",label:t("editor.heading.h3.tooltip"),isActive:()=>e.editor.isActive("heading",{level:3}),iconName:"Heading3",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:3}).run()},{name:"bulletList",label:t("editor.bulletlist.tooltip"),isActive:()=>e.editor.isActive("bulletList"),iconName:"List",action:()=>e.editor.chain().focus().clearNodes().toggleBulletList().run()},{name:"numberedList",label:t("editor.orderedlist.tooltip"),isActive:()=>e.editor.isActive("orderedList"),iconName:"ListOrdered",action:()=>e.editor.chain().focus().clearNodes().toggleOrderedList().run()},{name:"taskList",label:t("editor.tasklist.tooltip"),isActive:()=>e.editor.isActive("taskList"),iconName:"ListTodo",action:()=>e.editor.chain().focus().clearNodes().toggleTaskList().run()},{name:"blockquote",label:t("editor.blockquote.tooltip"),isActive:()=>e.editor.isActive("blockquote"),iconName:"TextQuote",action:()=>e.editor.chain().focus().clearNodes().toggleBlockquote().run()},{name:"codeBlock",label:t("editor.codeblock.tooltip"),isActive:()=>e.editor.isActive("codeBlock"),iconName:"Code2",action:()=>e.editor.chain().focus().clearNodes().toggleCodeBlock().run()}],[e.editor,t]),o=f.useMemo(()=>i.filter(a=>a.isActive()).pop()??{label:"Empty"},[i]);return n.jsx(n.Fragment,{children:n.jsxs(Z,{children:[n.jsx(Y,{children:n.jsxs(z,{variant:"ghost",className:"h-[32px] flex gap-1 px-1.5",children:[n.jsxs("span",{className:"whitespace-nowrap text-sm font-normal",children:[" ",o==null?void 0:o.label]}),n.jsx(l.ChevronDown,{className:"w-4 h-4"})]})}),n.jsx(V,{hideWhenDetached:!0,className:"w-full p-1",align:"start",sideOffset:5,children:i.map((a,s)=>{var d;const r=re[a.iconName];return n.jsx(J,{checked:((d=a.isActive)==null?void 0:d.call(a))||!1,onClick:()=>a.action(),className:"cursor-pointer",children:n.jsxs("div",{className:"flex items-center gap-2 px-2",children:[n.jsx(r,{className:"h3 w-3"}),n.jsxs("span",{children:[" ",a.label]})]})},s)})})]})})},xn=l.Extension.create({name:"text-bubble",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),toolbar:!1,button:()=>({component:gn,componentProps:{}})}}});function Ee({types:e,node:t}){return Array.isArray(e)&&e.includes(t.type)||t.type===e}const bn=l.Extension.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const e=new l.PluginKey(this.name),t=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>this.options.notAfter.includes(i.name));return[new l.Plugin({key:e,appendTransaction:(i,o,a)=>{const{doc:s,tr:r,schema:d}=a,c=e.getState(a),u=s.content.size,h=d.nodes[this.options.node];if(c)return r.insert(u,h.create())},state:{init:(i,o)=>{const a=o.tr.doc.lastChild;return!Ee({node:a,types:t})},apply:(i,o)=>{if(!i.docChanged)return o;const a=i.doc.lastChild;return!Ee({node:a,types:t})}}})]}}),vn=l.Extension.create({name:"base-kit",addExtensions(){const e=[];return this.options.multiColumn?(e.push(un.configure()),e.push(lt)):e.push(l.Document),this.options.placeholder!==!1&&e.push(l.Placeholder.configure({placeholder:({node:t,pos:i})=>{var o,a,s;return((o=t==null?void 0:t.type)==null?void 0:o.name)==="heading"?`${T.t(`editor.heading.h${t.attrs.level}.tooltip`)}`:((a=t==null?void 0:t.type)==null?void 0:a.name)==="codeBlock"||((s=t==null?void 0:t.type)==null?void 0:s.name)==="table"?"":i===0?T.t("editor.content"):T.t("editor.slash")},...this.options.placeholder})),this.options.focus!==!1&&e.push(l.FocusClasses.configure({className:"focus",...this.options.focus})),this.options.text!==!1&&e.push(l.Text.configure()),this.options.textBubble!==!1&&e.push(xn.configure()),this.options.gapcursor!==!1&&e.push(l.Gapcursor.configure()),this.options.dropcursor!==!1&&e.push(l.Dropcursor.configure({...this.options.dropcursor,width:2,class:"ProseMirror-dropcursor border-black"})),this.options.characterCount!==!1&&e.push(l.CharacterCount.configure(this.options.characterCount)),this.options.paragraph!==!1&&e.push(l.Paragraph.configure(this.options.paragraph)),this.options.hardBreak!==!1&&e.push(l.HardBreak.configure(this.options.hardBreak)),this.options.listItem!==!1&&e.push(l.ListItem.configure(this.options.listItem)),this.options.textStyle!==!1&&e.push(l.TextStyle.configure(this.options.textStyle)),this.options.trailingNode!==!1&&e.push(bn.configure(this.options.trailingNode)),this.options.selection!==!1&&e.push(fn),e}}),wn=l.Extension.create({name:"subAndSuperScript",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,extension:i,t:o})=>{const a=i.options.subscript,s=i.options.superscript,r={component:v,componentProps:{action:()=>t.commands.toggleSubscript(),isActive:()=>t.isActive("subscript")||!1,disabled:!t.can().toggleSubscript(),icon:"Subscript",tooltip:o("editor.subscript.tooltip")}},d={component:v,componentProps:{action:()=>t.commands.toggleSuperscript(),isActive:()=>t.isActive("superscript")||!1,disabled:!t.can().toggleSuperscript(),icon:"Superscript",tooltip:o("editor.superscript.tooltip")}},c=[];return a!==!1&&c.push(r),s!==!1&&c.push(d),c}}},addExtensions(){const e=[];return this.options.subscript!==!1&&e.push(l.Subscript$1.configure(this.options.subscript)),this.options.superscript!==!1&&e.push(l.Superscript$1.configure(this.options.superscript)),e}}),yn=e=>{var i;const t=f.useMemo(()=>{var s;const o=(s=e==null?void 0:e.items)==null?void 0:s.find(r=>r.isActive());return o&&!o.default?{...o,icon:o!=null&&o.icon?o==null?void 0:o.icon:e==null?void 0:e.icon}:{title:e.tooltip,icon:e.icon,isActive:()=>!1}},[e]);return n.jsxs(Z,{children:[n.jsx(Y,{disabled:e==null?void 0:e.disabled,children:n.jsx(v,{customClass:"w-12",icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:n.jsx(Ve,{className:"w-3 h-3 text-gray-500"})})}),n.jsx(V,{className:"w-full",children:(i=e==null?void 0:e.items)==null?void 0:i.map((o,a)=>n.jsxs(J,{checked:t.title===o.title,onClick:o.action,className:"flex gap-3 items-center",children:[n.jsx(p,{name:o==null?void 0:o.icon}),n.jsx("span",{className:"ml-1",children:o.title}),!!(o!=null&&o.shortcutKeys)&&n.jsx("span",{className:"text-xs tracking-widest opacity-60 ml-auto",children:we(o.shortcutKeys)})]},a))})]})},jn=l.Extension.create({name:"moreMark",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,extension:i,t:o}){const a=i.options.subscript,s=i.options.superscript,r={action:()=>t.commands.toggleSubscript(),isActive:()=>t.isActive("subscript")||!1,disabled:!t.can().toggleSubscript(),icon:"Subscript",title:o("editor.subscript.tooltip"),shortcutKeys:["mod","."]},d={action:()=>t.commands.toggleSuperscript(),isActive:()=>t.isActive("superscript")||!1,disabled:!t.can().toggleSuperscript(),icon:"Superscript",title:o("editor.superscript.tooltip"),shortcutKeys:["mod",","]},c=[];return a!==!1&&c.push(r),s!==!1&&c.push(d),{component:yn,componentProps:{icon:"Type",tooltip:o("editor.moremark"),disabled:!t.isEditable,items:c}}}}},addExtensions(){const e=[];return this.options.subscript!==!1&&e.push(l.Subscript$1.configure(this.options.subscript)),this.options.superscript!==!1&&e.push(l.Superscript$1.configure(this.options.superscript)),e}});var G=(e=>(e[e.max=7]="max",e[e.min=0]="min",e[e.more=1]="more",e[e.less=-1]="less",e))(G||{});function kn(e,t,i){return e<t?t:e>i?i:e}function Cn(e,t,i,o){const{doc:a,selection:s}=e;if(!a||!s||!(s instanceof l.TextSelection||s instanceof l.AllSelection))return e;const{from:r,to:d}=s;return a.nodesBetween(r,d,(c,u)=>{const h=c.type;return i.includes(h.name)?(e=Te(e,u,t),!1):!l.isList(c.type.name,o.extensionManager.extensions)}),e}function Te(e,t,i){if(!e.doc)return e;const o=e.doc.nodeAt(t);if(!o)return e;const r=kn((o.attrs.indent||0)+i,0,7);if(r===o.attrs.indent)return e;const d={...o.attrs,indent:r};return e.setNodeMarkup(t,o.type,d,o.marks)}function Oe({delta:e,types:t}){return({state:i,dispatch:o,editor:a})=>{const{selection:s}=i;let{tr:r}=i;return r=r.setSelection(s),r=Cn(r,e,t,a),r.docChanged?(o&&o(r),!0):!1}}const pn=l.Extension.create({name:"indent",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","blockquote"],minIndent:G.min,maxIndent:G.max,button({editor:t,t:i}){return[{component:v,componentProps:{action:()=>{t.commands.indent()},shortcutKeys:["Tab"],icon:"IndentIncrease",tooltip:i("editor.indent.tooltip")}},{component:v,componentProps:{action:()=>{t.commands.outdent()},shortcutKeys:["Shift","Tab"],icon:"IndentDecrease",tooltip:i("editor.outdent.tooltip")}}]}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>{const t=e.dataset.indent;return(t?Number.parseInt(t,10):0)||0},renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}}]},addCommands(){return{indent:()=>Oe({delta:G.more,types:this.options.types}),outdent:()=>Oe({delta:G.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});function Nn(e){return Number.parseFloat(e.replace("%",""))/100}const Ln=e=>{const{t}=R(),[i,o]=f.useState("default");function a(r){r==="default"?e.editor.commands.unsetLineHeight():e.editor.commands.setLineHeight(r),o(r)}const s=f.useMemo(()=>{const c=e.editor.extensionManager.extensions.find(u=>u.name==="lineHeight").options.lineHeights.map(u=>({label:Nn(u),value:u}));return c.unshift({label:t("editor.default"),value:"default"}),c},[e]);return n.jsxs(Z,{children:[n.jsx(Y,{disabled:e==null?void 0:e.disabled,children:n.jsx(v,{customClass:"w-12",icon:"LineHeight",tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,children:n.jsx(p,{className:"w-3 h-3 text-zinc-500 ml-1",name:"MenuDown"})})}),n.jsx(V,{className:"min-w-24",children:s==null?void 0:s.map((r,d)=>n.jsx(J,{checked:r.value===i,onClick:()=>a(r.value),children:r.label},`lineHeight-${d}`))})]})},Tn=["paragraph","heading","list_item","todo_item"];function Sn(e,t){const{selection:i,doc:o}=e;if(!i||!o||!(i instanceof l.TextSelection||i instanceof l.AllSelection))return e;const{from:a,to:s}=i,r=[],d=t&&t!==Ye?t:null;if(o.nodesBetween(a,s,(c,u)=>{const h=c.type;return Tn.includes(h.name)?((c.attrs.lineHeight||null)!==d&&r.push({node:c,pos:u,nodeType:h}),h.name!=="list_item"&&h.name!=="todo_item"):!0}),r.length===0)return e;for(const c of r){const{node:u,pos:h,nodeType:m}=c;let{attrs:g}=u;g={...g,lineHeight:d},e=e.setNodeMarkup(h,m,g,u.marks)}return e}function An(e){return({state:t,dispatch:i})=>{const{selection:o}=t;let{tr:a}=t;return a=a.setSelection(o),a=Sn(a,e),a.docChanged?(i&&i(a),!0):!1}}const Mn=l.Extension.create({name:"lineHeight",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","list_item","todo_item"],lineHeights:["100%","115%","150%","200%","250%","300%"],defaultHeight:Ye,button({editor:t,t:i}){return{component:Ln,componentProps:{editor:t,tooltip:i("editor.lineheight.tooltip")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||this.options.defaultHeight,renderHTML:e=>e.lineHeight===this.options.defaultHeight||!e.lineHeight?{}:{style:`line-height: ${e.lineHeight}`}}}}]},addCommands(){return{setLineHeight:e=>An(e),unsetLineHeight:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"lineHeight"))}}}),Rn=(e,t)=>{var H,D;const[i,o]=f.useState(0),[a,s]=f.useState(0),r=f.useRef(null),{t:d}=R(),c=f.useRef([]);f.useImperativeHandle(t,()=>({onKeyDown:u})),f.useEffect(()=>{if(!r.current)return;const y=a*1e3+i,j=c.current[y];j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},[i,a]);function u({event:y}){return y.key==="ArrowUp"?(h(),!0):y.key==="ArrowDown"?(m(),!0):y.key==="Enter"?(g(),!0):!1}function h(){var C;if(e.items.length===0)return!1;let y=i-1,j=a;y<0&&(j=a-1,y=((C=e.items[j])==null?void 0:C.commands.length)-1||0),j<0&&(j=e.items.length-1,y=e.items[j].commands.length-1),o(y),s(j)}function m(){if(e.items.length===0)return!1;const y=e.items[a].commands;let j=i+1,C=a;y.length-1<j&&(j=0,C=a+1),e.items.length-1<C&&(C=0),o(j),s(C)}function g(){if(e.items.length===0||a===-1||i===-1)return!1;b(a,i)}function b(y,j){const C=e.items[y].commands[j];e.command(C)}function w(y,j){b(y,j)}function L(y,j,C){c.current[y*1e3+j]=C}return n.jsx("div",{className:"bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800 text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-1",ref:r,children:(H=e==null?void 0:e.items)!=null&&H.length?n.jsx("div",{className:"grid grid-cols-1 gap-0.5 min-w-48",children:(D=e==null?void 0:e.items)==null?void 0:D.map((y,j)=>n.jsxs(f.Fragment,{children:[n.jsx("div",{className:"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-2 font-semibold tracking-wider select-none uppercase first:mt-0.5",children:y.title}),y.commands.map((C,B)=>n.jsxs("button",{className:`flex items-center gap-3 px-2 py-1.5 text-sm text-neutral-800 dark:text-neutral-200 text-left w-full rounded-sm outline-none transition-colors ${a===j&&i===B?"bg-accent text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200":"hover:bg-accent hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200"}`,ref:O=>L(j,B,O),onClick:()=>w(j,B),children:[C.iconUrl&&n.jsx("img",{className:"w-6 h-6",src:C.iconUrl,alt:""}),C.iconName&&n.jsx(p,{name:C.iconName,className:"mr-1 text-lg"}),C.label]},`command-${B}`))]},y.title))}):n.jsx("div",{className:"p-3",children:n.jsx("span",{className:"text-xs text-gray-800 dark:text-gray-100",children:d("editor.slash.empty")})})})},Hn=f.forwardRef(Rn);function Fn(e){return[{name:"format",title:T.t("editor.slash.format"),commands:[{name:"heading1",label:T.t("editor.heading.h1.tooltip"),aliases:["h1","bt","bt1"],iconName:"Heading1",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setHeading({level:1}).run()}},{name:"heading2",label:T.t("editor.heading.h2.tooltip"),aliases:["h2","bt","bt2"],iconName:"Heading2",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setNode("heading",{level:2}).run()}},{name:"heading3",label:T.t("editor.heading.h3.tooltip"),aliases:["h3","bt","bt3"],iconName:"Heading3",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setNode("heading",{level:3}).run()}},{name:"bulletList",label:T.t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).toggleBulletList().run()}},{name:"numberedList",label:T.t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).toggleOrderedList().run()}},{name:"taskList",label:T.t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).toggleTaskList().run()}},{name:"blockquote",label:T.t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setBlockquote().run()}},{name:"codeBlock",label:T.t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:i=>i.isActive("columns"),action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setCodeBlock().run()}}]},{name:"insert",title:T.t("editor.slash.insert"),commands:[{name:"image",label:T.t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:i=>i.isActive("columns"),action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setImageUpload().run()}},{name:"video",label:T.t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:i=>i.isActive("columns"),action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setVideoUpload().run()}},{name:"table",label:T.t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:i=>i.isActive("columns"),action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},{name:"horizontalRule",label:T.t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:i,range:o})=>{i.chain().focus().deleteRange(o).setHorizontalRule().run()}}]}]}const q="slashCommand";let k;const Dn=l.Extension.create({name:q,priority:200,onCreate(){k=l.tippy("body",{interactive:!0,trigger:"manual",placement:"bottom-start",theme:"slash-command",maxWidth:"16rem",offset:[16,8],popperOptions:{strategy:"fixed",modifiers:[{name:"flip",enabled:!1}]}})},addProseMirrorPlugins(){return[l.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new l.PluginKey(q),allow:({state:e,range:t})=>{var u,h,m;const i=e.doc.resolve(t.from),o=i.depth===1,a=i.parent.type.name==="paragraph",s=((u=i.parent.textContent)==null?void 0:u.charAt(0))==="/",r=this.editor.isActive("column"),d=(m=i.parent.textContent)==null?void 0:m.slice(Math.max(0,(h=i.parent.textContent)==null?void 0:h.indexOf("/"))),c=!(d!=null&&d.endsWith(" "));return(o&&a&&s||r&&a&&s)&&c},command:({editor:e,range:t,props:i})=>{const{view:o}=e;i.action({editor:e,range:t}),o.focus()},items:({query:e})=>(console.log(this),Fn(this.editor).map(s=>({...s,commands:s.commands.filter(r=>{const d=r.label.toLowerCase().trim(),c=e.toLowerCase().trim();if(r.aliases){const u=r.aliases.map(g=>g.toLowerCase().trim()),h=d.match(c),m=u.some(g=>g.match(c));return h||m}return d.match(c)}).filter(r=>r.shouldBeHidden?!r.shouldBeHidden(this.editor):!0)})).filter(s=>s.commands.length>0).map(s=>({...s,commands:s.commands.map(r=>({...r,isEnabled:!0}))}))),render:()=>{let e,t=null;return{onStart:i=>{var s;e=new l.ReactRenderer(Hn,{props:i,editor:i.editor});const{view:o}=i.editor,a=()=>{if(!i.clientRect)return i.editor.storage[q].rect;const r=i.clientRect();if(!r)return i.editor.storage[q].rect;let d=r.y;if(r.top+e.element.offsetHeight+40>window.innerHeight){const c=r.top+e.element.offsetHeight-window.innerHeight+40;d=r.y-c}return new DOMRect(r.x,d,r.width,r.height)};t=()=>{k==null||k[0].setProps({getReferenceClientRect:a})},(s=o.dom.parentElement)==null||s.addEventListener("scroll",t),k==null||k[0].setProps({getReferenceClientRect:a,appendTo:()=>document.body,content:e.element}),k==null||k[0].show()},onUpdate(i){var r;e.updateProps(i);const{view:o}=i.editor,a=()=>{if(!i.clientRect)return i.editor.storage[q].rect;const d=i.clientRect();return d?new DOMRect(d.x,d.y,d.width,d.height):i.editor.storage[q].rect},s=()=>{k==null||k[0].setProps({getReferenceClientRect:a})};(r=o.dom.parentElement)==null||r.addEventListener("scroll",s),i.editor.storage[q].rect=i.clientRect?a():{width:0,height:0,left:0,top:0,right:0,bottom:0},k==null||k[0].setProps({getReferenceClientRect:a})},onKeyDown(i){var o;return i.event.key==="Escape"?(k==null||k[0].hide(),!0):(k!=null&&k[0].state.isShown||k==null||k[0].show(),(o=e.ref)==null?void 0:o.onKeyDown(i))},onExit(i){var o;if(k==null||k[0].hide(),t){const{view:a}=i.editor;(o=a.dom.parentElement)==null||o.removeEventListener("scroll",t)}e.destroy()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}}),In=(e,t="px")=>{if(!e)return e;const i=Se(e)?String(e):e,o=Number.parseFloat(i),a=i.match(/[%A-Za-z]+$/),s=a?a[0]:t;return Number.isNaN(o)?e:o+s};function Bn(e,t,i){return e<t?t:e>i?i:e}const Se=e=>typeof e=="number",zn=e=>typeof e=="function";function Pn(e,t){if(!e)return!1;const{extensions:i=[]}=(e==null?void 0:e.extensionManager)??{};return!!i.find(a=>a.name===t)}const fe={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"},En=e=>{var O;const[t,i]=f.useState({width:Be,height:Be}),[o,a]=f.useState({width:0,height:0}),[s,r]=f.useState([fe.TOP_LEFT,fe.TOP_RIGHT,fe.BOTTOM_LEFT,fe.BOTTOM_RIGHT]),[d,c]=f.useState(!1),[u,h]=f.useState({x:0,y:0,w:0,h:0,dir:""}),m=f.useMemo(()=>{var I;const{src:x,alt:F,width:A,height:P}=(I=e==null?void 0:e.node)==null?void 0:I.attrs,U=Se(A)?A+"px":A,N=Se(P)?P+"px":P;return{src:x||void 0,alt:F||void 0,style:{width:U||void 0,height:N||void 0}}},[(O=e==null?void 0:e.node)==null?void 0:O.attrs]),g=f.useMemo(()=>{const{style:{width:x}}=m;return{width:x==="100%"?x:void 0}},[m]);function b(x){a({width:x.target.width,height:x.target.height})}function w(){const{editor:x,getPos:F}=e;x.commands.setNodeSelection(F())}const L=f.useCallback(l.throttle(function(){const{editor:x}=e,{width:F}=getComputedStyle(x.view.dom);i(A=>({...A,width:Number.parseInt(F,10)}))},ze),[e==null?void 0:e.editor]);function H(x,F){x.preventDefault(),x.stopPropagation();const A=o.width,P=o.height,U=A/P;let N=Number(e.node.attrs.width),I=Number(e.node.attrs.height);const E=t.width;N&&!I?(N=N>E?E:N,I=Math.round(N/U)):I&&!N?(N=Math.round(I*U),N=N>E?E:N):!N&&!I?(N=A>E?E:A,I=Math.round(N/U)):N=N>E?E:N,Fe.flushSync(()=>{c(!0),h({x:x.clientX,y:x.clientY,w:N,h:I,dir:F})})}const D=f.useCallback(l.throttle(function(x){if(x.preventDefault(),x.stopPropagation(),!d)return;const{x:F,y:A,w:P,h:U,dir:N}=u,I=(x.clientX-F)*(/l/.test(N)?-1:1);(x.clientY-A)*(/t/.test(N)?-1:1);const E=Bn(P+I,Ht,t.width);e.updateAttributes({width:E,height:null})},ze),[d,u,t,e.updateAttributes]),y=f.useCallback(x=>{x.preventDefault(),x.stopPropagation(),d&&(Fe.flushSync(()=>{h({x:0,y:0,w:0,h:0,dir:""}),c(!1)}),w())},[d,w]),j=f.useCallback(()=>{document==null||document.addEventListener("mousemove",D,!0),document==null||document.addEventListener("mouseup",y,!0)},[D,y]),C=f.useCallback(()=>{document==null||document.removeEventListener("mousemove",D,!0),document==null||document.removeEventListener("mouseup",y,!0)},[D,y]);f.useEffect(()=>(d?j():C(),()=>{C()}),[d,j,C]);const B=f.useMemo(()=>new ResizeObserver(()=>L()),[L]);return f.useEffect(()=>(B.observe(e.editor.view.dom),()=>{B.disconnect()}),[e.editor.view.dom,B]),n.jsx(l.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%"},children:n.jsxs("div",{draggable:"true","data-drag-handle":!0,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${d?"image-view__body--resizing":""}`,style:g,children:[n.jsx("img",{src:m.src,alt:m.alt,style:m.style,height:"auto",className:"image-view__body__image block",onLoad:b,onClick:w}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||d)&&n.jsx("div",{className:"image-resizer",children:s==null?void 0:s.map(x=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${x}`,onMouseDown:F=>H(F,x)},x))})]})})},On=l.Image.extend({inline(){return!0},group(){return"inline"},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const i=t.style.width||t.getAttribute("width")||null;return i==null?null:Number.parseInt(i,10)},renderHTML:t=>({width:t.width})}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!0,upload:null}},addNodeView(){return l.ReactNodeViewRenderer(En)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),updateImage:t=>({commands:i})=>i.updateAttributes(this.name,t)}},renderHTML({HTMLAttributes:e}){return["img",l.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]},parseHTML(){return[{tag:"img[src]"}]}}),st=l.Root2$2,Re=M.forwardRef(({className:e,...t},i)=>n.jsx(l.List$1,{ref:i,className:S("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Re.displayName=l.List$1.displayName;const le=M.forwardRef(({className:e,...t},i)=>n.jsx(l.Trigger$3,{ref:i,className:S("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));le.displayName=l.Trigger$3.displayName;const se=M.forwardRef(({className:e,...t},i)=>n.jsx(l.Content,{ref:i,className:S("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));se.displayName=l.Content.displayName;const ie=new l.PluginKey("upload-image"),_n=()=>new l.Plugin({key:ie,state:{init(){return l.DecorationSet.empty},apply(e,t){t=t.map(e.mapping,e.doc);const i=e.getMeta(ie);if(i!=null&&i.add)for(const{id:o,pos:a,src:s}of i.add){const r=$n(s),d=l.Decoration.widget(a,r,{id:o});t=t.add(e.doc,[d])}else if(i!=null&&i.remove)for(const o of i.remove)t=t.remove(t.find(void 0,void 0,a=>a.id===o));return t}},props:{decorations(e){return this.getState(e)}}});function $n(e){const t=document.createElement("div"),i=document.createElement("img");return i.setAttribute("class","opacity-50"),i.src=e,i.addEventListener("load",()=>{t.setAttribute("class","img-placeholder")}),t.append(i),t}function Un(e,t){var a;const o=ie.getState(e).find(void 0,void 0,s=>s.id===t);return o.length>0?(a=o[0])==null?void 0:a.from:null}const rt=({validateFn:e,onUpload:t})=>(i,o,a)=>{for(const s of i){if(e&&!e(s))continue;const r=Date.now().toString(),d=o.state.tr;d.selection.empty||d.deleteSelection();const c=URL.createObjectURL(s);d.setMeta(ie,{add:[{id:r,pos:a,src:c}]}),o.dispatch(d),t(s).then(u=>{var L;const{schema:h}=o.state,m=Un(o.state,r);if(m===null)return;const g=typeof u=="object"?c:u,b=(L=h.nodes.image)==null?void 0:L.create({src:g});if(!b)return;const w=o.state.tr.replaceWith(m,m,b).setMeta(ie,{remove:[r]});o.dispatch(w)},()=>{const u=o.state.tr.delete(a,a).setMeta(ie,{remove:[r]});o.dispatch(u)})}},Vn=(e,t,i)=>{var a;const o=[...((a=t.clipboardData)==null?void 0:a.files)||[]];if(o.length>0){t.preventDefault();const s=e.state.selection.from;return i(o,e,s+1),!0}return!1},Kn=(e,t,i,o)=>{var s;const a=[...((s=t.dataTransfer)==null?void 0:s.files)||[]];if(!i&&a.length>0){t.preventDefault();const r=e.posAtCoords({left:t.clientX,top:t.clientY});if(r)return o(a,e,r.pos+1),!0}return!1},qn=e=>{const{t}=R(),[i,o]=f.useState(""),a=f.useRef(null);function s(u){var w,L;const h=(w=u==null?void 0:u.target)==null?void 0:w.files;if(!e.editor||e.editor.isDestroyed||h.length===0)return;const m=h[0],g=(L=e.editor.extensionManager.extensions.find(H=>H.name==="imageUpload"))==null?void 0:L.options;rt({validateFn:()=>!0,onUpload:g.upload})([m],e.editor.view,e.getPos())}function r(u){u.preventDefault(),e.editor.chain().setImage({src:i}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run()}function d(u){u==null||u.preventDefault(),e.deleteNode()}function c(u){var h;u.preventDefault(),(h=a.current)==null||h.click()}return n.jsx(l.NodeViewWrapper,{className:"p-0 m-0","data-drag-handle":!0,children:n.jsxs(Q,{defaultOpen:!0,modal:!0,children:[n.jsx(ee,{asChild:!0,children:n.jsx("div",{className:"flex items-center w-full p-3 my-3 hover:bg-accent border border-border text-muted-foreground cursor-pointer rounded-sm transition-all",children:n.jsxs("div",{className:"flex justify-between items-center w-full",children:[n.jsxs("div",{className:"flex justify-center items-center gap-3",children:[n.jsx(p,{name:"ImageUp",className:"w-6 h-6"}),n.jsx("span",{className:"text-sm",children:t("editor.image.dialog.title")})]}),n.jsx(p,{name:"Trash2",className:"hover:text-foreground",onClick:d})]})})}),n.jsx(K,{className:"w-full",onOpenAutoFocus:u=>u.preventDefault(),children:n.jsxs(st,{defaultValue:"upload",className:"w-[400px]",activationMode:"manual",children:[n.jsxs(Re,{className:"grid w-full grid-cols-2",children:[n.jsxs(le,{value:"upload",children:[t("editor.image.dialog.tab.upload")," "]}),n.jsxs(le,{value:"link",children:[" ",t("editor.image.dialog.tab.url")," "]})]}),n.jsxs(se,{value:"upload",children:[n.jsx(z,{className:"w-full mt-1",size:"sm",onClick:c,children:t("editor.image.dialog.tab.upload")}),n.jsx("input",{type:"file",accept:"image/*",ref:a,multiple:!0,style:{display:"none"},onChange:s})]}),n.jsx(se,{value:"link",children:n.jsx("form",{onSubmit:r,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(X,{type:"url",autoFocus:!0,value:i,onChange:u=>o(u.target.value),required:!0,placeholder:t("editor.image.dialog.placeholder")}),n.jsx(z,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})})]})})},Wn={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5},Gn=l.Node.create({name:"imageUpload",isolating:!0,defining:!0,group:"block",draggable:!1,selectable:!0,inline:!1,onCreate(){if(typeof this.options.upload!="function")throw new TypeError("Image upload function should be a function")},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addCommands(){return{setImageUpload:()=>({commands:e})=>e.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return l.ReactNodeViewRenderer(qn)},addOptions(){var e;return{...Wn,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:i,t:o})=>({component:v,componentProps:{action:()=>t.commands.setImageUpload(),upload:i.options.upload,disabled:!t.can().setImage({}),icon:"ImageUp",tooltip:o("editor.image.tooltip")}})}},addProseMirrorPlugins(){const t=rt({validateFn:i=>!(!this.options.acceptMimes.includes(i.type)||i.size>this.options.maxSize),onUpload:this.options.upload});return[new l.Plugin({props:{handlePaste:(i,o)=>!o.clipboardData||[...o.clipboardData.items||[]].some(s=>s.type==="text/html")?!1:Vn(i,o,t),handleDrop:(i,o,a,s)=>(!(o instanceof DragEvent)||!o.dataTransfer||Kn(i,o,s,t),!1)}}),_n()]}});function Xn(e){return e=e.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/"),e=e.replace("https://vimeo.com/","https://player.vimeo.com/video/"),/^https?:\/\/www.bilibili.com\/video\/.*/i.test(e)&&(e=e.replace(/\?.*$/i,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),e.includes("drive.google.com")&&(e=e.replace("/view","/preview")),e}const Zn=l.Node.create({name:"video",group:"block",atom:!0,draggable:!0,addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?Xn(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:In(e)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"div[data-video] iframe"}]},renderHTML({HTMLAttributes:e}){const{width:t="100%"}=e??{},i={...e,width:"100%",height:"100%"},o=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`,a=`flex: 1;padding-bottom: ${9/16*100}%;`,d=["div",{style:o},["div",{style:a}],["iframe",i]];return["div",{...this.options.HTMLAttributes,"data-video":""},d]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}},addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,width:xe["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"}}}}),Yn=e=>{const{t}=R(),[i,o]=f.useState(""),[a,s]=f.useState(!1),r=f.useRef(null);function d(m){var L,H;s(!0);const g=(L=m==null?void 0:m.target)==null?void 0:L.files;if(!e.editor||e.editor.isDestroyed||g.length===0)return;const b=g[0],w=(H=e.editor.extensionManager.extensions.find(D=>D.name==="videoUpload"))==null?void 0:H.options;w==null||w.upload([b]).then(D=>{e.editor.chain().setVideo({src:D[0].src,width:"100%"}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run(),s(!1)})}function c(m){m.preventDefault(),e.editor.chain().setVideo({src:i,width:"100%"}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run()}function u(m){m.preventDefault(),e.deleteNode()}function h(m){var g;m.preventDefault(),(g=r.current)==null||g.click()}return n.jsx(l.NodeViewWrapper,{as:"div","data-drag-handle":!0,children:n.jsxs(Q,{defaultOpen:!0,modal:!0,children:[n.jsx(ee,{asChild:!0,children:n.jsx("div",{className:"flex items-center w-full p-3 my-3 hover:bg-accent border border-border text-muted-foreground cursor-pointer rounded-sm transition-all",children:a?n.jsxs("div",{className:"flex justify-center items-center gap-3 text-s",children:[n.jsx(p,{className:"animate-spin w-6 h-6",name:"LoaderCircle"}),n.jsxs("span",{children:[t("editor.video.dialog.uploading"),"..."]})]}):n.jsxs("div",{className:"flex justify-between items-center w-full",children:[n.jsxs("div",{className:"flex justify-center items-center gap-3",children:[n.jsx(p,{name:"Video",className:"w-6 h-6"}),n.jsx("span",{className:"text-sm",children:t("editor.video.dialog.title")})]}),n.jsx(p,{name:"Trash2",className:"hover:text-foreground",onClick:u})]})})}),n.jsx(K,{className:"w-full",onOpenAutoFocus:m=>m.preventDefault(),children:n.jsxs(st,{defaultValue:"upload",className:"w-[400px]",activationMode:"manual",children:[n.jsxs(Re,{className:"grid w-full grid-cols-2",children:[n.jsxs(le,{value:"upload",children:[t("editor.video.dialog.tab.upload")," "]}),n.jsxs(le,{value:"link",children:[" ",t("editor.video.dialog.link")," "]})]}),n.jsxs(se,{value:"upload",children:[n.jsx(z,{className:"w-full mt-1",size:"sm",onClick:h,children:t("editor.video.dialog.tab.upload")}),n.jsx("input",{type:"file",accept:"video/*",ref:r,multiple:!0,style:{display:"none"},onChange:d})]}),n.jsx(se,{value:"link",children:n.jsx("form",{onSubmit:c,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(X,{type:"url",autoFocus:!0,required:!0,placeholder:t("editor.video.dialog.placeholder"),value:i,onChange:m=>o(m.target.value)}),n.jsx(z,{type:"submit",children:t("editor.video.dialog.button.apply")})]})})})]})})]})})},Jn=l.Node.create({name:"videoUpload",isolating:!0,defining:!0,group:"block",draggable:!0,selectable:!0,inline:!1,parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addCommands(){return{setVideoUpload:()=>({commands:e})=>e.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return l.ReactNodeViewRenderer(Yn)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),upload:void 0,button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>t.commands.setVideoUpload(),isActive:()=>t.isActive("video")||!1,disabled:!t.can().setVideo({}),icon:"Video",tooltip:i("editor.video.tooltip")}})}}}),Qn=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ei=/CrOS/,ti=/android|ipad|playbook|silk/i;function _e(e={}){let t=e.ua||typeof navigator<"u"&&navigator.userAgent;return t&&typeof t=="object"&&t.headers&&typeof t.headers["user-agent"]=="string"&&(t=t.headers["user-agent"]),typeof t!="string"?!1:!!(Qn.test(t)&&!ei.test(t)||e.tablet&&ti.test(t)||e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.includes("Macintosh")&&t.includes("Safari"))}const $e=e=>Array.from({length:e}).map((t,i)=>i+1),ni=e=>{var h;const[t,i]=f.useState(!0),[o,a]=f.useState({rows:_e()?me:ue,cols:_e()?me:ue}),[s,r]=f.useState({rows:he,cols:he});function d(m,g){m===o.rows&&a(b=>({...b,rows:Math.min(m+1,me)})),g===o.cols&&a(b=>({...b,cols:Math.min(g+1,me)})),r({rows:m,cols:g})}function c(m,g){e==null||e.createTable({rows:m,cols:g,withHeaderRow:t}),u()}function u(){i(!1),a({rows:ue,cols:ue}),r({rows:he,cols:he})}return n.jsxs(Q,{children:[n.jsx(ee,{asChild:!0,children:n.jsx("button",{disabled:e==null?void 0:e.disabled,className:"m-0 p-0",children:e==null?void 0:e.children})}),n.jsx(K,{className:"w-full !p-2",align:"start",side:"bottom",children:n.jsxs("div",{className:"table-grid-size-editor p-0",children:[n.jsx("div",{className:"flex flex-col flex-wrap gap-1 justify-between",children:(h=$e(o==null?void 0:o.rows))==null?void 0:h.map(m=>{var g;return n.jsx("div",{className:"flex gap-1",children:(g=$e(o==null?void 0:o.cols))==null?void 0:g.map(b=>n.jsx("div",{className:`pa-1 cursor-pointer border-border ${b<=s.cols&&m<=s.rows&&"bg-foreground"}`,onMouseOver:()=>d(m,b),onMouseDown:()=>c(m,b),children:n.jsx("div",{className:"w-4 h-4 p-1 border rounded-[2px] box-border border-solid"})},`c-${b}`))},`r-${m}`)})}),n.jsxs("div",{className:"text-center text-sm text-zinc-600 mt-2",children:[s.rows," x ",s.cols]})]})})]})},ii=e=>{function t(i){e.disabled||e.editor.chain().focus().insertTable({...i,withHeaderRow:!1}).run()}return n.jsx(ni,{createTable:t,disabled:e==null?void 0:e.disabled,children:n.jsx("div",{className:"flex",children:n.jsx(v,{icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,color:e==null?void 0:e.color,action:e==null?void 0:e.action,isActive:e==null?void 0:e.isActive})})})},oi=(e,t,i)=>{if(!e.doc)return e;const o=e.doc.nodeAt(t);if(!o||i===o.attrs.backgroundColor)return e;const a={...o.attrs,backgroundColor:i};return e.setNodeMarkup(t,o.type,a,o.marks)},ai=(e,t,i)=>{const{doc:o,selection:a}=e;return!o||!a||!(a instanceof l.CellSelection)||a.forEachCell((s,r)=>{e=oi(e,r,i)}),e},Ue=(e,t)=>({tr:i,state:o,dispatch:a})=>{const{selection:s}=o;return i=i.setSelection(s),i=ai(i,t,e),i.docChanged?(a==null||a(i),!0):!1},li=l.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:e=>e.style.backgroundColor||"",renderHTML:e=>!e.backgroundColor||e.backgroundColor===""?{}:{style:`background-color: ${e.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:e=>Ue(e,this.options),unsetTableCellBackground:()=>Ue("",this.options)}}}),si=l.Table$1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:t,t:i})=>({component:ii,componentProps:{disabled:t.isActive("table")||!1,icon:"Table",tooltip:i("editor.table.tooltip"),editor:t}})}},addExtensions(){return[l.TableRow.configure(this.options.tableRow),l.TableHeader.configure(this.options.tableHeader),l.TableCell.configure(this.options.tableCell),li.configure(this.options.tableCellBackground)]}}),ri=l.Extension.create({name:"painter",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:i})=>({component:v,componentProps:{action:()=>{t.commands.setPainter(t==null?void 0:t.state.selection.$head.marks())},icon:"PaintRoller",tooltip:i("editor.format")}})}},addCommands(){return{setPainter:e=>({view:{dispatch:t,state:{tr:i},dom:o}})=>{const r=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#000" d="M9 22v-6H4V7q0-1.65 1.175-2.825T8 3h12v13h-5v6zM6 10h12V5h-1v4h-2V5h-1v2h-2V5H8q-.825 0-1.412.588T6 7zm0 4h12v-2H6zm0 0v-2z"/></svg>')}"), auto`;return o.style.cursor=r,t(i.setMeta("painterAction",{type:"start",marks:e})),!0}}},addProseMirrorPlugins(){return[new l.Plugin({key:new l.PluginKey("format-painter"),state:{init:()=>[],apply:(e,t)=>{const i=e.getMeta("painterAction");return i&&i.type==="start"?t=i.marks:i&&i.type==="end"&&(t=[]),t}},props:{handleDOMEvents:{mousedown(e,t){const i=this.getState(e.state);if(!i||i.length===0)return e.dom.style.cursor="",!1;const o=()=>{document.removeEventListener("mouseup",o);let{dispatch:a,state:{tr:s,selection:r},dom:d}=e;d.style.cursor="",s=s.removeMark(r.from,r.to);for(const c of i)c.type.name!="link"&&(s=s.addMark(r.from,r.to,c));a(s.setMeta("painterAction",{type:"end"}))};return document.addEventListener("mouseup",o),!0}}}})]}}),ae={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:["v.youku.com\\/v_show\\/id_\\w+\\=*"],idRule:"id_\\w+\\=*"},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:["www.bilibili.com\\/video\\/\\w+"]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:["v.qq.com\\/x\\/cover\\/\\w+\\/\\w+"]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:["\\.amap\\.com"]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:["map\\.baidu\\.com"]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:["https:\\/\\/\\w+.modao.cc\\/app\\/\\w+\\/embed\\/v2"],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:["https:\\/\\/lanhuapp.com\\/url\\/\\w+"],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:["https:\\/\\/www.figma.com\\/file\\/\\w+"]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:["https:\\/\\/www.canva.cn\\/design\\/.+\\/view"]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:["https:\\/\\/www.processon.com\\/embed\\/\\w+"]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:["https:\\/\\/codepen.io\\/.+\\/embed\\/\\w+"]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:["https:\\/\\/jinshuju.net\\/f\\/\\w+"]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:["https:\\/\\/goo.gl\\/maps\\/\\w+"]}};function di(e,t){const i=ae.youtube,o=t.matchedUrl;t.validLink=!0;const a=o.split("="),s=a.length;if(s>0){const r=a[s-1];t.src=`${i.srcPrefix}/${r}`,t.validId=!0}return t}function ci(e,t){const i=ae.youku,o=t.matchedUrl,a=i.idRule,s=new RegExp(a),r=o.match(s);if(r&&r.length>0){const d=r[0].slice(3);t.validId=!0,t.src=`${i.srcPrefix}/${d}`}else t.validId=!1;return t}function ui(e,t){const i=ae.bilibili,a=t.matchedUrl.split("/"),s=a.length;if(s>0){const r=a[s-1];t.src=`${i.srcPrefix}=${r}`,t.validId=!0}return t}function mi(e,t){const i=ae.qqvideo,a=t.matchedUrl.split("/"),s=a.length;if(s>0){const r=a[s-1];t.src=`${i.srcPrefix}=${r}`,t.validId=!0}return t}function hi(e,t){return t.src=e,t.validId=!0,t}function fi(e,t){return t.src=e,t.validId=!0,t}function gi(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function xi(e,t){return t.src=t.matchedUrl,t.validId=!0,t.originalLink=t.src,t}function bi(e,t){return t.src=t.matchedUrl,t.validId=!0,t.originalLink=t.src,t}function vi(e,t){const i=ae.figma;return t.src=`${i.srcPrefix}=${encodeURIComponent(t.matchedUrl)}`,t.validId=!0,t.originalLink=t.matchedUrl,t}function wi(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function yi(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function ji(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=t.src,t}function ki(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function Ci(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function pi(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const a=ae[e].linkRule;for(const s of a){const r=new RegExp(s),d=t.match(r);if(d&&d.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?d[1]:d[0],i}return i}const Ni=e=>{var i,o;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(o=e.includes)!=null&&o.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t},Li=e=>{let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=Ni(e);if(t=pi(i,e,t),!t.validLink)return t;switch(i){case"youtube":return di(e,t);case"youku":return ci(e,t);case"bilibili":return ui(e,t);case"qqvideo":return mi(e,t);case"amap":return hi(e,t);case"baidu_map":return fi(e,t);case"googlemaps":return gi(e,t);case"modao":return xi(e,t);case"lanhu":return bi(e,t);case"figma":return vi(e,t);case"canva":return wi(e,t);case"processon":return yi(e,t);case"codepen":return ji(e,t);case"jinshuju":return ki(e,t);case"iframe":return Ci(e,t)}return t},Ti=e=>{var a,s,r,d,c,u,h,m;const[t,i]=f.useState("");function o(){if(!t)return;const g=Li(t);g.validLink&&g.validId&&e.updateAttributes({src:g.src})}return n.jsx(n.Fragment,{children:n.jsxs(l.NodeViewWrapper,{as:"section",children:[!((s=(a=e==null?void 0:e.node)==null?void 0:a.attrs)!=null&&s.src)&&n.jsxs("div",{className:"max-w-[600px] mx-[auto] my-[12px] flex items-center justify-center gap-[10px] p-[10px] border-[1px] border-solid border-[#ccc] rounded-[12px]",children:[n.jsx(X,{value:t,onInput:g=>i(g.target.value),type:"url",className:"flex-1",autoFocus:!0,placeholder:"Enter link"}),n.jsx(z,{className:"w-[60px]",onClick:o,children:"OK"})]}),((d=(r=e==null?void 0:e.node)==null?void 0:r.attrs)==null?void 0:d.src)&&n.jsx("iframe",{src:(u=(c=e==null?void 0:e.node)==null?void 0:c.attrs)==null?void 0:u.src,frameBorder:"0",allowFullScreen:!0,title:(m=(h=e==null?void 0:e.node)==null?void 0:h.attrs)==null?void 0:m.src,className:"my-[12px]"})]})})},Si=l.Node.create({name:"iframes",group:"block",atom:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"},button:({editor:t,extension:i,t:o})=>({component:v,componentProps:{action:a=>t.commands.setIframe(a),upload:i.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:o("editor.iframe.tooltip")}})}},addAttributes(){return{src:{default:null},service:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["div",this.options.HTMLAttributes,["iframe",e]]},addNodeView(){return l.ReactNodeViewRenderer(Ti)},addCommands(){return{setIframe:e=>({tr:t,dispatch:i})=>{const{selection:o}=t,a=this.type.create(e);return i&&t.replaceRangeWith(o.from,o.to,a),!0}}}}),Ai=e=>{const{t}=R();return n.jsxs("div",{className:"flex items-center gap-2 p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:[n.jsx("a",{href:e==null?void 0:e.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline break-all",children:l.truncate(e==null?void 0:e.link,{length:50,omission:"…"})}),(e==null?void 0:e.link)&&n.jsx($,{orientation:"vertical",className:"h-4"}),n.jsxs("div",{className:"flex flex-nowrap",children:[n.jsx(v,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),action:()=>{e==null||e.onEdit()},tooltipOptions:{sideOffset:15}}),n.jsx(v,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),action:()=>{e==null||e.onClear()},tooltipOptions:{sideOffset:15}})]})]})},Mi=e=>{const[t,i]=f.useState(!1),o=f.useMemo(()=>{const{href:d}=e.editor.getAttributes("link");return d},[e]),a=f.useCallback(({editor:d})=>d.isActive("link"),[]),s=(d,c,u)=>{e.editor.chain().extendMarkRange("link").insertContent({type:"text",text:c,marks:[{type:"link",attrs:{href:d,target:u?"_blank":""}}]}).setLink({href:d}).focus().run(),i(!1)},r=f.useCallback(()=>{e.editor.chain().extendMarkRange("link").unsetLink().focus().run(),i(!1)},[e.editor]);return n.jsx(n.Fragment,{children:n.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:a,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{i(!1)}},children:e!=null&&e.disabled?n.jsx(n.Fragment,{}):n.jsx(n.Fragment,{children:t?n.jsx(ot,{onSetLink:s,editor:e==null?void 0:e.editor}):n.jsx(Ai,{editor:e==null?void 0:e.editor,onClear:r,onEdit:()=>{i(!0)},link:o})})})})},Ri=e=>{const t=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return t.map((o,a)=>({type:`image-${o}`,component:v,componentProps:{tooltip:T.t(`editor.${o.replace("-",".")}.tooltip`),icon:i[a],action:()=>e.commands.updateImage({width:Ne[o]}),isActive:()=>e.isActive("image",{width:Ne[o]})}}))},Hi=e=>{const t=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map((o,a)=>({type:`image-${o}`,component:v,componentProps:{tooltip:T.t(`editor.textalign.${o}.tooltip`),icon:i[o],action:()=>e.commands.setTextAlign(o),isActive:()=>e.isActive({textAlign:o})||!1,disabled:!e.can().setTextAlign(o)}}))},Fi=e=>{const t=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return t.map((o,a)=>({type:`video-${o}`,component:v,componentProps:{tooltip:T.t(`editor.${o.replace("-",".")}.tooltip`),icon:i[a],action:()=>e.commands.updateVideo({width:xe[o]}),isActive:()=>e.isActive("video",{width:xe[o]})}}))},Di=e=>[...Ri(e),...Hi(e),{type:"remove",component:v,componentProps:{editor:e,tooltip:T.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:i}=e.view;l.deleteSelection(t,i)}}}],Ii=e=>[...Fi(e),{type:"remove",component:v,componentProps:{editor:e,tooltip:T.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:i}=e.view;l.deleteSelection(t,i)}}}],Bi=(e,t)=>[Ke.configure().options.button({editor:e,t}),qe.configure().options.button({editor:e,t}),We.configure().options.button({editor:e,t}),Ge.configure().options.button({editor:e,t}),Xe.configure().options.button({editor:e,t}),at.configure().options.button({editor:e,t}),{type:"divider",component:void 0,componentProps:{}},et.configure().options.button({editor:e,t}),nt.configure().options.button({editor:e,t})],dt={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"},ct=({item:e,disabled:t,editor:i})=>{var a;const o=e.component;return o?n.jsx(f.Fragment,{children:e.type==="divider"?n.jsx($,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"}):n.jsx(n.Fragment,{children:n.jsx(o,{...e.componentProps,editor:i,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})})}):n.jsx(n.Fragment,{})},zi=e=>e.type.name==="image",Pi=e=>e.type.name==="video",Ei=e=>{const{lang:t}=R(),i=({editor:a})=>{const{selection:s}=a.view.state,{$from:r,to:d}=s;let c=!1;return a.view.state.doc.nodesBetween(r.pos,d,u=>{if(zi(u))return c=!0,!1}),c},o=f.useMemo(()=>e.disabled?[]:Di(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(l.BubbleMenu,{shouldShow:i,editor:e==null?void 0:e.editor,tippyOptions:dt,children:o!=null&&o.length?n.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:n.jsx("div",{className:"flex items-center flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:o==null?void 0:o.map((a,s)=>n.jsx(ct,{item:a,disabled:e.disabled,editor:e.editor},`bubbleMenu-image-${s}`))})}):n.jsx(n.Fragment,{})})})},Oi=e=>{const{lang:t}=R(),i=({editor:a})=>{const{selection:s}=a.view.state,{$from:r,to:d}=s;let c=!1;return a.view.state.doc.nodesBetween(r.pos,d,u=>{if(Pi(u))return c=!0,!1}),c},o=f.useMemo(()=>e.disabled?[]:Ii(e.editor),[e.editor,e.disabled,t]);return n.jsx(n.Fragment,{children:n.jsx(l.BubbleMenu,{shouldShow:i,editor:e==null?void 0:e.editor,tippyOptions:dt,children:o!=null&&o.length?n.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:n.jsx("div",{className:"flex items-center flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:o==null?void 0:o.map((a,s)=>n.jsx(ct,{item:a,disabled:e.disabled,editor:e.editor},`bubbleMenu-video-${s}`))})}):n.jsx(n.Fragment,{})})})},_i={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"},$i=({item:e,disabled:t,editor:i})=>{var a;const o=e.component;return o?n.jsx(f.Fragment,{children:n.jsx(o,{...e.componentProps,editor:i,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})}):n.jsx(n.Fragment,{})},Ui=e=>{const{t,lang:i}=R(),o=({editor:s})=>{const{selection:r}=s.view.state,{$from:d,to:c}=r;return d.pos===c?!1:r instanceof l.TextSelection},a=f.useMemo(()=>e.disabled||!(e!=null&&e.editor)?[]:Bi(e.editor,t),[e.disabled,e.editor,i,t]);return n.jsx(n.Fragment,{children:n.jsx(l.BubbleMenu,{shouldShow:o,editor:e==null?void 0:e.editor,tippyOptions:_i,children:a!=null&&a.length?n.jsx("div",{className:"border border-neutral-200 dark:border-neutral-800 px-3 py-2 transition-all select-none pointer-events-auto shadow-sm rounded-sm w-auto bg-background",children:n.jsx("div",{className:"flex items-center gap-[4px] flex-nowrap whitespace-nowrap h-[26px] justify-start relative",children:a==null?void 0:a.map((s,r)=>(s==null?void 0:s.type)==="divider"?n.jsx($,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"},`bubbleMenu-divider-${r}`):n.jsx($i,{item:s,disabled:e.disabled,editor:e.editor},`bubbleMenu-text-${r}`))})}):n.jsx(n.Fragment,{})})})},Vi=e=>{var C,B,O;const{t}=R(),[i,o]=f.useState(null),[a,s]=f.useState(-1),r=f.useRef(null),d=f.useRef(null),[c,u]=f.useState(!1);f.useEffect(()=>{r.current&&!e.editor.isDestroyed&&(d.current=l.DragHandlePlugin({editor:e.editor,element:r.current,pluginKey:"ContentItemMenu",tippyOptions:{offset:[-2,16],zIndex:99,moveTransition:"transform 0.15s ease-out"},onNodeChange:D}),e.editor.registerPlugin(d.current))},[e.editor,r]);function h(){const x=e.editor.chain();x.setNodeSelection(a).unsetAllMarks(),(i==null?void 0:i.type.name)!=="paragraph"&&x.setParagraph(),x.run()}function m(){e.editor.chain().focus().setNodeSelection(a).run(),document.execCommand("copy")}function g(){e.editor.commands.setNodeSelection(a);const{$anchor:x}=e.editor.state.selection,F=x.node(1)||e.editor.state.selection.node;e.editor.chain().setMeta("hideDragHandle",!0).insertContentAt(a+((i==null?void 0:i.nodeSize)||0),F.toJSON()).run()}function b(x){e.editor.commands.setTextAlign(x)}function w(){const x=Te(e.editor.state.tr,a,1);x.setMeta("hideDragHandle",!0),e.editor.view.dispatch&&e.editor.view.dispatch(x)}function L(){const x=Te(e.editor.state.tr,a,-1);e.editor.view.dispatch&&e.editor.view.dispatch(x)}function H(){e.editor.chain().setMeta("hideDragHandle",!0).setNodeSelection(a).deleteSelection().run()}function D(x){x.node&&o(x.node),s(x.pos)}function y(){var x;if(a!==-1){const F=(i==null?void 0:i.nodeSize)||0,A=a+F,P=(i==null?void 0:i.type.name)==="paragraph"&&((x=i==null?void 0:i.content)==null?void 0:x.size)===0,U=P?a+2:A+2;e.editor.chain().command(({dispatch:N,tr:I,state:E})=>N?(P?I.insertText("/",a,a+1):I.insert(A,E.schema.nodes.paragraph.create(null,[E.schema.text("/")])),N(I)):!0).focus(U).run()}}f.useEffect(()=>(c?e.editor.commands.setMeta("lockDragHandle",!0):e.editor.commands.setMeta("lockDragHandle",!1),()=>{e.editor.commands.setMeta("lockDragHandle",!1)}),[c]),f.useEffect(()=>()=>{d.current&&(e.editor.unregisterPlugin(l.dragHandlePluginDefaultKey),d.current=null)},[]),f.useEffect(()=>{var x;(x=e.editor)!=null&&x.isDestroyed&&d.current&&(e.editor.unregisterPlugin(e.pluginKey),d.current=null)},[(C=e.editor)==null?void 0:C.isDestroyed]);const j=x=>{e!=null&&e.disabled||u(x)};return n.jsx(n.Fragment,{children:n.jsx("div",{className:"drag-handle [transition-property:top,_left] ease-in-out duration-200 "+(e==null?void 0:e.className),style:{opacity:e!=null&&e.disabled?0:1},ref:r,children:n.jsxs("div",{className:"flex items-center gap-0.5 [transition-property:top,_left] ease-in-out duration-200",children:[n.jsx(z,{variant:"ghost",size:"icon",className:"w-7 h-7 cursor-grab",disabled:e==null?void 0:e.disabled,onClick:y,children:n.jsx(p,{name:"Plus",className:"text-lg text-neutral-600 dark:text-neutral-200"})}),n.jsxs(Z,{open:c,onOpenChange:j,children:[n.jsxs("div",{className:"flex flex-col relative",children:[n.jsxs(de,{children:[n.jsx(ce,{asChild:!0,disabled:e==null?void 0:e.disabled,children:n.jsx(z,{variant:"ghost",size:"icon",className:"w-7 h-7 cursor-grab relative z-[1]",disabled:e==null?void 0:e.disabled,onMouseUp:()=>{e!=null&&e.disabled||u(!0)},children:n.jsx(p,{name:"Grip",className:"text-sm dark:text-neutral-200 text-neutral-600"})})}),n.jsx(oe,{children:n.jsx("p",{children:t("editor.draghandle.tooltip")})})]}),n.jsx(Y,{className:"absolute top-0 left-0 w-[28px] h-[28px] z-0"})]}),n.jsxs(V,{className:"w-48",align:"start",side:"bottom",sideOffset:0,children:[n.jsxs(_,{onClick:H,className:"flex gap-3 focus:text-red-500 focus:bg-red-400 hover:bg-red-400 dark:hover:text-red-500 bg-opacity-10 hover:bg-opacity-20 focus:bg-opacity-30 dark:hover:bg-opacity-20",children:[n.jsx(p,{name:"Trash2"}),n.jsx("span",{children:t("editor.remove")})]}),n.jsxs(_,{className:"flex gap-3",onClick:h,children:[n.jsx(p,{name:"PaintRoller"}),n.jsx("span",{children:t("editor.clear.tooltip")})]}),n.jsxs(_,{className:"flex gap-3",onClick:m,children:[n.jsx(p,{name:"Clipboard"}),n.jsx("span",{children:t("editor.copyToClipboard")})]}),n.jsxs(_,{className:"flex gap-3",onClick:g,children:[n.jsx(p,{name:"Copy"}),n.jsx("span",{children:t("editor.copy")})]}),n.jsx(ye,{}),n.jsxs(Ie,{children:[n.jsxs(Ce,{className:"flex gap-3",children:[n.jsx(p,{name:"AlignCenter"}),n.jsx("span",{children:t("editor.textalign.tooltip")})]}),n.jsx(De,{children:n.jsxs(pe,{children:[n.jsxs(_,{className:"flex gap-3",onClick:()=>b("left"),children:[n.jsx(p,{name:"AlignLeft"}),n.jsx("span",{children:t("editor.textalign.left.tooltip")})]}),n.jsxs(_,{className:"flex gap-3",onClick:()=>b("center"),children:[n.jsx(p,{name:"AlignCenter"}),n.jsx("span",{children:t("editor.textalign.center.tooltip")})]}),n.jsxs(_,{className:"flex gap-3",onClick:()=>b("right"),children:[n.jsx(p,{name:"AlignRight"}),n.jsx("span",{children:t("editor.textalign.right.tooltip")})]})]})})]}),n.jsxs(Ie,{children:[n.jsxs(Ce,{className:"flex gap-3",children:[n.jsx(p,{name:"IndentIncrease"}),n.jsx("span",{children:t("editor.indent")})]}),n.jsx(De,{children:n.jsxs(pe,{children:[n.jsxs(_,{className:"flex gap-3",onClick:w,disabled:((B=i==null?void 0:i.attrs)==null?void 0:B.indent)>=G.max,children:[n.jsx(p,{name:"IndentIncrease"}),n.jsx("span",{children:t("editor.indent.tooltip")})]}),n.jsxs(_,{className:"flex gap-3",onClick:L,disabled:((O=i==null?void 0:i.attrs)==null?void 0:O.indent)<=G.min,children:[n.jsx(p,{name:"IndentDecrease"}),n.jsx("span",{children:t("editor.outdent.tooltip")})]})]})})]})]})]})]})})})},Ki=e=>{var w,L,H,D,y,j,C,B,O;const t=({editor:x})=>l.isActive(x.view.state,"table"),{t:i}=R();function o(){e.editor.chain().focus().addColumnBefore().run()}function a(){e.editor.chain().focus().addColumnAfter().run()}function s(){e.editor.chain().focus().deleteColumn().run()}function r(){e.editor.chain().focus().addRowBefore().run()}function d(){e.editor.chain().focus().addRowAfter().run()}function c(){e.editor.chain().focus().deleteRow().run()}function u(){e.editor.chain().focus().mergeCells().run()}function h(){var x;(x=e.editor)==null||x.chain().focus().splitCell().run()}function m(){e.editor.chain().focus().deleteTable().run()}function g(x){e.editor.chain().focus().setTableCellBackground(x).run()}const b=()=>{const{view:x,state:{selection:{from:F}}}=e.editor,A=x.domAtPos(F).node;if(!A)return new DOMRect(-1e3,-1e3,0,0);const P=A==null?void 0:A.closest(".tableWrapper");return P?P.getBoundingClientRect():new DOMRect(-1e3,-1e3,0,0)};return n.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,pluginKey:"table",shouldShow:t,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},maxWidth:"auto",getReferenceClientRect:b,plugins:[l.sticky],sticky:"popper"},children:n.jsxs("div",{className:"min-w-32 flex flex-row h-full items-center leading-none gap-0.5 p-2 w-full bg-background rounded-lg shadow-sm border border-border",children:[n.jsx(v,{icon:"BetweenHorizonalEnd",tooltip:i("editor.table.menu.insertColumnBefore"),action:o,"tooltip-options":{sideOffset:15},disabled:!((w=e==null?void 0:e.editor)!=null&&w.can().addColumnBefore())}),n.jsx(v,{icon:"BetweenHorizonalStart",tooltip:i("editor.table.menu.insertColumnAfter"),action:a,"tooltip-options":{sideOffset:15},disabled:!((L=e==null?void 0:e.editor)!=null&&L.can().addColumnAfter())}),n.jsx(v,{icon:"DeleteColumn",action:s,tooltip:i("editor.table.menu.deleteColumn"),"tooltip-options":{sideOffset:15},disabled:!((H=e==null?void 0:e.editor)!=null&&H.can().deleteColumn())}),n.jsx($,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"}),n.jsx(v,{icon:"BetweenVerticalEnd",action:r,tooltip:i("editor.table.menu.insertRowAbove"),"tooltip-options":{sideOffset:15},disabled:!((D=e==null?void 0:e.editor)!=null&&D.can().addRowBefore())}),n.jsx(v,{icon:"BetweenVerticalStart",action:d,tooltip:i("editor.table.menu.insertRowBelow"),"tooltip-options":{sideOffset:15},disabled:!((y=e==null?void 0:e.editor)!=null&&y.can().addRowAfter())}),n.jsx(v,{icon:"DeleteRow",action:c,tooltip:i("editor.table.menu.deleteRow"),"tooltip-options":{sideOffset:15},disabled:!((j=e==null?void 0:e.editor)!=null&&j.can().deleteRow())}),n.jsx($,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"}),n.jsx(v,{icon:"TableCellsMerge",action:u,tooltip:i("editor.table.menu.mergeCells"),"tooltip-options":{sideOffset:15},disabled:!((C=e==null?void 0:e.editor)!=null&&C.can().mergeCells())}),n.jsx(v,{icon:"TableCellsSplit",action:h,tooltip:i("editor.table.menu.splitCells"),"tooltip-options":{sideOffset:15},disabled:!((B=e==null?void 0:e.editor)!=null&&B.can().splitCell())}),n.jsx($,{orientation:"vertical",className:"mx-1 me-2 h-[16px]"}),n.jsx(tt,{editor:e==null?void 0:e.editor,tooltip:i("editor.table.menu.setCellsBgColor"),action:g,tooltipOptions:{sideOffset:15}}),n.jsx(v,{icon:"Trash2",tooltip:i("editor.table.menu.deleteTable"),action:m,"tooltip-options":{sideOffset:15},disabled:!((O=e==null?void 0:e.editor)!=null&&O.can().deleteTable())})]})})},qi=({editor:e,disabled:t})=>{const{t:i,lang:o}=R(),a=f.useMemo(()=>{const r=[...e.extensionManager.extensions].sort((c,u)=>{const h=c.options.sort??-1,m=u.options.sort??-1;return h-m});let d=[];for(const c of r){const{button:u,divider:h=!1,spacer:m=!1,toolbar:g=!0}=c.options;if(!u||!zn(u)||!g)continue;const b=u({editor:e,extension:c,t:i});if(Array.isArray(b)){const w=b.map((L,H)=>({button:L,divider:H===b.length-1?h:!1,spacer:H===0?m:!1}));d=[...d,...w];continue}d.push({button:b,divider:h,spacer:m})}return d},[e,i,o]);return n.jsx("div",{className:"border-b py-2 px-1",style:{pointerEvents:t?"none":"auto",opacity:t?.5:1},children:n.jsx("div",{className:"flex flex-wrap h-auto relative gap-y-1 gap-x-1",children:a.map((s,r)=>{var c,u;const d=s.button.component;return n.jsxs("div",{className:"flex items-center",children:[(s==null?void 0:s.spacer)&&n.jsx($,{orientation:"vertical",className:"h-[16px] mx-[10px]"}),n.jsx(d,{...s.button.componentProps,disabled:t||((u=(c=s==null?void 0:s.button)==null?void 0:c.componentProps)==null?void 0:u.disabled)}),(s==null?void 0:s.divider)&&n.jsx($,{orientation:"vertical",className:"h-auto mx-2"})]},r)})})})},Wi=(e,t)=>{const{view:i,state:{selection:{from:o}}}=e,a=document.querySelectorAll(".has-focus"),s=a.length,d=a[s-1];if(d&&d.dataset.type&&d.dataset.type===t||d&&d.classList&&d.classList.contains(t))return d;const c=i.domAtPos(o).node;let u=c;for(u.tagName||(u=c.parentElement);u&&!(u.dataset.type&&u.dataset.type===t)&&!u.classList.contains(t);)u=u.parentElement;return u},Gi=({editor:e})=>l.isActive(e.view.state,"columns"),Xi=e=>{const t=()=>{const s=Wi(e.editor,"columns");return(s==null?void 0:s.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},i=()=>{e.editor.chain().focus().setLayout(W.SidebarLeft).run()},o=()=>{e.editor.chain().focus().setLayout(W.SidebarRight).run()},a=()=>{e.editor.chain().focus().setLayout(W.TwoColumn).run()};return n.jsx(l.BubbleMenu,{editor:e==null?void 0:e.editor,pluginKey:"columns",shouldShow:Gi,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,plugins:[l.sticky],sticky:"popper"},children:n.jsx("div",{className:"p-2 bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800",children:n.jsxs("div",{className:"flex gap-1 items-center",children:[n.jsx(v,{title:"ok",icon:"PanelLeft",tooltip:"Left Sidebar",action:i,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:W.SidebarLeft}),tooltipOptions:{sideOffset:15}}),n.jsx(v,{title:"ok",icon:"Columns",tooltip:"Two-column layout",action:a,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:W.TwoColumn}),tooltipOptions:{sideOffset:15}}),n.jsx(v,{title:"ok",icon:"PanelRight",tooltip:"Right Sidebar",action:o,isActive:()=>e==null?void 0:e.editor.isActive("columns",{layout:W.SidebarRight}),tooltipOptions:{sideOffset:15}})]})})})},Zi=l.proxy({theme:"light"}),Yi={setTheme:e=>{Zi.theme=e}};function Ji(e,t){const{content:i,extensions:o,useEditorOptions:a={}}=e,{t:s}=R(),r=f.useMemo(()=>{const m=l.differenceBy(o,o,"name");return[...o.map(b=>{const w=o.find(L=>L.name===b.name);return w?b.configure(w.options):b}),...m].map((b,w)=>b.configure({sort:w}))},[o]),d=l.useEditor({extensions:r,content:i,onUpdate:({editor:m})=>{u(m)},...a});f.useEffect(()=>{document.body.classList.toggle("dark",e.dark),Yi.setTheme(e.dark?"dark":"light")},[e.dark]),f.useEffect(()=>{d==null||d.setEditable(!(e!=null&&e.disabled))},[d,e==null?void 0:e.disabled]);function c(m,g){return e!=null&&e.removeDefaultWrapper?g==="html"?m.isEmpty?"":m.getHTML():g==="json"?m.isEmpty?{}:m.getJSON():g==="text"?m.isEmpty?"":m.getText():"":g==="html"?m.getHTML():g==="json"?m.getJSON():g==="text"?m.getText():""}const u=l.throttle(m=>{var b;const g=c(m,e.output);(b=e==null?void 0:e.onChangeContent)==null||b.call(e,g)},Rt);f.useImperativeHandle(t,()=>({editor:d})),f.useEffect(()=>()=>{var m;(m=d==null?void 0:d.destroy)==null||m.call(d)},[]);const h=Pn(d,"characterCount");return d?n.jsx(pt,{delayDuration:0,children:n.jsxs("div",{className:"reactjs-tiptap-editor rounded-[0.5rem] bg-background shadow overflow-hidden outline outline-1",children:[!(e!=null&&e.hideBubble)&&n.jsxs(n.Fragment,{children:[n.jsx(Xi,{editor:d}),n.jsx(Ki,{editor:d}),n.jsx(Vi,{editor:d,disabled:e==null?void 0:e.disabled}),n.jsx(Mi,{editor:d,disabled:e==null?void 0:e.disabled}),n.jsx(Ui,{editor:d,disabled:e==null?void 0:e.disabled}),n.jsx(Ei,{editor:d,disabled:e==null?void 0:e.disabled}),n.jsx(Oi,{editor:d,disabled:e==null?void 0:e.disabled})]}),n.jsxs("div",{className:"flex flex-col w-full max-h-full",children:[!(e!=null&&e.hideToolbar)&&n.jsx(qi,{editor:d,disabled:e==null?void 0:e.disabled}),n.jsx(l.EditorContent,{className:`relative ${(e==null?void 0:e.contentClass)||""}`,editor:d}),n.jsx("div",{className:"flex justify-between border-t p-3 items-center",children:h&&n.jsx("div",{className:"flex flex-col",children:n.jsx("div",{className:"flex justify-end gap-3 text-sm",children:n.jsxs("span",{children:[d.storage.characterCount.characters()," ",s("editor.characters")]})})})})]})]})}):n.jsx(n.Fragment,{})}const Qi=f.forwardRef(Ji);exports.BaseKit=vn;exports.Blockquote=on;exports.Bold=Ke;exports.BulletList=Qt;exports.Clear=en;exports.Code=Xe;exports.CodeBlock=Nt;exports.Color=et;exports.ColumnToolbar=hn;exports.Columns=lt;exports.FontFamily=$t;exports.FontSize=Gt;exports.FormatPainter=ri;exports.Heading=Vt;exports.Highlight=nt;exports.History=cn;exports.HorizontalRule=sn;exports.Iframe=Si;exports.Image=On;exports.ImageUpload=Gn;exports.Indent=pn;exports.Italic=qe;exports.LineHeight=Mn;exports.Link=at;exports.MoreMark=jn;exports.OrderedList=tn;exports.SlashCommand=Dn;exports.Strike=Ge;exports.SubAndSuperScript=wn;exports.Table=si;exports.TaskList=nn;exports.TextAlign=qt;exports.Underline=We;exports.Video=Zn;exports.VideoUpload=Jn;exports.default=Qi;exports.locale=Ot;