reactjs-tiptap-editor-pro 0.2.26 → 0.2.28

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,141 +0,0 @@
1
- "use strict";var on=Object.create;var rt=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var an=Object.getPrototypeOf,ln=Object.prototype.hasOwnProperty;var dn=(e,t,n)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var hn=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of cn(t))!ln.call(e,s)&&s!==n&&rt(e,s,{get:()=>t[s],enumerable:!(i=sn(t,s))||i.enumerable});return e};var Ft=(e,t,n)=>(n=e!=null?on(an(e)):{},hn(t||!e||!e.__esModule?rt(n,"default",{value:e,enumerable:!0}):n,e));var Be=(e,t,n)=>dn(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),d=require("react"),A=require("./tiptap-gBG-1T-V.cjs"),y=require("./index-DV-nXpU1.cjs"),un=require("@radix-ui/react-separator"),S=require("./vendor-BJ0Yf78E.cjs"),xn=require("@radix-ui/react-toast"),C=require("lucide-react"),mn=require("@radix-ui/react-tooltip"),W=require("easydrawer"),ur=require("@radix-ui/react-slot"),fn=require("@radix-ui/react-toggle"),$e=require("@radix-ui/react-icons"),gn=require("@radix-ui/react-dialog"),pn=require("@radix-ui/react-popover"),wn=require("@radix-ui/react-label"),xr=require("re-resizable"),vt=require("katex"),Xe=require("mermaid"),mr=require("tippy.js"),vn=require("react-colorful"),bn=require("@radix-ui/react-switch"),jn=require("@radix-ui/react-tabs"),Cn=require("react-image-crop"),yn=require("@radix-ui/react-checkbox"),Tn=require("@radix-ui/react-dropdown-menu");function re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const V=re(d),fr=re(un),Q=re(xn),Pe=re(mn),gr=re(fn),te=re(gn),Ee=re(pn),pr=re(wn),lt=re(bn),je=re(jn),dt=re(yn),q=re(Tn);function P(...e){return S.twMerge(S.clsx(e))}let nt;function it(){return nt===void 0&&(nt=navigator.platform.includes("Mac")),nt}function wr(e){return`${e}`.toLowerCase()==="mod"?it()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?it()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?it()?"⇧":"Shift":e}function vr(e){return e.map(wr).join(" ")}const D=d.forwardRef((e,t)=>{const{icon:n=void 0,tooltip:i=void 0,disabled:s=!1,customClass:o="",loading:c=void 0,shortcutKeys:a=void 0,tooltipOptions:l={},action:h=void 0,isActive:u=void 0,children:x,asChild:m=!1,upload:f=!1,...w}=e,p=m?ur.Slot:St;return r.jsxs(Nt,{children:[r.jsx(Mt,{asChild:!0,children:r.jsxs(p,{"data-state":u!=null&&u()?"on":"off",onClick:h,ref:t,size:"sm",className:P("richtext-w-[32px] richtext-h-[32px]",o),disabled:s,...w,children:[n&&r.jsx(U,{name:n,className:"richtext-size-4"}),x]})}),i&&r.jsx(et,{...l,children:r.jsxs("div",{className:"richtext-flex richtext-max-w-24 richtext-flex-col richtext-items-center richtext-text-center",children:[r.jsx("div",{children:i}),!!(a!=null&&a.length)&&r.jsx("span",{children:vr(a)})]})})]})});function Je(e){function t(){const o=d.useRef(e),c=d.useCallback(()=>o.current,[]),a=d.useRef(new Set),l=d.useCallback(u=>{o.current={...o.current,...u},a.current.forEach(x=>x())},[]),h=d.useCallback(u=>(a.current.add(u),()=>a.current.delete(u)),[]);return{get:c,set:l,subscribe:h}}const n=d.createContext(null);function i({children:o}){return r.jsx(n.Provider,{value:t(),children:o})}function s(o){const c=d.useContext(n);if(!c)throw new Error("Store not found");return[d.useSyncExternalStore(c.subscribe,()=>o(c.get()),()=>o(e)),c.set]}return{Provider:i,useStore:s}}Je({value:!1});Je({value:!1});const{Provider:Sn,useStore:br}=Je({value:!1}),{Provider:Nn,useStore:jr}=Je({value:"light"});S.d("0");function Ie(e,t){return window.addEventListener(e,t),()=>{window.removeEventListener(e,t)}}function Qe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}const ue={UPLOAD_IMAGE:e=>`UPLOAD_IMAGE-${e}`,UPLOAD_VIDEO:e=>`UPLOAD_VIDEO-${e}`,EDIT:e=>`EDIT-${e}`,UPDATE_THEME:e=>`UPDATE_THEME-${e}`,SEARCH_REPLCE:"SEARCH_REPLACE"};function Cr(){const[e]=br(t=>t.value);return e}const Mn={setDisable:(e,t)=>{Qe(ue.EDIT(e),t)}};function Te(e,t){const{state:n}=t,i=n.selection.$anchor;let s=!1;if(i.depth)for(let o=i.depth;o>0;o--)i.node(o).type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(i.before(o),i.after(o)).scrollIntoView()),s=!0);else{const o=n.selection.node;o&&o.type.name===e&&(t.chain().deleteSelection().run(),s=!0)}if(!s){const o=i.pos;if(o){const c=n.tr.doc.nodeAt(o);c&&c.type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(o,o+c.nodeSize)),s=!0)}}return s}function bt(e,t,n){return e<t?t:e>n?n:e}const kn=e=>typeof e=="number",An=e=>typeof e=="string",En=e=>typeof e=="function";function In(e,t="px"){if(!e)return e;const n=kn(e)?String(e):e,i=Number.parseFloat(n),s=n.match(/[%a-z]+$/i),o=s?s[0]:t;return Number.isNaN(i)?e:i+o}function yr(e,t){if(!e)return!1;const{extensions:n=[]}=(e==null?void 0:e.extensionManager)??{};return!!n.find(s=>s.name===t)}function Ln(e){return e.map(t=>An(t)?{value:t,name:t}:t)}const Rn=S.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"}}),G=V.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...s},o)=>{const c=i?ur.Slot:"button";return r.jsx(c,{className:P(Rn({variant:t,size:n,className:e})),ref:o,...s})});G.displayName="Button";const Tr=q.Root,Sr=q.Trigger,Wt=q.Portal,Gt=q.Sub,ht=V.forwardRef(({className:e,inset:t,children:n,...i},s)=>r.jsxs(q.SubTrigger,{ref:s,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),...i,children:[n,r.jsx(C.ChevronRight,{className:"richtext-ml-auto richtext-h-4 richtext-w-4"})]}));ht.displayName=q.SubTrigger.displayName;const ut=V.forwardRef(({className:e,...t},n)=>r.jsx(q.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}));ut.displayName=q.SubContent.displayName;const jt=V.forwardRef(({className:e,sideOffset:t=4,...n},i)=>r.jsx(q.Portal,{children:r.jsx(q.Content,{ref:i,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})}));jt.displayName=q.Content.displayName;const ne=V.forwardRef(({className:e,inset:t,...n},i)=>r.jsx(q.Item,{ref:i,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}));ne.displayName=q.Item.displayName;const Nr=V.forwardRef(({className:e,children:t,checked:n,...i},s)=>r.jsxs(q.CheckboxItem,{ref:s,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,...i,children:[r.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:r.jsx(q.ItemIndicator,{children:r.jsx(C.Check,{className:"richtext-h-4 richtext-w-4"})})}),t]}));Nr.displayName=q.CheckboxItem.displayName;const _n=V.forwardRef(({className:e,children:t,...n},i)=>r.jsxs(q.RadioItem,{ref:i,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:[r.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:r.jsx(q.ItemIndicator,{children:r.jsx(C.Circle,{className:"richtext-h-2 richtext-w-2 richtext-fill-current"})})}),t]}));_n.displayName=q.RadioItem.displayName;const Pn=V.forwardRef(({className:e,inset:t,...n},i)=>r.jsx(q.Label,{ref:i,className:P("richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-font-semibold",t&&"richtext-pl-8",e),...n}));Pn.displayName=q.Label.displayName;const Ct=V.forwardRef(({className:e,...t},n)=>r.jsx(q.Separator,{ref:n,className:P("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...t}));Ct.displayName=q.Separator.displayName;function Mr({className:e,...t}){return r.jsx("span",{className:P("richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",e),...t})}Mr.displayName="DropdownMenuShortcut";const K=V.forwardRef(({className:e,type:t,...n},i)=>r.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:i,...n}));K.displayName="Input";const zn=S.cva("richtext-text-sm richtext-font-medium richtext-leading-none peer-disabled:richtext-cursor-not-allowed peer-disabled:richtext-opacity-70"),ie=V.forwardRef(({className:e,...t},n)=>r.jsx(pr.Root,{ref:n,className:P(zn(),e),...t}));ie.displayName=pr.Root.displayName;const xe=Ee.Root,me=Ee.Trigger,le=V.forwardRef(({className:e,align:t="center",sideOffset:n=4,...i},s)=>r.jsx(Ee.Portal,{children:r.jsx(Ee.Content,{ref:s,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),...i})}));le.displayName=Ee.Content.displayName;const J=V.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...i},s)=>r.jsx(fr.Root,{ref:s,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),...i}));J.displayName=fr.Root.displayName;const yt=V.forwardRef(({className:e,...t},n)=>r.jsx(lt.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:r.jsx(lt.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")})}));yt.displayName=lt.Root.displayName;const kr=je.Root,Tt=V.forwardRef(({className:e,...t},n)=>r.jsx(je.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}));Tt.displayName=je.List.displayName;const Le=V.forwardRef(({className:e,...t},n)=>r.jsx(je.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}));Le.displayName=je.Trigger.displayName;const Re=V.forwardRef(({className:e,...t},n)=>r.jsx(je.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}));Re.displayName=je.Content.displayName;const Dn=Q.Provider,Ar=V.forwardRef(({className:e,...t},n)=>r.jsx(Q.Viewport,{ref:n,className:P("richtext-fixed richtext-top-0 richtext-z-[100] richtext-flex richtext-max-h-screen richtext-w-full richtext-flex-col-reverse richtext-p-4 sm:richtext-bottom-0 sm:richtext-right-0 sm:richtext-top-auto sm:richtext-flex-col md:richtext-max-w-[420px]",e),...t}));Ar.displayName=Q.Viewport.displayName;const Hn=S.cva("richtext-group richtext-pointer-events-auto richtext-relative richtext-flex richtext-w-full richtext-items-center richtext-justify-between richtext-space-x-4 richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-p-6 richtext-pr-8 richtext-shadow-lg richtext-transition-all data-[swipe=cancel]:richtext-translate-x-0 data-[swipe=end]:richtext-translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:richtext-translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:richtext-transition-none data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[swipe=end]:richtext-animate-out data-[state=closed]:richtext-fade-out-80 data-[state=closed]:richtext-slide-out-to-right-full data-[state=open]:richtext-slide-in-from-top-full data-[state=open]:sm:richtext-slide-in-from-bottom-full",{variants:{variant:{default:"richtext-border richtext-bg-background richtext-text-foreground",destructive:"richtext-destructive richtext-group richtext-border-destructive richtext-bg-destructive richtext-text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Er=V.forwardRef(({className:e,variant:t,...n},i)=>r.jsx(Q.Root,{ref:i,className:P(Hn({variant:t}),e),...n}));Er.displayName=Q.Root.displayName;const On=V.forwardRef(({className:e,...t},n)=>r.jsx(Q.Action,{ref:n,className:P("richtext-inline-flex richtext-h-8 richtext-shrink-0 richtext-items-center richtext-justify-center richtext-rounded-md !richtext-border richtext-bg-transparent richtext-px-3 richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-secondary focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 group-[.destructive]:richtext-border-muted/40 group-[.destructive]:hover:richtext-border-destructive/30 group-[.destructive]:hover:richtext-bg-destructive group-[.destructive]:hover:richtext-text-destructive-foreground group-[.destructive]:focus:richtext-ring-destructive",e),...t}));On.displayName=Q.Action.displayName;const Ir=V.forwardRef(({className:e,...t},n)=>r.jsx(Q.Close,{ref:n,className:P("richtext-absolute richtext-right-2 richtext-top-2 richtext-rounded-md richtext-p-1 richtext-text-foreground/50 richtext-opacity-0 richtext-transition-opacity hover:richtext-text-foreground focus:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 group-hover:richtext-opacity-100 group-[.destructive]:richtext-text-red-300 group-[.destructive]:hover:richtext-text-red-50 group-[.destructive]:focus:richtext-ring-red-400 group-[.destructive]:focus:richtext-ring-offset-red-600",e),"toast-close":"",...t,children:r.jsx(C.X,{className:"richtext-h-4 richtext-w-4"})}));Ir.displayName=Q.Close.displayName;const Lr=V.forwardRef(({className:e,...t},n)=>r.jsx(Q.Title,{ref:n,className:P("richtext-text-sm richtext-font-semibold",e),...t}));Lr.displayName=Q.Title.displayName;const Rr=V.forwardRef(({className:e,...t},n)=>r.jsx(Q.Description,{ref:n,className:P("richtext-text-sm richtext-opacity-90",e),...t}));Rr.displayName=Q.Description.displayName;const Bn=S.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"}}),St=V.forwardRef(({className:e,variant:t,size:n,...i},s)=>r.jsx(gr.Root,{ref:s,className:P(Bn({variant:t,size:n,className:e})),...i}));St.displayName=gr.Root.displayName;const $n=Pe.Provider,Nt=Pe.Root,Mt=Pe.Trigger,et=V.forwardRef(({className:e,sideOffset:t=4,...n},i)=>r.jsx(Pe.Content,{ref:i,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}));et.displayName=Pe.Content.displayName;const Vn=1,Fn=1e6;let ot=0;function Wn(){return ot=(ot+1)%Number.MAX_SAFE_INTEGER,ot.toString()}const st=new Map;function qt(e){if(st.has(e))return;const t=setTimeout(()=>{st.delete(e),Ae({type:"REMOVE_TOAST",toastId:e})},Fn);st.set(e,t)}function Gn(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Vn)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?qt(n):e.toasts.forEach(i=>{qt(i.id)}),{...e,toasts:e.toasts.map(i=>i.id===n||n===void 0?{...i,open:!1}:i)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}}const Ue=[];let Ze={toasts:[]};function Ae(e){Ze=Gn(Ze,e),Ue.forEach(t=>{t(Ze)})}function qn({...e}){const t=Wn(),n=s=>Ae({type:"UPDATE_TOAST",toast:{...s,id:t}}),i=()=>Ae({type:"DISMISS_TOAST",toastId:t});return Ae({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:s=>{s||i()}}}),{id:t,dismiss:i,update:n}}function _r(){const[e,t]=V.useState(Ze);return V.useEffect(()=>(Ue.push(t),()=>{const n=Ue.indexOf(t);n>-1&&Ue.splice(n,1)}),[e]),{...e,toast:qn,dismiss:n=>Ae({type:"DISMISS_TOAST",toastId:n})}}const Pr=V.forwardRef(({className:e,...t},n)=>r.jsx(dt.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:r.jsx(dt.Indicator,{className:P("!richtext-flex !richtext-p-0 !richtext-items-center !richtext-justify-center !richtext-text-current"),children:r.jsx(C.Check,{className:"!richtext-h-4 !richtext-w-4"})})}));Pr.displayName=dt.Root.displayName;function Un(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.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 Zn(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.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"})})}function Xn(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"richtext-w-4 richtext-h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.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"})})}function Kn(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"richtext-w-4 richtext-h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.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"})})}function Yn(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.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 U(e){const t=Or[e.name];return t?r.jsx(t,{className:`richtext-size-4 ${(e==null?void 0:e.className)||""}`,onClick:e==null?void 0:e.onClick}):r.jsx(S.DynamicIcon,{className:`richtext-size-4 ${(e==null?void 0:e.className)||""}`,name:e.name,onClick:e==null?void 0:e.onClick})}function Jn(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.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 zr(e){return r.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:r.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function Qn(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function ei(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function ti(e){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:r.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 ri(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m-9 8h4m-2-2v4"})})}function ni(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m9 8h4m-2-2v4"})})}function ii(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 21v-4m0-4V9m0-4V3m-2 18h4M8 5v4h11l2-2l-2-2zm6 8v4H6l-2-2l2-2z"})})}function oi(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsx("path",{fill:"currentColor",d:"M23.943 19.806a.2.2 0 0 0-.168-.034c-1.26-1.855-2.873-3.61-4.419-5.315l-.252-.284c-.001-.073-.067-.12-.134-.15l-.084-.084c-.05-.1-.169-.167-.286-.1c-.47.234-.907.585-1.327.919c-.554.434-1.109.87-1.63 1.354a5 5 0 0 0-.588.618c-.084.117-.017.217.084.267c-.37.368-.74.736-1.109 1.12a.2.2 0 0 0-.05.134c0 .05.033.1.067.117l.655.502v.016c.924.92 2.554 2.173 4.285 3.527c.251.201.52.402.773.602c.117.134.234.285.335.418c.05.066.169.084.236.033c.033.034.084.067.118.1a.24.24 0 0 0 .1.034a.15.15 0 0 0 .135-.066a.24.24 0 0 0 .033-.1c.017 0 .017.016.034.016a.2.2 0 0 0 .134-.05l3.058-3.327c.12-.116.014-.267 0-.267m-7.628-.134l-1.546-1.17l-.15-.1c-.035-.017-.068-.05-.102-.067l-.117-.1c.66-.66 1.33-1.308 2-1.956c-.488.484-1.463 1.906-1.261 2.373c.002 0 .018.042.067.084zm4.1 3.126l-1.277-.97a27 27 0 0 0-1.58-1.504c.69.518 1.277.97 1.361 1.053c.673.585.638.485 1.093.87l.554.4c-.074.103-.151.148-.151.151m.336.25l-.034-.016a1 1 0 0 0 .152-.117zM.588 3.476c.033.217.084.435.117.636c.201 1.103.403 2.106.772 2.858l.152.568c.05.217.134.485.219.552a67 67 0 0 0 3.578 2.942a.18.18 0 0 0 .219 0s0 .016.016.016a.15.15 0 0 0 .118.05a.2.2 0 0 0 .134-.05c1.798-1.989 3.142-3.627 4.1-4.998c.068-.066.084-.167.084-.25c.067-.067.118-.151.185-.201c.067-.067.067-.184 0-.235l-.017-.016c0-.033-.017-.084-.05-.1c-.42-.401-.722-.685-1.042-.986a94 94 0 0 1-2.352-2.273c-.017-.017-.034-.034-.067-.034c-.336-.117-1.025-.234-1.882-.385c-1.277-.216-3.008-.517-4.57-.986c0 0-.101 0-.118.017l-.05.05C.05.714.022.707 0 .718c.017.1.017.167.05.284c0 .033.068.301.068.334zm7.19 4.78l-.033.034a.036.036 0 0 1 .033-.034M6.553 2.238c.101.1.521.502.622.585c-.437-.2-1.529-.702-2.034-.869c.505.1 1.194.201 1.412.284M.79 1.403c.252.434.454 1.939.655 3.41c-.118-.469-.201-.936-.302-1.372C.992 2.673.84 1.988.638 1.386c.124 0 .152.021.152.017m-.286-.369c0-.016 0-.033-.017-.033c.085 0 .135.017.202.05c0 .006-.145-.017-.185-.017m23.17-.217c.017-.066-.336-.367-.219-.384c.253-.017.253-.401 0-.401c-.335.017-.688.1-1.008.15c-.587.117-1.192.234-1.78.367a80 80 0 0 0-3.949.937c-.403.117-.857.2-1.243.401c-.135.067-.118.2-.05.284c-.034.017-.051.017-.085.034c-.117.017-.218.034-.335.05c-.102.017-.152.1-.135.2c0 .017.017.05.017.067c-.706.936-1.496 1.923-2.353 2.976c-.84.969-1.73 1.989-2.62 3.042c-2.84 3.31-6.05 7.07-9.594 10.38a.16.16 0 0 0 0 .234c.016.016.033.033.05.033c-.05.05-.101.085-.152.134q-.05.05-.05.1a.4.4 0 0 0-.067.084c-.067.067-.067.184.017.234c.067.066.185.066.235-.017c.017-.017.017-.033.033-.033a.265.265 0 0 1 .37 0c.202.217.404.435.588.618l-.42-.35c-.067-.067-.184-.05-.234.016c-.068.066-.051.184.016.234l4.469 3.727c.034.034.067.034.118.034a.15.15 0 0 0 .117-.05l.101-.1c.017.016.05.016.067.016c.05 0 .084-.016.118-.05c6.049-6.05 10.922-10.614 16.5-14.693c.05-.033.067-.1.067-.15c.067 0 .118-.05.15-.117c1.026-3.125 1.228-5.9 1.295-7.27c0-.059.016-.038.016-.068c.017-.033.017-.05.017-.05a.98.98 0 0 0-.067-.619m-10.82 4.915c.268-.301.537-.619.806-.903c-1.73 2.273-4.603 5.767-8.67 9.929c2.773-3.059 5.562-6.218 7.864-9.026M5.14 23.466c-.016-.017-.016-.017 0-.017zm2.504-2.156c.135-.15.27-.284.42-.434c0 0 0 .016.017.016c-.224.198-.433.418-.437.418m.69-.668c.099-.1.14-.173.284-.318c.992-1.02 2.017-2.04 3.059-3.076l.016-.016c.252-.2.555-.418.824-.619a228 228 0 0 0-4.184 4.029M14.852 3.91c-.554.719-1.176 1.671-1.697 2.423c-1.646 2.374-6.94 8.174-7.057 8.274a1190 1190 0 0 1-4.839 4.597l-.1.1c-.085-.1-.085-.25.016-.334C8.652 11.966 13.19 6.133 15.021 3.576c-.05.116-.084.216-.168.334zm2.906 3.427c-.671-.386-.99-.987-.806-1.572l.05-.2a.8.8 0 0 1 .085-.167a1.9 1.9 0 0 1 .756-.703c.016 0 .033 0 .05-.016c-.017-.034-.017-.084-.017-.134c.017-.1.085-.167.202-.167c.202 0 .824.184 1.059.384c.067.05.134.117.202.184c.084.1.218.268.285.401c.034.017.067.184.118.268c.033.134.067.284.05.418c-.017.016 0 .116-.017.116a1.6 1.6 0 0 1-.218.619c-.03.03.006.012-.05.067a1.2 1.2 0 0 1-.32.334a1.49 1.49 0 0 1-1.26.234a2 2 0 0 0-.169-.066m4.37 1.403c0 .017-.017.05 0 .067c-.034 0-.05.017-.085.034a110 110 0 0 0-3.915 3.025c1.11-.986 2.218-1.989 3.378-2.975c.336-.301.571-.686.638-1.12l.168-1.003v-.033c.085-.201.404-.118.353.1c-.004-.001-.173.795-.537 1.905"})})}function Dr(){return r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 32 32",children:[r.jsx("path",{fill:"currentColor",d:"M30 18v-2h-6v10h2v-4h3v-2h-3v-2zm-11 8h-4V16h4a3.003 3.003 0 0 1 3 3v4a3.003 3.003 0 0 1-3 3m-2-2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2zm-6-8H6v10h2v-3h3a2.003 2.003 0 0 0 2-2v-3a2 2 0 0 0-2-2m-3 5v-3h3l.001 3z"}),r.jsx("path",{fill:"currentColor",d:"M22 14v-4a.91.91 0 0 0-.3-.7l-7-7A.9.9 0 0 0 14 2H4a2.006 2.006 0 0 0-2 2v24a2 2 0 0 0 2 2h16v-2H4V4h8v6a2.006 2.006 0 0 0 2 2h6v2Zm-8-4V4.4l5.6 5.6Z"})]})}function Hr(){return r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",className:"icon",viewBox:"0 0 1024 1024",children:[r.jsx("path",{fill:"currentColor",d:"M679.253 402.364 618.77 561.015l-60.348-158.651a30.04 30.04 0 0 0-30.447-18.637 29.76 29.76 0 0 0-30.447 18.637l-60.416 158.651-60.416-158.651a30.515 30.515 0 0 0-38.843-17.272 28.945 28.945 0 0 0-17.954 37.547l88.815 233.267c4.369 11.469 15.7 19.115 28.398 19.115a30.31 30.31 0 0 0 28.468-19.115l62.395-163.908 62.396 163.84c4.437 11.605 15.701 19.183 28.4 19.183a30.31 30.31 0 0 0 28.466-19.115l88.747-233.267a28.945 28.945 0 0 0-17.886-37.547 30.447 30.447 0 0 0-38.912 17.272zm219.478 395.605-51.883-29.218c-28.672-16.18-52.224-3.072-52.224 29.082v.273H643.209a29.833 29.833 0 0 0-30.31 29.354c0 16.18 13.584 29.218 30.31 29.218h151.825c1.092 30.516 24.03 43.077 52.224 27.648l51.063-27.989c29.013-15.906 29.15-42.189.41-58.368"}),r.jsx("path",{fill:"currentColor",d:"m810.667 913.135-.478.068H201.796c-19.865 0-36.727-11.673-36.727-25.6v-618.36h154.965c51.268 0 92.911-39.39 92.911-87.858v-87.86H810.19c19.797 0 36.522 11.742 36.522 25.669V739.26h61.987V119.262c0-46.421-44.169-84.241-98.51-84.241H328.364l-225.28 194.56v658.09c0 46.285 44.236 84.105 98.713 84.105H810.19c43.759 0 80.554-24.713 93.32-58.573h-92.842zM350.89 94.89v86.562c0 16.11-13.858 29.286-30.925 29.286H216.815L350.959 94.891z"})]})}function si(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",color:"currentColor",children:[r.jsx("path",{d:"M14.86 22h-4.312c-3.291 0-4.937 0-6.08-.798a4.2 4.2 0 0 1-.863-.805c-.855-1.066-.855-2.6-.855-5.67v-2.545c0-2.963 0-4.445.473-5.628c.761-1.903 2.37-3.403 4.41-4.113C8.9 2 10.49 2 13.667 2c1.816 0 2.723 0 3.448.252c1.166.406 2.085 1.263 2.52 2.35c.27.676.27 1.523.27 3.216V10"}),r.jsx("path",{d:"M2.75 12c0-1.84 1.506-3.333 3.364-3.333c.672 0 1.464.116 2.117-.057a1.67 1.67 0 0 0 1.19-1.179c.174-.647.057-1.432.057-2.098C9.478 3.493 10.984 2 12.84 2m.002 16h2.523m-4.949-4.15c-.126-.8-.281-.801-1.61-.85h-1.01c-.557 0-1.009.448-1.009 1v3c0 .552.452 1 1.01 1h1.816c.39 0 .803-.313.803-.7v-1.1c0-.11-.113-.304-.224-.304H9.068M12.842 13h1.261m0 0h1.262m-1.262 0v4.875M21.251 13h-2.523c-.557 0-1.009.448-1.009 1v1.5m0 0V18m0-2.5h2.523"})]})})}function ci(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:r.jsx("path",{fill:"currentColor",d:"M6.5 3a.75.75 0 0 1 .697.471l3 7.5a.75.75 0 0 1-1.393.557L7.992 9.5H5.008l-.811 2.028a.75.75 0 0 1-1.393-.556l3-7.5A.75.75 0 0 1 6.5 3m0 2.77L5.608 8h1.784zm8.28-1.55a.75.75 0 1 0-1.06 1.06l.72.72h-3.69a.75.75 0 0 0 0 1.5h3.69l-.72.72a.75.75 0 0 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06zm0 7.5a.75.75 0 1 0-1.06 1.06l.72.72H3.75a.75.75 0 0 0 0 1.5h10.69l-.72.72a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06z"})})}function ai(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",children:r.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"4",children:[r.jsx("circle",{cx:"10",cy:"24",r:"4"}),r.jsx("circle",{cx:"38",cy:"10",r:"4"}),r.jsx("circle",{cx:"38",cy:"24",r:"4"}),r.jsx("circle",{cx:"38",cy:"38",r:"4"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M34 38H22V10h12M14 24h20"})]})})}function li(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:r.jsx("path",{fill:"currentColor",d:"M13.5 3a.75.75 0 0 0-.697.471l-3 7.5a.75.75 0 0 0 1.393.557l.812-2.028h2.984l.811 2.028a.75.75 0 0 0 1.393-.556l-3-7.5A.75.75 0 0 0 13.5 3m0 2.77L14.392 8h-1.784zM5.22 4.22a.75.75 0 0 1 1.06 1.06L5.56 6h3.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 0 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06zm0 7.5a.75.75 0 0 1 1.06 1.06l-.72.72h10.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06z"})})}function di(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"m3 21l7.548-7.548M21 3l-7.548 7.548m0 0L8 3H3l7.548 10.452m2.904-2.904L21 21h-5l-5.452-7.548",color:"currentColor"})})}function hi(){return r.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 24 24",children:r.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"})})}const Or={Bold:C.Bold,LoaderCircle:C.LoaderCircle,Italic:C.Italic,Underline:C.Underline,Quote:C.Quote,TextQuote:Zn,Strikethrough:C.Strikethrough,Minus:C.Minus,Eraser:C.Eraser,PaintRoller:C.PaintRoller,Redo2:C.Redo2,Undo2:C.Undo2,AlignCenter:$e.TextAlignCenterIcon,AlignJustify:$e.TextAlignJustifyIcon,AlignLeft:$e.TextAlignLeftIcon,AlignRight:$e.TextAlignRightIcon,ChevronDown:C.ChevronDown,Subscript:C.Subscript,Superscript:C.Superscript,Code:C.Code,Code2:C.CodeXml,Type:C.Type,IndentIncrease:C.IndentIncrease,IndentDecrease:C.IndentDecrease,List:C.List,ListOrdered:C.ListOrdered,ListTodo:C.ListTodo,Link:C.Link,ImageUp:C.ImageUp,Video:C.Video,Maximize:C.Maximize,Minimize:C.Minimize,Table:C.Table,Sparkles:C.Sparkles,Pencil:C.Pencil,Unlink:C.Unlink,BetweenHorizonalEnd:C.BetweenHorizonalEnd,BetweenHorizonalStart:C.BetweenHorizonalStart,BetweenVerticalStart:C.BetweenVerticalStart,BetweenVerticalEnd:C.BetweenVerticalEnd,TableCellsMerge:C.TableCellsMerge,TableCellsSplit:C.TableCellsSplit,Trash2:C.Trash2,Trash:C.Trash,Replace:C.Replace,ChevronsUpDown:C.ChevronsUpDown,LineHeight:Jn,Word:Yn,Heading1:C.Heading1,Heading2:C.Heading2,Heading3:C.Heading3,Heading4:C.Heading4,Heading5:C.Heading5,Heading6:C.Heading6,Columns2:C.Columns2,Columns3:C.Columns3,Columns4:C.Columns4,Plus:C.Plus,Grip:C.GripVertical,Copy:C.Copy,Clipboard:C.Clipboard,PanelLeft:C.PanelLeft,PanelRight:C.PanelRight,Columns:C.Columns2,Iframe:C.Frame,MenuDown:zr,SizeS:ti,SizeM:ei,SizeL:Qn,AspectRatio:Un,Emoji:C.SmilePlus,DeleteColumn:Xn,DeleteRow:Kn,SearchAndReplace:C.Replace,EmojiIcon:C.SmilePlusIcon,KatexIcon:C.Sigma,ExportPdf:Dr,ExportWord:Hr,ImportWord:hi,ColumnAddLeft:ri,ColumnAddRight:ni,BookMarked:C.BookMarked,Excalidraw:oi,ZoomIn:C.ZoomIn,ZoomOut:C.ZoomOut,Settings:C.Settings,Eye:C.Eye,TextDirection:ii,LeftToRight:ci,RightToLeft:li,Attachment:C.Paperclip,GifIcon:si,ChevronUp:C.ChevronUp,Crop:C.CropIcon,Mermaid:ai,Twitter:di,FlipX:C.FlipVertical,FlipY:C.FlipHorizontal,PencilRuler:C.PencilRuler};function ui({fill:e}){return r.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:r.jsxs("g",{id:"icon/背景颜色",children:[r.jsx("g",{id:"编组",fill:"currentColor",children:r.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[r.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"}),r.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"}),r.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"})]})}),r.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"})]})})})}function Br(e){const[t,n]=d.useState(void 0);function i(c){var a;(a=e.action)==null||a.call(e,c)}function s(){var c;(c=e.action)==null||c.call(e,t)}const o=d.useCallback(S.debounce(c=>{n(c)},350),[]);return r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-h-[32px]",children:[r.jsx(D,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:s,tooltipOptions:e==null?void 0:e.tooltipOptions,shortcutKeys:e==null?void 0:e.shortcutKeys,children:r.jsx("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-text-sm",children:r.jsx(ui,{fill:t})})}),r.jsx(Yr,{selectedColor:t,setSelectedColor:o,onChange:i,highlight:!0,disabled:e==null?void 0:e.disabled,children:r.jsx(G,{variant:"ghost",size:"icon",className:"!richtext-w-3 !richtext-h-[32px]",disabled:e==null?void 0:e.disabled,children:r.jsx(U,{className:"!richtext-w-3 !richtext-h-3 richtext-text-zinc-500",name:"MenuDown"})})})]})}function $r(e){const{t}=y.useLocale(),[n,i]=d.useState({text:"",link:""}),[s,o]=d.useState(!1);d.useEffect(()=>{var a;if(e!=null&&e.editor){const{href:l,target:h}=(a=e.editor)==null?void 0:a.getAttributes("link"),{from:u,to:x}=e.editor.state.selection,m=e.editor.state.doc.textBetween(u,x," ");i({link:l,text:m}),o(h==="_blank")}},[e==null?void 0:e.editor]);function c(a){a.preventDefault(),a.stopPropagation(),e==null||e.onSetLink(n.link,n.text,s)}return r.jsx("div",{className:"border-neutral-200 richtext-rounded-lg !richtext-border richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:r.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:c,children:[r.jsx(ie,{className:"mb-[6px]",children:t("editor.link.dialog.text")}),r.jsx("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:r.jsx(K,{className:"richtext-w-80",onChange:a=>i({...n,text:a.target.value}),placeholder:"Text",required:!0,type:"text",value:n.text})})}),r.jsx(ie,{className:"mb-[6px]",children:t("editor.link.dialog.link")}),r.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsxs("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:[r.jsx(K,{className:"richtext-pl-10",onChange:a=>i({...n,link:a.target.value}),required:!0,type:"url",value:n.link}),r.jsx("span",{className:"richtext-absolute richtext-inset-y-0 richtext-start-0 richtext-flex richtext-items-center richtext-justify-center richtext-px-2",children:r.jsx(U,{className:"richtext-size-5 richtext-text-muted-foreground",name:"Link"})})]})}),r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-space-x-2",children:[r.jsx(ie,{children:t("editor.link.dialog.openInNewTab")}),r.jsx(yt,{checked:s,onCheckedChange:a=>{o(a)}})]}),r.jsx(G,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:t("editor.link.dialog.button.apply")})]})})}function xi(e,t,n=null){return n?e.createChecked({index:t},n):e.createAndFill({index:t})}function mi(e){if(e.cached.columnsNodeTypes)return e.cached.columnsNodeTypes;const t={columns:e.nodes.columns,column:e.nodes.column};return e.cached.columnsNodeTypes=t,t}function fi(e,t,n=null){const i=mi(e),s=[];for(let o=0;o<t;o+=1){const c=xi(i.column,o,n);c&&s.push(c)}return i.columns.createChecked({cols:t},s)}function ct({state:e,dispatch:t,type:n}){const i=A.findParentNode(o=>o.type.name===_e.name)(e.selection),s=A.findParentNode(o=>o.type.name===kt.name)(e.selection);if(t&&i&&s){const o=i.node,c=s.node.attrs.index,a=o.toJSON();let l=c;n==="delete"?(l=c-1,a.content.splice(c,1)):(l=n==="addBefore"?c:c+1,a.content.splice(l,0,{type:"column",attrs:{index:c},content:[{type:"paragraph"}]})),a.attrs.cols=a.content.length,a.content.forEach((m,f)=>{m.attrs.index=f});const h=S.Node.fromJSON(e.schema,a);let u=i.pos;h.content.forEach((m,f,w)=>{w<l&&(u+=m.nodeSize)});const x=e.tr.setTime(Date.now());x.replaceWith(i.pos,i.pos+i.node.nodeSize,h).setSelection(S.TextSelection.near(x.doc.resolve(u))),t(x)}return!0}function Ut({state:e,dispatch:t,type:n}){const i=A.findParentNode(o=>o.type.name===_e.name)(e.selection),s=A.findParentNode(o=>o.type.name===kt.name)(e.selection);if(t&&i&&s){const o=i.node,c=s.node.attrs.index;let a=0;n==="before"?a=(c-1+o.attrs.cols)%o.attrs.cols:a=(c+1)%o.attrs.cols;let l=i.pos;o.content.forEach((u,x,m)=>{m<a&&(l+=u.nodeSize)});const h=e.tr.setTime(Date.now());return h.setSelection(S.TextSelection.near(h.doc.resolve(l))),t(h),!0}return!1}const gi=200,_e=A.Node.create({name:"columns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"column{1,}",priority:gi,addOptions(){return{HTMLAttributes:{class:"columns"}}},addAttributes(){return{cols:{default:2,parseHTML:e=>e.getAttribute("cols")}}},parseHTML(){return[{tag:"div[class=grid]"}]},renderHTML({HTMLAttributes:e}){return["div",A.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{insertColumns:e=>({tr:t,dispatch:n,editor:i})=>{const s=fi(i.schema,e&&e.cols||3);if(n){const o=t.selection.anchor+1;t.replaceSelectionWith(s).scrollIntoView().setSelection(S.TextSelection.near(t.doc.resolve(o)))}return!0},addColBefore:()=>({dispatch:e,state:t})=>ct({dispatch:e,state:t,type:"addBefore"}),addColAfter:()=>({dispatch:e,state:t})=>ct({dispatch:e,state:t,type:"addAfter"}),deleteCol:()=>({dispatch:e,state:t})=>ct({dispatch:e,state:t,type:"delete"})}},addKeyboardShortcuts(){return{"Mod-Alt-G":()=>this.editor.commands.insertColumns(),Tab:()=>Ut({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>Ut({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),kt=A.Node.create({name:"column",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"column"}}},addAttributes(){return{index:{default:0,parseHTML:e=>e.getAttribute("index")}}},parseHTML(){return[{tag:"div[class=column]"}]},renderHTML({HTMLAttributes:e}){return["div",A.mergeAttributes(this.options.HTMLAttributes,e),0]}});var Ke=(e=>(e[e.max=7]="max",e[e.min=0]="min",e[e.more=1]="more",e[e.less=-1]="less",e))(Ke||{});function pi(e,t,n){return e<t?t:e>n?n:e}function wi(e,t,n,i){const{doc:s,selection:o}=e;if(!s||!o||!(o instanceof S.TextSelection||o instanceof S.AllSelection))return e;const{from:c,to:a}=o;return s.nodesBetween(c,a,(l,h)=>{const u=l.type;return n.includes(u.name)?(e=xt(e,h,t),!1):!A.isList(l.type.name,i.extensionManager.extensions)}),e}function xt(e,t,n){if(!e.doc)return e;const i=e.doc.nodeAt(t);if(!i)return e;const c=pi((i.attrs.indent||0)+n,0,7);if(c===i.attrs.indent)return e;const a={...i.attrs,indent:c};return e.setNodeMarkup(t,i.type,a,i.marks)}function vi({delta:e,types:t}){return({state:n,dispatch:i,editor:s})=>{const{selection:o}=n;let{tr:c}=n;return c=c.setSelection(o),c=wi(c,e,t,s),c.docChanged?(i&&i(c),!0):!1}}const Vr={setOpen:(e,t)=>{Qe(ue.UPLOAD_IMAGE(e),t)}},de=te.Root,he=te.Trigger,bi=te.Portal,Fr=V.forwardRef(({className:e,...t},n)=>r.jsx(te.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}));Fr.displayName=te.Overlay.displayName;const se=V.forwardRef(({className:e,children:t,...n},i)=>r.jsxs(bi,{children:[r.jsx(Fr,{}),r.jsxs(te.Content,{ref:i,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,r.jsxs(te.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:[r.jsx(C.X,{className:"richtext-h-4 richtext-w-4"}),r.jsx("span",{className:"richtext-sr-only",children:"Close"})]})]})]}));se.displayName=te.Content.displayName;function Wr({className:e,...t}){return r.jsx("div",{className:P("richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",e),...t})}Wr.displayName="DialogHeader";function fe({className:e,...t}){return r.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})}fe.displayName="DialogFooter";const ce=V.forwardRef(({className:e,...t},n)=>r.jsx(te.Title,{ref:n,className:P("richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight",e),...t}));ce.displayName=te.Title.displayName;const ji=V.forwardRef(({className:e,...t},n)=>r.jsx(te.Description,{ref:n,className:P("richtext-text-sm richtext-text-muted-foreground",e),...t}));ji.displayName=te.Description.displayName;function Ci(e){return e.replace(/^.*\/|\..+$/g,"")}function yi(e){return e.split(".").pop()}function Ti(e){return e<1024?`${e} Byte`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function Si(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 Ni(e){return new Promise(t=>{const n=new FileReader;n.addEventListener("load",()=>{t({alt:e.name,src:n.result})},!1),n.readAsDataURL(e)})}function ze(e,t){const n=e.split(","),i=n[0].match(/:(.*?);/)[1],s=atob(n[n.length-1]);let o=s.length;const c=new Uint8Array(o);for(;o--;)c[o]=s.charCodeAt(o);return new File([c],t,{type:i})}function Mi({editor:e,imageInline:t,onClose:n}){const{t:i}=y.useLocale(),[s,o]=d.useState(!1),c=d.useRef(null),[a,l]=d.useState(),[h,u]=d.useState(""),x=d.useRef(null),[m,f]=d.useState({src:"",file:null});function w(v){if(c.current&&v.width&&v.height){const b=p(c.current,v);u(b)}}function p(v,b){const T=document.createElement("canvas"),E=v.naturalWidth/v.width,L=v.naturalHeight/v.height;T.width=b.width*E,T.height=b.height*L;const N=T.getContext("2d");return N&&(N.imageSmoothingEnabled=!1,N.drawImage(v,b.x*E,b.y*L,b.width*E,b.height*L,0,0,b.width*E,b.height*L)),T.toDataURL("image/png",1)}async function g(){var v,b;try{const T=ze(h,((v=m==null?void 0:m.file)==null?void 0:v.name)||"image.png"),E=(b=e.extensionManager.extensions.find(N=>N.name===ye.name))==null?void 0:b.options;let L="";E.upload?L=await E.upload(T):L=URL.createObjectURL(T),e.chain().focus().setImageInline({src:L,inline:t}).run(),o(!1),f({src:"",file:null}),n()}catch(T){console.log("Error cropping image",T)}}function R(v){var b;v.preventDefault(),(b=x.current)==null||b.click()}const M=async v=>{var L;const b=(L=v==null?void 0:v.target)==null?void 0:L.files;if(!e||e.isDestroyed||b.length===0)return;const T=b[0],E=await Ni(T);o(!0),f({src:E.src,file:T})};return r.jsxs(r.Fragment,{children:[r.jsx(G,{className:"richtext-mt-1 richtext-w-full",onClick:R,size:"sm",children:i("editor.image.dialog.tab.uploadCrop")}),r.jsxs(de,{open:s,children:[r.jsx(he,{}),r.jsxs(se,{children:[r.jsx(ce,{children:i("editor.image.dialog.tab.uploadCrop")}),r.jsx("div",{children:m.src&&r.jsx(Cn,{className:"richtext-w-full",crop:a,onChange:v=>l(v),onComplete:v=>w(v),children:r.jsx("img",{alt:"Crop me",ref:c,src:m.src})})}),r.jsxs(fe,{children:[r.jsxs(G,{onClick:()=>{o(!1),f({src:"",file:null})},children:[i("editor.imageUpload.cancel"),r.jsx(U,{className:"richtext-ml-[4px]",name:"Trash2"})]}),r.jsxs(G,{className:"richtext-w-fit",onClick:g,children:[i("editor.imageUpload.crop"),r.jsx(U,{className:"richtext-ml-[4px]",name:"Crop"})]})]})]})]}),r.jsx("input",{accept:"image/*",multiple:!0,onChange:M,ref:x,type:"file",style:{display:"none"}})]})}function ki(e){var w;const{t}=y.useLocale(),[n,i]=d.useState(!1),s=p=>{i(p.detail)},[o,c]=d.useState(""),a=d.useRef(null),[l,h]=d.useState(((w=e.editor.extensionManager.extensions.find(p=>p.name===ye.name))==null?void 0:w.options.defaultInline)||!1),u=d.useMemo(()=>{var g;return(g=e.editor.extensionManager.extensions.find(R=>R.name===ye.name))==null?void 0:g.options},[e.editor]);d.useEffect(()=>{const p=Ie(ue.UPLOAD_IMAGE(e.editor.id),s);return()=>{p()}},[]);async function x(p){var v;const g=(v=p==null?void 0:p.target)==null?void 0:v.files;if(!e.editor||e.editor.isDestroyed||g.length===0)return;const R=g[0];let M="";u.upload?M=await u.upload(R):M=URL.createObjectURL(R),e.editor.chain().focus().setImageInline({src:M,inline:l}).run(),i(!1),h(!1)}function m(p){p.preventDefault(),p.stopPropagation(),e.editor.chain().focus().setImageInline({src:o,inline:l}).run(),i(!1),h(!1),c("")}function f(p){var g;p.preventDefault(),(g=a.current)==null||g.click()}return r.jsxs(de,{onOpenChange:i,open:n,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>i(!0),icon:e.icon,tooltip:e.tooltip})}),r.jsxs(se,{children:[r.jsx(ce,{children:t("editor.image.dialog.title")}),r.jsxs(kr,{activationMode:"manual",defaultValue:u.resourceImage==="both"||u.resourceImage==="upload"?"upload":"link",children:[r.jsxs(Tt,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[u.resourceImage==="both"||u.resourceImage==="upload"?r.jsx(Le,{value:"upload",children:t("editor.image.dialog.tab.upload")}):r.jsx(r.Fragment,{}),u.resourceImage==="both"||u.resourceImage==="link"?r.jsx(Le,{value:"link",children:t("editor.image.dialog.tab.url")}):r.jsx(r.Fragment,{})]}),r.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[r.jsx(Pr,{checked:l,onCheckedChange:p=>{h(p)}}),r.jsx(ie,{children:t("editor.link.dialog.inline")})]}),r.jsxs(Re,{value:"upload",children:[r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[r.jsx(G,{className:"richtext-mt-1 richtext-w-full",onClick:f,size:"sm",children:t("editor.image.dialog.tab.upload")}),r.jsx(Mi,{editor:e.editor,imageInline:l,onClose:()=>Vr.setOpen(e.editor.id,!1)})]}),r.jsx("input",{accept:"image/*",multiple:!0,onChange:x,ref:a,type:"file",style:{display:"none"}})]}),r.jsx(Re,{value:"link",children:r.jsx("form",{onSubmit:m,children:r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[r.jsx(K,{autoFocus:!0,onChange:p=>c(p.target.value),placeholder:t("editor.image.dialog.placeholder"),required:!0,type:"url",value:o}),r.jsx(G,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})]})]})}const Ve={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Ai(e){var L,N;const[t,n]=d.useState({width:y.IMAGE_MAX_SIZE,height:y.IMAGE_MAX_SIZE}),[i,s]=d.useState({width:0,height:0}),[o]=d.useState([Ve.TOP_LEFT,Ve.TOP_RIGHT,Ve.BOTTOM_LEFT,Ve.BOTTOM_RIGHT]),[c,a]=d.useState(!1),[l,h]=d.useState({x:0,y:0,w:0,h:0,dir:""}),{align:u,inline:x}=(L=e==null?void 0:e.node)==null?void 0:L.attrs,m=d.useMemo(()=>{var ae;const{src:_,alt:j,width:k,height:B,flipX:O,flipY:H}=(ae=e==null?void 0:e.node)==null?void 0:ae.attrs,I=S.isNumber(k)?`${k}px`:k,$=S.isNumber(B)?`${B}px`:B,F=[];O&&F.push("rotateX(180deg)"),H&&F.push("rotateY(180deg)");const X=F.join(" ");return{src:_||void 0,alt:j||void 0,style:{width:I||void 0,height:$||void 0,transform:X||"none"}}},[(N=e==null?void 0:e.node)==null?void 0:N.attrs]),f=d.useMemo(()=>{const{style:{width:_}}=m;return{width:_==="100%"?_:void 0}},[m]);function w(_){s({width:_.target.width,height:_.target.height})}function p(){const{editor:_,getPos:j}=e;_.commands.setNodeSelection(j())}const g=d.useCallback(S.throttle(()=>{const{editor:_}=e,{width:j}=getComputedStyle(_.view.dom);n(k=>({...k,width:Number.parseInt(j,10)}))},y.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function R(_,j){_.preventDefault(),_.stopPropagation();const k=i.width,B=i.height,O=k/B;let H=Number(e.node.attrs.width),I=Number(e.node.attrs.height);const $=t.width;H&&!I?(H=H>$?$:H,I=Math.round(H/O)):I&&!H?(H=Math.round(I*O),H=H>$?$:H):!H&&!I?(H=k>$?$:k,I=Math.round(H/O)):H=H>$?$:H,a(!0),h({x:_.clientX,y:_.clientY,w:H,h:I,dir:j})}const M=d.useCallback(S.throttle(_=>{if(_.preventDefault(),_.stopPropagation(),!c)return;const{x:j,w:k,dir:B}=l,O=(_.clientX-j)*(/l/.test(B)?-1:1),H=S.clamp(k+O,y.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:H,height:null})},y.IMAGE_THROTTLE_WAIT_TIME),[c,l,t,e.updateAttributes]),v=d.useCallback(_=>{_.preventDefault(),_.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),a(!1),p())},[c,p]),b=d.useCallback(()=>{document==null||document.addEventListener("mousemove",M,!0),document==null||document.addEventListener("mouseup",v,!0)},[M,v]),T=d.useCallback(()=>{document==null||document.removeEventListener("mousemove",M,!0),document==null||document.removeEventListener("mouseup",v,!0)},[M,v]);d.useEffect(()=>(c?b():T(),()=>{T()}),[c,b,T]);const E=d.useMemo(()=>new ResizeObserver(()=>g()),[g]);return d.useEffect(()=>(E.observe(e.editor.view.dom),()=>{E.disconnect()}),[e.editor.view.dom,E]),r.jsx(A.NodeViewWrapper,{as:x?"span":"div",className:"image-view",style:{...f,textAlign:u,display:x?"inline":"block"},children:r.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:f,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[r.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:p,onLoad:w,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||c)&&r.jsx("div",{className:"image-resizer",children:o==null?void 0:o.map(_=>r.jsx("span",{className:`image-resizer__handler image-resizer__handler--${_}`,onMouseDown:j=>R(j,_)},`image-dir-${_}`))})]})})}const Ce=new S.PluginKey("upload-image");function Ei(){return new S.Plugin({key:Ce,state:{init(){return S.DecorationSet.empty},apply(e,t){t=t.map(e.mapping,e.doc);const n=e.getMeta(Ce);if(n!=null&&n.add)for(const{id:i,pos:s,src:o}of n.add){const c=Ii(o),a=S.Decoration.widget(s,c,{id:i});t=t.add(e.doc,[a])}else if(n!=null&&n.remove)for(const i of n.remove)t=t.remove(t.find(void 0,void 0,s=>s.id===i));return t}},props:{decorations(e){return this.getState(e)}}})}function Ii(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 Li(e,t){var s;const i=Ce.getState(e).find(void 0,void 0,o=>o.id===t);return i.length>0?(s=i[0])==null?void 0:s.from:null}function Ri({validateFn:e,onUpload:t,postUpload:n,defaultInline:i=!1}){return(s,o,c)=>{for(const a of s){if(e&&!e(a))continue;const l=Date.now().toString(),h=o.state.tr;h.selection.empty||h.deleteSelection();const u=URL.createObjectURL(a);h.setMeta(Ce,{add:[{id:l,pos:c,src:u}]}),o.dispatch(h),t(a).then(async x=>{var M;n&&typeof x=="string"&&(x=await n(x));const{schema:m}=o.state;let f=Li(o.state,l);if(f===null)return;const w=typeof x=="object"?u:x,p=(M=m.nodes.image)==null?void 0:M.create({src:w,inline:i});if(!p)return;const{doc:g}=o.state;f>g.content.size&&(f=g.content.size-1);const R=o.state.tr.replaceWith(f,f,p).setMeta(Ce,{remove:[l]});o.dispatch(R)},()=>{const x=o.state.tr.delete(c,c).setMeta(Ce,{remove:[l]});o.dispatch(x)})}}}function _i(e,t,n){var s;const i=[...((s=t.clipboardData)==null?void 0:s.files)||[]];if(i.length>0){t.preventDefault();const o=e.state.selection.from;return n(i,e,o+1),!0}return!1}function Pi(e,t,n,i){var o;const s=[...((o=t.dataTransfer)==null?void 0:o.files)||[]];if(!n&&s.length>0){t.preventDefault();const c=e.posAtCoords({left:t.clientX,top:t.clientY});if(c)return i(s,e,c.pos+1),!0}return!1}const zi={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,resourceImage:"both",defaultInline:!1},ye=A.Image.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...zi,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:n,t:i})=>{var s,o;return{component:ki,componentProps:{action:()=>!0,upload:n.options.upload,disabled:!((o=(s=t.can()).setImage)!=null&&o.call(s,{})),icon:"ImageUp",tooltip:i("editor.image.tooltip"),editor:t}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||null;return n?Number.parseInt(n,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})}}},addNodeView(){return A.ReactNodeViewRenderer(Ai)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:n})=>n.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImage:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:n,align:i,inline:s}=e,o=t||n?`transform: rotateX(${t?"180":"0"}deg) rotateY(${n?"180":"0"}deg);`:"",c=i?`text-align: ${i};`:"";return[s?"span":"div",{style:c,class:"image"},["img",A.mergeAttributes({height:"auto",style:o},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var o;const t=e==null?void 0:e.parentElement,n=e==null?void 0:e.getAttribute("width"),i=(e==null?void 0:e.getAttribute("flipx"))||!1,s=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(e==null?void 0:e.getAttribute("align"))||((o=t==null?void 0:t.style)==null?void 0:o.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:i==="true",flipY:s==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),i=(t==null?void 0:t.getAttribute("flipx"))||!1,s=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:i==="true",flipY:s==="true"}}}]},addProseMirrorPlugins(){const t=Ri({validateFn:n=>!(!this.options.acceptMimes.includes(n.type)||n.size>this.options.maxSize),onUpload:this.options.upload,defaultInline:this.options.defaultInline});return[new S.Plugin({props:{handlePaste:(n,i)=>!i.clipboardData||[...i.clipboardData.files||[]].some(o=>o.type==="text/html")?!1:_i(n,i,t),handleDrop:(n,i,s,o)=>(!(i instanceof DragEvent)||!i.dataTransfer||Pi(n,i,o,t),!1)}}),Ei()]}});function Di(e){return/\.(?:mp4|webm|ogg|mov)$/i.test(e)}function Hi(e){const{t}=y.useLocale(),[n,i]=d.useState(""),s=d.useRef(null),[o,c]=d.useState(""),[a,l]=d.useState(!1),h=w=>{l(w.detail)};d.useEffect(()=>{const w=Ie(ue.UPLOAD_VIDEO(e.editor.id),h);return()=>{w()}},[]);const u=d.useMemo(()=>{var p;return(p=e.editor.extensionManager.extensions.find(g=>g.name===At.name))==null?void 0:p.options},[e.editor]);async function x(w){var M;const p=(M=w==null?void 0:w.target)==null?void 0:M.files;if(!e.editor||e.editor.isDestroyed||p.length===0)return;const g=p[0];let R="";u.upload?R=await u.upload(g):R=URL.createObjectURL(g),e.editor.chain().focus().setVideo({src:R,width:"100%"}).run(),l(!1)}function m(w){w.preventDefault(),w.stopPropagation(),n&&(e.editor.chain().focus().setVideo({src:n,width:"100%"}).run(),l(!1))}function f(w){var p;w.preventDefault(),(p=s.current)==null||p.click()}return r.jsxs(de,{onOpenChange:l,open:a,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>l(!0),icon:e.icon,tooltip:e.tooltip})}),r.jsxs(se,{children:[r.jsx(ce,{children:t("editor.video.dialog.title")}),r.jsxs(kr,{activationMode:"manual",defaultValue:(u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="upload"?"upload":"link",children:[r.jsxs(Tt,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[((u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="upload")&&r.jsx(Le,{value:"upload",children:t("editor.video.dialog.tab.upload")}),((u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="link")&&r.jsx(Le,{value:"link",children:t("editor.video.dialog.link")})]}),r.jsxs(Re,{value:"upload",children:[r.jsx("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:r.jsx(G,{className:"richtext-mt-1 richtext-w-full",onClick:f,size:"sm",children:t("editor.video.dialog.tab.upload")})}),r.jsx("input",{accept:"video/*",multiple:!0,onChange:x,ref:s,type:"file",style:{display:"none"}})]}),r.jsxs(Re,{value:"link",children:[r.jsx("form",{onSubmit:m,children:r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[r.jsx(K,{autoFocus:!0,placeholder:t("editor.video.dialog.placeholder"),required:!0,type:"url",value:n,onChange:w=>{const p=w.target.value;if(!Di(p)){c("Invalid video URL"),i("");return}c(""),i(p)}}),r.jsx(G,{type:"submit",children:t("editor.video.dialog.button.apply")})]})}),o&&r.jsx("div",{className:"richtext-my-[5px] richtext-text-red-500",children:o})]})]})]})]})}function Oi(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(/\?.*$/,"").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 At=A.Node.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,resourceVideo:"both",width:y.VIDEO_SIZE["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"},button:({editor:e,t})=>{var n,i;return{component:Hi,componentProps:{action:()=>{},isActive:()=>e.isActive("video")||!1,disabled:!((i=(n=e.can()).setVideo)!=null&&i.call(n,{})),icon:"Video",tooltip:t("editor.video.tooltip"),editor:e}}}}},addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?Oi(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??{},n={...e,width:"100%",height:"100%"},i=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`,s=`flex: 1;padding-bottom: ${9/16*100}%;`,a=["div",{style:i},["div",{style:s}],["iframe",n]];return["div",{...this.options.HTMLAttributes,"data-video":""},a]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}}}),Bi=/(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,$i=/CrOS/,Vi=/android|ipad|playbook|silk/i;function Zt(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:!!(Bi.test(t)&&!$i.test(t)||e.tablet&&Vi.test(t)||e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.includes("Macintosh")&&t.includes("Safari"))}const Xt=e=>Array.from({length:e}).map((t,n)=>n+1);function Fi(e){var u;const[t,n]=d.useState(!0),[i,s]=d.useState({rows:Zt()?y.TABLE_MAX_GRID_SIZE:y.TABLE_INIT_GRID_SIZE,cols:Zt()?y.TABLE_MAX_GRID_SIZE:y.TABLE_INIT_GRID_SIZE}),[o,c]=d.useState({rows:y.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:y.TABLE_DEFAULT_SELECTED_GRID_SIZE});function a(x,m){x===i.rows&&s(f=>({...f,rows:Math.min(x+1,y.TABLE_MAX_GRID_SIZE)})),m===i.cols&&s(f=>({...f,cols:Math.min(m+1,y.TABLE_MAX_GRID_SIZE)})),c({rows:x,cols:m})}function l(x,m){e==null||e.createTable({rows:x,cols:m,withHeaderRow:t}),h()}function h(){n(!1),s({rows:y.TABLE_INIT_GRID_SIZE,cols:y.TABLE_INIT_GRID_SIZE}),c({rows:y.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:y.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{asChild:!0,children:e==null?void 0:e.children}),r.jsx(le,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:r.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[r.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(u=Xt(i==null?void 0:i.rows))==null?void 0:u.map(x=>{var m;return r.jsx("div",{className:"richtext-flex richtext-gap-1",children:(m=Xt(i==null?void 0:i.cols))==null?void 0:m.map(f=>r.jsx("div",{onMouseDown:()=>l(x,f),onMouseOver:()=>a(x,f),className:`richtext-cursor-pointer richtext-border-border ${f<=o.cols&&x<=o.rows&&"tableCellActive !richtext-bg-foreground"}`,children:r.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`c-${f}`))},`r-${x}`)})}),r.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-zinc-600",children:[o.rows,"x",o.cols]})]})})]})}function Wi(e){function t(n){e.disabled||e.editor.chain().focus().insertTable({...n,withHeaderRow:!1}).run()}return r.jsx(Fi,{createTable:t,children:r.jsx(D,{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})})}function Et(e){return t=>{const n=S.TableMap.get(t.$anchorCell.node(-1)),i=t.$anchorCell.start(-1),s=n.cellsInRect(e),o=n.cellsInRect(n.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i));for(let c=0,a=s.length;c<a;c+=1)if(!o.includes(s[c]))return!1;return!0}}function It(e){return A.findParentNode(t=>t.type.spec.tableRole&&t.type.spec.tableRole==="table")(e)}function Lt(e){return e instanceof S.CellSelection}function Gi(e){return t=>{if(Lt(t)){const n=S.TableMap.get(t.$anchorCell.node(-1));return Et({left:e,right:e+1,top:0,bottom:n.height})(t)}return!1}}function qi(e){return t=>{if(Lt(t)){const n=S.TableMap.get(t.$anchorCell.node(-1));return Et({left:0,right:n.width,top:e,bottom:e+1})(t)}return!1}}function Gr(e){if(Lt(e)){const t=S.TableMap.get(e.$anchorCell.node(-1));return Et({left:0,right:t.width,top:0,bottom:t.height})(e)}return!1}function Ui(e){return t=>{const n=It(t);if(n){const i=S.TableMap.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,c)=>{if(c>=0&&c<=i.width-1){const a=i.cellsInRect({left:c,right:c+1,top:0,bottom:i.height});return o.concat(a.map(l=>{const h=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:h}}))}return o},[])}return null}}function Zi(e){return t=>{const n=It(t);if(n){const i=S.TableMap.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,c)=>{if(c>=0&&c<=i.height-1){const a=i.cellsInRect({left:0,right:i.width,top:c,bottom:c+1});return o.concat(a.map(l=>{const h=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:h}}))}return o},[])}return null}}function qr(e){return t=>n=>{const i=It(n.selection),s=e==="row";if(i){const o=S.TableMap.get(i.node);if(t>=0&&t<(s?o.height:o.width)){const c=s?0:t,a=s?t:0,l=s?o.width:t+1,h=s?t+1:o.height,u=o.cellsInRect({left:c,top:a,right:s?l:c+1,bottom:s?a+1:h}),x=h-a===1?u:o.cellsInRect({left:s?c:l-1,top:s?h-1:a,right:l,bottom:h}),m=i.start+u[0],f=i.start+x[x.length-1],w=n.doc.resolve(m),p=n.doc.resolve(f);return n.setSelection(new S.CellSelection(p,w))}}return n}}const Xi=qr("column"),Ki=qr("row");function Yi({editor:e,view:t,state:n,from:i}){const s=t.domAtPos(i).node,c=t.nodeDOM(i)||s;if(!e.isActive(Rt.name)||!c||Gr(n.selection))return!1;let a=c;for(;a&&!["TD","TH"].includes(a.tagName);)a=a.parentElement;return!!(a&&a.querySelector&&a.querySelector("a.grip-column.selected"))}function Ji({editor:e,view:t,state:n,from:i}){const s=t.domAtPos(i).node,c=t.nodeDOM(i)||s;if(!e.isActive(Rt.name)||!c||Gr(n.selection))return!1;let a=c;for(;a&&!["TD","TH"].includes(a.tagName);)a=a.parentElement;return!!(a&&a.querySelector&&a.querySelector("a.grip-row.selected"))}const Qi=A.Node.create({name:"tableCell",content:"block+",tableRole:"cell",isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",A.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 S.Plugin({props:{decorations:t=>{if(!e)return S.DecorationSet.empty;const{doc:n,selection:i}=t,s=[],o=Ui(0)(i);return o&&o.forEach(({pos:c},a)=>{s.push(S.Decoration.widget(c+1,()=>{const l=qi(a)(i);let h="grip-row";l&&(h+=" selected"),a===0&&(h+=" first"),a===o.length-1&&(h+=" last");const u=document.createElement("a");return u.className=h,u.addEventListener("mousedown",x=>{x.preventDefault(),x.stopImmediatePropagation(),this.editor.view.dispatch(Ki(a)(this.editor.state.tr))}),u}))}),S.DecorationSet.create(n,s)}}})]}});function eo(e,t,n){if(!e.doc)return e;const i=e.doc.nodeAt(t);if(!i||n===i.attrs.backgroundColor)return e;const s={...i.attrs,backgroundColor:n};return e.setNodeMarkup(t,i.type,s,i.marks)}function to(e,t,n){const{doc:i,selection:s}=e;return!i||!s||!(s instanceof S.CellSelection)||s.forEachCell((o,c)=>{e=eo(e,c,n)}),e}function Kt(e,t){return({tr:n,state:i,dispatch:s})=>{const{selection:o}=i;return n=n.setSelection(o),n=to(n,t,e),n.docChanged?(s==null||s(n),!0):!1}}const ro=A.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=>Kt(e,this.options),unsetTableCellBackground:()=>Kt("",this.options)}}}),no=A.TableHeader.extend({addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(i=>Number.parseInt(i,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:e}=this.editor;return[new S.Plugin({props:{decorations:t=>{if(!e)return S.DecorationSet.empty;const{doc:n,selection:i}=t,s=[],o=Zi(0)(i);return o&&o.forEach(({pos:c},a)=>{s.push(S.Decoration.widget(c+1,()=>{const l=Gi(a)(i);let h="grip-column";l&&(h+=" selected"),a===0&&(h+=" first"),a===o.length-1&&(h+=" last");const u=document.createElement("a");return u.className=h,u.addEventListener("mousedown",x=>{x.preventDefault(),x.stopImmediatePropagation(),this.editor.view.dispatch(Xi(a)(this.editor.state.tr))}),u}))}),S.DecorationSet.create(n,s)}}})]}}),io=A.TableRow.extend({allowGapCursor:!1,content:"tableCell*"}),Rt=A.Table.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),resizable:!0,lastColumnResizable:!1,allowTableNodeSelection:!1,button:({editor:t,t:n})=>({component:Wi,componentProps:{disabled:t.isActive("table")||!1,icon:"Table",tooltip:n("editor.table.tooltip"),editor:t}})}},addExtensions(){return[io.configure(this.options.tableRow),no.configure(this.options.tableHeader),Qi.configure(this.options.tableCell),ro.configure(this.options.tableCellBackground)]}}),oo="_wrap_5y04w_1",so="_innerWrap_5y04w_15",Yt={wrap:oo,innerWrap:so};function co({editor:e,node:t,updateAttributes:n}){const i=Cr(),{url:s,width:o,height:c}=t.attrs,[a,l]=d.useState("");function h(){a&&e.chain().updateAttributes(pe.name,{url:a}).setNodeSelection(e.state.selection.from).focus().run()}const u=d.useCallback(x=>{n({width:x.width,height:x.height})},[n]);return r.jsxs(A.NodeViewWrapper,{children:[!s&&r.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-[#ccc] richtext-p-[10px]",children:[r.jsx(K,{autoFocus:!0,className:"richtext-flex-1",onInput:x=>l(x.target.value),placeholder:"Enter link",type:"url",value:a}),r.jsx(G,{className:"richtext-w-[60px]",onClick:h,children:"OK"})]}),s&&r.jsx(xr.Resizable,{size:{width:Number.parseInt(o),height:Number.parseInt(c)},onResizeStop:(x,m,f,w)=>{u({width:Number.parseInt(o)+w.width,height:Number.parseInt(c)+w.height})},children:r.jsx("div",{className:S.clsx(Yt.wrap,"render-wrapper"),children:r.jsx("div",{className:Yt.innerWrap,style:{pointerEvents:i?"none":"auto"},children:r.jsx("iframe",{className:"richtext-my-[12px] ",src:s})})})})]})}function ao(e){try{return JSON.stringify(e)}catch{return JSON.stringify({})}}function be(e,t=!1){return n=>{const i=e.startsWith("data-")?e:`data-${e}`;let s=decodeURIComponent(n.getAttribute(i));if(s==null||typeof s=="string"&&s==="null")try{const a=n.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);a&&a.length>0&&(s=(a.map(h=>h.trim()).reduce((h,u)=>{const x=u.indexOf("="),m=[u.slice(0,x),u.slice(x+1).slice(1,-1)];return h[m[0]]=m[1],h},{})[e.toLowerCase()]||"").replaceAll("&quot;",'"'))}catch(c){console.error("Error getDatasetAttribute ",c.message,n)}if(t)try{return JSON.parse(s)}catch{return{}}if(s.includes("%")||s.includes("auto"))return s;const o=Number.parseInt(s);return o!==o?s:o}}function lo(e){const{attrs:t}=e;return Object.keys(t).reduce((n,i)=>{const s=t[i];if(s==null)return n;let o="";return typeof s=="object"?o=ao(s):o=s,n[i]=o,n},Object.create(null))}const pe=A.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:i})=>({component:D,componentProps:{action:s=>t.commands.setIframe(s),upload:n.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:i("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:be("width")},height:{default:300,parseHTML:be("height")},url:{default:null,parseHTML:be("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",A.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:n,chain:i})=>{var o,c,a;if(((a=(c=(o=t.selection)==null?void 0:o.node)==null?void 0:c.type)==null?void 0:a.name)==this.name)return n.updateAttributes(this.name,e);const s=e||{url:""};return i().insertContent({type:this.name,attrs:s}).run()}}},addInputRules(){return[A.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return A.ReactNodeViewRenderer(co)}}),De=V.forwardRef(({className:e,...t},n)=>r.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}));De.displayName="Textarea";function ho(e){return e}function Se(e,t,n,i){const s=ho,[o,c]=d.useState(s(n)),a=d.useRef(o);return d.useEffect(()=>{const l=()=>{const h={...n,...e.getAttributes(t)};Object.keys(h).forEach(x=>{(h[x]===null||h[x]===void 0)&&(h[x]=n?n[x]:null)});const u=s(h);S.deepEqual(a.current,u)||(c(u),a.current=u)};return e.on("selectionUpdate",l),e.on("transaction",l),()=>{e.off("selectionUpdate",l),e.off("transaction",l)}},[e,n,t,s]),o}function uo({editor:e,...t}){const{t:n}=y.useLocale(),i=Se(e,ve.name,{text:"",defaultShowPicker:!1}),{text:s,defaultShowPicker:o}=i,[c,a]=d.useState(""),l=d.useCallback(()=>{e.chain().focus().setKatex({text:c}).run(),a("")},[e,c]);d.useEffect(()=>{o&&e.chain().updateAttributes(ve.name,{defaultShowPicker:!1}).focus().run()},[e,o]);const h=d.useMemo(()=>{try{return vt.renderToString(`${c}`)}catch{return c}},[c]),u=d.useMemo(()=>`${c}`.trim()?r.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:h||""}}):null,[c,h]);return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{asChild:!0,children:r.jsx(D,{icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip})}),r.jsxs(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:[r.jsx(ie,{className:"richtext-mb-[6px]",children:n("editor.formula.dialog.text")}),r.jsx("div",{className:"richtext-mb-[16px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm",children:r.jsx(De,{autoFocus:!0,className:"richtext-w-full",defaultValue:s,onChange:x=>a(x.target.value),placeholder:"Text",required:!0,rows:3,value:c})})}),u&&r.jsx("div",{className:"richtext-my-[10px] richtext-max-w-[286px] richtext-overflow-auto richtext-whitespace-nowrap richtext-rounded-[6px] !richtext-border richtext-p-[10px]",children:u}),r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[r.jsx(G,{className:"richtext-flex-1",onClick:l,children:"Submit"}),r.jsx("a",{href:"https://katex.org/docs/supported",rel:"noreferrer noopener",target:"_blank",children:r.jsx(C.HelpCircle,{size:16})})]})]})]})}function xo(){const[e]=jr(t=>t.value);return e}const mo={setTheme:(e,t)=>{Qe(ue.UPDATE_THEME(e),t)}};function fo(e,t=1){let n=0,i=0,s=0;if(e.startsWith("rgb")){const o=e.replace(/\s/g,"").match(/rgb\((.*)\)$/)[1].split(",");n=+o[0],i=+o[1],s=+o[2]}else if(e.startsWith("#")){let o=e.replace("#","");o.length===3&&(o=`${o[0]}${o[0]}${o[1]}${o[1]}${o[2]}${o[2]}`),n=Number.parseInt(o.substring(0,2),16),i=Number.parseInt(o.substring(2,4),16),s=Number.parseInt(o.substring(4,6),16)}else return e;return t>1&&t<=100&&(t=t/100),`rgba(${n},${i},${s},${t})`}function go({node:e}){const t=xo(),{text:n}=e.attrs,i=d.useMemo(()=>{const c="rgb(254, 242, 237)";return t==="dark"?fo(c,.75):c},[t]),s=d.useMemo(()=>{try{return vt.renderToString(`${n}`)}catch{return n}},[n]),o=d.useMemo(()=>n.trim()?r.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:s}}):r.jsx("span",{contentEditable:!1,children:"Not enter a formula"}),[n,s]);return r.jsx(A.NodeViewWrapper,{style:{display:"inline-block",backgroundColor:i},as:"span",children:o})}function po(e){return t=>t.getAttribute(e)}const ve=A.Node.create({name:"katex",group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{class:"katex"},button:({editor:e,t})=>({component:uo,componentProps:{editor:e,action:()=>!0,isActive:()=>!1,disabled:!1,icon:"KatexIcon",tooltip:t("editor.katex.tooltip")}})}},addAttributes(){return{text:{default:"",parseHTML:po("text")},defaultShowPicker:{default:!1}}},parseHTML(){return[{tag:"span.katex"}]},renderHTML({HTMLAttributes:e}){return["span",A.mergeAttributes(this.options&&this.options.HTMLAttributes||{},e)]},addCommands(){return{setKatex:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[A.nodeInputRule({find:/^\$katex\$$/,type:this.type,getAttributes:()=>({defaultShowPicker:!0})})]},addNodeView(){return A.ReactNodeViewRenderer(go)}});let at;function _t(){try{return at||(at=y.mitt()),at}catch{throw new Error("Error EventEmitter")}}const mt="OPEN_EXCALIDRAW_SETTING_MODAL";function wo(e,t){_t().on(e,t)}function vo(e,t){_t().off(e,t)}function bo(e){_t().emit(mt,e)}const jo=({editor:e})=>{const[t,n]=d.useState(null),[i,s]=d.useState({}),[o,c]=d.useState({elements:[],appState:{isLoading:!1},files:null}),[a,l]=d.useState(!1),[h,u]=d.useState(!0),[x,m]=d.useState(null),f=d.useCallback(R=>{R&&import("@excalidraw/excalidraw").then(M=>{n(M.Excalidraw)}).catch(m).finally(()=>u(!1))},[u]),w=d.useCallback(R=>{setTimeout(()=>{R.refresh()})},[]),p=d.useCallback((R,M,v)=>{s({elements:R,appState:{isLoading:!1},files:v})},[]),g=d.useCallback(()=>{if(!t){l(!1);return}e.chain().focus().setExcalidraw({data:i}).run(),l(!1)},[t,e,i,l]);return d.useEffect(()=>{const R=M=>{l(!0),M&&c(M.data)};return wo(mt,R),()=>{vo(mt,R)}},[e,l]),r.jsxs(de,{onOpenChange:l,open:a,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>l(!0),icon:"Excalidraw",tooltip:"Excalidraw"})}),r.jsxs(se,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[r.jsx(ce,{children:"Excalidraw"}),r.jsxs("div",{style:{height:"100%",borderWidth:1},children:[h&&r.jsx("p",{children:"Loading..."}),x&&r.jsx("p",{children:x&&x.message||"Error"}),r.jsx("div",{ref:f,style:{width:"100%",height:600},children:!h&&!x&&t?r.jsx(t,{initialData:o,langCode:"en",onChange:p,ref:w}):null})]}),r.jsx(fe,{children:r.jsx(G,{onClick:g,type:"button",children:"Save changes"})})]})]})},Co="_wrap_15k3c_1",yo="_renderWrap_15k3c_7",To="_title_15k3c_14",So="_handlerWrap_15k3c_30",Ne={wrap:Co,renderWrap:yo,title:To,handlerWrap:So},No=10,Mo=200,Jt=15,Qt={width:"100%",height:"100%",maxWidth:"100%"};function ko({editor:e,node:t,updateAttributes:n}){const i=d.useRef(null),s=e.isActive(we.name),{data:o,width:c,height:a}=t.attrs,[l,h]=d.useState(null),[u,x]=d.useState(!0),[m,f]=d.useState(null),[w,p]=d.useState(!1),[g,R]=d.useState(100),M=d.useCallback(T=>{T&&p(!0)},[p]),v=d.useCallback(T=>()=>{R(E=>bt(T==="minus"?E-Jt:E+Jt,No,Mo))},[]);d.useEffect(()=>{let T=!1;return import("@excalidraw/excalidraw").then(E=>{T||(i.current=E.exportToSvg)}).catch(E=>!T&&f(E)).finally(()=>!T&&x(!1)),()=>{T=!0}},[x,o]),d.useEffect(()=>{let T=!1;return(async()=>{if(T||u||m||!w||!o)return;const L=await i.current(o);T||(L.setAttribute("width","100%"),L.setAttribute("height","100%"),L.setAttribute("display","block"),h(L))})(),()=>{T=!0}},[o,u,m,w]);const b=T=>{n({width:T.width,height:T.height})};return r.jsx(A.NodeViewWrapper,{className:S.clsx(Ne.wrap,s&&Ne.isActive),children:r.jsx(S.VisibilitySensor,{onChange:M,children:r.jsx(xr.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(a)},onResizeStop:(T,E,L,N)=>{b({width:Number.parseInt(c)+N.width,height:Number.parseInt(a)+N.height})},children:r.jsxs("div",{className:S.clsx(Ne.renderWrap,"render-wrapper"),style:{...Qt,overflow:"hidden"},children:[m&&r.jsx("div",{style:Qt,children:r.jsx("p",{children:m.message||m})}),u&&r.jsx("p",{children:"Loading..."}),!u&&!m&&w&&r.jsx("div",{dangerouslySetInnerHTML:{__html:(l==null?void 0:l.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${g/100})`,transition:"all ease-in-out .3s"}}),r.jsx("div",{className:Ne.title}),r.jsxs("div",{className:Ne.handlerWrap,children:[r.jsx(D,{action:v("minus"),icon:"ZoomOut",tooltip:"Zoom Out"}),r.jsx(D,{action:v("plus"),icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})})}const Ao=d.memo(ko,(e,t)=>!!S.deepEqual(e.node.attrs,t.node.attrs)),er={elements:[]},we=A.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:be("width")},height:{default:240,parseHTML:be("height")},data:{default:er,parseHTML:be("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:t})=>({component:jo,componentProps:{editor:t}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:t}){return["div",A.mergeAttributes(this.options.HTMLAttributes,e,lo(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:n,chain:i})=>{var s,o,c;return e=e||{},e.data=e.data||er,((c=(o=(s=t.selection)==null?void 0:s.node)==null?void 0:o.type)==null?void 0:c.name)==this.name?n.updateAttributes(this.name,e):i().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return A.ReactNodeViewRenderer(Ao)},addInputRules(){return[A.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});function Eo({selectImage:e,giphyApiKey:t,children:n}){const[i,s]=d.useState([]),[o]=d.useState(15),c=d.useRef(null),a=(h,u="search")=>{if(!t)return;const m=`${u==="search"?`https://api.giphy.com/v1/gifs/search?q=${h}`:`https://api.giphy.com/v1/gifs/trending?q=${h}`}&limit=${o}&api_key=${t}`;fetch(m).then(f=>f.json()).then(f=>{s(f.data)}).catch(f=>{console.log(f)})};d.useEffect(()=>{a("","trend")},[]);const l=d.useCallback(S.debounce(h=>{if(!h.target.value){a("","trend");return}a(h.target.value)},350),[]);return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{asChild:!0,children:n}),r.jsx(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:r.jsx(K,{onChange:l,placeholder:"Search GIF",ref:c,type:"text"})}),r.jsx("div",{className:"richtext-max-h-[280px] richtext-overflow-y-auto",children:r.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1 ",children:i!=null&&i.length?i==null?void 0:i.map(h=>r.jsx("img",{alt:"giphy",className:"richtext-cursor-pointer richtext-text-center",height:h.images.fixed_width_downsampled.height,onClick:()=>e(h),src:h.images.fixed_width_downsampled.url,width:h.images.fixed_width_downsampled.width},`giphy-${h.id}`)):r.jsx("p",{children:"No GIFs found"})})})]}):r.jsx("div",{children:r.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Io({editor:e,icon:t,giphyApiKey:n,...i}){const s=o=>{const{url:c}=o.images.original;e.chain().focus().setImageGif({src:c}).run()};return r.jsx(Eo,{giphyApiKey:n,selectImage:s,children:r.jsx(D,{icon:t,tooltip:i==null?void 0:i.tooltip})})}const Fe={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Lo(e){var E,L;const[t,n]=d.useState({width:y.IMAGE_MAX_SIZE,height:y.IMAGE_MAX_SIZE}),[i,s]=d.useState({width:0,height:0}),[o]=d.useState([Fe.TOP_LEFT,Fe.TOP_RIGHT,Fe.BOTTOM_LEFT,Fe.BOTTOM_RIGHT]),[c,a]=d.useState(!1),[l,h]=d.useState({x:0,y:0,w:0,h:0,dir:""}),{align:u}=(E=e==null?void 0:e.node)==null?void 0:E.attrs,x=d.useMemo(()=>{var H;const{src:N,alt:_,width:j,height:k}=(H=e==null?void 0:e.node)==null?void 0:H.attrs,B=S.isNumber(j)?`${j}px`:j,O=S.isNumber(k)?`${k}px`:k;return{src:N||void 0,alt:_||void 0,style:{width:B||void 0,height:O||void 0}}},[(L=e==null?void 0:e.node)==null?void 0:L.attrs]),m=d.useMemo(()=>{const{style:{width:N}}=x;return{width:N==="100%"?N:void 0}},[x]);function f(N){s({width:N.target.width,height:N.target.height})}function w(){const{editor:N,getPos:_}=e;N.commands.setNodeSelection(_())}const p=d.useCallback(S.throttle(()=>{const{editor:N}=e,{width:_}=getComputedStyle(N.view.dom);n(j=>({...j,width:Number.parseInt(_,10)}))},y.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function g(N,_){N.preventDefault(),N.stopPropagation();const j=i.width,k=i.height,B=j/k;let O=Number(e.node.attrs.width),H=Number(e.node.attrs.height);const I=t.width;O&&!H?(O=O>I?I:O,H=Math.round(O/B)):H&&!O?(O=Math.round(H*B),O=O>I?I:O):!O&&!H?(O=j>I?I:j,H=Math.round(O/B)):O=O>I?I:O,a(!0),h({x:N.clientX,y:N.clientY,w:O,h:H,dir:_})}const R=d.useCallback(S.throttle(N=>{if(N.preventDefault(),N.stopPropagation(),!c)return;const{x:_,w:j,dir:k}=l,B=(N.clientX-_)*(/l/.test(k)?-1:1),O=S.clamp(j+B,y.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:O,height:null})},y.IMAGE_THROTTLE_WAIT_TIME),[c,l,t,e.updateAttributes]),M=d.useCallback(N=>{N.preventDefault(),N.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),a(!1),w())},[c,w]),v=d.useCallback(()=>{document==null||document.addEventListener("mousemove",R,!0),document==null||document.addEventListener("mouseup",M,!0)},[R,M]),b=d.useCallback(()=>{document==null||document.removeEventListener("mousemove",R,!0),document==null||document.removeEventListener("mouseup",M,!0)},[R,M]);d.useEffect(()=>(c?v():b(),()=>{b()}),[c,v,b]);const T=d.useMemo(()=>new ResizeObserver(()=>p()),[p]);return d.useEffect(()=>(T.observe(e.editor.view.dom),()=>{T.disconnect()}),[e.editor.view.dom,T]),r.jsx(A.NodeViewWrapper,{className:"image-view",style:{...m,width:"100%",textAlign:u},children:r.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:m,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[r.jsx("img",{alt:x.alt,className:"image-view__body__image block",height:"auto",onClick:w,onLoad:f,src:x.src,style:x.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||c)&&r.jsx("div",{className:"image-resizer",children:o==null?void 0:o.map(N=>r.jsx("span",{className:`image-resizer__handler image-resizer__handler--${N}`,onMouseDown:_=>g(_,N)},`image-dir-${N}`))})]})})}const Pt=A.Image.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",GIPHY_API_KEY:"",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:n,t:i})=>{var o;const s=((o=n==null?void 0:n.options)==null?void 0:o.GIPHY_API_KEY)||"";return{component:Io,componentProps:{editor:t,action:()=>{},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:i("editor.imageGif.tooltip"),giphyApiKey:s}}}}},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")||"10";return n===void 0?null:Number.parseInt(`${n}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return A.ReactNodeViewRenderer(Lo)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:n})=>n.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",A.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});function tt(e=8){return Math.random().toString(36).substring(2,e+2)}const tr=`graph TB
2
- a-->b`,Ro=({editor:e,upload:t})=>{const[n,i]=d.useState(tr),[s,o]=d.useState(""),[c,a]=d.useState(!1),l=d.useRef(null),h=async m=>{try{const{svg:f}=await Xe.render("mermaid-svg",m);o(f)}catch{o("")}},u=()=>{Xe.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),h(n)};d.useEffect(()=>{c&&u()},[c]),d.useEffect(()=>{c&&h(n)},[n]);const x=async()=>{if(n!==""){if(n){const m=l.current.querySelector("svg"),{width:f,height:w}=m.getBoundingClientRect(),p=`mermaid-${tt()}.svg`;let g=S.i(m.outerHTML);if(t){const R=ze(g,p);g=await t(R)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:g,alt:encodeURIComponent(n),width:f,height:w},!!n).run()}a(!1)}};return r.jsxs(de,{onOpenChange:a,open:c,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>a(!0),icon:"Mermaid",tooltip:"Mermaid"})}),r.jsxs(se,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[r.jsx(ce,{children:"Mermaid"}),r.jsx("div",{style:{height:"100%",borderWidth:1},children:r.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[r.jsx(De,{autoFocus:!0,className:"richtext-flex-1",defaultValue:tr,onChange:m=>i(m.target.value),placeholder:"Text",required:!0,rows:10,value:n,style:{color:"hsl(var(--richtext-foreground))"}}),r.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:s},ref:l,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),r.jsx(fe,{children:r.jsx(G,{onClick:x,type:"button",children:"Save changes"})})]})]})},We={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function _o({editor:e,node:t,updateAttributes:n,getPos:i,selected:s}){const[o,c]=d.useState({width:y.IMAGE_MAX_SIZE,height:y.IMAGE_MAX_SIZE}),[a,l]=d.useState({width:0,height:0}),[h]=d.useState([We.TOP_LEFT,We.TOP_RIGHT,We.BOTTOM_LEFT,We.BOTTOM_RIGHT]),[u,x]=d.useState(!1),[m,f]=d.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t==null?void 0:t.attrs,p=d.useMemo(()=>{const{src:j,alt:k,width:B,height:O}=t==null?void 0:t.attrs,H=A.isNumber(B)?`${B}px`:B,I=A.isNumber(O)?`${O}px`:O;return{src:j||void 0,alt:k||void 0,style:{width:H||void 0,height:I||void 0}}},[t==null?void 0:t.attrs]),g=d.useMemo(()=>{const{style:{width:j}}=p;return{width:j==="100%"?j:void 0}},[p]);function R(j){l({width:j.target.width,height:j.target.height})}function M(){e.commands.setNodeSelection(i())}const v=d.useCallback(S.throttle(()=>{const{width:j}=getComputedStyle(e.view.dom);c(k=>({...k,width:Number.parseInt(j,10)}))},y.IMAGE_THROTTLE_WAIT_TIME),[e]);function b(j,k){j.preventDefault(),j.stopPropagation();const B=a.width,O=a.height,H=B/O;let I=Number(t.attrs.width),$=Number(t.attrs.height);const F=o.width;I&&!$?(I=I>F?F:I,$=Math.round(I/H)):$&&!I?(I=Math.round($*H),I=I>F?F:I):!I&&!$?(I=B>F?F:B,$=Math.round(I/H)):I=I>F?F:I,x(!0),f({x:j.clientX,y:j.clientY,w:I,h:$,dir:k})}const T=d.useCallback(S.throttle(j=>{if(j.preventDefault(),j.stopPropagation(),!u)return;const{x:k,w:B,dir:O}=m,H=(j.clientX-k)*(/l/.test(O)?-1:1),{width:I,height:$}=t==null?void 0:t.attrs,F=I/$,X=bt(B+H,y.IMAGE_MIN_SIZE,o.width),ae=Math.round(X/F);n({width:X,height:ae})},y.IMAGE_THROTTLE_WAIT_TIME),[u,m,o,n,t==null?void 0:t.attrs]),E=d.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u&&(f({x:0,y:0,w:0,h:0,dir:""}),x(!1),M())},[u,M]),L=d.useCallback(()=>{document==null||document.addEventListener("mousemove",T,!0),document==null||document.addEventListener("mouseup",E,!0)},[T,E]),N=d.useCallback(()=>{document==null||document.removeEventListener("mousemove",T,!0),document==null||document.removeEventListener("mouseup",E,!0)},[T,E]);d.useEffect(()=>(u?L():N(),()=>{N()}),[u,L,N]);const _=d.useMemo(()=>new ResizeObserver(()=>v()),[v]);return d.useEffect(()=>(_.observe(e.view.dom),()=>{_.disconnect()}),[e.view.dom,_]),r.jsx(A.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%",textAlign:w},children:r.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...g,background:"#fff"},className:`image-view__body ${s?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[r.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:M,onLoad:R,src:p.src,style:p.style}),e.view.editable&&(s||u)&&r.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(j=>r.jsx("span",{className:`image-resizer__handler image-resizer__handler--${j}`,onMouseDown:k=>b(k,j)},`image-dir-${j}`))})]})})}const ft=A.Image.extend({name:"mermaid",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:t,t:n,extension:i})=>{var s;return{component:Ro,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:t,icon:"Mermaid",tooltip:n("editor.mermaid.tooltip"),upload:(s=i==null?void 0:i.options)==null?void 0:s.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const n=t.querySelector("img"),i=n==null?void 0:n.getAttribute("width");return i?Number.parseInt(i,10):320},renderHTML:t=>({width:t.width})},height:{default:null,parseHTML:t=>{const n=t.querySelector("img"),i=n==null?void 0:n.getAttribute("height");return i?Number.parseInt(i,10):212},renderHTML:t=>({height:t.height})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return A.ReactNodeViewRenderer(_o)},addCommands(){return{setMermaid:(e,t)=>({commands:n,editor:i})=>t?n.insertContent({type:this.name,attrs:e}):n.insertContentAt(i.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageMermaid:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageMermaid"},["img",A.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),i=t==null?void 0:t.getAttribute("height");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),width:n?Number.parseInt(n,10):null,height:i?Number.parseInt(i,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});function Po({node:e}){var i;const t=((i=e==null?void 0:e.attrs)==null?void 0:i.src)||"",n=t==null?void 0:t.split("/").pop();return n?r.jsx(A.NodeViewWrapper,{children:r.jsx("div",{"data-twitter":"",children:r.jsx(S.Tweet,{id:n})})}):null}function Ur(e){const{t}=y.useLocale(),[n,i]=d.useState("");d.useEffect(()=>{var o;if(e!=null&&e.editor){const{src:c}=(o=e.editor)==null?void 0:o.getAttributes(Ye.name);c&&i(c)}},[e==null?void 0:e.editor]);function s(o){o.preventDefault(),o.stopPropagation(),e==null||e.onSetLink(n)}return r.jsx("div",{className:"border-neutral-200 richtext-rounded-lg !richtext-border richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:r.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:s,children:[r.jsx(ie,{className:"mb-[6px]",children:t("editor.link.dialog.text")}),r.jsx("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:r.jsx(K,{className:"richtext-w-80",onChange:o=>i(o.target.value),placeholder:"Text",required:!0,type:"text",value:n})})}),r.jsx(G,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:t("editor.link.dialog.button.apply")})]})})}function zo(e){function t(n){e.action&&e.action(n)}return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{disabled:e==null?void 0:e.disabled,asChild:!0,children:r.jsx(D,{tooltip:e==null?void 0:e.tooltip,isActive:e==null?void 0:e.isActive,disabled:e==null?void 0:e.disabled,children:r.jsx(U,{name:e==null?void 0:e.icon})})}),r.jsx(le,{hideWhenDetached:!0,className:"richtext-w-full",align:"start",side:"bottom",children:r.jsx(Ur,{editor:e.editor,onSetLink:t})})]})}const Do=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,Ho=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function rr(e){return e.match(Ho)}const Ye=A.Node.create({name:"twitter",draggable:!0,selectable:!0,addOptions(){return{addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:e,t})=>({component:zo,componentProps:{action:n=>{e.commands.setTweet({src:n})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:t("editor.twitter.tooltip"),editor:e}})}},addNodeView(){return A.ReactNodeViewRenderer(Po,{attrs:this.options.HTMLAttributes})},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes(){return{src:{default:null}}},parseHTML(){return[{tag:"div[data-twitter]"}]},addCommands(){return{setTweet:e=>({commands:t})=>rr(e.src)?t.insertContent({type:this.name,attrs:e}):!1,updateTweet:e=>({commands:t})=>rr(e.src)?t.updateAttributes(this.name,{src:e.src}):!1}},addPasteRules(){return this.options.addPasteHandler?[A.nodePasteRule({find:Do,type:this.type,getAttributes:e=>({src:e.input})})]:[]},renderHTML({HTMLAttributes:e}){return["div",A.mergeAttributes({"data-twitter":""},e)]}}),Oo="_wrapper_rraz2_1",Bo="_tool_rraz2_17",$o="_active_rraz2_37",Vo="_pen_rraz2_41",Fo="_line_rraz2_48",Wo="_options_rraz2_56",Go="_colorWrap_rraz2_66",qo="_color_rraz2_66",Uo="_colorActive_rraz2_83",z={wrapper:Oo,tool:Bo,active:$o,pen:Vo,line:Fo,options:Wo,colorWrap:Go,color:qo,colorActive:Uo};function Zo(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function Xo(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function Ko(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function Yo(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function Jo(e){return r.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[r.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),r.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function Qo(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function es(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function ts(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function rs(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function ns(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function is(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),r.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function os(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function ss(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function cs(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function as(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function ls(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function ds(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function hs(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function us(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function xs(e){return r.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const ms=[W.Color4.blackHighlight,W.Color4.ofRGBA(166/255,81/255,167/255,.3),W.Color4.ofRGBA(247/255,78/255,158/255,.3),W.Color4.ofRGBA(166/255,83/255,88/255,.3),W.Color4.ofRGBA(246/255,130/255,28/255,.3),W.Color4.ofRGBA(166/255,198/255,0,.3),W.Color4.ofRGBA(98/255,186/255,70/255,.3)],nr=[W.Color4.black,W.Color4.fromHex("#007AFF"),W.Color4.fromHex("#A651A7"),W.Color4.fromHex("#F74E9E"),W.Color4.fromHex("#FF5358"),W.Color4.fromHex("#F6821C"),W.Color4.fromHex("#FFC600"),W.Color4.fromHex("#62BA46"),W.Color4.fromHex("#E6BFE8"),W.Color4.fromHex("#FEA3D2"),W.Color4.fromHex("#FFA0A3"),W.Color4.fromHex("#FBC276"),W.Color4.fromHex("#FFFB85"),W.Color4.fromHex("#AADC99")];function fs({onChange:e}){const[t,n]=d.useState(W.Color4.blackHighlight);return r.jsx("div",{className:z.colorWrap,children:ms.map((i,s)=>r.jsx("button",{style:{backgroundColor:i.toHexString()},className:P(z.color,{[z.colorActive]:t.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},s))})}function gt({onChange:e}){const[t,n]=d.useState(W.Color4.black);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:z.colorWrap,children:nr.slice(0,7).map((i,s)=>r.jsx("button",{style:{backgroundColor:i.toHexString()},className:P(z.color,{[z.colorActive]:t.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},s))}),r.jsx("div",{className:z.colorWrap,children:nr.slice(7).map((i,s)=>r.jsx("button",{style:{backgroundColor:i.toHexString()},className:P(z.color,{[z.colorActive]:t.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},s))})]})}function gs({setColorPen:e,setThicknessPen:t}){const[n,i]=d.useState(2);return r.jsxs("div",{className:z.options,children:[r.jsx("div",{children:r.jsx(gt,{onChange:s=>e(s)})}),r.jsx("div",{className:z.line}),r.jsx("div",{children:r.jsx("input",{max:10,min:1,step:.1,type:"range",value:n,onChange:s=>{t(Number.parseFloat(s.target.value)),i(Number.parseFloat(s.target.value))}})})]})}function ps({setColorHighlight:e}){return r.jsx("div",{className:z.options,children:r.jsx(fs,{onChange:t=>e(t)})})}function ws({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:n}){return r.jsxs("div",{className:z.options,children:[r.jsx("div",{children:r.jsx(gt,{onChange:i=>e(i)})}),r.jsx("div",{className:z.line}),r.jsx("div",{children:r.jsx(gt,{onChange:i=>t(i)})}),r.jsx("div",{className:z.line}),r.jsx("div",{children:r.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:i=>{n(Number.parseFloat(i.target.value))}})})]})}function Zr(e){const{setColorPen:t,refEditor:n,setThicknessPen:i,setColorHighlight:s,changeBorderColorShape:o,onUndo:c,changeColorShape:a,changeShape:l,onThicknessChange:h,onRedo:u,onClear:x}=e,[m,f]=d.useState(null),[w,p]=d.useState(0);return r.jsx(r.Fragment,{children:r.jsxs("div",{className:z.wrapper,children:[r.jsxs("div",{className:z.pen,children:[r.jsx("button",{className:P(z.tool,{[z.active]:m==="select"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="select"){f(null),g[0].setEnabled(!1);return}f("select"),g[0].setEnabled(!0)},children:r.jsx(Zo,{})}),r.jsx("div",{className:z.line}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="text"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(n.current.toolController.setToolEnabled(g[1]),m==="text"){g[1].setEnabled(!1),f(null);return}f("text"),g[1].setEnabled(!0)},children:r.jsx(Xo,{})}),r.jsx("div",{className:z.line}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="pencil"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="pencil"){f(null),g[2].setEnabled(!1);return}f("pencil"),g[2].setEnabled(!0)},children:r.jsx(Ko,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="highlighter"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="highlighter"){f(null),g[3].setEnabled(!1);return}f("highlighter"),g[3].setEnabled(!0)},children:r.jsx(Yo,{})}),r.jsx("div",{className:z.line}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="eraser"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="eraser"){f(null),g[4].setEnabled(!1);return}f("eraser"),g[4].setEnabled(!0)},children:r.jsx(Jo,{})}),r.jsx("div",{className:z.line}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===0}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(0),p(0)},children:r.jsx(Qo,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===1}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(1),p(1)},children:r.jsx(es,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===2}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(2),p(2)},children:r.jsx(ts,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===3}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(3),p(3)},children:r.jsx(rs,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===4}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(4),p(4)},children:r.jsx(ns,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===5}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(5),p(5)},children:r.jsx(is,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===6}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(6),p(6)},children:r.jsx(os,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===7}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(7),p(7)},children:r.jsx(ls,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===8}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(8),p(8)},children:r.jsx(ds,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===9}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(9),p(9)},children:r.jsx(hs,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===10}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(10),p(10)},children:r.jsx(us,{})}),r.jsx("button",{className:P(z.tool,{[z.active]:m==="shapes"&&w===11}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(11),p(11)},children:r.jsx(xs,{})}),r.jsx("div",{className:z.line}),r.jsx("button",{className:P(z.tool),onClick:c,children:r.jsx(ss,{})}),r.jsx("button",{className:P(z.tool),onClick:u,children:r.jsx(cs,{})}),r.jsx("button",{className:P(z.tool),onClick:x,children:r.jsx(as,{})})]}),r.jsxs("div",{className:z.optionsWrap,children:[m==="pencil"&&r.jsx(gs,{setColorPen:t,setThicknessPen:i}),m==="highlighter"&&r.jsx(ps,{setColorHighlight:s}),m==="shapes"&&r.jsx(ws,{changeBorderColorShape:o,changeColorShape:a,changeShape:l,onThicknessChange:h})]})]})})}let Me=!1;const vs=({editor:e,upload:t})=>{const[n,i]=d.useState(!1),s=d.useRef(null),o=d.useRef(null),c=()=>{(async()=>{const v=document.querySelector("#easydrawer");v&&(s.current=new W.Editor(v,{wheelEventsEnabled:!1,disableZoom:!0}),o.current=W.makeDropdownToolbar(s.current),o.current.addDefaultToolWidgets())})()};d.useEffect(()=>{n&&setTimeout(()=>{c()},200)},[n]);const a=async()=>{if(s.current){const M=s.current.toSVG(),v=M.outerHTML,b=`drawer-${tt()}.svg`;let T=S.i(M.outerHTML);if(t){const E=ze(T,b);T=await t(E)}e==null||e.chain().focus().setDrawer({type:"drawer",src:T,alt:encodeURIComponent(v),width:426,height:212},!!v).run()}i(!1)},l=M=>{const v=s.current.toolController.getPrimaryTools()[2],b=o.current.getWidgetById("pen-1");v&&b&&(v.setColor(M),b.serializeState())},h=M=>{const v=s.current.toolController.getPrimaryTools()[2],b=o.current.getWidgetById("pen-1");v&&b&&(v.setThickness(M),b.serializeState())},u=M=>{const v=s.current.toolController.getPrimaryTools()[3],b=o.current.getWidgetById("pen-2");v&&b&&(v.setColor(M),b.serializeState())},x=M=>{const v=o.current.getWidgetById("shape");v&&v.setShapeType(M)},m=M=>{const v=s.current.toolController.getPrimaryTools()[5],b=o.current.getWidgetById("shape");v&&b&&(v.setColor(M),b.serializeState())},f=M=>{const v=s.current.toolController.getPrimaryTools()[5],b=o.current.getWidgetById("shape");v&&b&&(v.setThickness(M),b.serializeState())},w=M=>{const v=s.current.toolController.getPrimaryTools()[5],b=o.current.getWidgetById("shape");v&&b&&(v.setBorderColor(M),b.serializeState())},p=()=>{if(Me){for(;s.current.history.redoStackSize>0;)s.current.history.redo();Me=!1;return}s.current.history.undo()},g=()=>{Me||s.current.history.redo()},R=()=>{if(!Me){for(;s.current.history.undoStackSize>0;)p();Me=!0}};return r.jsxs(de,{onOpenChange:i,open:n,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>i(!0),icon:"PencilRuler",tooltip:"Drawer"})}),r.jsxs(se,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[r.jsx(ce,{children:"Drawer"}),r.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[r.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),r.jsx(Zr,{changeBorderColorShape:w,changeColorShape:m,changeShape:x,onClear:R,onRedo:g,onThicknessChange:f,onUndo:p,refEditor:s,setColorHighlight:u,setColorPen:l,setThicknessPen:h})]}),r.jsx(fe,{children:r.jsx(G,{onClick:a,type:"button",children:"Save changes"})})]})]})},Ge={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function bs({editor:e,node:t,updateAttributes:n,getPos:i,selected:s}){const[o,c]=d.useState({width:y.IMAGE_MAX_SIZE,height:y.IMAGE_MAX_SIZE}),[a,l]=d.useState({width:0,height:0}),[h]=d.useState([Ge.TOP_LEFT,Ge.TOP_RIGHT,Ge.BOTTOM_LEFT,Ge.BOTTOM_RIGHT]),[u,x]=d.useState(!1),[m,f]=d.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t==null?void 0:t.attrs,p=d.useMemo(()=>{const{src:j,alt:k,width:B,height:O}=t==null?void 0:t.attrs,H=A.isNumber(B)?`${B}px`:B,I=A.isNumber(O)?`${O}px`:O;return{src:j||void 0,alt:k||void 0,style:{width:H||void 0,height:I||void 0}}},[t==null?void 0:t.attrs]),g=d.useMemo(()=>{const{style:{width:j}}=p;return{width:j==="100%"?j:void 0}},[p]);function R(j){l({width:j.target.width,height:j.target.height})}function M(){e.commands.setNodeSelection(i())}const v=d.useCallback(S.throttle(()=>{const{width:j}=getComputedStyle(e.view.dom);c(k=>({...k,width:Number.parseInt(j,10)}))},y.IMAGE_THROTTLE_WAIT_TIME),[e]);function b(j,k){j.preventDefault(),j.stopPropagation();const B=a.width,O=a.height,H=B/O;let I=Number(t.attrs.width),$=Number(t.attrs.height);const F=o.width;I&&!$?(I=I>F?F:I,$=Math.round(I/H)):$&&!I?(I=Math.round($*H),I=I>F?F:I):!I&&!$?(I=B>F?F:B,$=Math.round(I/H)):I=I>F?F:I,x(!0),f({x:j.clientX,y:j.clientY,w:I,h:$,dir:k})}const T=d.useCallback(S.throttle(j=>{if(j.preventDefault(),j.stopPropagation(),!u)return;const{x:k,w:B,dir:O}=m,H=(j.clientX-k)*(/l/.test(O)?-1:1),{width:I,height:$}=t==null?void 0:t.attrs,F=I/$,X=bt(B+H,y.IMAGE_MIN_SIZE,o.width),ae=Math.round(X/F);n({width:X,height:ae})},y.IMAGE_THROTTLE_WAIT_TIME),[u,m,o,n,t==null?void 0:t.attrs]),E=d.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u&&(f({x:0,y:0,w:0,h:0,dir:""}),x(!1),M())},[u,M]),L=d.useCallback(()=>{document==null||document.addEventListener("mousemove",T,!0),document==null||document.addEventListener("mouseup",E,!0)},[T,E]),N=d.useCallback(()=>{document==null||document.removeEventListener("mousemove",T,!0),document==null||document.removeEventListener("mouseup",E,!0)},[T,E]);d.useEffect(()=>(u?L():N(),()=>{N()}),[u,L,N]);const _=d.useMemo(()=>new ResizeObserver(()=>v()),[v]);return d.useEffect(()=>(_.observe(e.view.dom),()=>{_.disconnect()}),[e.view.dom,_]),r.jsx(A.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%",textAlign:w},children:r.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...g,background:"#fff"},className:`image-view__body ${s?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[r.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:M,onLoad:R,src:p.src,style:p.style}),e.view.editable&&(s||u)&&r.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(j=>r.jsx("span",{className:`image-resizer__handler image-resizer__handler--${j}`,onMouseDown:k=>b(k,j)},`image-dir-${j}`))})]})})}const pt=A.Image.extend({name:"drawer",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({editor:t,t:n,extension:i})=>{var s;return{component:vs,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:t,icon:"PencilRuler",tooltip:n("editor.drawer.tooltip"),upload:(s=i==null?void 0:i.options)==null?void 0:s.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const n=t.querySelector("img"),i=n==null?void 0:n.getAttribute("width");return i?Number.parseInt(i,10):320},renderHTML:t=>({width:t.width})},height:{default:null,parseHTML:t=>{const n=t.querySelector("img"),i=n==null?void 0:n.getAttribute("height");return i?Number.parseInt(i,10):212},renderHTML:t=>({height:t.height})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return A.ReactNodeViewRenderer(bs)},addCommands(){return{setDrawer:(e,t)=>({commands:n,editor:i})=>t?n.insertContent({type:this.name,attrs:e}):n.insertContentAt(i.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageDrawer"},["img",A.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),i=t==null?void 0:t.getAttribute("height");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),width:n?Number.parseInt(n,10):null,height:i?Number.parseInt(i,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});let ke=!1;function js({editor:e,attrs:t,extension:n}){const[i,s]=d.useState(!1),o=d.useRef(null),c=d.useRef(null),{alt:a,align:l}=t,h=n==null?void 0:n.options.upload,u=()=>{(async()=>{const L=document.querySelector("#easydrawer");L&&(o.current=new W.Editor(L,{wheelEventsEnabled:!1,disableZoom:!0}),c.current=W.makeDropdownToolbar(o.current),c.current.addDefaultToolWidgets(),o.current.loadFromSVG(decodeURIComponent(a)))})()};d.useEffect(()=>{i&&setTimeout(()=>{u()},200)},[i]);const x=async()=>{if(o.current){const E=o.current.toSVG(),L=E.outerHTML,N=`drawer-${tt()}.svg`;let _=S.i(E.outerHTML);if(h){const j=ze(_,N);_=await h(j)}e==null||e.chain().focus().setDrawer({type:"drawer",src:_,alt:encodeURIComponent(L),width:426,height:212},!!L).run(),e==null||e.commands.setAlignImageDrawer(l)}s(!1)},m=E=>{const L=o.current.toolController.getPrimaryTools()[2],N=c.current.getWidgetById("pen-1");L&&N&&(L.setColor(E),N.serializeState())},f=E=>{const L=o.current.toolController.getPrimaryTools()[2],N=c.current.getWidgetById("pen-1");L&&N&&(L.setThickness(E),N.serializeState())},w=E=>{const L=o.current.toolController.getPrimaryTools()[3],N=c.current.getWidgetById("pen-2");L&&N&&(L.setColor(E),N.serializeState())},p=E=>{const L=c.current.getWidgetById("shape");L&&L.setShapeType(E)},g=E=>{const L=o.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");L&&N&&(L.setColor(E),N.serializeState())},R=E=>{const L=o.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");L&&N&&(L.setThickness(E),N.serializeState())},M=E=>{const L=o.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");L&&N&&(L.setBorderColor(E),N.serializeState())},v=()=>{if(ke){for(;o.current.history.redoStackSize>0;)o.current.history.redo();ke=!1;return}o.current.history.undo()},b=()=>{ke||o.current.history.redo()},T=()=>{if(!ke){for(;o.current.history.undoStackSize>0;)v();ke=!0}};return r.jsxs(de,{onOpenChange:s,open:i,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>s(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),r.jsxs(se,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[r.jsx(ce,{children:"Edit Drawer"}),r.jsxs("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[r.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),r.jsx(Zr,{changeBorderColorShape:M,changeColorShape:g,changeShape:p,onClear:T,onRedo:b,onThicknessChange:R,onUndo:v,refEditor:o,setColorHighlight:w,setColorPen:m,setThicknessPen:f})]}),r.jsx(fe,{children:r.jsx(G,{onClick:x,type:"button",children:"Save changes"})})]})]})}function Xr(e,t){const[n,i]=d.useState(void 0);return d.useEffect(()=>{const s=()=>{const o=e.extensionManager.extensions.find(c=>c.name===t);o&&i(o)};return e.on("selectionUpdate",s),e.on("transaction",s),()=>{e.off("selectionUpdate",s),e.off("transaction",s)}},[e,t]),n}const Cs={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function ys({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?r.jsx(d.Fragment,{children:e.type==="divider"?r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):r.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):r.jsx(r.Fragment,{})}function Ts(e){return e.type.name==="drawer"}function Ss(e){const{lang:t}=y.useLocale(),n=Se(e.editor,pt.name),i=Xr(e.editor,pt.name),s=({editor:c})=>{const{selection:a}=c.view.state,{$from:l,to:h}=a;let u=!1;return c.view.state.doc.nodesBetween(l.pos,h,x=>{if(Ts(x))return u=!0,!1}),u},o=d.useMemo(()=>e.disabled?[]:Ks(e.editor),[e.disabled,e.editor,t]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:s,tippyOptions:Cs,children:o!=null&&o.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:o==null?void 0:o.map((c,a)=>c.type==="edit"&&(n!=null&&n.src)?r.jsx(js,{attrs:n,editor:e.editor,extension:i},`bubbleMenu-drawer-${a}`):r.jsx(ys,{disabled:e.disabled,editor:e.editor,item:c},`bubbleMenu-drawer-${a}`))})}):r.jsx(r.Fragment,{})})})}const Ns={padding:"0 12px 12px"},Kr=({width:e,maxWidth:t,height:n,onOk:i,children:s})=>{const{t:o}=y.useLocale(),[c,a]=d.useState({width:"",height:"",maxWidth:""});d.useEffect(()=>{a({width:e,height:n,maxWidth:t})},[n,t,e]);function l(h){h.preventDefault(),h.stopPropagation(),i(c)}return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{asChild:!0,children:s}),r.jsx(le,{children:r.jsx("div",{style:Ns,children:r.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:l,children:[r.jsx(ie,{className:"mb-[6px]",children:"Width"}),r.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:r.jsx(K,{type:"number",value:c.width,required:!0,onChange:h=>a({...c,width:h.target.value})})})}),r.jsx(ie,{className:"mb-[6px]",children:"Max Width"}),r.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:r.jsx(K,{type:"number",value:c.maxWidth,required:!0,onChange:h=>a({...c,maxWidth:h.target.value})})})}),r.jsx(ie,{className:"mb-[6px]",children:"Height"}),r.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:r.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:r.jsx(K,{type:"number",value:c.height,required:!0,onChange:h=>a({...c,height:h.target.value})})})}),r.jsx(G,{type:"submit",className:"richtext-self-end richtext-mt-2",children:o("editor.link.dialog.button.apply")})]})})})]})},ge=new Map;function Ms(e){const t=e.options.element;ge.has("width")||ge.set("width",t.clientWidth),ge.has("width")&&ge.get("width")<=0&&ge.set("width",t.clientWidth);const n={attributes:!0,childList:!0,subtree:!0},i=function(){ge.set("width",t.clientWidth)},s=new MutationObserver(i);return s.observe(t,n),e.on("destroy",()=>{s.disconnect()}),{width:ge.get("width")}}function ks({editor:e}){const{t}=y.useLocale(),{width:n}=Ms(e),i=Se(e,we.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:s,createUser:o,width:c,height:a}=i,l=d.useCallback(m=>{e.chain().updateAttributes(we.name,m).setNodeSelection(e.state.selection.from).focus().run()},[e]),h=d.useCallback(()=>{bo(i)},[e,i]),u=d.useCallback(()=>e.isActive(we.name),[e]),x=d.useCallback(()=>Te(we.name,e),[e]);return d.useEffect(()=>{s&&(h(),e.chain().updateAttributes(we.name,{defaultShowPicker:!1}).focus().run())},[o,s,e,h]),r.jsx(A.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:r.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:[r.jsx(D,{icon:"Pencil",action:h,tooltip:t("editor.edit")}),r.jsx(Kr,{width:c,maxWidth:n,height:a,onOk:l,children:r.jsx(D,{icon:"Settings",tooltip:t("editor.settings")})}),r.jsx(D,{icon:"Trash2",action:x,tooltip:t("editor.delete")})]})})}function As({editor:e}){const{t}=y.useLocale(),{width:n,height:i,url:s}=Se(e,pe.name,{width:0,height:0,url:"",defaultShowPicker:!1}),[o,c]=d.useState(!1),[a,l]=d.useState(""),h=d.useCallback(()=>{c(!1)},[c]);d.useEffect(()=>{o&&l(s)},[o,s]);const u=d.useCallback(()=>{e.chain().updateAttributes(pe.name,{url:a}).setNodeSelection(e.state.selection.from).focus().run(),c(!1)},[e,a,c]),x=d.useCallback(()=>{window.open(s,"_blank")},[s]),m=d.useCallback(()=>{c(!0)},[c]),f=d.useCallback(g=>{e.chain().updateAttributes(pe.name,g).setNodeSelection(e.state.selection.from).focus().run()},[e]),w=d.useCallback(()=>e.isActive(pe.name)&&!s,[e,s]),p=d.useCallback(()=>Te(pe.name,e),[e]);return r.jsxs(r.Fragment,{children:[r.jsx(A.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"iframe-bubble-menu",shouldShow:w,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:r.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:[r.jsx(D,{action:x,icon:"Eye",tooltip:"Visit Link"}),r.jsx(D,{action:m,icon:"Pencil",tooltip:"Open Edit Link"}),r.jsx(Kr,{width:n,height:i,onOk:f,children:r.jsx(D,{icon:"Settings",tooltip:t("editor.settings")})}),r.jsx(D,{action:p,icon:"Trash2",tooltip:t("editor.delete")})]})}),r.jsxs(de,{open:o,onOpenChange:c,children:[r.jsx(he,{}),r.jsxs(se,{children:[r.jsx(Wr,{children:r.jsx(ce,{children:"Edit Link Iframe"})}),r.jsx(K,{value:a,onInput:g=>l(g.target.value),type:"url",autoFocus:!0,placeholder:"Enter link"}),r.jsxs(fe,{children:[r.jsx(G,{onClick:h,children:"Cancel"}),r.jsx(G,{onClick:u,children:"OK"})]})]})]})]})}function Es({editor:e,...t}){const n=Se(e,ve.name,{text:"",defaultShowPicker:!1}),{text:i,defaultShowPicker:s}=n,[o,c]=d.useState(""),[a,l]=d.useState(!1),h=d.useCallback(()=>e.isActive(ve.name),[e]),u=d.useCallback(()=>Te(ve.name,e),[e]),x=d.useCallback(()=>{e.chain().focus().setKatex({text:o}).run(),l(!1)},[e,o]);d.useEffect(()=>{s&&(l(!0),e.chain().updateAttributes(ve.name,{defaultShowPicker:!1}).focus().run())},[e,s,l]),d.useEffect(()=>{a&&c(i||"")},[a]);const m=d.useMemo(()=>{try{return vt.renderToString(`${o}`)}catch{return o}},[o]),f=d.useMemo(()=>`${o}`.trim()?r.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:m||""}}):null,[o,m]);return r.jsx(A.BubbleMenu,{editor:e,pluginKey:"Katex-bubble-menu",shouldShow:h,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{l(!1)}},children:t!=null&&t.disabled?r.jsx(r.Fragment,{}):r.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:a?r.jsxs(r.Fragment,{children:[r.jsx(De,{value:o,onChange:w=>c(w.target.value),autoFocus:!0,placeholder:"Formula text",rows:3,defaultValue:i,style:{marginBottom:8}}),f&&r.jsx("div",{className:"richtext-my-[10px] richtext-p-[10px] richtext-rounded-[6px] !richtext-border-[1px] richtext-whitespace-nowrap richtext-overflow-auto",children:f}),r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[r.jsx(G,{onClick:x,className:"richtext-flex-1",children:"Submit"}),r.jsx("a",{href:"https://katex.org/docs/supported",target:"_blank",rel:"noreferrer noopener",children:r.jsx(C.HelpCircle,{size:16})})]})]}):r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[6px]",children:[r.jsx(D,{tooltip:"Edit",action:()=>l(!a),children:r.jsx(C.Pencil,{size:16})}),r.jsx(D,{tooltip:"Delete",action:u,children:r.jsx(C.Trash2,{size:16})})]})})})}const ir=`graph TB
3
- a-->b`,Is=({editor:e,attrs:t,extension:n})=>{const{alt:i,align:s}=t,[o,c]=d.useState(decodeURIComponent(i??ir)),[a,l]=d.useState(""),[h,u]=d.useState(!1),x=d.useRef(null),m=n==null?void 0:n.options.upload,f=async g=>{try{const{svg:R}=await Xe.render("mermaid-svg",g);l(R)}catch{l("")}},w=()=>{Xe.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),f(o)};d.useEffect(()=>{h&&w()},[h]),d.useEffect(()=>{h&&f(o)},[o]);const p=async()=>{if(o!==""){if(o){const g=x.current.querySelector("svg"),{width:R,height:M}=g.getBoundingClientRect(),v=`mermaid-${tt()}.svg`;let b=S.i(g.outerHTML);if(m){const T=ze(b,v);b=await m(T)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(o),width:R,height:M},!!o).run(),e==null||e.commands.setAlignImageMermaid(s)}u(!1)}};return r.jsxs(de,{onOpenChange:u,open:h,children:[r.jsx(he,{asChild:!0,children:r.jsx(D,{action:()=>u(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),r.jsxs(se,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[r.jsx(ce,{children:"Edit Mermaid"}),r.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:r.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[r.jsx(De,{autoFocus:!0,className:"richtext-flex-1",defaultValue:ir,onChange:g=>c(g.target.value),placeholder:"Text",required:!0,rows:10,value:o,style:{color:"hsl(var(--richtext-foreground))"}}),r.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:a},ref:x,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500,background:"#fff"}})]})}),r.jsx(fe,{children:r.jsx(G,{onClick:p,type:"button",children:"Save changes"})})]})]})},Ls={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Rs({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?r.jsx(d.Fragment,{children:e.type==="divider"?r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):r.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):r.jsx(r.Fragment,{})}function _s(e){return e.type.name==="mermaid"}function Ps(e){const{lang:t}=y.useLocale(),n=Se(e.editor,ft.name),i=Xr(e.editor,ft.name),s=({editor:c})=>{const{selection:a}=c.view.state,{$from:l,to:h}=a;let u=!1;return c.view.state.doc.nodesBetween(l.pos,h,x=>{if(_s(x))return u=!0,!1}),u},o=d.useMemo(()=>e.disabled?[]:Xs(e.editor),[e.disabled,e.editor,t]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:s,tippyOptions:Ls,children:o!=null&&o.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:o==null?void 0:o.map((c,a)=>c.type==="edit"&&(n!=null&&n.src)?r.jsx(Is,{attrs:n,editor:e.editor,extension:i},`bubbleMenu-mermaid-${a}`):r.jsx(Rs,{disabled:e.disabled,editor:e.editor,item:c},`bubbleMenu-mermaid-${a}`))})}):r.jsx(r.Fragment,{})})})}function zs({editor:e,disabled:t}){const[n,i]=d.useState(!1),{t:s}=y.useLocale(),o=d.useCallback(({editor:l})=>l.isActive(Ye.name),[]),c=l=>{e.commands.updateTweet({src:l}),i(!1)},a=d.useCallback(()=>Te(Ye.name,e),[e]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e,shouldShow:o,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{i(!1)}},children:t?r.jsx(r.Fragment,{}):r.jsx(r.Fragment,{children:n?r.jsx(Ur,{editor:e,onSetLink:c}):r.jsx("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-lg !richtext-border richtext-border-neutral-200 richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:r.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[r.jsx(D,{icon:"Pencil",tooltip:s("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{i(!0)}}),r.jsx(D,{action:a,icon:"Trash",tooltip:s("editor.delete"),tooltipOptions:{sideOffset:15}})]})})})})})}function Ds({editor:e,disabled:t,bubbleMenu:n}){const i=e.extensionManager.extensions.map(o=>o.name),s=()=>{var o,c,a,l,h,u,x,m,f,w,p,g,R,M,v;return[i.includes("columns")&&!((o=n==null?void 0:n.columnConfig)!=null&&o.hidden)?r.jsx(gc,{editor:e},"columns"):null,i.includes("table")&&!((c=n==null?void 0:n.tableConfig)!=null&&c.hidden)?r.jsx(cc,{editor:e,actions:(a=n==null?void 0:n.tableConfig)==null?void 0:a.actions},"table"):null,i.includes("link")&&!((l=n==null?void 0:n.linkConfig)!=null&&l.hidden)?r.jsx(lc,{disabled:t,editor:e},"link"):null,i.includes(ye.name)&&!((h=n==null?void 0:n.imageConfig)!=null&&h.hidden)?r.jsx(xc,{disabled:t,editor:e},"image"):null,i.includes(Pt.name)&&!((u=n==null?void 0:n.imageGifConfig)!=null&&u.hidden)?r.jsx(mc,{disabled:t,editor:e},"imageGif"):null,i.includes("video")&&!((x=n==null?void 0:n.videoConfig)!=null&&x.hidden)?r.jsx(fc,{disabled:t,editor:e},"video"):null,i.includes("katex")&&!((m=n==null?void 0:n.katexConfig)!=null&&m.hidden)?r.jsx(Es,{disabled:t,editor:e},"katex"):null,i.includes("excalidraw")&&!((f=n==null?void 0:n.excalidrawConfig)!=null&&f.hidden)?r.jsx(ks,{disabled:t,editor:e},"excalidraw"):null,i.includes("mermaid")&&!((w=n==null?void 0:n.mermaidConfig)!=null&&w.hidden)?r.jsx(Ps,{disabled:t,editor:e},"mermaid"):null,i.includes("iframe")&&!((p=n==null?void 0:n.iframeConfig)!=null&&p.hidden)?r.jsx(As,{disabled:t,editor:e},"iframe"):null,i.includes("twitter")&&!((g=n==null?void 0:n.twitterConfig)!=null&&g.hidden)?r.jsx(zs,{disabled:t,editor:e},"twitter"):null,(R=n==null?void 0:n.floatingMenuConfig)!=null&&R.hidden?null:r.jsx(nc,{disabled:t,editor:e},"content"),(M=n==null?void 0:n.textConfig)!=null&&M.hidden?null:r.jsx(sc,{disabled:t,editor:e},"text"),i.includes("drawer")&&!((v=n==null?void 0:n.drawerConfig)!=null&&v.hidden)?r.jsx(Ss,{disabled:t,editor:e},"drawer"):null]};return n!=null&&n.render?n.render({editor:e,disabled:t||!1,bubbleMenu:n},s()):s().filter(Boolean)}function or(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:r.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 Yr(e){const{t}=y.useLocale(),{highlight:n=!1,disabled:i=!1,selectedColor:s,setSelectedColor:o,onChange:c,colors:a=y.COLORS_LIST}=e,l=d.useMemo(()=>{const f=a,w=[];for(let p=0;p<f.length;p+=10)w.push(f.slice(p,p+10));return w},[a]),[h,u]=d.useState([]),x=f=>{const w=[...h],p=w.indexOf(f);p!==-1&&w.splice(p,1),w.unshift(f),w.length>10&&w.pop(),u(w)};function m(f){if(f===void 0){o==null||o(f),c==null||c(f);return}/^#([\da-f]{3}){1,2}$/i.test(f)&&(o==null||o(f),c==null||c(f),x(f))}return r.jsxs(xe,{modal:!0,children:[r.jsx(me,{asChild:!0,className:"!richtext-p-0",disabled:i,children:e==null?void 0:e.children}),r.jsx(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:r.jsxs("div",{className:"richtext-flex richtext-flex-col",children:[n?r.jsxs("div",{className:"rd-1 richtext-flex richtext-cursor-pointer richtext-items-center richtext-gap-[4px] richtext-p-1 hover:richtext-bg-accent",onClick:()=>m(void 0),children:[r.jsx(or,{}),r.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:t("editor.nofill")})]}):r.jsxs("div",{className:"rd-1 richtext-flex richtext-cursor-pointer richtext-items-center richtext-gap-[4px] richtext-p-1 hover:richtext-bg-accent",onClick:()=>{m(void 0)},children:[r.jsx(or,{}),r.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:t("editor.default")})]}),l.map((f,w)=>r.jsx("span",{className:"richtext-relative richtext-flex richtext-h-auto richtext-w-full richtext-p-0 last:richtext-pb-2",children:f.map((p,g)=>r.jsx("span",{className:"richtext-inline-block richtext-size-6 richtext-flex-[0_0_auto] richtext-cursor-pointer richtext-rounded-sm !richtext-border richtext-border-transparent richtext-p-0.5 hover:richtext-border-border hover:richtext-shadow-sm",onClick:()=>m(p),children:r.jsx("span",{className:"richtext-relative richtext-block richtext-size-[18px] richtext-rounded-[2px] richtext-border-transparent",style:{backgroundColor:p},children:p===s?r.jsx("svg",{className:"richtext-absolute -richtext-top-px richtext-left-px richtext-block richtext-size-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)"},children:r.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):r.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:r.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${g}`))},w)),r.jsxs("div",{children:[r.jsx("div",{className:"richtext-my-1 richtext-text-sm",children:t("editor.recent")}),r.jsx("span",{className:"richtext-relative richtext-flex richtext-h-auto richtext-w-full richtext-p-0 last:richtext-pb-2",children:h==null?void 0:h.map((f,w)=>r.jsx("span",{className:"richtext-inline-block richtext-size-6 richtext-flex-[0_0_auto] richtext-cursor-pointer richtext-rounded-sm !richtext-border richtext-border-transparent richtext-p-0.5 hover:richtext-border-border hover:richtext-shadow-sm",onClick:()=>m(f),children:r.jsx("span",{className:"richtext-relative richtext-block richtext-size-[18px] richtext-rounded-[2px] richtext-border-transparent",style:{backgroundColor:f},children:r.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:r.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-recent-${w}`))})]}),r.jsx(Hs,{setColor:m})]})})]})}function Hs({setColor:e}){const[t,n]=d.useState("#000000"),[i,s]=d.useState(!1),{t:o}=y.useLocale();return d.useEffect(()=>()=>{s(!1)},[]),r.jsxs(xe,{open:i,children:[r.jsx(me,{asChild:!0,children:r.jsxs("div",{className:"richtext-p-1.5 richtext-text-sm hover:richtext-cursor-pointer hover:richtext-bg-accent",onClick:c=>{c.preventDefault(),s(!0)},children:[o("editor.color.more"),"..."]})}),r.jsxs(le,{children:[r.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-justify-center",children:[r.jsx(vn.HexColorPicker,{color:t,onChange:n}),r.jsx(K,{className:"richtext-mt-[8px] richtext-w-full",type:"text",value:t.slice(1),onChange:c=>{c.preventDefault(),n(`#${c.target.value}`)}})]}),r.jsx(J,{className:"richtext-my-[10px]"}),r.jsx(G,{className:"richtext-w-full",onClick:c=>{c.preventDefault(),e(t),s(!1)},children:r.jsx(C.Plus,{size:16})})]})]})}function Os({editor:e,disabled:t,toolbar:n}){const{t:i,lang:s}=y.useLocale(),o=d.useMemo(()=>{const h=[...e.extensionManager.extensions].sort((x,m)=>{const f=x.options.sort??-1,w=m.options.sort??-1;return f-w});let u=[];for(const x of h){const{button:m,divider:f=!1,spacer:w=!1,toolbar:p=!0}=x.options;if(!m||!En(m)||!p)continue;const g=m({editor:e,extension:x,t:i});if(Array.isArray(g)){const R=g.map((M,v)=>({button:M,divider:v===g.length-1?f:!1,spacer:v===0?w:!1,type:x.type,name:x.name}));u=[...u,...R];continue}u.push({button:g,divider:f,spacer:w,type:x.type,name:x.name})}return u},[e,i,s]),c=l=>r.jsx("div",{className:"richtext-toolbar richtext-px-1 richtext-py-2 !richtext-border-b",style:{pointerEvents:t?"none":"auto",opacity:t?.5:1},children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-flex-wrap richtext-h-auto richtext-gap-y-1 richtext-gap-x-1",children:l})}),a=o.map((l,h)=>{var x,m;const u=l.button.component;return r.jsxs("div",{className:"richtext-flex richtext-items-center",children:[(l==null?void 0:l.spacer)&&r.jsx(J,{orientation:"vertical",className:"!richtext-h-[16px] !richtext-mx-[10px]"}),r.jsx(u,{...l.button.componentProps,disabled:t||((m=(x=l==null?void 0:l.button)==null?void 0:x.componentProps)==null?void 0:m.disabled)}),(l==null?void 0:l.divider)&&r.jsx(J,{orientation:"vertical",className:"!richtext-h-auto !richtext-mx-2"})]},`toolbar-item-${h}`)});return n&&(n!=null&&n.render)?n.render({editor:e,disabled:t||!1},o,a,c):c(a)}function Bs(e){const t=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return t.map((i,s)=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[s],action:()=>e.commands.updateImage({width:y.IMAGE_SIZE[i]}),isActive:()=>e.isActive("image",{width:y.IMAGE_SIZE[i]})}}))}function $s(e){const t=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return t.map((i,s)=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[s],action:()=>e.commands.updateImageGif({width:y.IMAGE_SIZE[i]}),isActive:()=>e.isActive("image",{width:y.IMAGE_SIZE[i]})}}))}function Vs(e){const t=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(i=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var s,o;return(o=(s=e.commands)==null?void 0:s.setAlignImage)==null?void 0:o.call(s,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function Fs(e){const t=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(i=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var s,o;return(o=(s=e.commands)==null?void 0:s.setAlignImageGif)==null?void 0:o.call(s,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function Ws(e){const t=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(i=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var s,o;return(o=(s=e.commands)==null?void 0:s.setAlignImageMermaid)==null?void 0:o.call(s,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function Gs(e){const t=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(i=>({type:`image-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var s,o;return(o=(s=e.commands)==null?void 0:s.setAlignImageDrawer)==null?void 0:o.call(s,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function qs(e){const t=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return t.map((i,s)=>({type:`video-${i}`,component:D,componentProps:{tooltip:y.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[s],action:()=>e.commands.updateVideo({width:y.VIDEO_SIZE[i]}),isActive:()=>e.isActive("video",{width:y.VIDEO_SIZE[i]})}}))}function Us(e){return[{type:"flipX",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const t=e.getAttributes("image"),{flipX:n}=t;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!n}).run()}}},{type:"flipY",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const t=e.getAttributes("image"),{flipY:n}=t;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!n}).run()}}},...Bs(e),...Vs(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;S.deleteSelection(t,n)}}}]}function Zs(e){return[...$s(e),...Fs(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;S.deleteSelection(t,n)}}}]}function Xs(e){return[...Ws(e),{type:"edit",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;S.deleteSelection(t,n)}}}]}function Ks(e){return[...Gs(e),{type:"edit",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.edit"),icon:"Pencil",action:()=>(console.log("AAA"),!0)}},{type:"remove",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;S.deleteSelection(t,n)}}}]}function Ys(e){return[...qs(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:y.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;S.deleteSelection(t,n)}}}]}function Js(e,t){return y.BUBBLE_TEXT_LIST.reduce((n,i)=>{if(i==="divider"&&n.length>0)return[...n,{type:"divider",component:void 0,componentProps:{}}];const s=e.extensionManager.extensions.find(o=>o.name===i);return s?[...n,s.configure().options.button({editor:e,t,extension:s})]:n},[])}function zt(e,t,n){const i=[],s=e.node(0);n=typeof n=="number"&&n>=0?n:e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos);const o=new S.NodeRange(e,t,n),c=o.depth===0?0:s.resolve(o.start).posAtIndex(0);return o.parent.forEach((a,l)=>{const h=c+l,u=h+a.nodeSize;if(h<o.start||h>=o.end)return;const x=new S.SelectionRange(s.resolve(h),s.resolve(u));i.push(x)}),i}class Dt{constructor(t,n){Be(this,"anchor");Be(this,"head");this.anchor=t,this.head=n}map(t){return new Dt(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),i=t.resolve(this.head);return new oe(n,i)}}class oe extends S.Selection{constructor(n,i,s,o=1){const{doc:c}=n,a=n===i,l=n.pos===c.content.size&&i.pos===c.content.size,h=a&&!l?c.resolve(i.pos+(o>0?1:-1)):i,u=a&&l?c.resolve(n.pos-(o>0?1:-1)):n,x=zt(u.min(h),u.max(h),s);super(h.pos>=n.pos?x[0].$from:x[x.length-1].$to,h.pos>=n.pos?x[x.length-1].$to:x[0].$from,x);Be(this,"depth");this.depth=s}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof oe&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,i){const s=n.resolve(i.map(this.anchor)),o=n.resolve(i.map(this.head));return new oe(s,o)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const o=this.ranges.slice(0,-1),c=o[0].$from,a=o[o.length-1].$to;return new oe(c,a,this.depth)}const i=this.ranges[0],s=n.resolve(Math.max(0,i.$from.pos-1));return new oe(this.$anchor,s,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const o=this.ranges.slice(1),c=o[0].$from,a=o[o.length-1].$to;return new oe(a,c,this.depth)}const i=this.ranges[this.ranges.length-1],s=n.resolve(Math.min(n.content.size,i.$to.pos+1));return new oe(this.$anchor,s,this.depth)}static fromJSON(n,i){return new oe(n.resolve(i.anchor),n.resolve(i.head))}static create(n,i,s,o,c=1){return new this(n.resolve(i),n.resolve(s),o,c)}getBookmark(){return new Dt(this.anchor,this.head)}}function Qs(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],i=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((s,o)=>{i[o].style.cssText=function(c){let a="";const l=getComputedStyle(c);for(let h=0;h<l.length;h+=1)a+=`${l[h]}:${l.getPropertyValue(l[h])};`;return a}(s)}),t}function qe(e,t){return window.getComputedStyle(e)[t]}function ec(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function sr(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}function Jr(e){const{x:t,y:n,direction:i,editor:s}=e;let o=null,c=null,a=null,l=t;for(;c===null&&l<window.innerWidth&&l>0;){const h=document.elementsFromPoint(l,n),u=h.findIndex(m=>m.classList.contains("ProseMirror")),x=h.slice(0,u);if(x.length>0){const m=x[0];if(o=m,a=s.view.posAtDOM(m,0),a>=0){c=s.state.doc.nodeAt(Math.max(a-1,0)),(c===null||c.isText)&&(c=s.state.doc.nodeAt(Math.max(a-1,0))),c||(c=s.state.doc.nodeAt(Math.max(a,0)));break}}i==="left"?l-=1:l+=1}return{resultElement:o,resultNode:c,pos:a!==null?a:null}}function tc(e,t){const{doc:n}=t.view.state,i=Jr({editor:t,x:e.clientX,y:e.clientY,direction:"right"});if(!i.resultNode||i.pos===null)return[];const s=e.clientX,o=function(u,x,m){const f=Number.parseInt(qe(u.dom,"paddingLeft"),10),w=Number.parseInt(qe(u.dom,"paddingRight"),10),p=Number.parseInt(qe(u.dom,"borderLeftWidth"),10),g=Number.parseInt(qe(u.dom,"borderLeftWidth"),10),R=u.dom.getBoundingClientRect();return{left:ec(x,R.left+f+p,R.right-w-g),top:m}}(t.view,s,e.clientY),c=t.view.posAtCoords(o);if(!c)return[];const{pos:a}=c;if(!n.resolve(a).parent)return[];const l=n.resolve(i.pos),h=n.resolve(i.pos+1);return zt(l,h,0)}function cr(e,t){const n=e.resolve(t),{depth:i}=n;return i===0?t:n.pos-n.parentOffset-1}function ar(e,t){const n=e.nodeAt(t),i=e.resolve(t);let{depth:s}=i,o=n;for(;s>0;){const c=i.node(s);s-=1,s===0&&(o=c)}return o}function lr(e,t){let n=t;for(;n&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n}const Qr=new S.PluginKey("dragHandle");function rc({pluginKey:e=Qr,element:t,editor:n,tippyOptions:i,onNodeChange:s}){const o=document.createElement("div");let c=null,a=!1,l=null,h=-1;return t.addEventListener("dragstart",u=>{const{view:x}=n;if(!u.dataTransfer)return;const{empty:m,$from:f,$to:w}=x.state.selection,p=tc(u,n),g=zt(f,w,0),R=g.some(_=>p.find(j=>j.$from===_.$from&&j.$to===_.$to)),M=m||!R?p:g;if(M.length===0)return;const{tr:v}=x.state,b=document.createElement("div"),T=M[0].$from.pos,E=M[M.length-1].$to.pos,L=oe.create(x.state.doc,T,E),N=L.content();M.forEach(_=>{const j=Qs(x.nodeDOM(_.$from.pos));b.append(j)}),b.style.position="absolute",b.style.top="-10000px",document.body.append(b),u.dataTransfer.clearData(),u.dataTransfer.setDragImage(b,0,0),x.dragging={slice:N,move:!0},v.setSelection(L),x.dispatch(v),document.addEventListener("drop",()=>sr(b),{once:!0}),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}),t.addEventListener("dragend",()=>{t&&(t.style.pointerEvents="auto")}),new S.Plugin({key:typeof e=="string"?new S.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(u,x){const m=u.getMeta("lockDragHandle"),f=u.getMeta("hideDragHandle");if(m!==void 0&&(a=m),f&&c)return c.hide(),a=!1,l=null,h=-1,s==null||s({editor:n,node:null,pos:-1}),x;if(u.docChanged&&h!==-1&&t&&c){const w=u.mapping.map(h);w!==h&&(h=w)}return x}},view:u=>{return x(),m(n.view.dom),c=mr(u.dom,{...f(),...i}),{update(b,T){if(!w(t,c)||(t.draggable=!a,!p(b,T)))return;const E=g(b);E&&R(b,E)},destroy(){v()}};function x(){t.draggable=!0,t.style.pointerEvents="auto"}function m(b){var T;(T=b.parentElement)==null||T.appendChild(o),o.appendChild(t),Object.assign(o.style,{pointerEvents:"none",position:"absolute",top:"0",left:"0"})}function f(){return{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,appendTo:o,content:t,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]}}}function w(b,T){return b&&T}function p(b,T){return!b.state.doc.eq(T.doc)&&h!==-1}function g(b){let T=b.nodeDOM(h);return T=lr(b,T),T===b.dom||(T==null?void 0:T.nodeType)!==1?null:T}function R(b,T){const E=b.posAtDOM(T,0),L=ar(n.state.doc,E);if(L===l)return;const N=cr(n.state.doc,E);l=L,h=N,s==null||s({editor:n,node:l,pos:h}),M(T)}function M(b){c.setProps({getReferenceClientRect:()=>b.getBoundingClientRect()}),c.show()}function v(){c==null||c.destroy(),t&&sr(o)}},props:{handleDOMEvents:{mouseleave:(u,x)=>{if(a||!m(x))return!1;return f(),w(),!1;function m(p){return p.target&&!o.contains(p.relatedTarget)}function f(){c==null||c.hide()}function w(){l=null,h=-1,s==null||s({editor:n,node:null,pos:-1})}},mousemove:S.debounce((u,x)=>{if(!t||!c||a)return!1;const m=Jr({x:x.clientX,y:x.clientY,direction:"right",editor:n});if(!m.resultElement||m.resultElement===u.dom)return!1;const f=lr(u,m.resultElement);if(f===u.dom||(f==null?void 0:f.nodeType)!==1)return!1;const w=u.posAtDOM(f,0),p=ar(n.state.doc,w);if(p===l)return!1;const g=cr(n.state.doc,w);return l=p,h=g,s==null||s({editor:n,node:l,pos:h}),c.setProps({getReferenceClientRect:()=>f.getBoundingClientRect()}),c.show(),!1},100)}}})}function nc(e){var N,_,j;const{pluginKey:t=Qr}=e,{t:n}=y.useLocale(),[i,s]=d.useState(null),[o,c]=d.useState(-1),a=d.useRef(null),l=d.useRef(null),[h,u]=d.useState(!1),x=e.editor.extensionManager.extensions.some(k=>k.name==="textAlign"),m=e.editor.extensionManager.extensions.some(k=>k.name==="indent"),f=e.editor.extensionManager.extensions.some(k=>k.name==="clear");d.useEffect(()=>{a.current&&!e.editor.isDestroyed&&(l.current=rc({editor:e.editor,element:a.current,pluginKey:"ContentItemMenu",tippyOptions:{offset:[-2,16],zIndex:99,moveTransition:"transform 0.15s ease-out"},onNodeChange:T}),e.editor.registerPlugin(l.current))},[e.editor,a]);function w(){const k=e.editor.chain();k.setNodeSelection(o).unsetAllMarks(),(i==null?void 0:i.type.name)!=="paragraph"&&k.setParagraph(),k.run()}function p(){e.editor.chain().focus().setNodeSelection(o).run(),document.execCommand("copy")}function g(){e.editor.commands.setNodeSelection(o);const{$anchor:k}=e.editor.state.selection,B=k.node(1)||e.editor.state.selection.node;e.editor.chain().setMeta("hideDragHandle",!0).insertContentAt(o+((i==null?void 0:i.nodeSize)||0),B.toJSON()).run()}function R(k){e.editor.commands.setTextAlign(k)}function M(){const k=xt(e.editor.state.tr,o,1);k.setMeta("hideDragHandle",!0),e.editor.view.dispatch&&e.editor.view.dispatch(k)}function v(){const k=xt(e.editor.state.tr,o,-1);e.editor.view.dispatch&&e.editor.view.dispatch(k)}function b(){e.editor.chain().setMeta("hideDragHandle",!0).setNodeSelection(o).deleteSelection().run()}function T(k){k.node&&s(k.node),c(k.pos)}function E(){var k;if(o!==-1){const B=(i==null?void 0:i.nodeSize)||0,O=o+B,H=(i==null?void 0:i.type.name)==="paragraph"&&((k=i==null?void 0:i.content)==null?void 0:k.size)===0,I=H?o+2:O+2;e.editor.chain().command(({dispatch:$,tr:F,state:X})=>$?(H?F.insertText("/",o,o+1):F.insert(O,X.schema.nodes.paragraph.create(null,[X.schema.text("/")])),$(F)):!0).focus(I).run()}}d.useEffect(()=>(h?e.editor.commands.setMeta("lockDragHandle",!0):e.editor.commands.setMeta("lockDragHandle",!1),()=>{e.editor.commands.setMeta("lockDragHandle",!1)}),[h]),d.useEffect(()=>()=>{l.current&&(e.editor.unregisterPlugin(t),l.current=null)},[]),d.useEffect(()=>{var k;(k=e.editor)!=null&&k.isDestroyed&&l.current&&(e.editor.unregisterPlugin(t),l.current=null)},[(N=e.editor)==null?void 0:N.isDestroyed]);const L=k=>{e!=null&&e.disabled||u(k)};return r.jsx("div",{ref:a,className:`drag-handle richtext-duration-200 richtext-ease-in-out [transition-property:top,_left] ${e==null?void 0:e.className}`,style:{opacity:e!=null&&e.disabled?0:1},children:r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5 richtext-duration-200 richtext-ease-in-out [transition-property:top,_left]",children:[r.jsx(G,{className:"!richtext-size-7 richtext-cursor-grab",disabled:e==null?void 0:e.disabled,onClick:E,size:"icon",type:"button",variant:"ghost",children:r.jsx(U,{className:"richtext-text-lg richtext-text-neutral-600 dark:richtext-text-neutral-200",name:"Plus"})}),r.jsxs(Tr,{onOpenChange:L,open:h,children:[r.jsxs("div",{className:"richtext-relative richtext-flex richtext-flex-col",children:[r.jsxs(Nt,{children:[r.jsx(Mt,{asChild:!0,disabled:e==null?void 0:e.disabled,children:r.jsx(G,{className:"richtext-relative richtext-z-[1] !richtext-size-7 richtext-cursor-grab",disabled:e==null?void 0:e.disabled,size:"icon",type:"button",variant:"ghost",onMouseUp:k=>{k.preventDefault(),!(e!=null&&e.disabled)&&u(!0)},children:r.jsx(U,{className:"richtext-text-sm richtext-text-neutral-600 dark:richtext-text-neutral-200",name:"Grip"})})}),r.jsx(et,{children:n("editor.draghandle.tooltip")})]}),r.jsx(Sr,{className:"richtext-absolute richtext-left-0 richtext-top-0 richtext-z-0 richtext-size-[28px]"})]}),r.jsxs(jt,{align:"start",className:"richtext-w-48",side:"bottom",sideOffset:0,children:[r.jsxs(ne,{className:"richtext-flex richtext-gap-3 richtext-bg-opacity-10 hover:richtext-bg-red-400 hover:richtext-bg-opacity-20 focus:richtext-bg-red-400 focus:richtext-bg-opacity-30 focus:richtext-text-red-500 dark:hover:richtext-bg-opacity-20 dark:hover:richtext-text-red-500",onClick:b,children:[r.jsx(U,{name:"Trash2"}),r.jsx("span",{children:n("editor.remove")})]}),f?r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:w,children:[r.jsx(U,{name:"PaintRoller"}),r.jsx("span",{children:n("editor.clear.tooltip")})]}):null,r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:p,children:[r.jsx(U,{name:"Clipboard"}),r.jsx("span",{children:n("editor.copyToClipboard")})]}),r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:g,children:[r.jsx(U,{name:"Copy"}),r.jsx("span",{children:n("editor.copy")})]}),x||m?r.jsx(Ct,{}):null,x?r.jsxs(Gt,{children:[r.jsxs(ht,{className:"richtext-flex richtext-gap-3",children:[r.jsx(U,{name:"AlignCenter"}),r.jsx("span",{children:n("editor.textalign.tooltip")})]}),r.jsx(Wt,{children:r.jsxs(ut,{children:[r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:()=>R("left"),children:[r.jsx(U,{name:"AlignLeft"}),r.jsx("span",{children:n("editor.textalign.left.tooltip")})]}),r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:()=>R("center"),children:[r.jsx(U,{name:"AlignCenter"}),r.jsx("span",{children:n("editor.textalign.center.tooltip")})]}),r.jsxs(ne,{className:"richtext-flex richtext-gap-3",onClick:()=>R("right"),children:[r.jsx(U,{name:"AlignRight"}),r.jsx("span",{children:n("editor.textalign.right.tooltip")})]})]})})]}):null,m?r.jsxs(Gt,{children:[r.jsxs(ht,{className:"richtext-flex richtext-gap-3",children:[r.jsx(U,{name:"IndentIncrease"}),r.jsx("span",{children:n("editor.indent")})]}),r.jsx(Wt,{children:r.jsxs(ut,{children:[r.jsxs(ne,{className:"richtext-flex richtext-gap-3",disabled:((_=i==null?void 0:i.attrs)==null?void 0:_.indent)>=Ke.max,onClick:M,children:[r.jsx(U,{name:"IndentIncrease"}),r.jsx("span",{children:n("editor.indent.tooltip")})]}),r.jsxs(ne,{className:"richtext-flex richtext-gap-3",disabled:((j=i==null?void 0:i.attrs)==null?void 0:j.indent)<=Ke.min,onClick:v,children:[r.jsx(U,{name:"IndentDecrease"}),r.jsx("span",{children:n("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}const ic={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function oc({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?r.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n}):r.jsx(r.Fragment,{})}function sc(e){const{t,lang:n}=y.useLocale(),i=({editor:o})=>{const{selection:c}=o.view.state,{$from:a,to:l}=c;return a.pos===l?!1:c instanceof S.TextSelection},s=d.useMemo(()=>e.disabled||!(e!=null&&e.editor)?[]:Js(e.editor,t),[e.disabled,e.editor,n,t]);return r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:i,tippyOptions:ic,children:s!=null&&s.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-gap-[4px] richtext-whitespace-nowrap",children:s==null?void 0:s.map((o,c)=>(o==null?void 0:o.type)==="divider"?r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"},`bubbleMenu-divider-${c}`):r.jsx(oc,{disabled:e.disabled,editor:e.editor,item:o},`bubbleMenu-text-${c}`))})}):r.jsx(r.Fragment,{})})}function cc({editor:e,disabled:t,actions:n}){var b,T,E,L,N,_,j,k,B,O,H,I,$,F,X,ae,He,$t;const i=d.useCallback(({view:Z,state:ee,from:Y})=>ee?Yi({editor:e,view:Z,state:ee,from:Y||0}):!1,[e]),s=d.useCallback(({view:Z,state:ee,from:Y})=>!ee||!Y?!1:Ji({editor:e,view:Z,state:ee,from:Y}),[e]),o=({editor:Z})=>{const{selection:ee}=Z.view.state,{$from:Y,to:Oe}=ee;return Y.pos===Oe?!1:ee instanceof S.TextSelection},c=({editor:Z})=>A.isActive(Z.view.state,"table"),a=Z=>(c(Z)||i(Z)||s(Z))&&!o(Z),{t:l}=y.useLocale();function h(){e.chain().focus().addColumnBefore().run()}function u(){e.chain().focus().addColumnAfter().run()}function x(){e.chain().focus().deleteColumn().run()}function m(){e.chain().focus().addRowBefore().run()}function f(){e.chain().focus().addRowAfter().run()}function w(){e.chain().focus().deleteRow().run()}function p(){e.chain().focus().mergeCells().run()}function g(){e==null||e.chain().focus().splitCell().run()}function R(){e.chain().focus().deleteTable().run()}function M(Z){e.chain().focus().setTableCellBackground(Z).run()}const v=()=>{var Vt;const{view:Z,state:{selection:{from:ee}}}=e,Y=Z.domAtPos(ee).node;if(!Y)return new DOMRect(-1e3,-1e3,0,0);const Oe=(Vt=Y==null?void 0:Y.closest)==null?void 0:Vt.call(Y,".tableWrapper");return Oe?Oe.getBoundingClientRect():new DOMRect(-1e3,-1e3,0,0)};return r.jsx(A.BubbleMenu,{editor:e,pluginKey:"table",shouldShow:a,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},maxWidth:"auto",getReferenceClientRect:v,plugins:[mr.sticky],sticky:"popper"},children:t?r.jsx(r.Fragment,{}):r.jsxs("div",{className:"richtext-flex richtext-size-full richtext-min-w-32 richtext-flex-row richtext-items-center richtext-gap-0.5 richtext-rounded-lg !richtext-border richtext-border-border richtext-bg-background richtext-p-2 richtext-leading-none richtext-shadow-sm",children:[n&&r.jsxs(r.Fragment,{children:[n.map((Z,ee)=>r.jsx(D,{...Z},ee)),r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"})]}),r.jsx(D,{action:h,disabled:!((T=(b=e==null?void 0:e.can())==null?void 0:b.addColumnBefore)!=null&&T.call(b)),icon:"BetweenHorizonalEnd",tooltip:l("editor.table.menu.insertColumnBefore"),"tooltip-options":{sideOffset:15}}),r.jsx(D,{action:u,disabled:!((L=(E=e==null?void 0:e.can())==null?void 0:E.addColumnAfter)!=null&&L.call(E)),icon:"BetweenHorizonalStart",tooltip:l("editor.table.menu.insertColumnAfter"),"tooltip-options":{sideOffset:15}}),r.jsx(D,{action:x,disabled:!((_=e==null?void 0:(N=e.can()).deleteColumn)!=null&&_.call(N)),icon:"DeleteColumn",tooltip:l("editor.table.menu.deleteColumn"),"tooltip-options":{sideOffset:15}}),r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),r.jsx(D,{action:m,disabled:!((k=e==null?void 0:(j=e.can()).addRowBefore)!=null&&k.call(j)),icon:"BetweenVerticalEnd",tooltip:l("editor.table.menu.insertRowAbove"),"tooltip-options":{sideOffset:15}}),r.jsx(D,{action:f,disabled:!((O=(B=e==null?void 0:e.can())==null?void 0:B.addRowAfter)!=null&&O.call(B)),icon:"BetweenVerticalStart",tooltip:l("editor.table.menu.insertRowBelow"),"tooltip-options":{sideOffset:15}}),r.jsx(D,{action:w,disabled:!((I=(H=e==null?void 0:e.can())==null?void 0:H.deleteRow)!=null&&I.call(H)),icon:"DeleteRow",tooltip:l("editor.table.menu.deleteRow"),"tooltip-options":{sideOffset:15}}),r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),r.jsx(D,{action:p,disabled:!((F=($=e==null?void 0:e.can())==null?void 0:$.mergeCells)!=null&&F.call($)),icon:"TableCellsMerge",tooltip:l("editor.table.menu.mergeCells"),"tooltip-options":{sideOffset:15}}),r.jsx(D,{action:g,disabled:!((ae=(X=e==null?void 0:e.can())==null?void 0:X.splitCell)!=null&&ae.call(X)),icon:"TableCellsSplit",tooltip:l("editor.table.menu.splitCells"),"tooltip-options":{sideOffset:15}}),r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),r.jsx(Br,{action:M,editor:e,tooltip:l("editor.table.menu.setCellsBgColor"),tooltipOptions:{sideOffset:15}}),r.jsx(D,{action:R,disabled:!(($t=(He=e==null?void 0:e.can())==null?void 0:He.deleteTable)!=null&&$t.call(He)),icon:"Trash2",tooltip:l("editor.table.menu.deleteTable"),"tooltip-options":{sideOffset:15}})]})})}function ac(e){const{t}=y.useLocale();return r.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2 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:[r.jsx("a",{href:e==null?void 0:e.link,target:"_blank",rel:"noopener noreferrer",className:"richtext-text-sm richtext-underline richtext-break-all",children:S.truncate(e==null?void 0:e.link,{length:50,omission:"…"})}),(e==null?void 0:e.link)&&r.jsx(J,{orientation:"vertical",className:"!richtext-h-4"}),r.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[r.jsx(D,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),action:()=>{e==null||e.onEdit()},tooltipOptions:{sideOffset:15}}),r.jsx(D,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),action:()=>{e==null||e.onClear()},tooltipOptions:{sideOffset:15}})]})]})}function lc({editor:e,disabled:t}){const[n,i]=d.useState(!1),s=d.useMemo(()=>{const{href:l}=e.getAttributes("link");return l},[e]),o=d.useCallback(({editor:l})=>l.isActive("link"),[]),c=(l,h,u)=>{e.chain().extendMarkRange("link").insertContent({type:"text",text:h,marks:[{type:"link",attrs:{href:l,target:u?"_blank":""}}]}).setLink({href:l}).focus().run(),i(!1)},a=d.useCallback(()=>{e.chain().extendMarkRange("link").unsetLink().focus().run(),i(!1)},[e]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e,shouldShow:o,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{i(!1)}},children:t?r.jsx(r.Fragment,{}):r.jsx(r.Fragment,{children:n?r.jsx($r,{onSetLink:c,editor:e}):r.jsx(ac,{editor:e,onClear:a,onEdit:()=>{i(!0)},link:s})})})})}const Ht={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Ot({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?r.jsx(d.Fragment,{children:e.type==="divider"?r.jsx(J,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):r.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):r.jsx(r.Fragment,{})}function dc(e){return e.type.name===ye.name}function hc(e){return e.type.name===Pt.name}function uc(e){return e.type.name===At.name}function xc(e){const{lang:t}=y.useLocale(),n=({editor:s})=>{const{selection:o}=s.view.state,{$from:c,to:a}=o;let l=!1;return s.view.state.doc.nodesBetween(c.pos,a,h=>{if(dc(h))return l=!0,!1}),l},i=d.useMemo(()=>e.disabled?[]:Us(e.editor),[e.disabled,e.editor,t]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Ht,children:i!=null&&i.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((s,o)=>r.jsx(Ot,{disabled:e.disabled,editor:e.editor,item:s},`bubbleMenu-image-${o}`))})}):r.jsx(r.Fragment,{})})})}function mc(e){const{lang:t}=y.useLocale(),n=({editor:s})=>{const{selection:o}=s.view.state,{$from:c,to:a}=o;let l=!1;return s.view.state.doc.nodesBetween(c.pos,a,h=>{if(hc(h))return l=!0,!1}),l},i=d.useMemo(()=>e.disabled?[]:Zs(e.editor),[e.disabled,e.editor,t]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Ht,children:i!=null&&i.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((s,o)=>r.jsx(Ot,{disabled:e.disabled,editor:e.editor,item:s},`bubbleMenu-image-gif-${o}`))})}):r.jsx(r.Fragment,{})})})}function fc(e){const{lang:t}=y.useLocale(),n=({editor:s})=>{const{selection:o}=s.view.state,{$from:c,to:a}=o;let l=!1;return s.view.state.doc.nodesBetween(c.pos,a,h=>{if(uc(h))return l=!0,!1}),l},i=d.useMemo(()=>e.disabled?[]:Ys(e.editor),[e.editor,e.disabled,t]);return r.jsx(r.Fragment,{children:r.jsx(A.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Ht,children:i!=null&&i.length?r.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:r.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((s,o)=>r.jsx(Ot,{disabled:e.disabled,editor:e.editor,item:s},`bubbleMenu-video-${o}`))})}):r.jsx(r.Fragment,{})})})}function gc({editor:e}){const{t}=y.useLocale(),n=d.useCallback(()=>e.isActive(_e.name),[e]),i=d.useCallback(()=>Te(_e.name,e),[e]),s=d.useCallback(()=>e.chain().focus().addColBefore().run(),[e]),o=d.useCallback(()=>e.chain().focus().addColAfter().run(),[e]),c=d.useCallback(()=>e.chain().focus().deleteCol().run(),[e]);return r.jsx(A.BubbleMenu,{pluginKey:"columns-bubble-menu",editor:e,shouldShow:n,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:r.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:[r.jsx(D,{action:s,icon:"ColumnAddLeft",tooltip:t("editor.table.menu.insertColumnBefore")}),r.jsx(D,{action:o,icon:"ColumnAddRight",tooltip:t("editor.table.menu.insertColumnAfter")}),r.jsx(D,{action:c,icon:"DeleteColumn",tooltip:t("editor.table.menu.deleteColumn")}),r.jsx(D,{action:i,icon:"Trash2",tooltip:t("editor.table.menu.delete_column")})]})})}function pc({editor:e,extensions:t}){const{t:n}=y.useLocale(),i=d.useMemo(()=>{var s,o,c;return(c=(o=(s=t==null?void 0:t.find(a=>a.name==="base-kit"))==null?void 0:s.options)==null?void 0:o.characterCount)==null?void 0:c.limit},[t]);return i?r.jsx("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-p-3 richtext-border-t",children:r.jsx("div",{className:"richtext-flex richtext-flex-col",children:r.jsx("div",{className:"richtext-flex richtext-justify-end richtext-gap-3 richtext-text-sm",children:r.jsxs("span",{children:[e.storage.characterCount.characters(),"/",i," ",n("editor.characters")]})})})}):r.jsx("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-p-3 richtext-border-t",children:r.jsx("div",{className:"richtext-flex richtext-flex-col",children:r.jsx("div",{className:"richtext-flex richtext-justify-end richtext-gap-3 richtext-text-sm",children:r.jsxs("span",{children:[e.storage.characterCount.characters()," ",n("editor.characters")]})})})})}function wc(){const{toasts:e}=_r();return r.jsxs(Dn,{children:[e.map(({id:t,title:n,description:i,action:s,...o})=>r.jsxs(Er,{...o,children:[r.jsxs("div",{className:"richtext-grid richtext-gap-1",children:[n&&r.jsx(Lr,{children:n}),i&&r.jsx(Rr,{children:i})]}),s,r.jsx(Ir,{})]},t)),r.jsx(Ar,{})]})}const vc=`
4
- .reactjs-tiptap-editor,
5
- .richtext-dialog-content {
6
- button,
7
- input:where([type=button]),
8
- input:where([type=reset]),
9
- input:where([type=submit]) {
10
- -webkit-appearance: button;
11
- background-color: transparent;
12
- background-image: none;
13
- }
14
-
15
- input,
16
- optgroup,
17
- select,
18
- textarea {
19
- font-family: inherit;
20
- font-feature-settings: inherit;
21
- font-variation-settings: inherit;
22
- font-size: 100%;
23
- font-weight: inherit;
24
- line-height: inherit;
25
- letter-spacing: inherit;
26
- color: inherit;
27
- }
28
-
29
- button {
30
- font-family: inherit;
31
- font-feature-settings: inherit;
32
- font-variation-settings: inherit;
33
- font-size: 100%;
34
- font-weight: inherit;
35
- line-height: inherit;
36
- letter-spacing: inherit;
37
- color: inherit;
38
- }
39
-
40
- *,
41
- ::before,
42
- ::after {
43
- box-sizing: border-box;
44
- border-width: 0;
45
- border-style: solid;
46
- border-color: hsl(var(--richtext-border));
47
- }
48
-
49
- background-color: hsl(var(--richtext-background));
50
- color: hsl(var(--richtext-foreground));
51
-
52
- hr {
53
- height: 0;
54
- color: inherit;
55
- border-top-width: 1px;
56
- }
57
-
58
- a {
59
- color: inherit;
60
- text-decoration: inherit;
61
- }
62
-
63
- b,
64
- strong {
65
- font-weight: bolder;
66
- }
67
-
68
- code,
69
- kbd,
70
- samp,
71
- pre {
72
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
73
- font-feature-settings: normal;
74
- font-variation-settings: normal;
75
- font-size: 1em;
76
- }
77
-
78
- table {
79
- text-indent: 0;
80
- border-color: inherit;
81
- border-collapse: collapse;
82
- }
83
-
84
- input, textarea {
85
- border-width: 1px;
86
- }
87
-
88
- textarea {
89
- resize: vertical;
90
- }
91
-
92
- input::placeholder,
93
- textarea::placeholder {
94
- opacity: 1;
95
- color: #9ca3af;
96
- }
97
-
98
- button, input, textarea {
99
- cursor: pointer;
100
- color: inherit;
101
- }
102
-
103
- img,
104
- svg,
105
- video,
106
- canvas,
107
- audio,
108
- iframe,
109
- embed,
110
- object {
111
- display: block;
112
- vertical-align: middle;
113
- }
114
-
115
- img,
116
- video {
117
- max-width: 100%;
118
- height: auto;
119
- }
120
- }
121
-
122
- div[data-radix-popper-content-wrapper],
123
- div[data-tippy-root] {
124
- *,
125
- ::before,
126
- ::after {
127
- box-sizing: border-box;
128
- border-width: 0;
129
- border-style: solid;
130
- border-color: hsl(var(--richtext-border));
131
- }
132
-
133
- background-color: hsl(var(--richtext-background));
134
- color: hsl(var(--richtext-foreground));
135
-
136
- button, input, textarea {
137
- cursor: pointer;
138
- color: inherit;
139
- }
140
- }
141
- `,bc=d.memo(({children:e,id:t})=>{const[,n]=br(c=>c.value),[,i]=jr(c=>c.value),s=c=>{n({value:c.detail})},o=c=>{i({value:c.detail})};return d.useEffect(()=>{const c=Ie(ue.EDIT(t),s),a=Ie(ue.UPDATE_THEME(t),o);return()=>{c(),a()}},[]),r.jsx(r.Fragment,{children:e})});function jc({children:e,id:t}){return r.jsx(Sn,{children:r.jsx(Nn,{children:r.jsx(bc,{id:t,children:e})})})}const dr="data-rc-order",hr="data-rc-priority",Cc="rc-util-key",wt=new Map;function yc(e,t){if(!e)return!1;if(e.contains)return e.contains(t);let n=t;for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function en({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:Cc}function Bt(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function Tc(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function tn(e){return[...(wt.get(e)||e).children].filter(t=>t.tagName==="STYLE")}function rn(e,t={}){const{csp:n,prepend:i,priority:s=0}=t,o=Tc(i),c=o==="prependQueue",a=document.createElement("style");a.setAttribute(dr,o),c&&s&&a.setAttribute(hr,`${s}`),n!=null&&n.nonce&&(a.nonce=n==null?void 0:n.nonce),a.innerHTML=e;const l=Bt(t),{firstChild:h}=l;if(i){if(c){const u=tn(l).filter(x=>{if(!["prepend","prependQueue"].includes(x.getAttribute(dr)))return!1;const m=Number(x.getAttribute(hr)||0);return s>=m});if(u.length>0)return l.insertBefore(a,u.at(-1).nextSibling),a}h.before(a)}else l.append(a);return a}function nn(e,t={}){const n=Bt(t);return tn(n).find(i=>i.getAttribute(en(t))===e)}function Sc(e,t={}){const n=nn(e,t);n&&n.remove()}function Nc(e,t){const n=wt.get(e);if(!n||!yc(document,n)){const i=rn("",t),{parentNode:s}=i;wt.set(e,s),i.remove()}}function Mc(e,t,n={}){var c,a,l;const i=Bt(n);Nc(i,n);const s=nn(t,n);if(s)return(c=n.csp)!=null&&c.nonce&&s.nonce!==((a=n.csp)==null?void 0:a.nonce)&&(s.nonce=(l=n.csp)==null?void 0:l.nonce),s.innerHTML!==e&&(s.innerHTML=e),s;const o=rn(e,n);return o.setAttribute(en(n),t),o}function kc(e,t){const{content:n,extensions:i,useEditorOptions:s={}}=e,o=d.useId(),c=d.useMemo(()=>{const x=S.differenceBy(i,i,"name");return[...i.map(f=>{const w=i.find(p=>p.name===f.name);return w?f.configure(w.options):f}),...x].map((f,w)=>f.configure({sort:w}))},[i]),a=S.throttle(x=>{var f;const m=h(x,e.output);(f=e==null?void 0:e.onChangeContent)==null||f.call(e,m)},y.EDITOR_UPDATE_WATCH_THROTTLE_WAIT_TIME),l=A.useEditor({extensions:c,content:n,onUpdate:({editor:x})=>{a&&a(x)},...s});d.useImperativeHandle(t,()=>({editor:l})),d.useEffect(()=>{document.documentElement.classList.toggle("dark",e.dark),mo.setTheme(o,e.dark?"dark":"light")},[e.dark]),d.useEffect(()=>{l==null||l.setEditable(!(e!=null&&e.disabled)),Mn.setDisable(o,!(e!=null&&e.disabled))},[l,e==null?void 0:e.disabled]),d.useEffect(()=>((e==null?void 0:e.resetCSS)!==!1&&Mc(vc,"react-tiptap-reset"),()=>{Sc("react-tiptap-reset")}),[e==null?void 0:e.resetCSS]);function h(x,m){return e!=null&&e.removeDefaultWrapper?m==="html"?x.isEmpty?"":x.getHTML():m==="json"?x.isEmpty?{}:x.getJSON():m==="text"?x.isEmpty?"":x.getText():"":m==="html"?x.getHTML():m==="json"?x.getJSON():m==="text"?x.getText():""}d.useLayoutEffect(()=>{l&&(l.id=o)},[o,l]),d.useEffect(()=>()=>{var x;(x=l==null?void 0:l.destroy)==null||x.call(l)},[]);const u=yr(l,"characterCount");return l?r.jsxs("div",{className:"reactjs-tiptap-editor",children:[r.jsx(jc,{id:o,children:r.jsx($n,{delayDuration:0,disableHoverableContent:!0,children:r.jsx("div",{className:"richtext-overflow-hidden richtext-rounded-[0.5rem] richtext-bg-background richtext-shadow richtext-outline richtext-outline-1",children:r.jsxs("div",{className:"richtext-flex richtext-max-h-full richtext-w-full richtext-flex-col",children:[!(e!=null&&e.hideToolbar)&&r.jsx(Os,{disabled:!!(e!=null&&e.disabled),editor:l,toolbar:e.toolbar}),r.jsx(A.EditorContent,{className:`richtext-relative ${(e==null?void 0:e.contentClass)||""}`,editor:l}),u&&r.jsx(pc,{editor:l,extensions:i}),!(e!=null&&e.hideBubble)&&r.jsx(Ds,{bubbleMenu:e==null?void 0:e.bubbleMenu,disabled:e==null?void 0:e.disabled,editor:l})]})})})}),r.jsx(wc,{})]}):r.jsx(r.Fragment,{})}const Ac=d.forwardRef(kc);exports.ActionButton=D;exports.Button=G;exports.ColorPicker=Yr;exports.Column=kt;exports.Drawer=pt;exports.DropdownMenu=Tr;exports.DropdownMenuCheckboxItem=Nr;exports.DropdownMenuContent=jt;exports.DropdownMenuItem=ne;exports.DropdownMenuSeparator=Ct;exports.DropdownMenuShortcut=Mr;exports.DropdownMenuTrigger=Sr;exports.EVENTS=ue;exports.Excalidraw=we;exports.ExportPdf=Dr;exports.ExportWord=Hr;exports.HighlightActionButton=Br;exports.IconComponent=U;exports.Iframe=pe;exports.Image=ye;exports.ImageGif=Pt;exports.IndentProps=Ke;exports.Input=K;exports.Katex=ve;exports.Label=ie;exports.LinkEditBlock=$r;exports.MenuDown=zr;exports.Mermaid=ft;exports.MultiColumn=_e;exports.Popover=xe;exports.PopoverContent=le;exports.PopoverTrigger=me;exports.RichTextEditor=Ac;exports.Switch=yt;exports.Table=Rt;exports.Toggle=St;exports.Tooltip=Nt;exports.TooltipContent=et;exports.TooltipTrigger=Mt;exports.Twitter=Ye;exports.Video=At;exports.actionDialogImage=Vr;exports.cn=P;exports.createIndentCommand=vi;exports.deleteNode=Te;exports.dispatchEvent=Qe;exports.ensureNameValueOptions=Ln;exports.extractFileExtension=yi;exports.extractFilename=Ci;exports.getDatasetAttribute=be;exports.getShortcutKey=wr;exports.getShortcutKeys=vr;exports.hasExtension=yr;exports.icons=Or;exports.listenEvent=Ie;exports.normalizeFileSize=Ti;exports.normalizeFileType=Si;exports.useEditableEditor=Cr;exports.useToast=_r;