advanced-editor-react
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
2 lines • 293 kB
JavaScript
"use strict";var Jn=Object.create;var ht=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ni=Object.prototype.hasOwnProperty;var ii=(e,t,n)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ri=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ei(t))!ni.call(e,a)&&a!==n&&ht(e,a,{get:()=>t[a],enumerable:!(r=Qn(t,a))||r.enumerable});return e};var Ut=(e,t,n)=>(n=e!=null?Jn(ti(e)):{},ri(t||!e||!e.__esModule?ht(n,"default",{value:e,enumerable:!0}):n,e));var re=(e,t,n)=>ii(e,typeof t!="symbol"?t+"":t,n);const i=require("react/jsx-runtime"),l=require("react");require("@radix-ui/react-toast");const w=require("lucide-react"),f=require("./tiptap-moBkdTRS.cjs"),j=require("./vendor-BD4J2iOI.cjs"),Ve=require("shiki"),p=require("./locales-BoveDUvl.cjs"),ai=require("@radix-ui/react-select"),Mt=require("@radix-ui/react-slot"),rt=require("tippy.js"),Me=require("react-dom"),oi=require("react-image-crop"),de=require("valtio"),si=require("@radix-ui/react-checkbox"),It=require("scroll-into-view-if-needed"),ci=require("@radix-ui/react-tabs"),se=require("prosemirror-docx"),li=require("docx"),it=require("mermaid"),di=require("@radix-ui/react-dialog"),Et=require("katex"),hi=require("@radix-ui/react-popover"),ui=require("@radix-ui/react-label"),mn=require("re-resizable"),mi=require("@radix-ui/react-separator"),xi=require("react-colorful"),Ye=require("@radix-ui/react-icons"),fi=require("@radix-ui/react-switch"),gi=require("@radix-ui/react-dropdown-menu"),pi=require("@radix-ui/react-tooltip"),bi=require("@radix-ui/react-toggle");function J(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const B=J(l),q=J(ai),_t=J(si),ve=J(ci),Y=J(di),Ue=J(hi),xn=J(ui),fn=J(mi),vt=J(fi),F=J(gi),We=J(pi),gn=J(bi);let ut;function mt(){return ut===void 0&&(ut=navigator.platform.includes("Mac")),ut}function at(e){return`${e}`.toLowerCase()==="mod"?mt()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?mt()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?mt()?"⇧":"Shift":e}function ot(e){return e.map(at).join(" ")}function P(...e){return j.twMerge(j.clsx(e))}const k=l.forwardRef((e,t)=>{const{icon:n=void 0,tooltip:r=void 0,disabled:a=!1,customClass:o="",shortcutKeys:s=void 0,tooltipOptions:c={},action:h=void 0,isActive:d=void 0,children:u,asChild:m=!1,upload:x=!1,...g}=e,b=Xe[n],_=m?Mt.Slot:Ze;return i.jsxs(He,{children:[i.jsx(Oe,{asChild:!0,children:i.jsxs(_,{ref:t,size:"sm",className:P("richtext-w-[32px] richtext-h-[32px]",o),disabled:a,onClick:h,"data-state":d!=null&&d()?"on":"off",...g,children:[b&&i.jsx(b,{className:"richtext-w-4 richtext-h-4"}),u]})}),r&&i.jsx(je,{...c,children:i.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24",children:[i.jsx("div",{children:r}),!!(s!=null&&s.length)&&i.jsx("span",{children:ot(s)})]})})]})}),Rt=l.forwardRef(({asChild:e,...t},n)=>{var o;const r=Xe[t.icon],a=e?Mt.Slot:V;return i.jsxs(He,{children:[i.jsx(Oe,{asChild:!0,children:i.jsx(a,{ref:n,className:"richtext-h-[32px] richtext-px-[5px] richtext-py-0 richtext-min-w-24 richtext-overflow-hidden",variant:"ghost",disabled:t==null?void 0:t.disabled,...t,children:i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-h-full richtext-font-normal",children:[(t==null?void 0:t.title)&&i.jsx("div",{className:"richtext-flex-grow richtext-text-sm richtext-text-left richtext-truncate",children:t==null?void 0:t.title}),r&&i.jsx(r,{className:"richtext-flex-shrink-0 richtext-w-3 richtext-h-3 richtext-ml-1 richtext-text-zinc-500"})]})})}),i.jsx(je,{children:i.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24",children:[(t==null?void 0:t.tooltip)&&i.jsx("div",{children:t==null?void 0:t.tooltip}),i.jsx("div",{className:"richtext-flex",children:!!((o=t==null?void 0:t.shortcutKeys)!=null&&o.length)&&i.jsx("span",{children:ot(t==null?void 0:t.shortcutKeys)})})]})})]})});function Ge(e,t){const{state:n}=t,r=n.selection.$anchor;let a=!1;if(r.depth)for(let o=r.depth;o>0;o--)r.node(o).type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(r.before(o),r.after(o)).scrollIntoView()),a=!0);else{const o=n.selection.node;o&&o.type.name===e&&(t.chain().deleteSelection().run(),a=!0)}if(!a){const o=r.pos;if(o){const s=n.tr.doc.nodeAt(o);s&&s.type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(o,o+s.nodeSize)),a=!0)}}return a}function wi(e){return e}function qe(e,t,n,r){const a=wi,[o,s]=l.useState(a(n)),c=l.useRef(o);return l.useEffect(()=>{const h=()=>{const d={...n,...e.getAttributes(t)};Object.keys(d).forEach(m=>{(d[m]===null||d[m]===void 0)&&(d[m]=n?n[m]:null)});const u=a(d);j.deepEqual(c.current,u)||(s(u),c.current=u)};return e.on("selectionUpdate",h),e.on("transaction",h),()=>{e.off("selectionUpdate",h),e.off("transaction",h)}},[e,n,t,a]),o}const Ke=B.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{className:P("richtext-flex richtext-min-h-[80px] richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:n,...t}));Ke.displayName="Textarea";const _i=j.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50",{variants:{variant:{default:"!richtext-bg-primary !richtext-text-primary-foreground hover:!richtext-bg-primary/90",destructive:"richtext-bg-destructive richtext-text-destructive-foreground hover:richtext-bg-destructive/90",outline:"richtext-border richtext-border-input richtext-bg-background hover:richtext-bg-accent hover:richtext-text-accent-foreground",secondary:"richtext-bg-secondary richtext-text-secondary-foreground hover:richtext-bg-secondary/80",ghost:"hover:richtext-bg-accent hover:richtext-text-accent-foreground",link:"richtext-text-primary richtext-underline-offset-4 hover:richtext-underline"},size:{default:"richtext-h-10 richtext-px-4 richtext-py-2",sm:"richtext-h-9 richtext-rounded-md richtext-px-3",lg:"richtext-h-11 richtext-rounded-md richtext-px-8",icon:"richtext-h-10 richtext-w-10"}},defaultVariants:{variant:"default",size:"default"}}),V=B.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},o)=>{const s=r?Mt.Slot:"button";return i.jsx(s,{className:P(_i({variant:t,size:n,className:e})),ref:o,...a})});V.displayName="Button";const he=F.Root,ue=F.Trigger,Wt=F.Portal,Gt=F.Sub,yt=B.forwardRef(({className:e,inset:t,children:n,...r},a)=>i.jsxs(F.SubTrigger,{ref:a,className:P("richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none focus:richtext-bg-accent data-[state=open]:richtext-bg-accent",t&&"richtext-pl-8",e),...r,children:[n,i.jsx(w.ChevronRight,{className:"richtext-ml-auto richtext-h-4 richtext-w-4"})]}));yt.displayName=F.SubTrigger.displayName;const jt=B.forwardRef(({className:e,...t},n)=>i.jsx(F.SubContent,{ref:n,className:P("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-lg data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...t}));jt.displayName=F.SubContent.displayName;const ce=B.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(F.Portal,{children:i.jsx(F.Content,{ref:r,sideOffset:t,className:P("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...n})}));ce.displayName=F.Content.displayName;const ee=B.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(F.Item,{ref:r,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",t&&"richtext-pl-8",e),...n}));ee.displayName=F.Item.displayName;const ye=B.forwardRef(({className:e,children:t,checked:n,...r},a)=>i.jsxs(F.CheckboxItem,{ref:a,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),checked:n,...r,children:[i.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:i.jsx(F.ItemIndicator,{children:i.jsx(w.Check,{className:"richtext-h-4 richtext-w-4"})})}),t]}));ye.displayName=F.CheckboxItem.displayName;const vi=B.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(F.RadioItem,{ref:r,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),...n,children:[i.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:i.jsx(F.ItemIndicator,{children:i.jsx(w.Circle,{className:"richtext-h-2 richtext-w-2 richtext-fill-current"})})}),t]}));vi.displayName=F.RadioItem.displayName;const yi=B.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(F.Label,{ref:r,className:P("richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-font-semibold",t&&"richtext-pl-8",e),...n}));yi.displayName=F.Label.displayName;const st=B.forwardRef(({className:e,...t},n)=>i.jsx(F.Separator,{ref:n,className:P("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...t}));st.displayName=F.Separator.displayName;function pn({className:e,...t}){return i.jsx("span",{className:P("richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",e),...t})}pn.displayName="DropdownMenuShortcut";const Z=B.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:P("richtext-flex richtext-h-10 richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background file:richtext-border-0 file:richtext-bg-transparent file:richtext-text-sm file:richtext-font-medium placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:r,...n}));Z.displayName="Input";const ji=j.cva("richtext-text-sm richtext-font-medium richtext-leading-none peer-disabled:richtext-cursor-not-allowed peer-disabled:richtext-opacity-70"),X=B.forwardRef(({className:e,...t},n)=>i.jsx(xn.Root,{ref:n,className:P(ji(),e),...t}));X.displayName=xn.Root.displayName;const ne=Ue.Root,ie=Ue.Trigger,Q=B.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>i.jsx(Ue.Portal,{children:i.jsx(Ue.Content,{ref:a,align:t,sideOffset:n,className:P("richtext-z-50 richtext-w-72 richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...r})}));Q.displayName=Ue.Content.displayName;const te=B.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>i.jsx(fn.Root,{ref:a,decorative:n,orientation:t,className:P("richtext-shrink-0 richtext-bg-border",t==="horizontal"?"richtext-h-[1px] richtext-w-full":"richtext-h-full richtext-w-[1px]",e),...r}));te.displayName=fn.Root.displayName;const zt=B.forwardRef(({className:e,...t},n)=>i.jsx(vt.Root,{className:P("richtext-peer richtext-inline-flex richtext-h-6 richtext-w-11 richtext-shrink-0 richtext-cursor-pointer richtext-items-center richtext-rounded-full richtext-border-2 richtext-border-transparent richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 focus-visible:richtext-ring-offset-background disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50 data-[state=checked]:richtext-bg-primary data-[state=unchecked]:richtext-bg-input",e),...t,ref:n,children:i.jsx(vt.Thumb,{className:P("richtext-pointer-events-none richtext-block richtext-h-5 richtext-w-5 richtext-rounded-full richtext-bg-background richtext-shadow-lg richtext-ring-0 richtext-transition-transform data-[state=checked]:richtext-translate-x-5 data-[state=unchecked]:richtext-translate-x-0")})}));zt.displayName=vt.Root.displayName;const Ht=ve.Root,ct=B.forwardRef(({className:e,...t},n)=>i.jsx(ve.List,{ref:n,className:P("richtext-inline-flex richtext-h-10 richtext-items-center richtext-justify-center richtext-rounded-md richtext-bg-muted richtext-p-1 richtext-text-muted-foreground",e),...t}));ct.displayName=ve.List.displayName;const Ie=B.forwardRef(({className:e,...t},n)=>i.jsx(ve.Trigger,{ref:n,className:P("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-sm richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-all focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=active]:richtext-bg-background data-[state=active]:richtext-text-foreground data-[state=active]:richtext-shadow-sm",e),...t}));Ie.displayName=ve.Trigger.displayName;const Ee=B.forwardRef(({className:e,...t},n)=>i.jsx(ve.Content,{ref:n,className:P("richtext-mt-2 richtext-ring-offset-background focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2",e),...t}));Ee.displayName=ve.Content.displayName;const ki=j.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-muted hover:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=on]:richtext-bg-accent data-[state=on]:richtext-text-accent-foreground",{variants:{variant:{default:"richtext-bg-transparent",outline:"richtext-border richtext-border-input richtext-bg-transparent hover:richtext-bg-accent hover:richtext-text-accent-foreground"},size:{default:"richtext-h-10 richtext-px-3",sm:"richtext-h-9 richtext-px-2",lg:"richtext-h-11 richtext-px-5"}},defaultVariants:{variant:"default",size:"default"}}),Ze=B.forwardRef(({className:e,variant:t,size:n,...r},a)=>i.jsx(gn.Root,{ref:a,className:P(ki({variant:t,size:n,className:e})),...r}));Ze.displayName=gn.Root.displayName;const Ci=We.Provider,He=We.Root,Oe=We.Trigger,je=B.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(We.Content,{ref:r,sideOffset:t,className:P("richtext-z-50 richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-text-popover-foreground richtext-shadow-md richtext-animate-in richtext-fade-in-0 richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...n}));je.displayName=We.Content.displayName;const Ni=q.Root,Si=q.Value,bn=B.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(q.Trigger,{ref:r,className:P("richtext-flex richtext-h-10 richtext-w-full richtext-items-center richtext-justify-between richtext-rounded-md richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background placeholder:richtext-text-muted-foreground focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50 [&>span]:richtext-line-clamp-1",e),...n,children:[t,i.jsx(q.Icon,{asChild:!0,children:i.jsx(w.ChevronDown,{className:"richtext-h-4 richtext-w-4 richtext-opacity-50"})})]}));bn.displayName=q.Trigger.displayName;const wn=B.forwardRef(({className:e,...t},n)=>i.jsx(q.ScrollUpButton,{ref:n,className:P("richtext-flex richtext-cursor-default richtext-items-center richtext-justify-center richtext-py-1",e),...t,children:i.jsx(w.ChevronUp,{className:"richtext-h-4 richtext-w-4"})}));wn.displayName=q.ScrollUpButton.displayName;const _n=B.forwardRef(({className:e,...t},n)=>i.jsx(q.ScrollDownButton,{ref:n,className:P("richtext-flex richtext-cursor-default richtext-items-center richtext-justify-center richtext-py-1",e),...t,children:i.jsx(w.ChevronDown,{className:"richtext-h-4 richtext-w-4"})}));_n.displayName=q.ScrollDownButton.displayName;const vn=B.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>i.jsx(q.Portal,{children:i.jsxs(q.Content,{ref:a,className:P("richtext-relative richtext-z-50 richtext-max-h-60 richtext-overflow-y-auto richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md richtext-border richtext-bg-popover richtext-text-popover-foreground richtext-shadow-md data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:richtext-translate-y-1 data-[side=left]:richtext--translate-x-1 data-[side=right]:richtext-translate-x-1 data-[side=top]:richtext--translate-y-1",e),position:n,...r,children:[i.jsx(wn,{}),i.jsx(q.Viewport,{className:P("richtext-p-1",n==="popper"&&"richtext-h-[var(--radix-select-trigger-height)] richtext-w-full richtext-min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(_n,{})]})}));vn.displayName=q.Content.displayName;const Ai=B.forwardRef(({className:e,...t},n)=>i.jsx(q.Label,{ref:n,className:P("richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-font-semibold",e),...t}));Ai.displayName=q.Label.displayName;const kt=B.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(q.Item,{ref:r,className:P("richtext-relative richtext-flex richtext-w-full richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),...n,children:[i.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:i.jsx(q.ItemIndicator,{children:i.jsx(w.Check,{className:"richtext-h-4 richtext-w-4"})})}),i.jsx(q.ItemText,{children:t})]}));kt.displayName=q.Item.displayName;const Ti=B.forwardRef(({className:e,...t},n)=>i.jsx(q.Separator,{ref:n,className:P("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...t}));Ti.displayName=q.Separator.displayName;const yn=B.forwardRef(({className:e,...t},n)=>i.jsx(_t.Root,{ref:n,className:P("!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-p-0 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-2 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",e),...t,children:i.jsx(_t.Indicator,{className:P("!richtext-flex !richtext-p-0 !richtext-items-center !richtext-justify-center !richtext-text-current"),children:i.jsx(w.Check,{className:"!richtext-h-4 !richtext-w-4"})})}));yn.displayName=_t.Root.displayName;function Li({editor:e,...t}){const n=qe(e,_e.name,{text:"",defaultShowPicker:!1}),{text:r,defaultShowPicker:a}=n,[o,s]=l.useState(""),[c,h]=l.useState(!1),d=l.useCallback(()=>e.isActive(_e.name),[e]),u=l.useCallback(()=>Ge(_e.name,e),[e]),m=l.useCallback(()=>{e.chain().focus().setKatex({text:o}).run(),h(!1)},[e,o]);l.useEffect(()=>{a&&(h(!0),e.chain().updateAttributes(_e.name,{defaultShowPicker:!1}).focus().run())},[e,a,h]),l.useEffect(()=>{c&&s(r||"")},[c]);const x=l.useMemo(()=>{try{return Et.renderToString(`${o}`)}catch{return o}},[o]),g=l.useMemo(()=>`${o}`.trim()?i.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:x||""}}):null,[o,x]);return i.jsx(f.BubbleMenu,{editor:e,pluginKey:"Katex-bubble-menu",shouldShow:d,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{h(!1)}},children:t!=null&&t.disabled?i.jsx(i.Fragment,{}):i.jsx("div",{className:"richtext-p-2 richtext-bg-white !richtext-border richtext-rounded-lg richtext-shadow-sm dark:richtext-bg-black richtext-border-neutral-200 dark:richtext-border-neutral-800",children:c?i.jsxs(i.Fragment,{children:[i.jsx(Ke,{value:o,onChange:b=>s(b.target.value),autoFocus:!0,placeholder:"Formula text",rows:3,defaultValue:r,style:{marginBottom:8}}),g&&i.jsx("div",{className:"richtext-my-[10px] richtext-p-[10px] richtext-rounded-[6px] !richtext-border-[1px] richtext-whitespace-nowrap richtext-overflow-auto",children:g}),i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[i.jsx(V,{onClick:m,className:"richtext-flex-1",children:"Submit"}),i.jsx("a",{href:"https://katex.org/docs/supported",target:"_blank",rel:"noreferrer noopener",children:i.jsx(w.HelpCircle,{size:16})})]})]}):i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[6px]",children:[i.jsx(k,{tooltip:"Edit",action:()=>h(!c),children:i.jsx(w.Pencil,{size:16})}),i.jsx(k,{tooltip:"Delete",action:u,children:i.jsx(w.Trash2,{size:16})})]})})})}function jn(e){return e=e||new Map,{all:e,on(t,n){const r=e.get(t);r?r.push(n):e.set(t,[n])},off(t,n){const r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit(t,n){let r=e.get(t);r&&[...r].map(a=>{a(n)}),r=e.get("*"),r&&[...r].map(a=>{a(t,n)})}}}const Mi={padding:"0 12px 12px"},kn=({width:e,maxWidth:t,height:n,onOk:r,children:a})=>{const{t:o}=p.useLocale(),[s,c]=l.useState({width:"",height:"",maxWidth:""});l.useEffect(()=>{c({width:e,height:n,maxWidth:t})},[n,t,e]);function h(d){d.preventDefault(),d.stopPropagation(),r(s)}return i.jsxs(ne,{modal:!0,children:[i.jsx(ie,{asChild:!0,children:a}),i.jsx(Q,{children:i.jsx("div",{style:Mi,children:i.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:h,children:[i.jsx(X,{className:"mb-[6px]",children:"Width"}),i.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:i.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:i.jsx(Z,{type:"number",value:s.width,required:!0,onChange:d=>c({...s,width:d.target.value})})})}),i.jsx(X,{className:"mb-[6px]",children:"Max Width"}),i.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:i.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:i.jsx(Z,{type:"number",value:s.maxWidth,required:!0,onChange:d=>c({...s,maxWidth:d.target.value})})})}),i.jsx(X,{className:"mb-[6px]",children:"Height"}),i.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:i.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:i.jsx(Z,{type:"number",value:s.height,required:!0,onChange:d=>c({...s,height:d.target.value})})})}),i.jsx(V,{type:"submit",className:"richtext-self-end richtext-mt-2",children:o("editor.link.dialog.button.apply")})]})})})]})},Ii="_wrap_15k3c_1",Ei="_renderWrap_15k3c_7",Ri="_title_15k3c_14",zi="_handlerWrap_15k3c_30",De={wrap:Ii,renderWrap:Ei,title:Ri,handlerWrap:zi};function Cn(e,t,n){return e<t?t:e>n?n:e}const Hi=e=>typeof e=="number",Oi=e=>typeof e=="string",Pi=e=>typeof e=="function";function Di(e,t="px"){if(!e)return e;const n=Hi(e)?String(e):e,r=Number.parseFloat(n),a=n.match(/[a-z%]+$/i),o=a?a[0]:t;return Number.isNaN(r)?e:r+o}function Nn(e,t){if(!e)return!1;const{extensions:n=[]}=(e==null?void 0:e.extensionManager)??{};return!!n.find(a=>a.name===t)}function Ct(e){return e.map(t=>Oi(t)?{value:t,name:t}:t)}const Bi=10,$i=200,qt=15,Kt={width:"100%",height:"100%",maxWidth:"100%"};function Fi({editor:e,node:t,updateAttributes:n}){const r=l.useRef(null),a=e.isActive(pe.name),{data:o,width:s,height:c}=t.attrs,[h,d]=l.useState(null),[u,m]=l.useState(!0),[x,g]=l.useState(null),[b,_]=l.useState(!1),[A,T]=l.useState(100),N=l.useCallback(C=>{C&&_(!0)},[_]),y=l.useCallback(C=>()=>{T(L=>Cn(C==="minus"?L-qt:L+qt,Bi,$i))},[]);l.useEffect(()=>{let C=!1;return import("@excalidraw/excalidraw").then(L=>{C||(r.current=L.exportToSvg)}).catch(L=>!C&&g(L)).finally(()=>!C&&m(!1)),()=>{C=!0}},[m,o]),l.useEffect(()=>{let C=!1;return(async()=>{if(C||u||x||!b||!o)return;const R=await r.current(o);C||(R.setAttribute("width","100%"),R.setAttribute("height","100%"),R.setAttribute("display","block"),d(R))})(),()=>{C=!0}},[o,u,x,b]);const v=C=>{n({width:C.width,height:C.height})};return i.jsx(f.NodeViewWrapper,{className:j.clsx(De.wrap,a&&De.isActive),children:i.jsx(j.VisibilitySensor,{onChange:N,children:i.jsx(mn.Resizable,{size:{width:Number.parseInt(s),height:Number.parseInt(c)},onResizeStop:(C,L,R,E)=>{v({width:Number.parseInt(s)+E.width,height:Number.parseInt(c)+E.height})},children:i.jsxs("div",{className:j.clsx(De.renderWrap,"render-wrapper"),style:{...Kt,overflow:"hidden"},children:[x&&i.jsx("div",{style:Kt,children:i.jsx("p",{children:x.message||x})}),u&&i.jsx("p",{children:"Loading..."}),!u&&!x&&b&&i.jsx("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${A/100})`,transition:"all ease-in-out .3s"},dangerouslySetInnerHTML:{__html:(h==null?void 0:h.outerHTML)??""}}),i.jsx("div",{className:De.title}),i.jsxs("div",{className:De.handlerWrap,children:[i.jsx(k,{icon:"ZoomOut",action:y("minus"),tooltip:"Zoom Out"}),i.jsx(k,{icon:"ZoomIn",action:y("plus"),tooltip:"Zoom In"})]})]})})})})}const Vi=l.memo(Fi,(e,t)=>!!j.deepEqual(e.node.attrs,t.node.attrs));function Ui(e,t="{}"){try{return JSON.stringify(e)}catch{return t}}function Wi(e){try{return JSON.stringify(e)}catch{return JSON.stringify({})}}function K(e,t=!1){return n=>{const r=e.startsWith("data-")?e:`data-${e}`;let a=decodeURIComponent(n.getAttribute(r));if(a==null||typeof a=="string"&&a==="null")try{const c=n.outerHTML.match(/([\s\S])+?="([\s\S])+?"/g);c&&c.length&&(a=(c.map(d=>d.trim()).reduce((d,u)=>{const m=u.indexOf("="),x=[u.slice(0,m),u.slice(m+1).slice(1,-1)];return d[x[0]]=x[1],d},{})[e.toLowerCase()]||"").replaceAll(""",'"'))}catch(s){console.error("Error getDatasetAttribute ",s.message,n)}if(t)try{return JSON.parse(a)}catch{return{}}if(a.includes("%")||a.includes("auto"))return a;const o=Number.parseInt(a);return o!==o?a:o}}function Gi(e){const{attrs:t}=e;return Object.keys(t).reduce((n,r)=>{const a=t[r];if(a==null)return n;let o="";return typeof a=="object"?o=Wi(a):o=a,n[r]=o,n},Object.create(null))}const ke=Y.Root,Ce=Y.Trigger,qi=Y.Portal,Sn=B.forwardRef(({className:e,...t},n)=>i.jsx(Y.Overlay,{ref:n,className:P("richtext-fixed richtext-inset-0 richtext-z-50 richtext-bg-black/80 richtext- data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0",e),...t}));Sn.displayName=Y.Overlay.displayName;const me=B.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(qi,{children:[i.jsx(Sn,{}),i.jsxs(Y.Content,{ref:r,className:P("richtext-dialog-content richtext-fixed richtext-left-[50%] richtext-top-[50%] richtext-z-50 richtext-grid richtext-w-full richtext-max-w-lg richtext-translate-x-[-50%] richtext-translate-y-[-50%] richtext-gap-4 richtext-border richtext-bg-background richtext-p-6 richtext-shadow-lg richtext-duration-200 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[state=closed]:richtext-slide-out-to-left-1/2 data-[state=closed]:richtext-slide-out-to-top-[48%] data-[state=open]:richtext-slide-in-from-left-1/2 data-[state=open]:richtext-slide-in-from-top-[48%] sm:richtext-rounded-lg",e),...n,children:[t,i.jsxs(Y.Close,{className:"richtext-absolute richtext-right-4 richtext-top-4 richtext-rounded-sm richtext-opacity-70 richtext-ring-offset-background richtext-transition-opacity hover:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-pointer-events-none data-[state=open]:richtext-bg-accent data-[state=open]:richtext-text-muted-foreground",children:[i.jsx(w.X,{className:"richtext-h-4 richtext-w-4"}),i.jsx("span",{className:"richtext-sr-only",children:"Close"})]})]})]}));me.displayName=Y.Content.displayName;function An({className:e,...t}){return i.jsx("div",{className:P("richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",e),...t})}An.displayName="DialogHeader";function Pe({className:e,...t}){return i.jsx("div",{className:P("richtext-flex richtext-flex-col-reverse sm:richtext-flex-row sm:richtext-justify-end sm:richtext-space-x-2",e),...t})}Pe.displayName="DialogFooter";const xe=B.forwardRef(({className:e,...t},n)=>i.jsx(Y.Title,{ref:n,className:P("richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight",e),...t}));xe.displayName=Y.Title.displayName;const Ki=B.forwardRef(({className:e,...t},n)=>i.jsx(Y.Description,{ref:n,className:P("richtext-text-sm richtext-text-muted-foreground",e),...t}));Ki.displayName=Y.Description.displayName;let xt;function Ot(){try{return xt||(xt=jn()),xt}catch{throw new Error("Error EventEmitter")}}const Nt="OPEN_EXCALIDRAW_SETTING_MODAL";function Zi(e,t){Ot().on(e,t)}function Xi(e,t){Ot().off(e,t)}function Yi(e){Ot().emit(Nt,e)}const Ji=({editor:e})=>{const[t,n]=l.useState(null),[r,a]=l.useState({}),[o,s]=l.useState({elements:[],appState:{isLoading:!1},files:null}),[c,h]=l.useState(!1),[d,u]=l.useState(!0),[m,x]=l.useState(null),g=l.useCallback(T=>{T&&import("@excalidraw/excalidraw").then(N=>{n(N.Excalidraw)}).catch(x).finally(()=>u(!1))},[u]),b=l.useCallback(T=>{setTimeout(()=>{T.refresh()})},[]),_=l.useCallback((T,N,y)=>{a({elements:T,appState:{isLoading:!1},files:y})},[]),A=l.useCallback(()=>{if(!t){h(!1);return}e.chain().focus().setExcalidraw({data:r}).run(),h(!1)},[t,e,r,h]);return l.useEffect(()=>{const T=N=>{h(!0),N&&s(N.data)};return Zi(Nt,T),()=>{Xi(Nt,T)}},[e,h]),i.jsxs(ke,{open:c,onOpenChange:h,children:[i.jsx(Ce,{asChild:!0,children:i.jsx(k,{icon:"Excalidraw",tooltip:"Excalidraw",action:()=>h(!0)})}),i.jsxs(me,{className:"!richtext-max-w-[1300px] richtext-z-[99999]",children:[i.jsx(xe,{children:"Excalidraw"}),i.jsxs("div",{style:{height:"100%",borderWidth:1},children:[d&&i.jsx("p",{children:"Loading..."}),m&&i.jsx("p",{children:m&&m.message||"Error"}),i.jsx("div",{style:{width:"100%",height:600},ref:g,children:!d&&!m&&t?i.jsx(t,{ref:b,onChange:_,langCode:"en",initialData:o}):null})]}),i.jsx(Pe,{children:i.jsx(V,{type:"button",onClick:A,children:"Save changes"})})]})]})},Zt={elements:[]},pe=f.Node.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:K("width")},height:{default:240,parseHTML:K("height")},data:{default:Zt,parseHTML:K("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:t})=>({component:Ji,componentProps:{editor:t}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:t}){return["div",f.mergeAttributes(this.options.HTMLAttributes,e,Gi(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:n,chain:r})=>{var a,o,s;return e=e||{},e.data=e.data||Zt,((s=(o=(a=t.selection)==null?void 0:a.node)==null?void 0:o.type)==null?void 0:s.name)==this.name?n.updateAttributes(this.name,e):r().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return f.ReactNodeViewRenderer(Vi)},addInputRules(){return[f.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}}),fe=new Map;function Qi(e){const t=e.options.element;fe.has("width")||fe.set("width",t.clientWidth),fe.has("width")&&fe.get("width")<=0&&fe.set("width",t.clientWidth);const n={attributes:!0,childList:!0,subtree:!0},r=function(){fe.set("width",t.clientWidth)},a=new MutationObserver(r);return a.observe(t,n),e.on("destroy",()=>{a.disconnect()}),{width:fe.get("width")}}function er({editor:e}){const{t}=p.useLocale(),{width:n}=Qi(e),r=qe(e,pe.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:a,createUser:o,width:s,height:c}=r,h=l.useCallback(x=>{e.chain().updateAttributes(pe.name,x).setNodeSelection(e.state.selection.from).focus().run()},[e]),d=l.useCallback(()=>{Yi(r)},[e,r]),u=l.useCallback(()=>e.isActive(pe.name),[e]),m=l.useCallback(()=>Ge(pe.name,e),[e]);return l.useEffect(()=>{a&&(d(),e.chain().updateAttributes(pe.name,{defaultShowPicker:!1}).focus().run())},[o,a,e,d]),i.jsx(f.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"excalidraw-bubble-menu",shouldShow:u,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:i.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[i.jsx(k,{icon:"Pencil",action:d,tooltip:t("editor.edit")}),i.jsx(kn,{width:s,maxWidth:n,height:c,onOk:h,children:i.jsx(k,{icon:"Settings",tooltip:t("editor.settings")})}),i.jsx(k,{icon:"Trash2",action:m,tooltip:t("editor.delete")})]})})}const tr="_wrap_5y04w_1",nr="_innerWrap_5y04w_15",Xt={wrap:tr,innerWrap:nr},Tn=de.proxy({disable:!1});function lt(){return de.useSnapshot(Tn).disable}const ir={setDisable:e=>{Tn.disable=e}};function rr({editor:e,node:t,updateAttributes:n}){const r=lt(),{url:a,width:o,height:s}=t.attrs,[c,h]=l.useState("");function d(){c&&e.chain().updateAttributes(be.name,{url:c}).setNodeSelection(e.state.selection.from).focus().run()}const u=l.useCallback(m=>{n({width:m.width,height:m.height})},[n]);return i.jsxs(f.NodeViewWrapper,{children:[!a&&i.jsxs("div",{className:"richtext-max-w-[600px] richtext-mx-[auto] richtext-my-[12px] richtext-flex richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-p-[10px] richtext-border-[1px] richtext-border-solid richtext-border-[#ccc] richtext-rounded-[12px]",children:[i.jsx(Z,{value:c,onInput:m=>h(m.target.value),type:"url",className:"richtext-flex-1",autoFocus:!0,placeholder:"Enter link"}),i.jsx(V,{className:"richtext-w-[60px]",onClick:d,children:"OK"})]}),a&&i.jsx(mn.Resizable,{size:{width:Number.parseInt(o),height:Number.parseInt(s)},onResizeStop:(m,x,g,b)=>{u({width:Number.parseInt(o)+b.width,height:Number.parseInt(s)+b.height})},children:i.jsx("div",{className:j.clsx(Xt.wrap,"render-wrapper"),children:i.jsx("div",{className:Xt.innerWrap,style:{pointerEvents:r?"none":"auto"},children:i.jsx("iframe",{src:a,className:"richtext-my-[12px] "})})})})]})}const be=f.Node.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:n,t:r})=>({component:k,componentProps:{action:a=>t.commands.setIframe(a),upload:n.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:K("width")},height:{default:300,parseHTML:K("height")},url:{default:null,parseHTML:K("url")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",f.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:n,chain:r})=>{var o,s,c;if(((c=(s=(o=t.selection)==null?void 0:o.node)==null?void 0:s.type)==null?void 0:c.name)==this.name)return n.updateAttributes(this.name,e);const a=e||{url:""};return r().insertContent({type:this.name,attrs:a}).run()}}},addInputRules(){return[f.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return f.ReactNodeViewRenderer(rr)}});function ar({editor:e}){const{t}=p.useLocale(),{width:n,height:r,url:a}=qe(e,be.name,{width:0,height:0,url:"",defaultShowPicker:!1}),[o,s]=l.useState(!1),[c,h]=l.useState(""),d=l.useCallback(()=>{s(!1)},[s]);l.useEffect(()=>{o&&h(a)},[o,a]);const u=l.useCallback(()=>{e.chain().updateAttributes(be.name,{url:c}).setNodeSelection(e.state.selection.from).focus().run(),s(!1)},[e,c,s]),m=l.useCallback(()=>{window.open(a,"_blank")},[a]),x=l.useCallback(()=>{s(!0)},[s]),g=l.useCallback(A=>{e.chain().updateAttributes(be.name,A).setNodeSelection(e.state.selection.from).focus().run()},[e]),b=l.useCallback(()=>e.isActive(be.name)&&!a,[e,a]),_=l.useCallback(()=>Ge(be.name,e),[e]);return i.jsxs(i.Fragment,{children:[i.jsx(f.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"iframe-bubble-menu",shouldShow:b,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:i.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[i.jsx(k,{action:m,icon:"Eye",tooltip:"Visit Link"}),i.jsx(k,{action:x,icon:"Pencil",tooltip:"Open Edit Link"}),i.jsx(kn,{width:n,height:r,onOk:g,children:i.jsx(k,{icon:"Settings",tooltip:t("editor.settings")})}),i.jsx(k,{action:_,icon:"Trash2",tooltip:t("editor.delete")})]})}),i.jsxs(ke,{open:o,onOpenChange:s,children:[i.jsx(Ce,{}),i.jsxs(me,{children:[i.jsx(An,{children:i.jsx(xe,{children:"Edit Link Iframe"})}),i.jsx(Z,{value:c,onInput:A=>h(A.target.value),type:"url",autoFocus:!0,placeholder:"Enter link"}),i.jsxs(Pe,{children:[i.jsx(V,{onClick:d,children:"Cancel"}),i.jsx(V,{onClick:u,children:"OK"})]})]})]})]})}function Ln(e=8){return Math.random().toString(36).substring(2,e+2)}function or(e){return e.replace(/^.*\/|\..+$/g,"")}function sr(e){return e.split(".").pop()}function cr(e){return e<1024?`${e} Byte`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function lr(e){return e?e==="application/pdf"?"pdf":e.startsWith("application/")&&[".document","word"].some(t=>e.includes(t))?"word":e.startsWith("application/")&&["presentation"].some(t=>e.includes(t))?"excel":e.startsWith("application/")&&["sheet"].some(t=>e.includes(t))?"ppt":e.startsWith("image")?"image":e.startsWith("audio")?"audio":e.startsWith("video")?"video":"file":"file"}function dr(e){return new Promise(t=>{const n=new FileReader;n.addEventListener("load",()=>{t({alt:e.name,src:n.result})},!1),n.readAsDataURL(e)})}function Mn(e,t){const n=e.split(","),r=n[0].match(/:(.*?);/)[1],a=atob(n[n.length-1]);let o=a.length;const s=new Uint8Array(o);for(;o--;)s[o]=a.charCodeAt(o);return new File([s],t,{type:r})}const Yt=`graph TB
a-->b`,hr=({editor:e,attrs:t,extension:n})=>{const{alt:r,align:a}=t,[o,s]=l.useState(decodeURIComponent(r??Yt)),[c,h]=l.useState(""),[d,u]=l.useState(!1),m=l.useRef(null),x=n==null?void 0:n.options.upload,g=async A=>{try{const{svg:T}=await it.render("mermaid-svg",A);h(T)}catch{h("")}},b=()=>{it.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),g(o)};l.useEffect(()=>{d&&b()},[d]),l.useEffect(()=>{d&&g(o)},[o]);const _=async()=>{if(o!==""){if(o){const A=m.current.querySelector("svg"),{width:T,height:N}=A.getBoundingClientRect(),y=`mermaid-${Ln()}.svg`;let v=j.i(A.outerHTML);if(x){const C=Mn(v,y);v=await x(C)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:v,alt:encodeURIComponent(o),width:T,height:N},!!o).run(),e==null||e.commands.setAlignImageMermaid(a)}u(!1)}};return i.jsxs(ke,{open:d,onOpenChange:u,children:[i.jsx(Ce,{asChild:!0,children:i.jsx(k,{icon:"Pencil",tooltip:"Edit Mermaid",action:()=>u(!0)})}),i.jsxs(me,{className:"!richtext-max-w-[1300px] richtext-z-[99999]",children:[i.jsx(xe,{children:"Edit Mermaid"}),i.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:i.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[i.jsx(Ke,{className:"richtext-flex-1",value:o,onChange:A=>s(A.target.value),autoFocus:!0,required:!0,rows:10,defaultValue:Yt,placeholder:"Text",style:{color:"hsl(var(--richtext-foreground))"}}),i.jsx("div",{className:"richtext-flex-1 richtext-flex richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500,background:"#fff"},ref:m,dangerouslySetInnerHTML:{__html:c}})]})}),i.jsx(Pe,{children:i.jsx(V,{type:"button",onClick:_,children:"Save changes"})})]})]})};function ur(e,t){const[n,r]=l.useState(void 0);return l.useEffect(()=>{const a=()=>{const o=e.extensionManager.extensions.find(s=>s.name===t);o&&r(o)};return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e,t]),n}const mr={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function xr({item:e,disabled:t,editor:n}){var a;const r=e.component;return r?i.jsx(l.Fragment,{children:e.type==="divider"?i.jsx(te,{orientation:"vertical",className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]"}):i.jsx(r,{...e.componentProps,editor:n,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})}):i.jsx(i.Fragment,{})}function fr(e){return e.type.name==="mermaid"}function gr(e){const{lang:t}=p.useLocale(),n=qe(e.editor,Lt.name),r=ur(e.editor,Lt.name),a=({editor:s})=>{const{selection:c}=s.view.state,{$from:h,to:d}=c;let u=!1;return s.view.state.doc.nodesBetween(h.pos,d,m=>{if(fr(m))return u=!0,!1}),u},o=l.useMemo(()=>e.disabled?[]:ra(e.editor),[e.disabled,e.editor,t]);return i.jsx(i.Fragment,{children:i.jsx(f.BubbleMenu,{shouldShow:a,editor:e==null?void 0:e.editor,tippyOptions:mr,children:o!=null&&o.length?i.jsx("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:i.jsx("div",{className:"richtext-flex richtext-items-center richtext-flex-nowrap richtext-whitespace-nowrap richtext-h-[26px] richtext-justify-start richtext-relative",children:o==null?void 0:o.map((s,c)=>s.type==="edit"&&(n!=null&&n.src)?i.jsx(hr,{editor:e.editor,attrs:n,extension:r},`bubbleMenu-mermaid-${c}`):i.jsx(xr,{item:s,disabled:e.disabled,editor:e.editor},`bubbleMenu-mermaid-${c}`))})}):i.jsx(i.Fragment,{})})})}function pr({editor:e,disabled:t,bubbleMenu:n}){const r=e.extensionManager.extensions.map(o=>o.name),a=()=>{var o,s,c,h,d,u,m,x,g,b,_,A;return[r.includes("columns")&&!((o=n==null?void 0:n.columnConfig)!=null&&o.hidden)?i.jsx(ka,{editor:e},"columns"):null,r.includes("table")&&!((s=n==null?void 0:n.tableConfig)!=null&&s.hidden)?i.jsx(fa,{editor:e},"table"):null,r.includes("link")&&!((c=n==null?void 0:n.linkConfig)!=null&&c.hidden)?i.jsx(pa,{editor:e,disabled:t},"link"):null,r.includes("image")&&!((h=n==null?void 0:n.imageConfig)!=null&&h.hidden)?i.jsx(va,{editor:e,disabled:t},"image"):null,r.includes($t.name)&&!((d=n==null?void 0:n.imageGifConfig)!=null&&d.hidden)?i.jsx(ya,{editor:e,disabled:t},"imageGif"):null,r.includes("video")&&!((u=n==null?void 0:n.videoConfig)!=null&&u.hidden)?i.jsx(ja,{editor:e,disabled:t},"video"):null,r.includes("katex")&&!((m=n==null?void 0:n.katexConfig)!=null&&m.hidden)?i.jsx(Li,{editor:e,disabled:t},"katex"):null,r.includes("excalidraw")&&!((x=n==null?void 0:n.excalidrawConfig)!=null&&x.hidden)?i.jsx(er,{editor:e,disabled:t},"excalidraw"):null,r.includes("mermaid")&&!((g=n==null?void 0:n.mermaidConfig)!=null&&g.hidden)?i.jsx(gr,{editor:e,disabled:t},"mermaid"):null,r.includes("iframe")&&!((b=n==null?void 0:n.iframeConfig)!=null&&b.hidden)?i.jsx(ar,{editor:e,disabled:t},"iframe"):null,(_=n==null?void 0:n.floatingMenuConfig)!=null&&_.hidden?null:i.jsx(la,{editor:e,disabled:t},"content"),(A=n==null?void 0:n.textConfig)!=null&&A.hidden?null:i.jsx(ma,{editor:e,disabled:t},"text")]};return n!=null&&n.render?n.render({editor:e,disabled:t||!1,bubbleMenu:n},a()):a().filter(Boolean)}function Jt(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:i.jsx("path",{fill:"currentColor",d:"M18 14c0-4-6-10.8-6-10.8s-1.33 1.51-2.73 3.52l8.59 8.59c.09-.42.14-.86.14-1.31m-.88 3.12L12.5 12.5L5.27 5.27L4 6.55l3.32 3.32C6.55 11.32 6 12.79 6 14c0 3.31 2.69 6 6 6c1.52 0 2.9-.57 3.96-1.5l2.63 2.63l1.27-1.27z"})})}function In(e){const{t}=p.useLocale(),{highlight:n=!1,disabled:r=!1,selectedColor:a,setSelectedColor:o,onChange:s,colors:c=p.COLORS_LIST}=e,h=l.useMemo(()=>{const g=c,b=[];for(let _=0;_<g.length;_+=10)b.push(g.slice(_,_+10));return b},[c]),[d,u]=l.useState([]),m=g=>{const b=[...d],_=b.indexOf(g);_!==-1&&b.splice(_,1),b.unshift(g),b.length>10&&b.pop(),u(b)};function x(g){if(g===void 0){o==null||o(g),s==null||s(g);return}/^#([\da-f]{3}){1,2}$/i.test(g)&&(o==null||o(g),s==null||s(g),m(g))}return i.jsxs(ne,{modal:!0,children:[i.jsx(ie,{className:"!richtext-p-0",disabled:r,asChild:!0,children:e==null?void 0:e.children}),i.jsx(Q,{hideWhenDetached:!0,className:"richtext-w-full richtext-h-full richtext-p-2",align:"start",side:"bottom",children:i.jsxs("div",{className:"richtext-flex richtext-flex-col",children:[n?i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-p-1 richtext-cursor-pointer rd-1 richtext-gap-[4px] hover:richtext-bg-accent",onClick:()=>x(void 0),children:[i.jsx(Jt,{}),i.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:t("editor.nofill")})]}):i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-p-1 richtext-cursor-pointer rd-1 richtext-gap-[4px] hover:richtext-bg-accent",onClick:()=>{x(void 0)