@veevarts/design-system 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +12 -15
- package/dist/index.js +4992 -8767
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),S=require("@heroui/react"),A=require("react"),_e=require("framer-motion"),Rn=require("@tiptap/react"),M=require("lucide-react"),Ns=require("@tiptap/extension-underline"),Rs=require("@tiptap/extension-color"),Ds=require("@tiptap/extension-highlight"),Ls=require("@tiptap/extension-link"),Bs=require("@tiptap/extension-task-list"),Ps=require("@tiptap/extension-task-item"),zs=require("@tiptap/extension-text-align"),Ge={brand:{primary:"#C14615",secondary:"#000000",accent:"#F59E0B"},semantic:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},neutral:{white:"#FFFFFF",black:"#000000",gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"}}},Fs={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem","4xl":"6rem","5xl":"8rem"},js={fontFamily:{primary:'"NeueMontreal", system-ui, sans-serif',secondary:'"Scholar", Georgia, serif',sans:'"NeueMontreal", system-ui, sans-serif',serif:'"Scholar", Georgia, serif',mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem"},fontWeight:{normal:"400",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.75"}},$s={colors:{primary:{50:"#fef5f1",100:"#fde8e0",200:"#fbd5c7",300:"#f7b79f",400:"#f18d68",500:Ge.brand.primary,600:"#a83b11",700:"#8b2f0e",800:"#73260d",900:"#5f210c",DEFAULT:Ge.brand.primary},secondary:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:Ge.brand.secondary,600:"#000000",700:"#000000",800:"#000000",900:"#000000",DEFAULT:Ge.brand.secondary}}};function Hs({children:n}){return m.jsx(S.HeroUIProvider,{children:n})}function Vs({color:n="primary",radius:e="full",...t}){return m.jsx(S.Button,{color:n,radius:e,...t})}function Js(n){return m.jsx("div",{className:"w-full p-8",children:m.jsx("div",{className:"container mx-auto flex items-center justify-center",children:m.jsx(S.Alert,{description:"This component needs to be implemented using HeroUI Navbar, NavbarBrand, NavbarContent, and NavbarItem components. Include logo, navigation links, language selector dropdown, and authentication state.",title:"TODO: Implement Navbar Pattern",variant:"faded"})})})}var Yt;const qs=typeof document<"u"?(Yt=A.useInsertionEffect)!==null&&Yt!==void 0?Yt:A.useLayoutEffect:()=>{};function Ws(n,e,t){let[r,i]=A.useState(n||e),s=A.useRef(r),o=A.useRef(n!==void 0),l=n!==void 0;A.useEffect(()=>{let f=o.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?n:r;qs(()=>{s.current=a});let[,c]=A.useReducer(()=>({}),{}),u=A.useCallback((f,...d)=>{let h=typeof f=="function"?f(s.current):f;Object.is(s.current,h)||(s.current=h,i(h),c(),t?.(h,...d))},[t]);return[a,u]}function Ks(n){return m.jsx("svg",{...n,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:m.jsx(_e.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const _r=A.forwardRef(({color:n="primary",stepsCount:e=3,defaultStep:t=0,label:r,onStepChange:i,currentStep:s,hideProgressBars:o=!1,stepClassName:l,className:a,...c},u)=>{const[f,d]=Ws(s,t,i),h=A.useMemo(()=>{let g,p;const y=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(n){case"primary":g="[--step-color:var(--heroui-primary)]",p="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":g="[--step-color:var(--heroui-secondary)]",p="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":g="[--step-color:var(--heroui-success)]",p="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":g="[--step-color:var(--heroui-warning)]",p="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":g="[--step-color:var(--heroui-danger)]",p="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":g="[--step-color:var(--heroui-default)]",p="[--step-fg-color:var(--heroui-default-foreground)]";break;default:g="[--step-color:var(--heroui-primary)]",p="[--step-fg-color:var(--heroui-primary-foreground)]";break}return y.unshift(p),y.unshift(g),y},[n]);return m.jsxs("nav",{ref:u,"aria-label":"Progress",className:S.cn("flex max-w-fit items-center overflow-x-auto",a),...c,children:[r&&m.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3",children:r}),m.jsx("ol",{className:S.cn("flex flex-row flex-nowrap gap-x-3",h,a),children:Array.from({length:e})?.map((g,p)=>{const y=f===p?"active":f<p?"inactive":"complete";return m.jsx("li",{className:"relative flex w-full items-center pr-12",children:m.jsxs("button",{"aria-current":y==="active"?"step":void 0,className:S.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",l),onClick:()=>d(p),children:[m.jsx("div",{className:"h-full relative flex items-center",children:m.jsx(_e.LazyMotion,{features:_e.domAnimation,children:m.jsx(_e.m.div,{animate:y,className:"relative",children:m.jsx(_e.m.div,{animate:y,className:S.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":y==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:m.jsx("div",{className:"flex items-center justify-center",children:y==="complete"?m.jsx(Ks,{className:"h-5 w-5 text-(--active-fg-color)"}):m.jsx("span",{})})})})})}),p<e-1&&!o&&m.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":p},children:m.jsx("div",{className:S.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":p<f})})})]},p)},p)})})]})});_r.displayName="Stepper";function Us(n){return m.jsx("footer",{className:"w-full py-12",children:m.jsx("div",{className:"container mx-auto px-6 flex items-center justify-center",children:m.jsx(S.Alert,{description:"This component needs to be implemented using HeroUI Link components. Include grid layout with link sections, logo, social media icons, and copyright text. Should be responsive and adapt to mobile/desktop.",title:"TODO: Implement Footer Pattern",variant:"faded"})})})}function rt(n){return typeof n=="string"?n:n.type}function Se({className:n}){return m.jsx("div",{className:`flex items-center h-6 ${n||""}`,children:m.jsx(S.Divider,{orientation:"vertical"})})}function de({icon:n,label:e,isActive:t=!1,isDisabled:r=!1,onClick:i,shortcut:s,iconSize:o=16,className:l}){const a=s?`${e} (${s})`:e;return m.jsx(S.Tooltip,{content:a,children:m.jsx(S.Button,{size:"sm",radius:"sm",color:t?"primary":"default",variant:t?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:i,"aria-label":e,className:l,children:m.jsx(n,{size:o})})})}const ce={bold:{execute:({editor:n})=>n.chain().focus().toggleBold().run(),canExecute:n=>n.can().chain().focus().toggleBold().run(),isActive:n=>n.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:n})=>n.chain().focus().toggleItalic().run(),canExecute:n=>n.can().chain().focus().toggleItalic().run(),isActive:n=>n.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:n})=>n.chain().focus().toggleStrike().run(),canExecute:n=>n.can().chain().focus().toggleStrike().run(),isActive:n=>n.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:n})=>n.chain().focus().toggleUnderline().run(),canExecute:n=>n.can().chain().focus().toggleUnderline().run(),isActive:n=>n.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:n})=>n.chain().focus().toggleCode().run(),canExecute:n=>n.can().chain().focus().toggleCode().run(),isActive:n=>n.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:n,config:e})=>{const t=e?.type==="textColor"?e.color:"";t?n.chain().focus().setColor(t).run():n.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:n=>n.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:n,config:e})=>{const t=e?.type==="highlight"?e.color:"";t?n.chain().focus().setHighlight({color:t}).run():n.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:n=>n.isActive("highlight"),label:"Highlight"},link:{execute:({editor:n,config:e})=>{const t=e?.type==="link"?e.href:"";if(t){const r=e?.type==="link"?e.target:void 0,i=e?.type==="link"?e.rel:void 0;n.chain().focus().setLink({href:t,target:r,rel:i}).run()}else n.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:n=>n.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:n})=>n.chain().focus().setParagraph().run(),canExecute:n=>n.can().chain().focus().setParagraph().run(),isActive:n=>n.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:n,config:e})=>{const t=e?.type==="heading"?e.level:1;n.chain().focus().toggleHeading({level:t}).run()},canExecute:(n,e)=>{const t=e?.type==="heading"?e.level:1;return n.can().chain().focus().toggleHeading({level:t}).run()},isActive:(n,e)=>e?.type==="heading"?n.isActive("heading",{level:e.level}):n.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:n})=>n.chain().focus().toggleBulletList().run(),canExecute:n=>n.can().chain().focus().toggleBulletList().run(),isActive:n=>n.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:n})=>n.chain().focus().toggleOrderedList().run(),canExecute:n=>n.can().chain().focus().toggleOrderedList().run(),isActive:n=>n.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:n})=>n.chain().focus().toggleTaskList().run(),canExecute:n=>n.can().chain().focus().toggleTaskList().run(),isActive:n=>n.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:n})=>n.chain().focus().toggleCodeBlock().run(),canExecute:n=>n.can().chain().focus().toggleCodeBlock().run(),isActive:n=>n.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:n})=>n.chain().focus().toggleBlockquote().run(),canExecute:n=>n.can().chain().focus().toggleBlockquote().run(),isActive:n=>n.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:n})=>n.chain().focus().setHorizontalRule().run(),canExecute:n=>n.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:n})=>n.chain().focus().setHardBreak().run(),canExecute:n=>n.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:n,config:e})=>{const t=e?.type==="textAlign"?e.alignment:"left";n.chain().focus().setTextAlign(t).run()},canExecute:()=>!0,isActive:(n,e)=>e?.type==="textAlign"?n.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:n})=>n.chain().focus().unsetAllMarks().run(),canExecute:n=>n.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:n})=>n.chain().focus().clearNodes().run(),canExecute:n=>n.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:n})=>n.chain().focus().undo().run(),canExecute:n=>n.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:n})=>n.chain().focus().redo().run(),canExecute:n=>n.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},_s={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Gs({editor:n,levels:e=[1,2,3,4,5,6],isDisabled:t=!1}){const[,r]=A.useState(0);A.useEffect(()=>{const o=()=>r(l=>l+1);return n.on("selectionUpdate",o),n.on("transaction",o),()=>{n.off("selectionUpdate",o),n.off("transaction",o)}},[n]);const i=e.find(o=>n.isActive("heading",{level:o})),s=o=>{const l=Number(o),a=ce.heading;a&&a.execute({editor:n,config:{type:"heading",level:l}})};return m.jsxs(S.Dropdown,{children:[m.jsx(S.DropdownTrigger,{children:m.jsx(S.Button,{size:"sm",radius:"sm",variant:i?"solid":"bordered",color:i?"primary":"default",isDisabled:t,startContent:m.jsx(M.Heading,{size:16}),"aria-label":"Select heading level",children:i?`H${i}`:"H"})}),m.jsx(S.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:i?new Set([String(i)]):new Set,onAction:s,children:e.map(o=>m.jsx(S.DropdownItem,{startContent:n.isActive("heading",{level:o})?m.jsx(M.Check,{size:16}):m.jsx("div",{className:"w-4"}),children:_s[o]},o))})]})}const Qt={bulletList:{label:"Bullet List",icon:M.List},orderedList:{label:"Numbered List",icon:M.ListOrdered},taskList:{label:"Task List",icon:M.ListTodo}};function Zs({editor:n,types:e=["bulletList","orderedList","taskList"],isDisabled:t=!1}){const[,r]=A.useState(0);A.useEffect(()=>{const l=()=>r(a=>a+1);return n.on("selectionUpdate",l),n.on("transaction",l),()=>{n.off("selectionUpdate",l),n.off("transaction",l)}},[n]);const i=e.find(l=>n.isActive(l)),s=i?Qt[i].icon:M.List,o=l=>{const c=ce[l];c&&c.execute({editor:n})};return m.jsxs(S.Dropdown,{children:[m.jsx(S.DropdownTrigger,{children:m.jsx(S.Button,{size:"sm",radius:"sm",variant:i?"solid":"bordered",color:i?"primary":"default",isDisabled:t,isIconOnly:!0,"aria-label":"Select list type",children:m.jsx(s,{size:16})})}),m.jsx(S.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:i?new Set([i]):new Set,onAction:o,children:e.map(l=>{const a=Qt[l].icon;return m.jsx(S.DropdownItem,{startContent:m.jsx(a,{size:16}),children:Qt[l].label},l)})})]})}function Xs({colors:n,selectedColor:e,onColorSelect:t,columns:r=4}){return m.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:n.map(i=>{const s=e===i;return m.jsx("button",{type:"button",onClick:()=>t(i),className:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),b=require("@heroui/react"),T=require("react"),Te=require("framer-motion"),Ft=require("@tiptap/react"),k=require("lucide-react"),m=require("@tiptap/core"),Br=require("@tiptap/extension-underline"),Fr=require("@tiptap/extension-color"),Hr=require("@tiptap/extension-highlight"),jr=require("@tiptap/extension-link"),$r=require("@tiptap/extension-task-list"),qr=require("@tiptap/extension-task-item"),Jr=require("@tiptap/extension-text-align"),Me={brand:{primary:"#C14615",secondary:"#000000",accent:"#F59E0B"},semantic:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},neutral:{white:"#FFFFFF",black:"#000000",gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"}}},Kr={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem","4xl":"6rem","5xl":"8rem"},Vr={fontFamily:{primary:'"NeueMontreal", system-ui, sans-serif',secondary:'"Scholar", Georgia, serif',sans:'"NeueMontreal", system-ui, sans-serif',serif:'"Scholar", Georgia, serif',mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem"},fontWeight:{normal:"400",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.75"}},Ur={colors:{primary:{50:"#fef5f1",100:"#fde8e0",200:"#fbd5c7",300:"#f7b79f",400:"#f18d68",500:Me.brand.primary,600:"#a83b11",700:"#8b2f0e",800:"#73260d",900:"#5f210c",DEFAULT:Me.brand.primary},secondary:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:Me.brand.secondary,600:"#000000",700:"#000000",800:"#000000",900:"#000000",DEFAULT:Me.brand.secondary}}};function Wr({children:n}){return f.jsx(b.HeroUIProvider,{children:n})}function Zr({color:n="primary",radius:e="full",...t}){return f.jsx(b.Button,{color:n,radius:e,...t})}function _r(n){return f.jsx("div",{className:"w-full p-8",children:f.jsx("div",{className:"container mx-auto flex items-center justify-center",children:f.jsx(b.Alert,{description:"This component needs to be implemented using HeroUI Navbar, NavbarBrand, NavbarContent, and NavbarItem components. Include logo, navigation links, language selector dropdown, and authentication state.",title:"TODO: Implement Navbar Pattern",variant:"faded"})})})}var ft;const Gr=typeof document<"u"?(ft=T.useInsertionEffect)!==null&&ft!==void 0?ft:T.useLayoutEffect:()=>{};function Xr(n,e,t){let[r,s]=T.useState(n||e),i=T.useRef(r),o=T.useRef(n!==void 0),l=n!==void 0;T.useEffect(()=>{let d=o.current;d!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${d?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?n:r;Gr(()=>{i.current=a});let[,c]=T.useReducer(()=>({}),{}),u=T.useCallback((d,...h)=>{let p=typeof d=="function"?d(i.current):d;Object.is(i.current,p)||(i.current=p,s(p),c(),t?.(p,...h))},[t]);return[a,u]}function Yr(n){return f.jsx("svg",{...n,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:f.jsx(Te.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const Ln=T.forwardRef(({color:n="primary",stepsCount:e=3,defaultStep:t=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,...c},u)=>{const[d,h]=Xr(i,t,s),p=T.useMemo(()=>{let y,g;const x=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(n){case"primary":y="[--step-color:var(--heroui-primary)]",g="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":y="[--step-color:var(--heroui-secondary)]",g="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":y="[--step-color:var(--heroui-success)]",g="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":y="[--step-color:var(--heroui-warning)]",g="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":y="[--step-color:var(--heroui-danger)]",g="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":y="[--step-color:var(--heroui-default)]",g="[--step-fg-color:var(--heroui-default-foreground)]";break;default:y="[--step-color:var(--heroui-primary)]",g="[--step-fg-color:var(--heroui-primary-foreground)]";break}return x.unshift(g),x.unshift(y),x},[n]);return f.jsxs("nav",{ref:u,"aria-label":"Progress",className:b.cn("flex max-w-fit items-center overflow-x-auto",a),...c,children:[r&&f.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3",children:r}),f.jsx("ol",{className:b.cn("flex flex-row flex-nowrap gap-x-3",p,a),children:Array.from({length:e})?.map((y,g)=>{const x=d===g?"active":d<g?"inactive":"complete";return f.jsx("li",{className:"relative flex w-full items-center pr-12",children:f.jsxs("button",{"aria-current":x==="active"?"step":void 0,className:b.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",l),onClick:()=>h(g),children:[f.jsx("div",{className:"h-full relative flex items-center",children:f.jsx(Te.LazyMotion,{features:Te.domAnimation,children:f.jsx(Te.m.div,{animate:x,className:"relative",children:f.jsx(Te.m.div,{animate:x,className:b.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":x==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:f.jsx("div",{className:"flex items-center justify-center",children:x==="complete"?f.jsx(Yr,{className:"h-5 w-5 text-(--active-fg-color)"}):f.jsx("span",{})})})})})}),g<e-1&&!o&&f.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":g},children:f.jsx("div",{className:b.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":g<d})})})]},g)},g)})})]})});Ln.displayName="Stepper";function Qr(n){return f.jsx("footer",{className:"w-full py-12",children:f.jsx("div",{className:"container mx-auto px-6 flex items-center justify-center",children:f.jsx(b.Alert,{description:"This component needs to be implemented using HeroUI Link components. Include grid layout with link sections, logo, social media icons, and copyright text. Should be responsive and adapt to mobile/desktop.",title:"TODO: Implement Footer Pattern",variant:"faded"})})})}function we(n){return typeof n=="string"?n:n.type}function oe({className:n}){return f.jsx("div",{className:`flex items-center h-6 ${n||""}`,children:f.jsx(b.Divider,{orientation:"vertical"})})}function Q({icon:n,label:e,isActive:t=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return f.jsx(b.Tooltip,{content:a,children:f.jsx(b.Button,{size:"sm",radius:"sm",color:t?"primary":"default",variant:t?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:f.jsx(n,{size:o})})})}const X={bold:{execute:({editor:n})=>n.chain().focus().toggleBold().run(),canExecute:n=>n.can().chain().focus().toggleBold().run(),isActive:n=>n.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:n})=>n.chain().focus().toggleItalic().run(),canExecute:n=>n.can().chain().focus().toggleItalic().run(),isActive:n=>n.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:n})=>n.chain().focus().toggleStrike().run(),canExecute:n=>n.can().chain().focus().toggleStrike().run(),isActive:n=>n.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:n})=>n.chain().focus().toggleUnderline().run(),canExecute:n=>n.can().chain().focus().toggleUnderline().run(),isActive:n=>n.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:n})=>n.chain().focus().toggleCode().run(),canExecute:n=>n.can().chain().focus().toggleCode().run(),isActive:n=>n.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:n,config:e})=>{const t=e?.type==="textColor"?e.color:"";t?n.chain().focus().setColor(t).run():n.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:n=>n.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:n,config:e})=>{const t=e?.type==="highlight"?e.color:"";t?n.chain().focus().setHighlight({color:t}).run():n.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:n=>n.isActive("highlight"),label:"Highlight"},link:{execute:({editor:n,config:e})=>{const t=e?.type==="link"?e.href:"";if(t){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;n.chain().focus().setLink({href:t,target:r,rel:s}).run()}else n.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:n=>n.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:n})=>n.chain().focus().setParagraph().run(),canExecute:n=>n.can().chain().focus().setParagraph().run(),isActive:n=>n.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:n,config:e})=>{const t=e?.type==="heading"?e.level:1;n.chain().focus().toggleHeading({level:t}).run()},canExecute:(n,e)=>{const t=e?.type==="heading"?e.level:1;return n.can().chain().focus().toggleHeading({level:t}).run()},isActive:(n,e)=>e?.type==="heading"?n.isActive("heading",{level:e.level}):n.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:n})=>n.chain().focus().toggleBulletList().run(),canExecute:n=>n.can().chain().focus().toggleBulletList().run(),isActive:n=>n.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:n})=>n.chain().focus().toggleOrderedList().run(),canExecute:n=>n.can().chain().focus().toggleOrderedList().run(),isActive:n=>n.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:n})=>n.chain().focus().toggleTaskList().run(),canExecute:n=>n.can().chain().focus().toggleTaskList().run(),isActive:n=>n.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:n})=>n.chain().focus().toggleCodeBlock().run(),canExecute:n=>n.can().chain().focus().toggleCodeBlock().run(),isActive:n=>n.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:n})=>n.chain().focus().toggleBlockquote().run(),canExecute:n=>n.can().chain().focus().toggleBlockquote().run(),isActive:n=>n.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:n})=>n.chain().focus().setHorizontalRule().run(),canExecute:n=>n.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:n})=>n.chain().focus().setHardBreak().run(),canExecute:n=>n.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:n,config:e})=>{const t=e?.type==="textAlign"?e.alignment:"left";n.chain().focus().setTextAlign(t).run()},canExecute:()=>!0,isActive:(n,e)=>e?.type==="textAlign"?n.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:n})=>n.chain().focus().unsetAllMarks().run(),canExecute:n=>n.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:n})=>n.chain().focus().clearNodes().run(),canExecute:n=>n.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:n})=>n.chain().focus().undo().run(),canExecute:n=>n.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:n})=>n.chain().focus().redo().run(),canExecute:n=>n.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},es={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function ts({editor:n,levels:e=[1,2,3,4,5,6],isDisabled:t=!1}){const[,r]=T.useState(0);T.useEffect(()=>{const o=()=>r(l=>l+1);return n.on("selectionUpdate",o),n.on("transaction",o),()=>{n.off("selectionUpdate",o),n.off("transaction",o)}},[n]);const s=e.find(o=>n.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=X.heading;a&&a.execute({editor:n,config:{type:"heading",level:l}})};return f.jsxs(b.Dropdown,{children:[f.jsx(b.DropdownTrigger,{children:f.jsx(b.Button,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:t,startContent:f.jsx(k.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),f.jsx(b.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>f.jsx(b.DropdownItem,{startContent:n.isActive("heading",{level:o})?f.jsx(k.Check,{size:16}):f.jsx("div",{className:"w-4"}),children:es[o]},o))})]})}const ht={bulletList:{label:"Bullet List",icon:k.List},orderedList:{label:"Numbered List",icon:k.ListOrdered},taskList:{label:"Task List",icon:k.ListTodo}};function ns({editor:n,types:e=["bulletList","orderedList","taskList"],isDisabled:t=!1}){const[,r]=T.useState(0);T.useEffect(()=>{const l=()=>r(a=>a+1);return n.on("selectionUpdate",l),n.on("transaction",l),()=>{n.off("selectionUpdate",l),n.off("transaction",l)}},[n]);const s=e.find(l=>n.isActive(l)),i=s?ht[s].icon:k.List,o=l=>{const c=X[l];c&&c.execute({editor:n})};return f.jsxs(b.Dropdown,{children:[f.jsx(b.DropdownTrigger,{children:f.jsx(b.Button,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:t,isIconOnly:!0,"aria-label":"Select list type",children:f.jsx(i,{size:16})})}),f.jsx(b.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=ht[l].icon;return f.jsx(b.DropdownItem,{startContent:f.jsx(a,{size:16}),children:ht[l].label},l)})})]})}function rs({colors:n,selectedColor:e,onColorSelect:t,columns:r=4}){return f.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:n.map(s=>{const i=e===s;return f.jsx("button",{type:"button",onClick:()=>t(s),className:`
|
|
2
2
|
w-8 h-8 rounded-full border-2 cursor-pointer
|
|
3
3
|
transition-all duration-200
|
|
4
4
|
hover:scale-110 hover:shadow-md
|
|
5
5
|
focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2
|
|
6
|
-
${
|
|
7
|
-
`,style:{backgroundColor:
|
|
6
|
+
${i?"border-primary ring-2 ring-primary ring-offset-2 scale-110":"border-divider"}
|
|
7
|
+
`,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const ss=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],is=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function pt(n){return/^#([0-9A-F]{3}){1,2}$/i.test(n)}const R={min:50,max:200,step:10,default:100},Qt={lineHeight:24,toolbarHeight:60},os={bold:k.Bold,italic:k.Italic,strike:k.Strikethrough,underline:k.Underline,code:k.Code,textColor:k.Palette,highlight:k.Highlighter,link:k.Link2,paragraph:k.FileText,heading:k.Heading,bulletList:k.List,orderedList:k.ListOrdered,taskList:k.ListTodo,codeBlock:k.CodeSquare,blockquote:k.Quote,horizontalRule:k.Minus,clearMarks:k.Eraser,clearNodes:k.Eraser,undo:k.Undo2,redo:k.Redo2,hardBreak:k.CornerDownLeft,textAlign:k.AlignLeft},ls={left:k.AlignLeft,center:k.AlignCenter,right:k.AlignRight,justify:k.AlignJustify};function le(n){return os[n]}function as({value:n,onChange:e,onApply:t,placeholder:r="#000000"}){const[s,i]=T.useState(""),o=c=>{const u=c.target.value;e(u),s&&i("")},l=()=>{if(!n){i("Please enter a color");return}if(!pt(n)){i("Invalid hex color (e.g., #FF0000)");return}i(""),t(n)},a=c=>{c.key==="Enter"&&(c.preventDefault(),l())};return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx(b.Input,{type:"text",value:n,onChange:o,onKeyDown:a,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:f.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:pt(n)?n:"transparent"}})}),f.jsx(b.Button,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!n||!pt(n),children:f.jsx(k.Check,{size:16})})]}),f.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function en({editor:n,type:e,allowCustomColor:t=!0,label:r,isDisabled:s=!1}){const[i,o]=T.useState(!1),[l,a]=T.useState(""),c=e==="textColor"?ss:is,u=g=>{const x=X[e];x&&x.execute({editor:n,config:{type:e,color:g}}),o(!1),a("")},d=g=>{u(g)},h=()=>{const g=X[e];g&&g.execute({editor:n,config:{type:e,color:""}}),o(!1)},p=e==="textColor"?n.isActive("textStyle"):n.isActive("highlight"),y=e==="textColor"?k.Palette:k.Highlighter;return f.jsxs(b.Popover,{isOpen:i,onOpenChange:o,placement:"bottom",showArrow:!0,children:[f.jsx(b.PopoverTrigger,{children:f.jsx(b.Button,{size:"sm",radius:"sm",variant:p?"solid":"bordered",color:p?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:f.jsx(y,{size:16})})}),f.jsx(b.PopoverContent,{className:"w-64",children:f.jsxs("div",{className:"px-2 py-3 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm font-semibold",children:r}),f.jsx(b.Button,{size:"sm",variant:"light",isIconOnly:!0,onPress:h,"aria-label":"Clear color",children:f.jsx(k.X,{size:16})})]}),f.jsx(rs,{colors:c,onColorSelect:u}),t&&f.jsxs(f.Fragment,{children:[f.jsx(b.Divider,{}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),f.jsx(as,{value:l,onChange:a,onApply:d})]})]})]})})]})}function cs({zoom:n,onZoomChange:e,min:t=R.min,max:r=R.max,step:s=R.step}){const i=()=>{const d=Math.max(t,n-s);e(d)},o=()=>{const d=Math.min(r,n+s);e(d)},l=()=>{e(R.default)},a=n<=t,c=n>=r,u=n===R.default;return f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(b.Tooltip,{content:"Zoom out",children:f.jsx(b.Button,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:a,onPress:i,"aria-label":"Zoom out",children:f.jsx(k.ZoomOut,{size:16})})}),f.jsx(b.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",children:f.jsxs("button",{type:"button",onClick:l,disabled:u,className:`
|
|
8
8
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
9
9
|
${u?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
-
`,"aria-label":`Zoom level ${n}%`,children:[n,"%"]})}),m.jsx(S.Tooltip,{content:"Zoom in",children:m.jsx(S.Button,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:o,"aria-label":"Zoom in",children:m.jsx(M.ZoomIn,{size:16})})})]})}function io({children:n,id:e,label:t,className:r,useButtonGroup:i=!0}){return i?m.jsx(S.ButtonGroup,{size:"sm",id:e,"aria-label":t,className:r,children:n}):m.jsx("div",{id:e,role:"group","aria-label":t,className:`flex items-center gap-2 ${r||""}`,children:n})}function Gr(n,e){const t=A.useMemo(()=>{if(!n)return{};const s={};return Array.from(new Set(e.map(l=>rt(l)))).forEach(l=>{const a=ce[l];if(a)try{const c=a.canExecute?.(n)??!0,u=a.isActive?.(n)??!1;s[l]={isActive:u,isDisabled:!c,canExecute:c}}catch(c){console.warn(`Extension not available for modifier: ${l}`,c),s[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s},[n,e]),[r,i]=A.useState(t);return A.useEffect(()=>{if(!n)return;const s=()=>{const o={};Array.from(new Set(e.map(a=>rt(a)))).forEach(a=>{const c=ce[a];if(c)try{const u=c.canExecute?.(n)??!0,f=c.isActive?.(n)??!1;o[a]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${a}`,u),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i(o)};return n.on("selectionUpdate",s),n.on("transaction",s),()=>{n.off("selectionUpdate",s),n.off("transaction",s)}},[n,e,t]),r}function Zr(n){const e=A.useCallback((s,o)=>{if(!n)return;const l=ce[s];if(l)try{l.execute({editor:n,config:o})}catch(a){console.warn(`Failed to execute command for modifier: ${s}`,a)}},[n]),t=A.useCallback(s=>{e(s)},[e]),r=A.useCallback((s,o)=>{if(!n)return!1;const l=ce[s];try{return l?.canExecute?.(n,o)??!1}catch(a){return console.warn(`Failed to check canExecute for modifier: ${s}`,a),!1}},[n]),i=A.useCallback((s,o)=>{if(!n)return!1;const l=ce[s];try{return l?.isActive?.(n,o)??!1}catch(a){return console.warn(`Failed to check isActive for modifier: ${s}`,a),!1}},[n]);return{executeCommand:e,toggleModifier:t,canExecute:r,isActive:i}}function so(n=$.default){const[e,t]=A.useState(n),r=A.useCallback((l=$.step)=>{t(a=>Math.min($.max,a+l))},[]),i=A.useCallback((l=$.step)=>{t(a=>Math.max($.min,a-l))},[]),s=A.useCallback(()=>{t($.default)},[]),o=A.useCallback(l=>{const a=Math.max($.min,Math.min($.max,l));t(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:i,resetZoom:s,isMinZoom:e<=$.min,isMaxZoom:e>=$.max,isDefaultZoom:e===$.default}}const oo=["bold","italic","strike","underline","code"];function lo({editor:n,modifiers:e}){const t=Gr(n,e),{toggleModifier:r}=Zr(n);if(!n)return null;const i=e.map(s=>rt(s)).filter(s=>oo.includes(s));return i.length===0?null:m.jsx(io,{id:"text-formatting",label:"Text formatting",children:i.map(s=>{const o=t[s],l=we(s);return m.jsx(de,{icon:l,label:s.charAt(0).toUpperCase()+s.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(s)},s)})})}function ao({editor:n,modifiers:e,zoom:t=100,onZoomChange:r,sticky:i=!0,className:s}){const o=Gr(n,e),{toggleModifier:l,executeCommand:a}=Zr(n);if(!n)return null;const c=e.map(T=>rt(T)),u=c.some(T=>["bold","italic","strike","underline","code"].includes(T)),f=c.some(T=>["textColor","highlight"].includes(T)),d=c.includes("heading"),h=c.includes("textAlign"),g=c.some(T=>["bulletList","orderedList","taskList"].includes(T)),p=c.includes("blockquote"),y=c.includes("codeBlock"),b=c.includes("link"),O=c.includes("horizontalRule"),E=c.some(T=>["undo","redo"].includes(T)),R=t!==void 0&&r!==void 0,j=i?"sticky top-0 z-10":"";return m.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${j} ${s||""}`,children:m.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[u&&m.jsxs(m.Fragment,{children:[m.jsx(lo,{editor:n,modifiers:e}),(f||d||h||g||p||y||b||O||E||R)&&m.jsx(Se,{})]}),f&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-1",children:[c.includes("textColor")&&m.jsx(ir,{editor:n,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),c.includes("highlight")&&m.jsx(ir,{editor:n,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(d||h||g||p||y||b||O||E||R)&&m.jsx(Se,{})]}),d&&m.jsxs(m.Fragment,{children:[m.jsx(Gs,{editor:n}),(h||g||p||y||b||O||E||R)&&m.jsx(Se,{})]}),h&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(T=>{const ie=to[T],G=n.isActive({textAlign:T});return m.jsx(de,{icon:ie,label:`Align ${T}`,isActive:G,onClick:()=>a("textAlign",{type:"textAlign",alignment:T})},T)})}),(g||p||y||b||O||E||R)&&m.jsx(Se,{})]}),g&&m.jsxs(m.Fragment,{children:[m.jsx(Zs,{editor:n,types:c.filter(T=>["bulletList","orderedList","taskList"].includes(T))}),(p||y||b||O||E||R)&&m.jsx(Se,{})]}),(p||y||b||O)&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-1",children:[p&&m.jsx(de,{icon:we("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>l("blockquote")}),y&&m.jsx(de,{icon:we("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>l("codeBlock")}),b&&m.jsx(de,{icon:we("link"),label:"Link",isActive:o.link?.isActive,isDisabled:o.link?.isDisabled,onClick:()=>{const T=window.prompt("Enter URL:");T&&a("link",{type:"link",href:T})}}),O&&m.jsx(de,{icon:we("horizontalRule"),label:"Horizontal rule",onClick:()=>l("horizontalRule")})]}),(E||R)&&m.jsx(Se,{})]}),E&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-1",children:[c.includes("undo")&&m.jsx(de,{icon:we("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>l("undo")}),c.includes("redo")&&m.jsx(de,{icon:we("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>l("redo")})]}),R&&m.jsx(Se,{})]}),R&&m.jsx(ro,{zoom:t,onZoomChange:r})]})})}function z(n){this.content=n}z.prototype={constructor:z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new z(t)},addToStart:function(n,e){return new z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new z(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new z(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=z.from(n),n.size?new z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=z.from(n),n.size?new z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};z.from=function(n){if(n instanceof z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new z(e)};function Xr(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Xr(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Yr(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Yr(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class x{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new x(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new x(r,i)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new x(i,s)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Xr(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Yr(this,e,t,r)}findIndex(e){if(e==0)return pt(0,e);if(e==this.size)return pt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?pt(t+1,s):pt(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new x(t||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const tn={index:0,offset:0};function pt(n,e){return tn.index=n,tn.offset=e,tn}function Mt(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Mt(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Mt(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let I=class yn{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Mt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return yn.none;if(e instanceof yn)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};I.none=[];class vt extends Error{}class k{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ei(this.content,e+this.openStart,t);return r&&new k(r,this.openStart,this.openEnd)}removeBetween(e,t){return new k(Qr(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return k.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new k(x.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new k(e,r,i)}}k.empty=new k(x.empty,0,0);function Qr(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Qr(s.content,e-i-1,t-i-1)))}function ei(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=ei(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}function co(n,e,t){if(t.openStart>n.depth)throw new vt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new vt("Inconsistent open depths");return ti(n,e,t,0)}function ti(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=ti(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Ie(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=uo(t,n);return Ie(s,ri(n,o,l,e,r))}else return Ie(s,At(n,e,r))}function ni(n,e){if(!e.type.compatibleContent(n.type))throw new vt("Cannot join "+e.type.name+" onto "+n.type.name)}function xn(n,e,t){let r=n.node(t);return ni(r,e.node(t)),r}function Oe(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Qe(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Oe(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Oe(i.child(l),r);e&&e.depth==t&&e.textOffset&&Oe(e.nodeBefore,r)}function Ie(n,e){return n.type.checkContent(e),n.copy(e)}function ri(n,e,t,r,i){let s=n.depth>i&&xn(n,e,i+1),o=r.depth>i&&xn(t,r,i+1),l=[];return Qe(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(ni(s,o),Oe(Ie(s,ri(n,e,t,r,i+1)),l)):(s&&Oe(Ie(s,At(n,e,i+1)),l),Qe(e,t,i,l),o&&Oe(Ie(o,At(t,r,i+1)),l)),Qe(r,null,i,l),new x(l)}function At(n,e,t){let r=[];if(Qe(null,n,t,r),n.depth>t){let i=xn(n,e,t+1);Oe(Ie(i,At(n,e,t+1)),r)}return Qe(e,null,t,r),new x(r)}function uo(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(x.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class it{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Tt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new it(t,r,s)}static resolveCached(e,t){let r=sr.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else sr.set(e,r=new fo);let i=r.elts[r.i]=it.resolve(e,t);return r.i=(r.i+1)%ho,i}}class fo{constructor(){this.elts=[],this.i=0}}const ho=12,sr=new WeakMap;class Tt{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const po=Object.create(null);let Ne=class bn{constructor(e,t,r,i=I.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Mt(this.attrs,t||e.defaultAttrs||po)&&I.sameSet(this.marks,r||I.none)}copy(e=null){return e==this.content?this:new bn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new bn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return k.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new k(c,i.depth-o,s.depth-o)}replace(e,t,r){return co(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return it.resolveCached(this,e)}resolveNoCache(e){return it.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ii(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=x.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!I.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=x.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Ne.prototype.text=void 0;class Et extends Ne{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ii(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Et(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Et(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ii(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Pe{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new mo(e,t);if(r.next==null)return Pe.empty;let i=si(r);r.next&&r.err("Unexpected trailing text");let s=So(Co(i));return wo(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return x.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:f}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
11
|
-
`)}}Pe.empty=new Pe(!0);class mo{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function si(n){let e=[];do e.push(go(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function go(n){let e=[];do e.push(yo(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function yo(n){let e=ko(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=xo(n,e);else break;return e}function or(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function xo(n,e){let t=or(n),r=t;return n.eat(",")&&(n.next!="}"?r=or(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function bo(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function ko(n){if(n.eat("(")){let e=si(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=bo(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Co(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function oi(n,e){return e-n}function lr(n,e){let t=[];return r(e),t.sort(oi);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function So(n){let e=Object.create(null);return t(lr(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);lr(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Pe(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(oi);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function wo(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function li(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function ai(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function ci(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function ui(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new vo(n,r,e[r]);return t}let ar=class fi{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ui(e,r.attrs),this.defaultAttrs=li(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ai(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ne(this,this.computeAttrs(e),x.from(t),I.setFrom(r))}createChecked(e=null,t,r){return t=x.from(t),this.checkContent(t),new Ne(this,this.computeAttrs(e),t,I.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=x.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(x.empty,!0);return s?new Ne(this,e,t.append(s),I.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ci(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:I.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new fi(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Mo(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class vo{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Mo(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Dn{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=ui(e,i.attrs),this.excluded=null;let s=li(this.attrs);this.instance=s?new I(this,s):null}create(e=null){return!e&&this.instance?this.instance:new I(this,ai(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Dn(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){ci(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ao{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=z.from(e.nodes),t.marks=z.from(e.marks||{}),this.nodes=ar.compile(this.spec.nodes,this),this.marks=Dn.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Pe.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?cr(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:cr(this,o.split(" "))}this.nodeFromJSON=i=>Ne.fromJSON(this,i),this.markFromJSON=i=>I.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ar){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Et(r,r.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function cr(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function To(n){return n.tag!=null}function Eo(n){return n.style!=null}class Re{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(To(i))this.tags.push(i);else if(Eo(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new fr(this,t,!1);return r.addAll(e,I.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new fr(this,t,!0);return r.addAll(e,I.none,t.from,t.to),k.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(No(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=dr(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=dr(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Re(e,Re.schemaRules(e)))}}const di={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Oo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hi={ol:!0,ul:!0},st=1,kn=2,et=4;function ur(n,e,t){return e!=null?(e?st:0)|(e==="full"?kn:0):n&&n.whitespace=="pre"?st|kn:t&~et}class mt{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=I.none,this.match=s||(o&et?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&st)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!di.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class fr{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=ur(null,t.preserveWhitespace,0)|(r?et:0);i?s=new mt(i.type,i.attrs,I.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new mt(null,null,I.none,!0,null,o):s=new mt(e.schema.topNodeType,null,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&kn?"full":this.localPreserveWS||(i.options&st)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
12
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;hi.hasOwnProperty(o)&&this.parser.normalizeLists&&Io(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Oo.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(di.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
13
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=I.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):hr(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=ur(e,s,o.options);o.options&et&&o.content.length==0&&(l|=et);let a=I.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):hr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new mt(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=st)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Io(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&hi.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function No(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function dr(n){let e={};for(let t in n)e[t]=n[t];return e}function hr(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class $t{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=nn(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=kt(nn(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&kt(nn(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return kt(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=pr(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return pr(e.marks)}}function pr(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function nn(n){return n.document||window.document}const mr=new WeakMap;function Ro(n){let e=mr.get(n);return e===void 0&&mr.set(n,e=Do(n)),e}function Do(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function kt(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ro(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:g}=kt(n,d,t,r);if(a.appendChild(h),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const pi=65535,mi=Math.pow(2,16);function Lo(n,e){return n+e*mi}function gr(n){return n&pi}function Bo(n){return(n-(n&pi))/mi}const gi=1,yi=2,Ct=4,xi=8;class Cn{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&xi)>0}get deletedBefore(){return(this.delInfo&(gi|Ct))>0}get deletedAfter(){return(this.delInfo&(yi|Ct))>0}get deletedAcross(){return(this.delInfo&Ct)>0}}class X{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&X.empty)return X.empty}recover(e){let t=0,r=gr(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Bo(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let g=e==(t<0?a:f)?null:Lo(l/3,e-a),p=e==a?yi:e==f?gi:Ct;return(t<0?e!=a:e!=f)&&(p|=xi),new Cn(h,p,g)}i+=u-c}return r?e+i:new Cn(e+i,0,null)}touches(e,t){let r=0,i=gr(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new X(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?X.empty:new X(e<0?[0,-e,0]:[0,0,e])}}X.empty=new X([]);class Ot{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Ot(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ot;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Cn(e,i,null)}}const rn=Object.create(null);class J{getMap(){return X.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=rn[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in rn)throw new RangeError("Duplicate use of step JSON ID "+e);return rn[e]=t,t.prototype.jsonID=e,t}}class D{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new D(e,null)}static fail(e){return new D(null,e)}static fromReplace(e,t,r,i){try{return D.ok(e.replace(t,r,i))}catch(s){if(s instanceof vt)return D.fail(s.message);throw s}}}function Ln(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Ln(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return x.fromArray(r)}class ve extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new k(Ln(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return D.fromReplace(e,this.from,this.to,s)}invert(){return new Ae(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ve(t.pos,r.pos,this.mark)}merge(e){return e instanceof ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ve(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ve(t.from,t.to,e.markFromJSON(t.mark))}}J.jsonID("addMark",ve);class Ae extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new k(Ln(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return D.fromReplace(e,this.from,this.to,r)}invert(){return new ve(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ae(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ae&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ae(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ae(t.from,t.to,e.markFromJSON(t.mark))}}J.jsonID("removeMark",Ae);class Te extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return D.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return D.fromReplace(e,this.pos,this.pos+1,new k(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Te(this.pos,t.marks[i]);return new Te(this.pos,this.mark)}}return new ot(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Te(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Te(t.pos,e.markFromJSON(t.mark))}}J.jsonID("addNodeMark",Te);class ot extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return D.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return D.fromReplace(e,this.pos,this.pos+1,new k(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Te(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ot(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ot(t.pos,e.markFromJSON(t.mark))}}J.jsonID("removeNodeMark",ot);class Z extends J{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Sn(e,this.from,this.to)?D.fail("Structure replace would overwrite content"):D.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new X([this.from,this.to-this.from,this.slice.size])}invert(e){return new Z(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Z(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Z)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Z(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Z(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Z(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}}J.jsonID("replace",Z);class K extends J{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Sn(e,this.from,this.gapFrom)||Sn(e,this.gapTo,this.to)))return D.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return D.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?D.fromReplace(e,this.from,this.to,r):D.fail("Content does not fit in gap")}getMap(){return new X([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new K(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new K(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new K(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}J.jsonID("replaceAround",K);function Sn(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Po(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ke(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!Po(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Bn(n,e,t=null,r=n){let i=zo(n,e),s=i&&Fo(r,e);return s?i.map(yr).concat({type:e,attrs:t}).concat(s.map(yr)):null}function yr(n){return{type:n,attrs:null}}function zo(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Fo(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function ue(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),g=r&&r[u+1];g&&(h=h.replaceChild(0,g.type.create(g.attrs)));let p=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!p.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function be(n,e){let t=n.resolve(e),r=t.index();return bi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function jo(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function bi(n,e){return!!(n&&e&&!n.isLeaf&&jo(n,e))}function Ht(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&bi(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function ki(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Pn(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return $o(i,s,r)?new Z(e,t,r):new Ho(i,s,r).fit()}function $o(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Ho{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new k(s,o,l);return e>-1?new K(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Z(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=sn(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(o?c.matchType(o.type)||(f=c.fillBefore(x.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=sn(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=sn(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new k(Ze(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new k(Ze(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let p=0;p<s.length;p++)this.openFrontierNode(s[p]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let p=0;p<i.childCount;p++)u.push(i.child(p));f=f.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let p=l.child(c),y=f.matchType(p.type);if(!y)break;c++,(c>1||a==0||p.content.size)&&(f=y,u.push(Ci(p.mark(d.allowedMarks(p.marks)),c==1?a:0,c==l.childCount?h:-1)))}let g=c==l.childCount;g||(h=-1),this.placed=Xe(this.placed,t,x.from(u)),this.frontier[t].match=f,g&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let p=0,y=l;p<h;p++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=g?e==0?k.empty:new k(Ze(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new k(Ze(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!on(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=on(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=on(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Xe(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Xe(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Xe(this.placed,this.frontier.length,t))}}function Ze(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ze(n.firstChild.content,e-1,t)))}function Xe(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Xe(n.lastChild.content,e-1,t)))}function sn(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ci(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Ci(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),n.copy(r)}function on(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Vo(t,s.content,o)?l:null}function Vo(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}class tt extends J{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return D.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return D.fromReplace(e,this.pos,this.pos+1,new k(x.from(i),0,t.isLeaf?0:1))}getMap(){return X.empty}invert(e){return new tt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new tt(t.pos,t.attr,t.value)}}J.jsonID("attr",tt);class It extends J{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return D.ok(r)}getMap(){return X.empty}invert(e){return new It(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new It(t.attr,t.value)}}J.jsonID("docAttr",It);let lt=class extends Error{};lt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};lt.prototype=Object.create(Error.prototype);lt.prototype.constructor=lt;lt.prototype.name="TransformError";const ln=Object.create(null);class v{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jo(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=k.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?k.empty:t),l==0&&kr(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),kr(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new w(e):$e(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?$e(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):$e(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Y(e.node(0))}static atStart(e){return $e(e,e,0,0,1)||new Y(e)}static atEnd(e){return $e(e,e,e.content.size,e.childCount,-1)||new Y(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ln[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ln)throw new RangeError("Duplicate use of selection JSON ID "+e);return ln[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}}v.prototype.visible=!0;class Jo{constructor(e,t){this.$from=e,this.$to=t}}let xr=!1;function br(n){!xr&&!n.parent.inlineContent&&(xr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class w extends v{constructor(e,t=e){br(e),br(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return v.near(r);let i=e.resolve(t.map(this.anchor));return new w(i.parent.inlineContent?i:r,r)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof w&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new w(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=v.findFrom(t,r,!0)||v.findFrom(t,-r,!0);if(s)t=s.$head;else return v.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(v.findFrom(e,-r,!0)||v.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new w(e,t)}}v.jsonID("text",w);class Vt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Vt(e.map(this.anchor),e.map(this.head))}resolve(e){return w.between(e.resolve(this.anchor),e.resolve(this.head))}}class C extends v{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?v.near(s):new C(s)}content(){return new k(x.from(this.node),0,0)}eq(e){return e instanceof C&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new zn(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new C(e.resolve(t.anchor))}static create(e,t){return new C(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}C.prototype.visible=!1;v.jsonID("node",C);class zn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Vt(r,r):new zn(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&C.isSelectable(r)?new C(t):v.near(t)}}class Y extends v{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let r=v.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Y(e)}map(e){return new Y(e)}eq(e){return e instanceof Y}getBookmark(){return qo}}v.jsonID("all",Y);const qo={map(){return this},resolve(n){return new Y(n)}};function $e(n,e,t,r,i,s=!1){if(e.inlineContent)return w.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&C.isSelectable(l))return C.create(n,t-(i<0?l.nodeSize:0))}else{let a=$e(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function kr(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Z||i instanceof K))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(v.near(n.doc.resolve(o),t))}function Cr(n,e){return!e||!n?n:n.bind(e)}class gt{constructor(e,t,r){this.name=e,this.init=Cr(t.init,r),this.apply=Cr(t.apply,r)}}new gt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new gt("selection",{init(n,e){return n.selection||v.atStart(e.doc)},apply(n){return n.selection}}),new gt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new gt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Si(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Si(i,e,{})),t[r]=i}return t}class ne{constructor(e){this.spec=e,this.props={},e.props&&Si(e.props,this,this.props),this.key=e.key?e.key.key:wi("plugin")}getState(e){return e[this.key]}}const an=Object.create(null);function wi(n){return n in an?n+"$"+ ++an[n]:(an[n]=0,n+"$")}class ae{constructor(e="key"){this.key=wi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ze=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Mi=function(n,e,t,r){return t&&(Sr(n,e,t,r,-1)||Sr(n,e,t,r,1))},Wo=/^(img|br|input|textarea|hr)$/i;function Sr(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Nt(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Fn(n)||Wo.test(n.nodeName)||n.contentEditable=="false")return!1;e=ze(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Nt(n):0}else return!1}}function Nt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ko(n,e,t){for(let r=e==0,i=e==Nt(n);r||i;){if(n==t)return!0;let s=ze(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Nt(n)}}function Fn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const vi=function(n){return n.focusNode&&Mi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ai(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const le=typeof navigator<"u"?navigator:null,wr=typeof document<"u"?document:null,ke=le&&le.userAgent||"",wn=/Edge\/(\d+)/.exec(ke),Ti=/MSIE \d/.exec(ke),Mn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ke),dt=!!(Ti||Mn||wn),Ei=Ti?document.documentMode:Mn?+Mn[1]:wn?+wn[1]:0,Jt=!dt&&/gecko\/(\d+)/i.test(ke);Jt&&+(/Firefox\/(\d+)/.exec(ke)||[0,0])[1];const vn=!dt&&/Chrome\/(\d+)/.exec(ke),fe=!!vn,Oi=vn?+vn[1]:0,Fe=!dt&&!!le&&/Apple Computer/.test(le.vendor),jn=Fe&&(/Mobile\/\w+/.test(ke)||!!le&&le.maxTouchPoints>2),ee=jn||(le?/Mac/.test(le.platform):!1),Ii=le?/Win/.test(le.platform):!1,ht=/Android \d/.test(ke),$n=!!wr&&"webkitFontSmoothing"in wr.documentElement.style,Uo=$n?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function _o(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(vi(t)){for(a=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&C.isSelectable(f)&&i.parent&&!(f.isInline&&Ko(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new C(o==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=o,d=o;for(let h=0;h<t.rangeCount;h++){let g=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(g.startContainer,g.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(f<0)return null;[a,o]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Ri(n,u,l,f)}return c}function Ni(n){return n.editable?n.hasFocus():Yo(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Hn(n,e=!1){let t=n.state.selection;if(Xo(n,t),!!Ni(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&fe){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Mi(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Zo(n);else{let{anchor:r,head:i}=t,s,o;Mr&&!(t instanceof w)&&(t.$from.parent.inlineContent||(s=vr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=vr(n,t.to))),n.docView.setSelection(r,i,n,e),Mr&&(s&&Ar(s),o&&Ar(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Go(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Mr=Fe||fe&&Oi<63;function vr(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Fe&&i&&i.contentEditable=="false")return cn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return cn(i);if(s)return cn(s)}}function cn(n){return n.contentEditable="true",Fe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ar(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Go(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ni(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Zo(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ze(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&dt&&Ei<=11&&(t.disabled=!0,t.disabled=!1)}function Xo(n,e){if(e instanceof C){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Tr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Tr(n)}function Tr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ri(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||w.between(e,t,r)}function Yo(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function An(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&v.findFrom(s,e)}function he(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Er(n,e,t){let r=n.state.selection;if(r instanceof w)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return he(n,new w(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=An(n.state,e);return i&&i instanceof C?he(n,i):!1}else if(!(ee&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?C.isSelectable(s)?he(n,new C(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):$n?he(n,new w(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof C&&r.node.isInline)return he(n,new w(e>0?r.$to:r.$from));{let i=An(n.state,e);return i?he(n,i):!1}}}function Rt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function nt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function je(n,e){return e<0?Qo(n):el(n)}function Qo(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Jt&&t.nodeType==1&&r<Rt(t)&&nt(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(nt(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Di(t))break;{let l=t.previousSibling;for(;l&&nt(l,-1);)i=t.parentNode,s=ze(l),l=l.previousSibling;if(l)t=l,r=Rt(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Tn(n,t,r):i&&Tn(n,i,s)}function el(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Rt(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(nt(l,1))s=t,o=++r;else break}else{if(Di(t))break;{let l=t.nextSibling;for(;l&&nt(l,1);)s=l.parentNode,o=ze(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Rt(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Tn(n,s,o)}function Di(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function tl(n,e){for(;n&&e==n.childNodes.length&&!Fn(n);)e=ze(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function nl(n,e){for(;n&&!e&&!Fn(n);)e=ze(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Tn(n,e,t){if(e.nodeType!=3){let s,o;(o=tl(e,t))?(e=o,t=0):(s=nl(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(vi(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Hn(n)},50)}function Or(n,e){let t=n.state.doc.resolve(e);if(!(fe||Ii)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ir(n,e,t){let r=n.state.selection;if(r instanceof w&&!r.empty||t.indexOf("s")>-1||ee&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=An(n.state,e);if(o&&o instanceof C)return he(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Y?v.near(o,e):v.findFrom(o,e);return l?he(n,l):!1}return!1}function Nr(n,e){if(!(n.state.selection instanceof w))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Rr(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function rl(n){if(!Fe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Rr(n,r,"true"),setTimeout(()=>Rr(n,r,"false"),20)}return!1}function il(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function sl(n,e){let t=e.keyCode,r=il(e);if(t==8||ee&&t==72&&r=="c")return Nr(n,-1)||je(n,-1);if(t==46&&!e.shiftKey||ee&&t==68&&r=="c")return Nr(n,1)||je(n,1);if(t==13||t==27)return!0;if(t==37||ee&&t==66&&r=="c"){let i=t==37?Or(n,n.state.selection.from)=="ltr"?-1:1:-1;return Er(n,i,r)||je(n,i)}else if(t==39||ee&&t==70&&r=="c"){let i=t==39?Or(n,n.state.selection.from)=="ltr"?1:-1:1;return Er(n,i,r)||je(n,i)}else{if(t==38||ee&&t==80&&r=="c")return Ir(n,-1,r)||je(n,-1);if(t==40||ee&&t==78&&r=="c")return rl(n)||Ir(n,1,r)||je(n,1);if(r==(ee?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Li(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||$t.fromSchema(n.state.schema),l=$i(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ji[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let g=l.createElement(u[h]);for(;a.firstChild;)g.appendChild(a.firstChild);a.appendChild(g),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
10
|
+
`,"aria-label":`Zoom level ${n}%`,children:[n,"%"]})}),f.jsx(b.Tooltip,{content:"Zoom in",children:f.jsx(b.Button,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:o,"aria-label":"Zoom in",children:f.jsx(k.ZoomIn,{size:16})})})]})}function us({children:n,id:e,label:t,className:r,useButtonGroup:s=!0}){return s?f.jsx(b.ButtonGroup,{size:"sm",id:e,"aria-label":t,className:r,children:n}):f.jsx("div",{id:e,role:"group","aria-label":t,className:`flex items-center gap-2 ${r||""}`,children:n})}function Rn(n,e){const t=T.useMemo(()=>{if(!n)return{};const i={};return Array.from(new Set(e.map(l=>we(l)))).forEach(l=>{const a=X[l];if(a)try{const c=a.canExecute?.(n)??!0,u=a.isActive?.(n)??!1;i[l]={isActive:u,isDisabled:!c,canExecute:c}}catch(c){console.warn(`Extension not available for modifier: ${l}`,c),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[n,e]),[r,s]=T.useState(t);return T.useEffect(()=>{if(!n)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>we(a)))).forEach(a=>{const c=X[a];if(c)try{const u=c.canExecute?.(n)??!0,d=c.isActive?.(n)??!1;o[a]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${a}`,u),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return n.on("selectionUpdate",i),n.on("transaction",i),()=>{n.off("selectionUpdate",i),n.off("transaction",i)}},[n,e,t]),r}function Pn(n){const e=T.useCallback((i,o)=>{if(!n)return;const l=X[i];if(l)try{l.execute({editor:n,config:o})}catch(a){console.warn(`Failed to execute command for modifier: ${i}`,a)}},[n]),t=T.useCallback(i=>{e(i)},[e]),r=T.useCallback((i,o)=>{if(!n)return!1;const l=X[i];try{return l?.canExecute?.(n,o)??!1}catch(a){return console.warn(`Failed to check canExecute for modifier: ${i}`,a),!1}},[n]),s=T.useCallback((i,o)=>{if(!n)return!1;const l=X[i];try{return l?.isActive?.(n,o)??!1}catch(a){return console.warn(`Failed to check isActive for modifier: ${i}`,a),!1}},[n]);return{executeCommand:e,toggleModifier:t,canExecute:r,isActive:s}}function ds(n=R.default){const[e,t]=T.useState(n),r=T.useCallback((l=R.step)=>{t(a=>Math.min(R.max,a+l))},[]),s=T.useCallback((l=R.step)=>{t(a=>Math.max(R.min,a-l))},[]),i=T.useCallback(()=>{t(R.default)},[]),o=T.useCallback(l=>{const a=Math.max(R.min,Math.min(R.max,l));t(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=R.min,isMaxZoom:e>=R.max,isDefaultZoom:e===R.default}}const fs=["bold","italic","strike","underline","code"];function hs({editor:n,modifiers:e}){const t=Rn(n,e),{toggleModifier:r}=Pn(n);if(!n)return null;const s=e.map(i=>we(i)).filter(i=>fs.includes(i));return s.length===0?null:f.jsx(us,{id:"text-formatting",label:"Text formatting",children:s.map(i=>{const o=t[i],l=le(i);return f.jsx(Q,{icon:l,label:i.charAt(0).toUpperCase()+i.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(i)},i)})})}function ps({editor:n,modifiers:e,zoom:t=100,onZoomChange:r,sticky:s=!0,className:i}){const o=Rn(n,e),{toggleModifier:l,executeCommand:a}=Pn(n);if(!n)return null;const c=e.map(v=>we(v)),u=c.some(v=>["bold","italic","strike","underline","code"].includes(v)),d=c.some(v=>["textColor","highlight"].includes(v)),h=c.includes("heading"),p=c.includes("textAlign"),y=c.some(v=>["bulletList","orderedList","taskList"].includes(v)),g=c.includes("blockquote"),x=c.includes("codeBlock"),N=c.includes("link"),j=c.includes("horizontalRule"),B=c.some(v=>["undo","redo"].includes(v)),V=t!==void 0&&r!==void 0,Se=s?"sticky top-0 z-10":"";return f.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${Se} ${i||""}`,children:f.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[u&&f.jsxs(f.Fragment,{children:[f.jsx(hs,{editor:n,modifiers:e}),(d||h||p||y||g||x||N||j||B||V)&&f.jsx(oe,{})]}),d&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[c.includes("textColor")&&f.jsx(en,{editor:n,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),c.includes("highlight")&&f.jsx(en,{editor:n,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(h||p||y||g||x||N||j||B||V)&&f.jsx(oe,{})]}),h&&f.jsxs(f.Fragment,{children:[f.jsx(ts,{editor:n}),(p||y||g||x||N||j||B||V)&&f.jsx(oe,{})]}),p&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(v=>{const lt=ls[v],Fe=n.isActive({textAlign:v});return f.jsx(Q,{icon:lt,label:`Align ${v}`,isActive:Fe,onClick:()=>a("textAlign",{type:"textAlign",alignment:v})},v)})}),(y||g||x||N||j||B||V)&&f.jsx(oe,{})]}),y&&f.jsxs(f.Fragment,{children:[f.jsx(ns,{editor:n,types:c.filter(v=>["bulletList","orderedList","taskList"].includes(v))}),(g||x||N||j||B||V)&&f.jsx(oe,{})]}),(g||x||N||j)&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[g&&f.jsx(Q,{icon:le("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>l("blockquote")}),x&&f.jsx(Q,{icon:le("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>l("codeBlock")}),N&&f.jsx(Q,{icon:le("link"),label:"Link",isActive:o.link?.isActive,isDisabled:o.link?.isDisabled,onClick:()=>{const v=window.prompt("Enter URL:");v&&a("link",{type:"link",href:v})}}),j&&f.jsx(Q,{icon:le("horizontalRule"),label:"Horizontal rule",onClick:()=>l("horizontalRule")})]}),(B||V)&&f.jsx(oe,{})]}),B&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[c.includes("undo")&&f.jsx(Q,{icon:le("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>l("undo")}),c.includes("redo")&&f.jsx(Q,{icon:le("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>l("redo")})]}),V&&f.jsx(oe,{})]}),V&&f.jsx(cs,{zoom:t,onZoomChange:r})]})})}const ms=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,gs=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ys=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xs=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,bs=m.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[m.markInputRule({find:ms,type:this.type}),m.markInputRule({find:ys,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:gs,type:this.type}),m.markPasteRule({find:xs,type:this.type})]}}),ks=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Cs=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ss=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,As=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ts=m.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[m.markInputRule({find:ks,type:this.type}),m.markInputRule({find:Ss,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Cs,type:this.type}),m.markPasteRule({find:As,type:this.type})]}}),Ms=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Es=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ns=m.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[m.markInputRule({find:Ms,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Es,type:this.type})]}}),vs=/(^|[^`])`([^`]+)`(?!`)/,Os=/(^|[^`])`([^`]+)`(?!`)/g,ws=m.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[m.markInputRule({find:vs,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Os,type:this.type})]}}),Is=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},Ds=m.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Is(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),Ls=m.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,m.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>m.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),zn=m.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Rs="listItem",tn="textStyle",nn=/^\s*([-+*])\s$/,Ps=m.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rs,this.editor.getAttributes(tn)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=m.wrappingInputRule({find:nn,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=m.wrappingInputRule({find:nn,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(tn),editor:this.editor})),[n]}}),zs="listItem",rn="textStyle",sn=/^(\d+)\.\s$/,Bs=m.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",m.mergeAttributes(this.options.HTMLAttributes,t),0]:["ol",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(zs,this.editor.getAttributes(rn)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=m.wrappingInputRule({find:sn,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=m.wrappingInputRule({find:sn,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(rn)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Fs=m.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function Bn(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Bn(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Fn(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Fn(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new C(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new C(r,s)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new C(s,i)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Bn(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Fn(this,e,t,r)}findIndex(e){if(e==0)return He(0,e);if(e==this.size)return He(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?He(t+1,i):He(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const mt={index:0,offset:0};function He(n,e){return mt.index=n,mt.offset=e,mt}function Et(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Et(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Et(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class q{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Et(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return q.none;if(e instanceof q)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}}q.none=[];class Hs extends Error{}class S{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=jn(this.content,e+this.openStart,t);return r&&new S(r,this.openStart,this.openEnd)}removeBetween(e,t){return new S(Hn(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return S.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(C.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new S(e,r,s)}}S.empty=new S(C.empty,0,0);function Hn(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Hn(i.content,e-s-1,t-s-1)))}function jn(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=jn(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function js(n){return n.tag!=null}function $s(n){return n.style!=null}class Ue{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(js(s))this.tags.push(s);else if($s(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new ln(this,t,!1);return r.addAll(e,q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ln(this,t,!0);return r.addAll(e,q.none,t.from,t.to),S.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Ks(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=an(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=an(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ue(e,Ue.schemaRules(e)))}}const $n={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},qs={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qn={ol:!0,ul:!0},Ie=1,Nt=2,Ne=4;function on(n,e,t){return e!=null?(e?Ie:0)|(e==="full"?Nt:0):n&&n.whitespace=="pre"?Ie|Nt:t&~Ne}class je{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=q.none,this.match=i||(o&Ne?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ie)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!$n.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ln{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=on(null,t.preserveWhitespace,0)|(r?Ne:0);s?i=new je(s.type,s.attrs,q.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new je(null,null,q.none,!0,null,o):i=new je(e.schema.topNodeType,null,q.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&Nt?"full":this.localPreserveWS||(s.options&Ie)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;qn.hasOwnProperty(o)&&this.parser.normalizeLists&&Js(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:qs.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if($n.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
12
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=q.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):cn(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=on(e,i,o.options);o.options&Ne&&o.content.length==0&&(l|=Ne);let a=q.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):cn(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new je(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Ie)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Js(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qn.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Ks(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function an(n){let e={};for(let t in n)e[t]=n[t];return e}function cn(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class nt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=gt(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Je(gt(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Je(gt(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Je(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=un(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return un(e.marks)}}function un(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function gt(n){return n.document||window.document}const dn=new WeakMap;function Vs(n){let e=dn.get(n);return e===void 0&&dn.set(n,e=Us(n)),e}function Us(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Je(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Vs(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:y}=Je(n,h,t,r);if(a.appendChild(p),y){if(l)throw new RangeError("Multiple content holes");l=y}}}return{dom:a,contentDOM:l}}const Jn=65535,Kn=Math.pow(2,16);function Ws(n,e){return n+e*Kn}function fn(n){return n&Jn}function Zs(n){return(n-(n&Jn))/Kn}const Vn=1,Un=2,Ke=4,Wn=8;class vt{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Wn)>0}get deletedBefore(){return(this.delInfo&(Vn|Ke))>0}get deletedAfter(){return(this.delInfo&(Un|Ke))>0}get deletedAcross(){return(this.delInfo&Ke)>0}}class F{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&F.empty)return F.empty}recover(e){let t=0,r=fn(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Zs(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:t:t,p=a+s+(h<0?0:u);if(r)return p;let y=e==(t<0?a:d)?null:Ws(l/3,e-a),g=e==a?Un:e==d?Vn:Ke;return(t<0?e!=a:e!=d)&&(g|=Wn),new vt(p,g,y)}s+=u-c}return r?e+s:new vt(e+s,0,null)}touches(e,t){let r=0,s=fn(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new F(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?F.empty:new F(e<0?[0,-e,0]:[0,0,e])}}F.empty=new F([]);class We{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new We(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new We;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new vt(e,s,null)}}const yt=Object.create(null);class P{getMap(){return F.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yt[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yt)throw new RangeError("Duplicate use of step JSON ID "+e);return yt[e]=t,t.prototype.jsonID=e,t}}class w{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new w(e,null)}static fail(e){return new w(null,e)}static fromReplace(e,t,r,s){try{return w.ok(e.replace(t,r,s))}catch(i){if(i instanceof Hs)return w.fail(i.message);throw i}}}function Ht(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(Ht(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return C.fromArray(r)}class ce extends P{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new S(Ht(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,i)}invert(){return new ue(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ce(t.pos,r.pos,this.mark)}merge(e){return e instanceof ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ce(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ce(t.from,t.to,e.markFromJSON(t.mark))}}P.jsonID("addMark",ce);class ue extends P{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new S(Ht(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,r)}invert(){return new ce(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ue(t.pos,r.pos,this.mark)}merge(e){return e instanceof ue&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ue(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ue(t.from,t.to,e.markFromJSON(t.mark))}}P.jsonID("removeMark",ue);class de extends P{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new S(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new de(this.pos,t.marks[s]);return new de(this.pos,this.mark)}}return new De(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new de(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new de(t.pos,e.markFromJSON(t.mark))}}P.jsonID("addNodeMark",de);class De extends P{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new S(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new de(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new De(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new De(t.pos,e.markFromJSON(t.mark))}}P.jsonID("removeNodeMark",De);class G extends P{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Ot(e,this.from,this.to)?w.fail("Structure replace would overwrite content"):w.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new F([this.from,this.to-this.from,this.slice.size])}invert(e){return new G(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new G(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof G)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new G(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new G(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new G(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}P.jsonID("replace",G);class ke extends P{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Ot(e,this.from,this.gapFrom)||Ot(e,this.gapTo,this.to)))return w.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return w.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?w.fromReplace(e,this.from,this.to,r):w.fail("Content does not fit in gap")}getMap(){return new F([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ke(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new ke(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ke(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}P.jsonID("replaceAround",ke);function Ot(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function Zn(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class ve extends P{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return w.fromReplace(e,this.pos,this.pos+1,new S(C.from(s),0,t.isLeaf?0:1))}getMap(){return F.empty}invert(e){return new ve(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ve(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ve(t.pos,t.attr,t.value)}}P.jsonID("attr",ve);class Ze extends P{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return w.ok(r)}getMap(){return F.empty}invert(e){return new Ze(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ze(t.attr,t.value)}}P.jsonID("docAttr",Ze);let Le=class extends Error{};Le=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Le.prototype=Object.create(Error.prototype);Le.prototype.constructor=Le;Le.prototype.name="TransformError";const xt=Object.create(null);class E{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new _s(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=S.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?S.empty:t),l==0&&mn(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),mn(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new M(e):xe(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?xe(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):xe(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Z(e.node(0))}static atStart(e){return xe(e,e,0,0,1)||new Z(e)}static atEnd(e){return xe(e,e,e.content.size,e.childCount,-1)||new Z(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xt[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in xt)throw new RangeError("Duplicate use of selection JSON ID "+e);return xt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}}E.prototype.visible=!0;class _s{constructor(e,t){this.$from=e,this.$to=t}}let hn=!1;function pn(n){!hn&&!n.parent.inlineContent&&(hn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class M extends E{constructor(e,t=e){pn(e),pn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return E.near(r);let s=e.resolve(t.map(this.anchor));return new M(s.parent.inlineContent?s:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof M&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new rt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new M(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(i)t=i.$head;else return E.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new M(e,t)}}E.jsonID("text",M);class rt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new rt(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}}class A extends E{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?E.near(i):new A(i)}content(){return new S(C.from(this.node),0,0)}eq(e){return e instanceof A&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new jt(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new A(e.resolve(t.anchor))}static create(e,t){return new A(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}A.prototype.visible=!1;E.jsonID("node",A);class jt{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new rt(r,r):new jt(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&A.isSelectable(r)?new A(t):E.near(t)}}class Z extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let r=E.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Z(e)}map(e){return new Z(e)}eq(e){return e instanceof Z}getBookmark(){return Gs}}E.jsonID("all",Z);const Gs={map(){return this},resolve(n){return new Z(n)}};function xe(n,e,t,r,s,i=!1){if(e.inlineContent)return M.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&A.isSelectable(l))return A.create(n,t-(s<0?l.nodeSize:0))}else{let a=xe(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function mn(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof G||s instanceof ke))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(E.near(n.doc.resolve(o),t))}function gn(n,e){return!e||!n?n:n.bind(e)}class $e{constructor(e,t,r){this.name=e,this.init=gn(t.init,r),this.apply=gn(t.apply,r)}}new $e("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new $e("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new $e("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new $e("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function _n(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=_n(s,e,{})),t[r]=s}return t}class st{constructor(e){this.spec=e,this.props={},e.props&&_n(e.props,this,this.props),this.key=e.key?e.key.key:Gn("plugin")}getState(e){return e[this.key]}}const bt=Object.create(null);function Gn(n){return n in bt?n+"$"+ ++bt[n]:(bt[n]=0,n+"$")}class $t{constructor(e="key"){this.key=Gn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Xs=/^```([a-z]+)?[\s\n]$/,Ys=/^~~~([a-z]+)?[\s\n]$/,Qs=m.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",m.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
14
13
|
|
|
15
|
-
`);return{
|
|
16
|
-
`))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:h}=n.state,g=$t.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(p=>{let y=o.appendChild(document.createElement("p"));p&&y.appendChild(g.serializeNode(h.text(p,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),o=cl(t),$n&&ul(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Re.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!ol.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=fl(Dr(l,+u[1],+u[2]),u[4]);else if(l=k.maxOpen(ll(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=Dr(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}const ol=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ll(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&zi(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Fi(o[o.length-1],s.length));let u=Pi(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return x.from(o)}return n}function Pi(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function zi(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=zi(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(x.from(Pi(t,n,i+1))))}}function Fi(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Fi(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function En(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=En(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Dr(n,e,t){return e<n.openStart&&(n=new k(En(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new k(En(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ji={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Lr=null;function $i(){return Lr||(Lr=document.implementation.createHTMLDocument("title"))}let un=null;function al(n){let e=window.trustedTypes;return e?(un||(un=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),un.createHTML(n)):n}function cl(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=$i().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&ji[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=al(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function ul(n){let e=n.querySelectorAll(fe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fl(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=x.from(a.create(r[l+1],i)),s++,o++}return new k(i,s,o)}const re={},Q={};function me(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Vi(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ht&&fe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),jn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ai(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||sl(n,t)?t.preventDefault():me(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(Vi(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ee&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function qt(n){return{left:n.clientX,top:n.clientY}}function dl(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Vn(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ve(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function hl(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&C.isSelectable(r)?(Ve(n,new C(t)),!0):!1}function pl(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof C&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(C.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ve(n,C.create(n.state.doc,i)),!0):!1}function ml(n,e,t,r,i){return Vn(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?pl(n,t):hl(n,t))}function gl(n,e,t,r){return Vn(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function yl(n,e,t,r){return Vn(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||xl(n,t,r)}function xl(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ve(n,w.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Ve(n,w.create(r,l+1,l+1+o.content.size));else if(C.isSelectable(o))Ve(n,C.create(r,l));else continue;return!0}}function Jn(n){return Dt(n)}const Hi=ee?"metaKey":"ctrlKey";re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Jn(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&dl(t,n.input.lastClick)&&!t[Hi]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(qt(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new bl(n,o,t,!!r)):(s=="doubleClick"?gl:yl)(n,o.pos,o.inside,t)?t.preventDefault():me(n,"pointer"))};class bl{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Hi],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof C&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Jt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),me(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Hn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(qt(e))),this.updateAllowDefault(e),this.allowDefault||!t?me(this.view,"pointer"):ml(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Fe&&this.mightDrag&&!this.mightDrag.node.isAtom||fe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ve(this.view,v.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):me(this.view,"pointer")}move(e){this.updateAllowDefault(e),me(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}re.touchstart=n=>{n.input.lastTouch=Date.now(),Jn(n),me(n,"pointer")};re.touchmove=n=>{n.input.lastTouch=Date.now(),me(n,"pointer")};re.contextmenu=n=>Jn(n);function Vi(n,e){return n.composing?!0:Fe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const kl=ht?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof w&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||fe&&Ii&&Cl(n)))n.markCursor=n.state.storedMarks||t.marks(),Dt(n,!0),n.markCursor=null;else if(Dt(n,!e.selection.empty),Jt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}Ji(n,kl)};function Cl(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Q.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ji(n,20))};function Ji(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Dt(n),e))}function Sl(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=wl());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function wl(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Dt(n,e=!1){if(!(ht&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sl(n),e||n.docView&&n.docView.dirty){let t=_o(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ml(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const at=dt&&Ei<15||jn&&Uo<604;re.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=at?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Li(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ml(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vl(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Al(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?On(n,r.value,null,i,e):On(n,r.textContent,r.innerHTML,i,e)},50)}function On(n,e,t,r,i){let s=Bi(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||k.empty)))return!0;if(!s)return!1;let o=vl(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qi(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!ht)return;let r=at?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&On(n,qi(r),r.getData("text/html"),i,t)?t.preventDefault():Al(n,t)};class Tl{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const El=ee?"altKey":"ctrlKey";function Wi(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[El]}re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(qt(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof C?i.to-1:i.to))){if(r&&r.mightDrag)o=C.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(o=C.create(n.state.doc,f.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=Li(n,l);(!t.dataTransfer.files.length||!fe||Oi>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(at?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",at||t.dataTransfer.setData("text/plain",c),n.dragging=new Tl(u,Wi(n,t),o)};re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{try{Ol(n,e,n.dragging)}finally{n.dragging=null}};function Ol(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(qt(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=Bi(n,qi(e.dataTransfer),at?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Wi(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||k.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?ki(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&C.isSelectable(s.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new C(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,p,y,b)=>h=b),a.setSelection(Ri(n,d,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Hn(n)},20))};re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};re.beforeinput=(n,e)=>{if(fe&&ht&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ai(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Q)re[n]=Q[n];function ct(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Lt{constructor(e,t){this.toDOM=e,this.spec=t||De,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new oe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Lt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ct(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ge{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new oe(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ge&&ct(this.attrs,e.attrs)&&ct(this.spec,e.spec)}static is(e){return e.type instanceof ge}destroy(){}}class qn{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new oe(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof qn&&ct(this.attrs,e.attrs)&&ct(this.spec,e.spec)}destroy(){}}class oe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new oe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new oe(e,e,new Lt(t,r))}static inline(e,t,r,i){return new oe(e,t,new ge(r,i))}static node(e,t,r,i){return new oe(e,t,new qn(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ge}get widget(){return this.type instanceof Lt}}const He=[],De={};class B{constructor(e,t){this.local=e.length?e:He,this.children=t.length?t:He}static create(e,t){return t.length?Bt(t,e,0,De):q}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==q||e.maps.length==0?this:this.mapInner(e,t,0,0,r||De)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Il(this.children,o||[],e,t,r,i,s):o?new B(o.sort(Le),He):q}add(e,t){return t.length?this==q?B.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Ui(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,Bt(u,l,c+1,De)),s+=3}});let o=Ki(s?_i(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new B(o.length?this.local.concat(o).sort(Le):this.local,i||this.children)}remove(e){return e.length==0||this==q?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=q?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new B(i,r):q}forChild(e,t){if(this==q)return this;if(t.isLeaf)return B.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof ge){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new B(i.sort(Le),He);return r?new Me([l,r]):l}return r||q}eq(e){if(this==e)return!0;if(!(e instanceof B)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Wn(this.localsInner(e))}localsInner(e){if(this==q)return He;if(e.inlineContent||!this.local.some(ge.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ge||t.push(this.local[r]);return t}forEachSet(e){e(this)}}B.empty=new B([],[]);B.removeOverlap=Wn;const q=B.empty;class Me{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,De));return Me.from(r)}forChild(e,t){if(t.isLeaf)return B.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=q&&(s instanceof Me?r=r.concat(s.members):r.push(s))}return Me.from(r)}eq(e){if(!(e instanceof Me)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Wn(r?t:t.sort(Le)):He}static from(e){switch(e.length){case 0:return q;case 1:return e[0];default:return new Me(e.every(t=>t instanceof B)?e:e.reduce((t,r)=>t.concat(r instanceof B?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Il(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,g,p)=>{let y=p-g-(h-d);for(let b=0;b<l.length;b+=3){let O=l[b+1];if(O<0||d>O+u-f)continue;let E=l[b]+u-f;h>=E?l[b+1]=d<=E?-2:-1:d>=u&&y&&(l[b]+=y,l[b+1]+=y)}f+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-i,{index:g,offset:p}=r.content.findIndex(f),y=r.maybeChild(g);if(y&&p==f&&p+y.nodeSize==h){let b=l[c+2].mapInner(t,y,u+1,n[c]+s+1,o);b!=q?(l[c]=f,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Nl(l,n,e,t,i,s,o),u=Bt(c,r,0,o);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new B(e.sort(Le),l)}function Ki(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new oe(i.from+e,i.to+e,i.type))}return t}function Nl(n,e,t,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?t.push(f):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Ui(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function _i(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Bt(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Ui(n,l,a+t);if(c){s=!0;let u=Bt(c,l,t+a+1,r);u!=q&&i.push(a,a+l.nodeSize,u)}});let o=Ki(s?_i(n):n,-t).sort(Le);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new B(o,i):q}function Le(n,e){return n.from-e.from||n.to-e.to}function Wn(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Br(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Br(e,i,r.copy(s.from,r.to)));break}}}return e}function Br(n,e,t){for(;e<n.length&&Le(t,n[e])>0;)e++;n.splice(e,0,t)}var ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Pt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rl=typeof navigator<"u"&&/Mac/.test(navigator.platform),Dl=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var F=0;F<10;F++)ye[48+F]=ye[96+F]=String(F);for(var F=1;F<=24;F++)ye[F+111]="F"+F;for(var F=65;F<=90;F++)ye[F]=String.fromCharCode(F+32),Pt[F]=String.fromCharCode(F);for(var fn in ye)Pt.hasOwnProperty(fn)||(Pt[fn]=ye[fn]);function Ll(n){var e=Rl&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Dl&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Pt:ye)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Bl=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Pl=typeof navigator<"u"&&/Win/.test(navigator.platform);function zl(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Bl?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Fl(n){let e=Object.create(null);for(let t in n)e[zl(t)]=n[t];return e}function dn(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function jl(n){let e=Fl(n);return function(t,r){let i=Ll(r),s,o=e[dn(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[dn(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Pl&&r.ctrlKey&&r.altKey)&&(s=ye[r.keyCode])&&s!=i){let l=e[dn(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Kn=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Gi(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Zi=(n,e,t)=>{let r=Gi(n,t);if(!r)return!1;let i=Un(r);if(!i){let o=r.blockRange(),l=o&&Ke(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(ss(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Je(s,"end")||C.isSelectable(s)))for(let o=r.depth;;o--){let l=Pn(n.doc,r.before(o),r.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Je(s,"end")?v.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):C.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},$l=(n,e,t)=>{let r=Gi(n,t);if(!r)return!1;let i=Un(r);return i?Xi(n,i,e):!1},Hl=(n,e,t)=>{let r=Qi(n,t);if(!r)return!1;let i=_n(r);return i?Xi(n,i,e):!1};function Xi(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Pn(n.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof Z&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(w.create(u.doc,s)),t(u.scrollIntoView())}return!0}function Je(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Yi=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Un(r)}let o=s&&s.nodeBefore;return!o||!C.isSelectable(o)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Un(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Qi(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const es=(n,e,t)=>{let r=Qi(n,t);if(!r)return!1;let i=_n(r);if(!i)return!1;let s=i.nodeAfter;if(ss(n,i,e,1))return!0;if(r.parent.content.size==0&&(Je(s,"start")||C.isSelectable(s))){let o=Pn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Je(s,"start")?v.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):C.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},ts=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=_n(r)}let o=s&&s.nodeAfter;return!o||!C.isSelectable(o)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos)).scrollIntoView()),!0)};function _n(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Vl=(n,e)=>{let t=n.selection,r=t instanceof C,i;if(r){if(t.node.isTextblock||!be(n.doc,t.from))return!1;i=t.from}else if(i=Ht(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(C.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Jl=(n,e)=>{let t=n.selection,r;if(t instanceof C){if(t.node.isTextblock||!be(n.doc,t.to))return!1;r=t.to}else if(r=Ht(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},ql=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Ke(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},ns=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
17
|
-
`).scrollIntoView()),!0)};function Gn(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Wl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Gn(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(v.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},rs=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Y||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Gn(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(w.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},is=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(ue(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ke(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Kl(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof C&&e.selection.node.isBlock)return!r.parentOffset||!ue(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Gn(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof w||e.selection instanceof Y)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=ue(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=ue(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),g=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(g.index(),g.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Ul=Kl(),_l=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(C.create(n.doc,i))),!0)};function Gl(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||be(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ss(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Gl(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,g=x.empty;for(let b=o.length-1;b>=0;b--)g=x.from(o[b].create(null,g));g=x.from(i.copy(g));let p=n.tr.step(new K(e.pos-1,h,e.pos,h,new k(g,1,0),o.length,!0)),y=p.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&be(p.doc,y.pos)&&p.join(y.pos),t(p.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:v.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&Ke(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&Je(s,"start",!0)&&Je(i,"end")){let h=i,g=[];for(;g.push(h),!h.isTextblock;)h=h.lastChild;let p=s,y=1;for(;!p.isTextblock;p=p.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,p.content)){if(t){let b=x.empty;for(let E=g.length-1;E>=0;E--)b=x.from(g[E].copy(b));let O=n.tr.step(new K(e.pos-g.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new k(b,g.length,0),0,!0));t(O.scrollIntoView())}return!0}}return!1}function ls(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(w.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Zl=ls(-1),Xl=ls(1);function Yl(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Bn(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Pr(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Zn(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Zn(Kn,Zi,Yi);Zn(Kn,es,ts);Zn(ns,rs,is,Ul);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ql(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return ea(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ea(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new Tt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Tt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Bn(s,t,r,e);return l?(n&&ta(n,e,l,i,t),!0):!1}function ta(n,e,t,r,i){let s=x.empty;for(let u=t.length-1;u>=0;u--)s=x.from(t[u].type.create(t[u].attrs,s));n.step(new K(e.start-(r?2:0),e.end,e.start,e.end,new k(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&ue(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function na(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?ra(e,t,n,s):ia(e,t,s):!0:!1}}function ra(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new K(s-1,o,s,o,new k(x.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Tt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ke(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return be(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function ia(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,g=t.endIndex-1,p=t.startIndex;g>p;g--)h-=i.child(g).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?x.empty:x.from(i))))return!1;let f=s.pos,d=f+o.nodeSize;return r.step(new K(f-(l?1:0),d+(a?1:0),f+1,d-1,new k((l?x.empty:x.from(i.copy(x.empty))).append(a?x.empty:x.from(i.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function sa(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=x.from(c?n.create():null),f=new k(x.from(n.create(null,x.from(l.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new K(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function as(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class oa{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const f=a(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(d=>d===!0)),f={...Object.fromEntries(Object.entries(r).map(([d,h])=>[d,(...p)=>{const y=this.buildProps(c,t),b=h(...p)(y);return l.push(b),f}])),run:u};return f}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:as({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}function H(n,e,t){return n.config[e]===void 0&&n.parent?H(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?H(n.parent,e,t):null}):n.config[e]}function la(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function V(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function W(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),l.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=s}),r},{})}function aa(n){return typeof n=="function"}function L(n,e=void 0,...t){return aa(n)?e?n.bind(e)(...t):n(...t):n}function ca(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Wt{constructor(e){this.find=e.find,this.handler=e.handler}}function ua(n){return Object.prototype.toString.call(n).slice(8,-1)}function yt(n){return ua(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Kt(n,e){const t={...n};return yt(n)&&yt(e)&&Object.keys(e).forEach(r=>{yt(e[r])&&yt(n[r])?t[r]=Kt(n[r],e[r]):t[r]=e[r]}),t}class xe{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(H(this,"addOptions",{name:this.name}))),this.storage=L(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xe(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Kt(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new xe(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(H(t,"addOptions",{name:t.name})),t.storage=L(H(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}class fa{constructor(e){this.find=e.find,this.handler=e.handler}}class U{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(H(this,"addOptions",{name:this.name}))),this.storage=L(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new U(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Kt(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new U({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(H(t,"addOptions",{name:t.name})),t.storage=L(H(t,"addStorage",{name:t.name,options:t.options})),t}}function da(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
14
|
+
`);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(E.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[m.textblockTypeInputRule({find:Xs,type:this.type,getAttributes:n=>({language:n[1]})}),m.textblockTypeInputRule({find:Ys,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new st({key:new $t("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
|
|
15
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(M.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),ei=/^\s*>\s$/,ti=m.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[m.wrappingInputRule({find:ei,type:this.type})]}}),ni=m.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",m.mergeAttributes(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!m.canInsertNode(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):m.isNodeSelection(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(M.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(A.create(o.doc,c.pos)):o.setSelection(M.create(o.doc,c.pos));else{const d=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();d&&(o.insert(u,d),o.setSelection(M.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[m.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ri=m.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",m.mergeAttributes(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
16
|
+
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var _e=200,D=function(){};D.prototype.append=function(e){return e.length?(e=D.from(e),!this.length&&e||e.length<_e&&this.leafAppend(e)||this.length<_e&&e.leafPrepend(this)||this.appendInner(e)):this};D.prototype.prepend=function(e){return e.length?D.from(e).append(this):this};D.prototype.appendInner=function(e){return new si(this,e)};D.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?D.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};D.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};D.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};D.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};D.from=function(e){return e instanceof D?e:e&&e.length?new Xn(e):D.empty};var Xn=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=_e)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=_e)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(D);D.empty=new Xn([]);var si=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(D);const ii=500;class J{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new U(d.map));let p=d.step.map(s.slice(i)),y;p&&o.maybeStep(p).doc&&(y=o.mapping.maps[o.mapping.maps.length-1],c.push(new U(y,void 0,void 0,c.length+u.length))),i--,y&&s.appendMap(y,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new J(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new U(e.mapping.maps[u],d,t),p;(p=a&&a.merge(h))&&(h=p,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(o++,t=void 0),s||(a=h)}let c=o-r.depth;return c>li&&(l=oi(l,c),o-=c),new J(l.append(i),o)}remapping(e,t){let r=new We;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new J(this.items.append(e.map(t=>new U(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=t;this.items.forEach(h=>{let p=i.getMirror(--a);if(p==null)return;o=Math.min(o,p);let y=i.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),x=h.selection&&h.selection.map(i.slice(a+1,p));x&&l++,r.push(new U(y,g,x))}else r.push(new U(y))},s);let c=[];for(let h=t;h<o;h++)c.push(new U(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new J(u,l);return d.emptyItemCount()>ii&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let d=new U(c.invert(),a,u),h,p=s.length-1;(h=s.length&&s[p].merge(d))?s[p]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new J(D.from(s.reverse()),i)}}J.empty=new J(D.empty,0);function oi(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class U{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new U(t.getMap().invert(),t,this.selection)}}}class ee{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const li=20;function ai(n,e,t,r){let s=t.getMeta(fe),i;if(s)return s.historyState;t.getMeta(di)&&(n=new ee(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(fe))return o.getMeta(fe).redo?new ee(n.done.addTransform(t,void 0,r,Ve(e)),n.undone,yn(t.mapping.maps),n.prevTime,n.prevComposition):new ee(n.done,n.undone.addTransform(t,void 0,r,Ve(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ci(t,n.prevRanges)),c=o?kt(n.prevRanges,t.mapping):yn(t.mapping.maps);return new ee(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ve(e)),J.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new ee(n.done.rebased(t,i),n.undone.rebased(t,i),kt(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ee(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),kt(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ci(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function yn(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function kt(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function ui(n,e,t){let r=Ve(e),s=fe.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new ee(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(fe,{redo:t,historyState:a})}let Ct=!1,xn=null;function Ve(n){let e=n.plugins;if(xn!=e){Ct=!1,xn=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ct=!0;break}}return Ct}const fe=new $t("history"),di=new $t("closeHistory");function fi(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new st({key:fe,state:{init(){return new ee(J.empty,J.empty,null,0,-1)},apply(e,t,r){return ai(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Qn:r=="historyRedo"?er:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Yn(n,e){return(t,r)=>{let s=fe.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=ui(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Qn=Yn(!1,!0),er=Yn(!0,!0),Ee=m.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Qn(n,e),redo:()=>({state:n,dispatch:e})=>er(n,e)}},addProseMirrorPlugins(){return[fi(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),hi=m.Node.create({name:"doc",topNode:!0,content:"block+"}),pi=m.Node.create({name:"text",group:"inline"});function mi(n={}){return new st({view(e){return new gi(e,n)}})}class gi{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(t){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let p=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(p){let y=p.getBoundingClientRect(),g=d?y.bottom:y.top;d&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:y.left,right:y.right,top:g-x,bottom:g+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,p=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*p}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Zn(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const yi=m.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[mi(this.options)]}});var se={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ge={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xi=typeof navigator<"u"&&/Mac/.test(navigator.platform),bi=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var L=0;L<10;L++)se[48+L]=se[96+L]=String(L);for(var L=1;L<=24;L++)se[L+111]="F"+L;for(var L=65;L<=90;L++)se[L]=String.fromCharCode(L+32),Ge[L]=String.fromCharCode(L);for(var St in se)Ge.hasOwnProperty(St)||(Ge[St]=se[St]);function ki(n){var e=xi&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bi&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ge:se)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ci=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Si=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ai(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ci?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Ti(n){let e=Object.create(null);for(let t in n)e[Ai(t)]=n[t];return e}function At(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Mi(n){let e=Ti(n);return function(t,r){let s=ki(r),i,o=e[At(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[At(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Si&&r.ctrlKey&&r.altKey)&&(i=se[r.keyCode])&&i!=s){let l=e[At(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const me=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},tr=function(n,e,t,r){return t&&(bn(n,e,t,r,-1)||bn(n,e,t,r,1))},Ei=/^(img|br|input|textarea|hr)$/i;function bn(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;if(e==(s<0?0:Xe(n))){let o=n.parentNode;if(!o||o.nodeType!=1||qt(n)||Ei.test(n.nodeName)||n.contentEditable=="false")return!1;e=me(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else n=o,e=s<0?Xe(n):0}else return!1}}function Xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ni(n,e,t){for(let r=e==0,s=e==Xe(n);r||s;){if(n==t)return!0;let i=me(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==Xe(n)}}function qt(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const nr=function(n){return n.focusNode&&tr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function rr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _=typeof navigator<"u"?navigator:null,kn=typeof document<"u"?document:null,ie=_&&_.userAgent||"",wt=/Edge\/(\d+)/.exec(ie),sr=/MSIE \d/.exec(ie),It=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ie),ze=!!(sr||It||wt),ir=sr?document.documentMode:It?+It[1]:wt?+wt[1]:0,it=!ze&&/gecko\/(\d+)/i.test(ie);it&&+(/Firefox\/(\d+)/.exec(ie)||[0,0])[1];const Dt=!ze&&/Chrome\/(\d+)/.exec(ie),Y=!!Dt,or=Dt?+Dt[1]:0,ge=!ze&&!!_&&/Apple Computer/.test(_.vendor),Jt=ge&&(/Mobile\/\w+/.test(ie)||!!_&&_.maxTouchPoints>2),$=Jt||(_?/Mac/.test(_.platform):!1),lr=_?/Win/.test(_.platform):!1,Be=/Android \d/.test(ie),Kt=!!kn&&"webkitFontSmoothing"in kn.documentElement.style,vi=Kt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Oi(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(nr(t)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&A.isSelectable(d)&&s.parent&&!(d.isInline&&Ni(t.focusNode,t.focusOffset,s.dom))){let h=s.posBefore;c=new A(o==h?l:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,h=o;for(let p=0;p<t.rangeCount;p++){let y=t.getRangeAt(p);d=Math.min(d,n.docView.posFromDOM(y.startContainer,y.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(y.endContainer,y.endOffset,-1))}if(d<0)return null;[a,o]=h==n.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=cr(n,u,l,d)}return c}function ar(n){return n.editable?n.hasFocus():Li(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Vt(n,e=!1){let t=n.state.selection;if(Di(n,t),!!ar(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Y){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&tr(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ii(n);else{let{anchor:r,head:s}=t,i,o;Cn&&!(t instanceof M)&&(t.$from.parent.inlineContent||(i=Sn(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Sn(n,t.to))),n.docView.setSelection(r,s,n,e),Cn&&(i&&An(i),o&&An(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wi(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Cn=ge||Y&&or<63;function Sn(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(ge&&s&&s.contentEditable=="false")return Tt(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Tt(s);if(i)return Tt(i)}}function Tt(n){return n.contentEditable="true",ge&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function An(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wi(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ar(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ii(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,me(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ze&&ir<=11&&(t.disabled=!0,t.disabled=!1)}function Di(n,e){if(e instanceof A){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Tn(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Tn(n)}function Tn(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function cr(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||M.between(e,t,r)}function Li(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Lt(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&E.findFrom(i,e)}function te(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Mn(n,e,t){let r=n.state.selection;if(r instanceof M)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return te(n,new M(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Lt(n.state,e);return s&&s instanceof A?te(n,s):!1}else if(!($&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?A.isSelectable(i)?te(n,new A(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Kt?te(n,new M(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return te(n,new M(e>0?r.$to:r.$from));{let s=Lt(n.state,e);return s?te(n,s):!1}}}function Ye(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Oe(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ye(n,e){return e<0?Ri(n):Pi(n)}function Ri(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(it&&t.nodeType==1&&r<Ye(t)&&Oe(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Oe(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ur(t))break;{let l=t.previousSibling;for(;l&&Oe(l,-1);)s=t.parentNode,i=me(l),l=l.previousSibling;if(l)t=l,r=Ye(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Rt(n,t,r):s&&Rt(n,s,i)}function Pi(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Ye(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Oe(l,1))i=t,o=++r;else break}else{if(ur(t))break;{let l=t.nextSibling;for(;l&&Oe(l,1);)i=l.parentNode,o=me(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=Ye(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Rt(n,i,o)}function ur(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function zi(n,e){for(;n&&e==n.childNodes.length&&!qt(n);)e=me(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Bi(n,e){for(;n&&!e&&!qt(n);)e=me(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Rt(n,e,t){if(e.nodeType!=3){let i,o;(o=zi(e,t))?(e=o,t=0):(i=Bi(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(nr(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Vt(n)},50)}function En(n,e){let t=n.state.doc.resolve(e);if(!(Y||lr)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Nn(n,e,t){let r=n.state.selection;if(r instanceof M&&!r.empty||t.indexOf("s")>-1||$&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Lt(n.state,e);if(o&&o instanceof A)return te(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Z?E.near(o,e):E.findFrom(o,e);return l?te(n,l):!1}return!1}function vn(n,e){if(!(n.state.selection instanceof M))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function On(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Fi(n){if(!ge||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;On(n,r,"true"),setTimeout(()=>On(n,r,"false"),20)}return!1}function Hi(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ji(n,e){let t=e.keyCode,r=Hi(e);if(t==8||$&&t==72&&r=="c")return vn(n,-1)||ye(n,-1);if(t==46&&!e.shiftKey||$&&t==68&&r=="c")return vn(n,1)||ye(n,1);if(t==13||t==27)return!0;if(t==37||$&&t==66&&r=="c"){let s=t==37?En(n,n.state.selection.from)=="ltr"?-1:1:-1;return Mn(n,s,r)||ye(n,s)}else if(t==39||$&&t==70&&r=="c"){let s=t==39?En(n,n.state.selection.from)=="ltr"?1:-1:1;return Mn(n,s,r)||ye(n,s)}else{if(t==38||$&&t==80&&r=="c")return Nn(n,-1,r)||ye(n,-1);if(t==40||$&&t==78&&r=="c")return Fi(n)||Nn(n,1,r)||ye(n,1);if(r==($?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function dr(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=n.someProp("clipboardSerializer")||nt.fromSchema(n.state.schema),l=yr(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=gr[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let y=l.createElement(u[p]);for(;a.firstChild;)y.appendChild(a.firstChild);a.appendChild(y),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
18
17
|
|
|
19
|
-
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,i,(a,c,u,f)=>{var d;a.isBlock&&c>r&&(l+=s);const h=o?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:f,range:e})),!1;a.isText&&(l+=(d=a?.text)===null||d===void 0?void 0:d.slice(Math.max(r,c)-c,i-c))}),l}function ha(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}U.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ne({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=ha(t);return da(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});const pa=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),ma=(n=!1)=>({commands:e})=>e.setContent("",n),ga=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(a)),d=c.resolve(u.map(a+l.nodeSize)),h=f.blockRange(d);if(!h)return;const g=Ke(h);if(l.type.isTextblock){const{defaultType:p}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,p)}(g||g===0)&&e.lift(h,g)})}),!0},ya=n=>e=>n(e),xa=()=>({state:n,dispatch:e})=>rs(n,e),ba=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new w(r.doc.resolve(Math.max(o-1,0)))),!0},ka=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1},Ca=n=>({tr:e,state:t,dispatch:r})=>{const i=V(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Sa=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},wa=()=>({state:n,dispatch:e})=>Kn(n,e),Ma=()=>({commands:n})=>n.keyboardShortcut("Enter"),va=()=>({state:n,dispatch:e})=>Wl(n,e);function zt(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ca(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function cs(n,e,t={}){return n.find(r=>r.type===e&&zt(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function zr(n,e,t={}){return!!cs(n,e,t)}function Xn(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!cs([...i.node.marks],e,t)))return;let o=i.index,l=n.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&zr([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&zr([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Ce(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const Aa=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Ce(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const f=Xn(a,s,e);if(f&&f.from<=c&&f.to>=u){const d=w.create(o,f.from,f.to);t.setSelection(d)}}return!0},Ta=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function us(n){return n instanceof w}function Ee(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Ea(n,e=null){if(!e)return null;const t=v.atStart(n),r=v.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?w.create(n,Ee(0,i,s),Ee(n.content.size,i,s)):w.create(n,Ee(e,i,s),Ee(e,i,s))}function Fr(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ft(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Oa(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Ia=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ft()||Fr())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),Oa()&&!Ft()&&!Fr()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!us(t.state.selection))return o(),!0;const l=Ea(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Na=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ra=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),fs=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&fs(r)}return n};function xt(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return fs(t)}function ut(n,e,t){if(n instanceof Ne||n instanceof x)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return x.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),ut("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Ao({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Re.fromSchema(a).parseSlice(xt(n),t.parseOptions):Re.fromSchema(a).parse(xt(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Re.fromSchema(e);return t.slice?s.parseSlice(xt(n),t.parseOptions).content:s.parse(xt(n),t.parseOptions)}return ut("",e,t)}function Da(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof Z||i instanceof K))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(v.near(n.doc.resolve(o),t))}const La=n=>!("type"in n),Ba=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{s.emit("contentError",{editor:s,error:y,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ut(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=ut(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,h=!0;if((La(l)?l:[l]).forEach(y=>{y.check(),d=d?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===f&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,f+=1)}let p;if(d){if(Array.isArray(e))p=e.map(y=>y.text||"").join("");else if(e instanceof x){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),p=y}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,u,f)}else p=l,r.replaceWith(u,f,p);t.updateSelection&&Da(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:p})}return!0},Pa=()=>({state:n,dispatch:e})=>Vl(n,e),za=()=>({state:n,dispatch:e})=>Jl(n,e),Fa=()=>({state:n,dispatch:e})=>Zi(n,e),ja=()=>({state:n,dispatch:e})=>es(n,e),$a=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ht(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Ha=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ht(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Va=()=>({state:n,dispatch:e})=>$l(n,e),Ja=()=>({state:n,dispatch:e})=>Hl(n,e);function ds(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function qa(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ft()||ds()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const Wa=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=qa(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Yn(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?V(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(f,d)=>{if(f.isText)return;const h=Math.max(r,d),g=Math.min(i,d+f.nodeSize);l.push({node:f,from:h,to:g})});const a=i-r,c=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>zt(f.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((f,d)=>f+d.to-d.from,0)>=a}const Ka=(n,e={})=>({state:t,dispatch:r})=>{const i=V(n,t.schema);return Yn(t,i,e)?ql(t,r):!1},Ua=()=>({state:n,dispatch:e})=>is(n,e),_a=n=>({state:e,dispatch:t})=>{const r=V(n,e.schema);return na(r)(e,t)},Ga=()=>({state:n,dispatch:e})=>ns(n,e);function hs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function jr(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const Za=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=hs(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=V(n,r.schema)),l==="mark"&&(o=Ce(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,jr(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(f=>{o===f.type&&t.addMark(u,u+c.nodeSize,o.create(jr(f.attrs,e)))})})}),!0):!1},Xa=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Ya=()=>({tr:n,dispatch:e})=>{if(e){const t=new Y(n.doc);n.setSelection(t)}return!0},Qa=()=>({state:n,dispatch:e})=>Yi(n,e),ec=()=>({state:n,dispatch:e})=>ts(n,e),tc=()=>({state:n,dispatch:e})=>_l(n,e),nc=()=>({state:n,dispatch:e})=>Xl(n,e),rc=()=>({state:n,dispatch:e})=>Zl(n,e);function ic(n,e,t={},r={}){return ut(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const sc=(n,e=!1,t={},r={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{var a,c;const{doc:u}=s;if(t.preserveWhitespace!=="full"){const f=ic(n,i.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return o&&s.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function oc(n,e){const t=Ce(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function lc(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function ac(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Qn(n){return e=>ac(e.$from,n)}function ps(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=Xn(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function St(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function cc(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Ce(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>zt(f.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:d})=>{const h=f.pos,g=d.pos;n.doc.nodesBetween(h,g,(p,y)=>{if(!p.isText&&!p.marks.length)return;const b=Math.max(h,y),O=Math.min(g,y+p.nodeSize),E=O-b;o+=E,l.push(...p.marks.map(R=>({mark:R,from:b,to:O})))})}),o===0)return!1;const a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>zt(f.mark.attrs,t,{strict:!1})).reduce((f,d)=>f+d.to-d.from,0),c=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,d)=>f+d.to-d.from,0);return(a>0?a+c:a)>=o}function $r(n,e){const{nodeExtensions:t}=la(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=L(H(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function ms(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(ms(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function uc(n){return n instanceof C}function fc(n,e,t){var r;const{selection:i}=e;let s=null;if(us(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,f,d)=>{if(c)return!1;if(u.isInline){const h=!d||d.type.allowsMarkType(t),g=!!t.isInSet(u.marks)||!u.marks.some(p=>p.type.excludes(t));c=h&&g}return!c}),c})}const dc=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Ce(n,r.schema);if(i)if(o){const c=oc(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(d,h)=>{const g=Math.max(h,u),p=Math.min(h+d.nodeSize,f);d.marks.find(b=>b.type===a)?d.marks.forEach(b=>{a===b.type&&t.addMark(g,p,a.create({...b.attrs,...e}))}):t.addMark(g,p,a.create(e))})});return fc(r,t,a)},hc=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),pc=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=V(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Pr(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Pr(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},mc=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=Ee(n,0,r.content.size),s=C.create(r,i);e.setSelection(s)}return!0},gc=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=w.atStart(r).from,l=w.atEnd(r).to,a=Ee(i,o,l),c=Ee(s,o,l),u=w.create(r,a,c);e.setSelection(u)}return!0},yc=n=>({state:e,dispatch:t})=>{const r=V(n,e.schema);return sa(r)(e,t)};function Hr(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}const xc=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=St(c,l.node().type.name,l.node().attrs);if(s instanceof C&&s.node.isBlock)return!l.parentOffset||!ue(o,l.pos)?!1:(r&&(n&&Hr(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:lc(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&d?[{type:d,attrs:u}]:void 0,g=ue(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!g&&ue(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(g=!0,h=d?[{type:d,attrs:u}]:void 0),r){if(g&&(s instanceof w&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),d&&!f&&!l.parentOffset&&l.parent.type!==d)){const p=e.mapping.map(l.before()),y=e.doc.resolve(p);l.node(-1).canReplaceWith(y.index(),y.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}n&&Hr(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return g},bc=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const l=V(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const f=a.node(-1);if(f.type!==l)return!1;const d=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let b=x.empty;const O=a.index(-1)?1:a.index(-2)?2:3;for(let G=a.depth-O;G>=a.depth-3;G-=1)b=x.from(a.node(G).copy(b));const E=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...St(d,a.node().type.name,a.node().attrs),...e},j=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(R))||void 0;b=b.append(x.from(l.createAndFill(null,j)||void 0));const T=a.before(a.depth-(O-1));t.replace(T,a.after(-E),new k(b,4-O,0));let ie=-1;t.doc.nodesBetween(T,t.doc.content.size,(G,Ut)=>{if(ie>-1)return!1;G.isTextblock&&G.content.size===0&&(ie=Ut+1)}),ie>-1&&t.setSelection(w.near(t.doc.resolve(ie))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,g={...St(d,f.type.name,f.attrs),...e},p={...St(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:g},{type:h,attrs:p}]:[{type:l,attrs:g}];if(!ue(t.doc,a.pos,2))return!1;if(i){const{selection:b,storedMarks:O}=r,{splittableMarks:E}=s.extensionManager,R=O||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!R||!i)return!0;const j=R.filter(T=>E.includes(T.type.name));t.ensureMarks(j)}return!0},hn=(n,e)=>{const t=Qn(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&be(n.doc,t.pos)&&n.join(t.pos),!0},pn=(n,e)=>{const t=Qn(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&be(n.doc,r)&&n.join(r),!0},kc=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:f,splittableMarks:d}=i.extensionManager,h=V(n,o.schema),g=V(e,o.schema),{selection:p,storedMarks:y}=o,{$from:b,$to:O}=p,E=b.blockRange(O),R=y||p.$to.parentOffset&&p.$from.marks();if(!E)return!1;const j=Qn(T=>$r(T.type.name,f))(p);if(E.depth>=1&&j&&E.depth-j.depth<=1){if(j.node.type===h)return c.liftListItem(g);if($r(j.node.type.name,f)&&h.validContent(j.node.content)&&l)return a().command(()=>(s.setNodeMarkup(j.pos,h),!0)).command(()=>hn(s,h)).command(()=>pn(s,h)).run()}return!t||!R||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>hn(s,h)).command(()=>pn(s,h)).run():a().command(()=>{const T=u().wrapInList(h,r),ie=R.filter(G=>d.includes(G.type.name));return s.ensureMarks(ie),T?!0:c.clearNodes()}).wrapInList(h,r).command(()=>hn(s,h)).command(()=>pn(s,h)).run()},Cc=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Ce(n,r.schema);return cc(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Sc=(n,e,t={})=>({state:r,commands:i})=>{const s=V(n,r.schema),o=V(e,r.schema),l=Yn(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},wc=(n,e={})=>({state:t,commands:r})=>{const i=V(n,t.schema);return Yn(t,i,e)?r.lift(i):r.wrapIn(i,e)},Mc=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},vc=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},Ac=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ce(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!i)return!0;if(u&&o){let{from:d,to:h}=l;const g=(s=c.marks().find(y=>y.type===a))===null||s===void 0?void 0:s.attrs,p=Xn(c,a,g);p&&(d=p.from,h=p.to),t.removeMark(d,h,a)}else f.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},Tc=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=hs(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=V(n,r.schema)),l==="mark"&&(o=Ce(n,r.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let f,d,h,g;t.selection.empty?r.doc.nodesBetween(c,u,(p,y)=>{s&&s===p.type&&(h=Math.max(y,c),g=Math.min(y+p.nodeSize,u),f=y,d=p)}):r.doc.nodesBetween(c,u,(p,y)=>{y<c&&s&&s===p.type&&(h=Math.max(y,c),g=Math.min(y+p.nodeSize,u),f=y,d=p),y>=c&&y<=u&&(s&&s===p.type&&t.setNodeMarkup(y,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(b=>{if(o===b.type){const O=Math.max(y,c),E=Math.min(y+p.nodeSize,u);t.addMark(O,E,o.create({...b.attrs,...e}))}}))}),d&&(f!==void 0&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&t.addMark(h,g,o.create({...p.attrs,...e}))}))}),!0):!1},Ec=(n,e={})=>({state:t,dispatch:r})=>{const i=V(n,t.schema);return Yl(i,e)(t,r)},Oc=(n,e={})=>({state:t,dispatch:r})=>{const i=V(n,t.schema);return Ql(i,e)(t,r)};var Ic=Object.freeze({__proto__:null,blur:pa,clearContent:ma,clearNodes:ga,command:ya,createParagraphNear:xa,cut:ba,deleteCurrentNode:ka,deleteNode:Ca,deleteRange:Sa,deleteSelection:wa,enter:Ma,exitCode:va,extendMarkRange:Aa,first:Ta,focus:Ia,forEach:Na,insertContent:Ra,insertContentAt:Ba,joinBackward:Fa,joinDown:za,joinForward:ja,joinItemBackward:$a,joinItemForward:Ha,joinTextblockBackward:Va,joinTextblockForward:Ja,joinUp:Pa,keyboardShortcut:Wa,lift:Ka,liftEmptyBlock:Ua,liftListItem:_a,newlineInCode:Ga,resetAttributes:Za,scrollIntoView:Xa,selectAll:Ya,selectNodeBackward:Qa,selectNodeForward:ec,selectParentNode:tc,selectTextblockEnd:nc,selectTextblockStart:rc,setContent:sc,setMark:dc,setMeta:hc,setNode:pc,setNodeSelection:mc,setTextSelection:gc,sinkListItem:yc,splitBlock:xc,splitListItem:bc,toggleList:kc,toggleMark:Cc,toggleNode:Sc,toggleWrap:wc,undoInputRule:Mc,unsetAllMarks:vc,unsetMark:Ac,updateAttributes:Tc,wrapIn:Ec,wrapInList:Oc});U.create({name:"commands",addCommands(){return{...Ic}}});U.create({name:"drop",addProseMirrorPlugins(){return[new ne({key:new ae("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}});U.create({name:"editable",addProseMirrorPlugins(){return[new ne({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}});const Nc=new ae("focusEvents");U.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ne({key:Nc,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}});U.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:d,parent:h}=f,g=f.parent.isTextblock&&d>0?l.doc.resolve(d-1):f,p=g.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=p&&g.parent.childCount===1?y===f.pos:v.atStart(c).from===d;return!u||!h.type.isTextblock||h.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ft()||ds()?s:i},addProseMirrorPlugins(){return[new ne({key:new ae("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(p=>p.getMeta("composition")))return;const r=n.some(p=>p.docChanged)&&!e.doc.eq(t.doc),i=n.some(p=>p.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=v.atStart(e.doc).from,c=v.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!ms(t.doc))return;const d=t.tr,h=as({state:t,transaction:d}),{commands:g}=new oa({editor:this.editor,state:h});if(g.clearNodes(),!!d.steps.length)return d}})]}});U.create({name:"paste",addProseMirrorPlugins(){return[new ne({key:new ae("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}});U.create({name:"tabindex",addProseMirrorPlugins(){return[new ne({key:new ae("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});function qe(n){return new Wt({find:n.find,handler:({state:e,range:t,match:r})=>{const i=L(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(ps(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const d=t.from+a+o.length;s.addMark(t.from+a,d,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function Rc(n){return new Wt({find:n.find,handler:({state:e,range:t,match:r})=>{const i=L(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()}})}function In(n){return new Wt({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=L(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function ft(n){return new Wt({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=L(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&Bn(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:f,storedMarks:d}=e,{splittableMarks:h}=n.editor.extensionManager,g=d||f.$to.parentOffset&&f.$from.marks();if(g){const p=g.filter(y=>h.includes(y.type.name));o.ensureMarks(p)}}if(n.keepAttributes){const f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&be(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)}})}class _{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(H(this,"addOptions",{name:this.name}))),this.storage=L(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new _(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Kt(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new _(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(H(t,"addOptions",{name:t.name})),t.storage=L(H(t,"addStorage",{name:t.name,options:t.options})),t}}function We(n){return new fa({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=L(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),f=t.from+a.indexOf(l),d=f+l.length;if(ps(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===n.type&&y!==g.mark.type)).filter(g=>g.to>f).length)return null;d<t.to&&o.delete(d,t.to),f>t.from&&o.delete(t.from+u,f),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Dc(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof C){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}const Lc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Bc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Pc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,zc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Fc=xe.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[qe({find:Lc,type:this.type}),qe({find:Pc,type:this.type})]},addPasteRules(){return[We({find:Bc,type:this.type}),We({find:zc,type:this.type})]}}),jc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,$c=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Hc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Vc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Jc=xe.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[qe({find:jc,type:this.type}),qe({find:Hc,type:this.type})]},addPasteRules(){return[We({find:$c,type:this.type}),We({find:Vc,type:this.type})]}}),qc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Wc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Kc=xe.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[qe({find:qc,type:this.type})]},addPasteRules(){return[We({find:Wc,type:this.type})]}}),Uc=/(^|[^`])`([^`]+)`(?!`)/,_c=/(^|[^`])`([^`]+)`(?!`)/g,Gc=xe.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[qe({find:Uc,type:this.type})]},addPasteRules(){return[We({find:_c,type:this.type})]}}),Zc=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,i;const s=t.getAttribute("style"),o=(i=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||i===void 0?void 0:i.getAttribute("style");t.setAttribute("style",`${o};${s}`)})},Xc=xe.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Zc(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",W(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),Yc=_.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,W(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>In({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),gs=_.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Qc="listItem",Vr="textStyle",Jr=/^\s*([-+*])\s$/,eu=_.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",W(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Qc,this.editor.getAttributes(Vr)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=ft({find:Jr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ft({find:Jr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vr),editor:this.editor})),[n]}}),tu="listItem",qr="textStyle",Wr=/^(\d+)\.\s$/,nu=_.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",W(this.options.HTMLAttributes,t),0]:["ol",W(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tu,this.editor.getAttributes(qr)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=ft({find:Wr,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ft({find:Wr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(qr)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),ru=_.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",W(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),iu=/^```([a-z]+)?[\s\n]$/,su=/^~~~([a-z]+)?[\s\n]$/,ou=_.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",W(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(w.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),lu=/^\s*>\s$/,au=_.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",W(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ft({find:lu,type:this.type})]}}),cu=_.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",W(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Dc(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:i}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):uc(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(w.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(C.create(o.doc,c.pos)):o.setSelection(w.create(o.doc,c.pos));else{const f=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(o.insert(u,f),o.setSelection(w.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Rc({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),uu=_.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",W(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
23
|
-
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const f=a.filter(d=>l.includes(d.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jt=200,P=function(){};P.prototype.append=function(e){return e.length?(e=P.from(e),!this.length&&e||e.length<jt&&this.leafAppend(e)||this.length<jt&&e.leafPrepend(this)||this.appendInner(e)):this};P.prototype.prepend=function(e){return e.length?P.from(e).append(this):this};P.prototype.appendInner=function(e){return new fu(this,e)};P.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?P.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};P.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};P.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};P.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};P.from=function(e){return e instanceof P?e:e&&e.length?new ys(e):P.empty};var ys=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=jt)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=jt)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(P);P.empty=new ys([]);var fu=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(P);const du=500;class te{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),s=i.maps.length),s--,u.push(f);return}if(i){u.push(new se(f.map));let h=f.step.map(i.slice(s)),g;h&&o.maybeStep(h).doc&&(g=o.mapping.maps[o.mapping.maps.length-1],c.push(new se(g,void 0,void 0,c.length+u.length))),s--,g&&i.appendMap(g,s)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(s)):f.selection,a=new te(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new se(e.mapping.maps[u],f,t),h;(h=a&&a.merge(d))&&(d=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(o++,t=void 0),i||(a=d)}let c=o-r.depth;return c>pu&&(l=hu(l,c),o-=c),new te(l.append(s),o)}remapping(e,t){let r=new Ot;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new te(this.items.append(e.map(t=>new se(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let g=s.maps[h];if(d.step){let p=e.steps[h].invert(e.docs[h]),y=d.selection&&d.selection.map(s.slice(a+1,h));y&&l++,r.push(new se(g,p,y))}else r.push(new se(g))},i);let c=[];for(let d=t;d<o;d++)c.push(new se(s.maps[d]));let u=this.items.slice(0,i).append(c).append(r),f=new te(u,l);return f.emptyItemCount()>du&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let f=new se(c.invert(),a,u),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else o.map&&r--},this.items.length,0),new te(P.from(i.reverse()),s)}}te.empty=new te(P.empty,0);function hu(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class se{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new se(t.getMap().invert(),t,this.selection)}}}class pe{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const pu=20;function mu(n,e,t,r){let i=t.getMeta(Be),s;if(i)return i.historyState;t.getMeta(xu)&&(n=new pe(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Be))return o.getMeta(Be).redo?new pe(n.done.addTransform(t,void 0,r,wt(e)),n.undone,Kr(t.mapping.maps),n.prevTime,n.prevComposition):new pe(n.done,n.undone.addTransform(t,void 0,r,wt(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!gu(t,n.prevRanges)),c=o?mn(n.prevRanges,t.mapping):Kr(t.mapping.maps);return new pe(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,wt(e)),te.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new pe(n.done.rebased(t,s),n.undone.rebased(t,s),mn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pe(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),mn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function gu(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Kr(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function mn(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function yu(n,e,t){let r=wt(e),i=Be.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new pe(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Be,{redo:t,historyState:a})}let gn=!1,Ur=null;function wt(n){let e=n.plugins;if(Ur!=e){gn=!1,Ur=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){gn=!0;break}}return gn}const Be=new ae("history"),xu=new ae("closeHistory");function bu(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ne({key:Be,state:{init(){return new pe(te.empty,te.empty,null,0,-1)},apply(e,t,r){return mu(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?bs:r=="historyRedo"?ks:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function xs(n,e){return(t,r)=>{let i=Be.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=yu(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const bs=xs(!1,!0),ks=xs(!0,!0),Ye=U.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>bs(n,e),redo:()=>({state:n,dispatch:e})=>ks(n,e)}},addProseMirrorPlugins(){return[bu(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),ku=_.create({name:"doc",topNode:!0,content:"block+"}),Cu=_.create({name:"text",group:"inline"});function Su(n={}){return new ne({view(e){return new wu(e,n)}})}class wu{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let g=h.getBoundingClientRect(),p=f?g.bottom:g.top;f&&d&&(p=(p+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:g.left,right:g.right,top:p-y,bottom:p+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*o;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,h=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ki(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Mu=U.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Su(this.options)]}});class N extends v{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return N.valid(r)?new N(r):v.near(r)}content(){return k.empty}eq(e){return e instanceof N&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new N(e.resolve(t.pos))}getBookmark(){return new er(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!vu(e)||!Au(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&N.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(N.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!C.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(N.valid(l))return l}return null}}}N.prototype.visible=!1;N.findFrom=N.findGapCursorFrom;v.jsonID("gapcursor",N);class er{constructor(e){this.pos=e}map(e){return new er(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return N.valid(t)?new N(t):v.near(t)}}function Cs(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function vu(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Cs(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Au(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Cs(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Tu(){return new ne({props:{decorations:Nu,createSelectionBetween(n,e,t){return e.pos==t.pos&&N.valid(t)?new N(t):null},handleClick:Ou,handleKeyDown:Eu,handleDOMEvents:{beforeinput:Iu}}})}const Eu=jl({ArrowLeft:bt("horiz",-1),ArrowRight:bt("horiz",1),ArrowUp:bt("vert",-1),ArrowDown:bt("vert",1)});function bt(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof w){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=N.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new N(c))),!0):!1}}function Ou(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!N.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&C.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new N(r))),!0)}function Iu(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof N))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=x.empty;for(let o=r.length-1;o>=0;o--)i=x.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new k(i,0,0));return s.setSelection(w.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Nu(n){if(!(n.selection instanceof N))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",B.create(n.doc,[oe.widget(n.selection.head,e,{key:"gapcursor"})])}const Ru=U.create({name:"gapCursor",addProseMirrorPlugins(){return[Tu()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=L(H(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Ue={bold:{category:"mark",extension:Fc,priority:100},italic:{category:"mark",extension:Jc,priority:100},strike:{category:"mark",extension:Kc,priority:100},underline:{category:"mark",extension:Ns.Underline,priority:100},code:{category:"mark",extension:Gc,priority:100},textColor:{category:"mark",extension:Rs.Color,defaultOptions:{types:["textStyle"]},priority:90},highlight:{category:"mark",extension:Ds.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Ls.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},paragraph:{category:"node",extension:gs,priority:100},heading:{category:"node",extension:Yc,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:eu,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:nu,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Bs.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ou,priority:100},blockquote:{category:"node",extension:au,priority:100},horizontalRule:{category:"node",extension:cu,priority:100},hardBreak:{category:"node",extension:uu,priority:100},undo:{category:"extension",extension:Ye,priority:50},redo:{category:"extension",extension:Ye,priority:50},textAlign:{category:"extension",extension:zs.TextAlign,defaultOptions:{types:["heading","paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:Ye,priority:50},clearNodes:{category:"extension",extension:Ye,priority:50}},Du=[ku,Cu,gs,Xc,ru,Ps.TaskItem,Ye,Mu,Ru];function Lu(n){const e=[],t=new Set,r=new Set;Du.forEach(l=>{l&&(e.push(l),r.add(l.name),l.name==="history"&&(t.add("undo"),t.add("redo")))});const i=n.map(l=>rt(l)),s=new Set;return i.forEach(l=>{const a=Ue[l];a?.requiredExtensions&&a.requiredExtensions.forEach(c=>{s.add(c)})}),s.forEach(l=>{if(t.has(l))return;const a=Ue[l];if(!a||a.extension===null)return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l)}),i.forEach(l=>{if(t.has(l))return;const a=Ue[l];if(!a||a.extension===null){console.warn(`Extension not found or not installed for modifier: ${l}`);return}if(a.extension.name==="history"&&t.has("undo"))return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l),(l==="undo"||l==="redo")&&(t.add("undo"),t.add("redo"))}),e.sort((l,a)=>{const c=Object.values(Ue).find(h=>h?.extension?.name===l.name),u=Object.values(Ue).find(h=>h?.extension?.name===a.name),f=c?.priority??100;return(u?.priority??100)-f})}const Ss={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks","paragraph",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks","paragraph",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},Bu=({modifiers:n,zoom:e,onZoomChange:t})=>{const{editor:r}=Rn.useCurrentEditor();return m.jsx(ao,{editor:r,modifiers:n,zoom:e,onZoomChange:t})},Pu=({showCharacterCount:n,showWordCount:e})=>{const{editor:t}=Rn.useCurrentEditor();if(!t||!n&&!e)return null;const r=t.getText(),i=r.length,s=r.split(/\s+/).filter(o=>o.length>0).length;return m.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[n&&m.jsxs("span",{children:[i," characters"]}),e&&m.jsxs("span",{children:[s," words"]})]})},Nn=A.forwardRef((n,e)=>{const{minRows:t=10,maxRows:r=30,disableAutosize:i=!1,showCharacterCount:s=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Ss.full,variant:c="bordered",initialContent:u,content:f,onContentChange:d,onUpdate:h,isReadOnly:g=!1,isDisabled:p=!1,...y}=n,{zoom:b,setZoom:O}=so(),E=rr.lineHeight,R=t*E,j=i?void 0:r*E,T=A.useMemo(()=>Lu(a),[a]),{Component:ie,label:G,shouldLabelBeOutside:Ut,getBaseProps:Ms,getLabelProps:vs,getInputWrapperProps:tr}=S.useInput({...y,variant:c,ref:e,isMultiline:!0}),As=G?m.jsx("label",{...vs(),children:G}):null,Ts=A.useCallback(({editor:_t})=>{const Gt=_t.getHTML(),Es=_t.getJSON(),Zt=_t.getText(),Os=Zt.length,Is=Zt.split(/\s+/).filter(Xt=>Xt.length>0).length,nr={html:Gt,json:Es,text:Zt,characters:Os,words:Is};if(d?.(nr),h?.(nr),"onChange"in y&&typeof y.onChange=="function"){const Xt={target:{value:Gt},currentTarget:{value:Gt}};y.onChange(Xt)}},[d,h,y]);return m.jsxs(ie,{...Ms(),children:[Ut?As:null,m.jsx("div",{...tr(),className:S.cn(tr().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:j?`${j+rr.toolbarHeight}px`:void 0,overflow:j?"auto":void 0},children:m.jsx(Rn.EditorProvider,{editable:!g&&!p,slotBefore:l?m.jsx(Bu,{modifiers:a,zoom:b,onZoomChange:O}):void 0,slotAfter:m.jsx(Pu,{showCharacterCount:s,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${R}px`,fontSize:`${b}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:T,content:f||u||n.defaultValue||"",onUpdate:Ts})})]})});Nn.displayName="TipTapEditor";const ws=A.forwardRef((n,e)=>{const{adapter:t="tiptap",variant:r="bordered",...i}=n;return t==="tiptap"?m.jsx(Nn,{...i,variant:r,ref:e}):(console.warn(`Adapter "${t}" is not supported. Using TipTap.`),m.jsx(Nn,{...i,variant:r,ref:e}))});ws.displayName="RichTextArea";function zu(n){return m.jsx("div",{className:"min-h-screen flex flex-col",children:m.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:m.jsx(S.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}function Fu(n){return m.jsx("div",{className:"min-h-screen flex flex-col",children:m.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:m.jsx(S.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}exports.Button=Vs;exports.ConfirmationPageTemplate=zu;exports.EventDetailsTemplate=Fu;exports.Footer=Us;exports.HeroUIProvider=Hs;exports.Navbar=Js;exports.RICH_TEXT_PRESETS=Ss;exports.RichTextArea=ws;exports.Stepper=_r;exports.colors=Ge;exports.spacing=Fs;exports.theme=$s;exports.typography=js;Object.keys(S).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>S[n]})});
|
|
18
|
+
`);return{dom:a,text:h,slice:e}}function fr(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,i||r,n)}),i)return l=new S(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
19
|
+
`))),0,0),n.someProp("transformPasted",h=>{l=h(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",h=>h(e,s,r,n));if(d)l=d;else{let h=s.marks(),{schema:p}=n.state,y=nt.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=o.appendChild(document.createElement("p"));g&&x.appendChild(y.serializeNode(p.text(g,h)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Ki(t),Kt&&Vi(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ue.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!$i.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ui(wn(l,+u[1],+u[2]),u[4]);else if(l=S.maxOpen(qi(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;h<l.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);l=wn(l,d,h)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const $i=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function qi(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&pr(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=mr(o[o.length-1],i.length));let u=hr(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return C.from(o)}return n}function hr(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function pr(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=pr(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(C.from(hr(t,n,s+1))))}}function mr(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,mr(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function Pt(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=Pt(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function wn(n,e,t){return e<n.openStart&&(n=new S(Pt(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new S(Pt(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const gr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let In=null;function yr(){return In||(In=document.implementation.createHTMLDocument("title"))}let Mt=null;function Ji(n){let e=window.trustedTypes;return e?(Mt||(Mt=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Mt.createHTML(n)):n}function Ki(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=yr().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&gr[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Ji(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Vi(n){let e=n.querySelectorAll(Y?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ui(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=C.from(a.create(r[l+1],s)),i++,o++}return new S(s,i,o)}const K={},H={};function ne(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}H.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!br(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Be&&Y&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Jt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,rr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ji(n,t)?t.preventDefault():ne(n,"key")};H.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};H.keypress=(n,e)=>{let t=e;if(br(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||$&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function ot(n){return{left:n.clientX,top:n.clientY}}function Wi(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ut(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function Ce(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Zi(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Ce(n,new A(t)),!0):!1}function _i(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof A&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(A.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(Ce(n,A.create(n.state.doc,s)),!0):!1}function Gi(n,e,t,r,s){return Ut(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?_i(n,t):Zi(n,t))}function Xi(n,e,t,r){return Ut(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function Yi(n,e,t,r){return Ut(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||Qi(n,t,r)}function Qi(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ce(n,M.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Ce(n,M.create(r,l+1,l+1+o.content.size));else if(A.isSelectable(o))Ce(n,A.create(r,l));else continue;return!0}}function Wt(n){return Qe(n)}const xr=$?"metaKey":"ctrlKey";K.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Wt(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Wi(t,n.input.lastClick)&&!t[xr]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button};let o=n.posAtCoords(ot(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new eo(n,o,t,!!r)):(i=="doubleClick"?Xi:Yi)(n,o.pos,o.inside,t)?t.preventDefault():ne(n,"pointer"))};class eo{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[xr],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&it&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ne(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Vt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ot(e))),this.updateAllowDefault(e),this.allowDefault||!t?ne(this.view,"pointer"):Gi(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ge&&this.mightDrag&&!this.mightDrag.node.isAtom||Y&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ce(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ne(this.view,"pointer")}move(e){this.updateAllowDefault(e),ne(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}K.touchstart=n=>{n.input.lastTouch=Date.now(),Wt(n),ne(n,"pointer")};K.touchmove=n=>{n.input.lastTouch=Date.now(),ne(n,"pointer")};K.contextmenu=n=>Wt(n);function br(n,e){return n.composing?!0:ge&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const to=Be?5e3:-1;H.compositionstart=H.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof M&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Y&&lr&&no(n)))n.markCursor=n.state.storedMarks||t.marks(),Qe(n,!0),n.markCursor=null;else if(Qe(n,!e.selection.empty),it&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}kr(n,to)};function no(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}H.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,kr(n,20))};function kr(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Qe(n),e))}function ro(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=so());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function so(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Qe(n,e=!1){if(!(Be&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ro(n),e||n.docView&&n.docView.dirty){let t=Oi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function io(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Re=ze&&ir<15||Jt&&vi<604;K.copy=H.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=Re?null:t.clipboardData,o=r.content(),{dom:l,text:a}=dr(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):io(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function oo(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function lo(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?zt(n,r.value,null,s,e):zt(n,r.textContent,r.innerHTML,s,e)},50)}function zt(n,e,t,r,s){let i=fr(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||S.empty)))return!0;if(!i)return!1;let o=oo(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cr(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}H.paste=(n,e)=>{let t=e;if(n.composing&&!Be)return;let r=Re?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&zt(n,Cr(r),r.getData("text/html"),s,t)?t.preventDefault():lo(n,t)};class ao{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const co=$?"altKey":"ctrlKey";function Sr(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[co]}K.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(ot(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof A?s.to-1:s.to))){if(r&&r.mightDrag)o=A.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=A.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=dr(n,l);(!t.dataTransfer.files.length||!Y||or>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Re?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Re||t.dataTransfer.setData("text/plain",c),n.dragging=new ao(u,Sr(n,t),o)};K.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};H.dragover=H.dragenter=(n,e)=>e.preventDefault();H.drop=(n,e)=>{try{uo(n,e,n.dragging)}finally{n.dragging=null}};function uo(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ot(e));if(!r)return;let s=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",p=>{i=p(i,n,!1)}):i=fr(n,Cr(e.dataTransfer),Re?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(t&&Sr(n,e));if(n.someProp("handleDrop",p=>p(n,e,i||S.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Zn(n.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(o){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&A.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new A(h));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((y,g,x,N)=>p=N),a.setSelection(cr(n,h,a.doc.resolve(p)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}K.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Vt(n)},20))};K.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};K.beforeinput=(n,e)=>{if(Y&&Be&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,rr(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in H)K[n]=H[n];function Pe(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class et{constructor(e,t){this.toDOM=e,this.spec=t||he,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new W(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof et&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pe(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class re{constructor(e,t){this.attrs=e,this.spec=t||he}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new W(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof re&&Pe(this.attrs,e.attrs)&&Pe(this.spec,e.spec)}static is(e){return e.type instanceof re}destroy(){}}class Zt{constructor(e,t){this.attrs=e,this.spec=t||he}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new W(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof Zt&&Pe(this.attrs,e.attrs)&&Pe(this.spec,e.spec)}destroy(){}}class W{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new W(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new W(e,e,new et(t,r))}static inline(e,t,r,s){return new W(e,t,new re(r,s))}static node(e,t,r,s){return new W(e,t,new Zt(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof re}get widget(){return this.type instanceof et}}const be=[],he={};class I{constructor(e,t){this.local=e.length?e:be,this.children=t.length?t:be}static create(e,t){return t.length?tt(t,e,0,he):z}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==z||e.maps.length==0?this:this.mapInner(e,t,0,0,r||he)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?fo(this.children,o||[],e,t,r,s,i):o?new I(o.sort(pe),be):z}add(e,t){return t.length?this==z?I.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Tr(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,tt(u,l,c+1,he)),i+=3}});let o=Ar(i?Mr(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new I(o.length?this.local.concat(o).sort(pe):this.local,s||this.children)}remove(e){return e.length==0||this==z?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=z?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new I(s,r):z}forChild(e,t){if(this==z)return this;if(t.isLeaf)return I.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof re){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new I(s.sort(pe),be);return r?new ae([l,r]):l}return r||z}eq(e){if(this==e)return!0;if(!(e instanceof I)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return _t(this.localsInner(e))}localsInner(e){if(this==z)return be;if(e.inlineContent||!this.local.some(re.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof re||t.push(this.local[r]);return t}forEachSet(e){e(this)}}I.empty=new I([],[]);I.removeOverlap=_t;const z=I.empty;class ae{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,he));return ae.from(r)}forChild(e,t){if(t.isLeaf)return I.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=z&&(i instanceof ae?r=r.concat(i.members):r.push(i))}return ae.from(r)}eq(e){if(!(e instanceof ae)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?_t(r?t:t.sort(pe)):be}static from(e){switch(e.length){case 0:return z;case 1:return e[0];default:return new ae(e.every(t=>t instanceof I)?e:e.reduce((t,r)=>t.concat(r instanceof I?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function fo(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((h,p,y,g)=>{let x=g-y-(p-h);for(let N=0;N<l.length;N+=3){let j=l[N+1];if(j<0||h>j+u-d)continue;let B=l[N]+u-d;p>=B?l[N+1]=h<=B?-2:-1:h>=u&&x&&(l[N]+=x,l[N+1]+=x)}d+=x}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),p=h-s,{index:y,offset:g}=r.content.findIndex(d),x=r.maybeChild(y);if(x&&g==d&&g+x.nodeSize==p){let N=l[c+2].mapInner(t,x,u+1,n[c]+i+1,o);N!=z?(l[c]=d,l[c+1]=p,l[c+2]=N):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ho(l,n,e,t,s,i,o),u=tt(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let p=u.children[d];for(;h<l.length&&l[h]<p;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new I(e.sort(pe),l)}function Ar(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new W(s.from+e,s.to+e,s.type))}return t}function ho(n,e,t,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Tr(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Mr(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function tt(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Tr(n,l,a+t);if(c){i=!0;let u=tt(c,l,t+a+1,r);u!=z&&s.push(a,a+l.nodeSize,u)}});let o=Ar(i?Mr(n):n,-t).sort(pe);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new I(o,s):z}function pe(n,e){return n.from-e.from||n.to-e.to}function _t(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),Dn(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Dn(e,s,r.copy(i.from,r.to)));break}}}return e}function Dn(n,e,t){for(;e<n.length&&pe(t,n[e])>0;)e++;n.splice(e,0,t)}class O extends E{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return O.valid(r)?new O(r):E.near(r)}content(){return S.empty}eq(e){return e instanceof O&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new O(e.resolve(t.pos))}getBookmark(){return new Gt(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!po(e)||!mo(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&O.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(O.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!A.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(O.valid(l))return l}return null}}}O.prototype.visible=!1;O.findFrom=O.findGapCursorFrom;E.jsonID("gapcursor",O);class Gt{constructor(e){this.pos=e}map(e){return new Gt(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return O.valid(t)?new O(t):E.near(t)}}function Er(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function po(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Er(s.type))return!0;if(s.inlineContent)return!1}}return!0}function mo(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Er(s.type))return!0;if(s.inlineContent)return!1}}return!0}function go(){return new st({props:{decorations:ko,createSelectionBetween(n,e,t){return e.pos==t.pos&&O.valid(t)?new O(t):null},handleClick:xo,handleKeyDown:yo,handleDOMEvents:{beforeinput:bo}}})}const yo=Mi({ArrowLeft:qe("horiz",-1),ArrowRight:qe("horiz",1),ArrowUp:qe("vert",-1),ArrowDown:qe("vert",1)});function qe(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=O.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new O(c))),!0):!1}}function xo(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!O.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&A.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new O(r))),!0)}function bo(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof O))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=C.empty;for(let o=r.length-1;o>=0;o--)s=C.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new S(s,0,0));return i.setSelection(M.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function ko(n){if(!(n.selection instanceof O))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",I.create(n.doc,[W.widget(n.selection.head,e,{key:"gapcursor"})])}const Co=m.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[go()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=m.callOrReturn(m.getExtensionField(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Ae={bold:{category:"mark",extension:bs,priority:100},italic:{category:"mark",extension:Ts,priority:100},strike:{category:"mark",extension:Ns,priority:100},underline:{category:"mark",extension:Br.Underline,priority:100},code:{category:"mark",extension:ws,priority:100},textColor:{category:"mark",extension:Fr.Color,defaultOptions:{types:["textStyle"]},priority:90},highlight:{category:"mark",extension:Hr.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:jr.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},paragraph:{category:"node",extension:zn,priority:100},heading:{category:"node",extension:Ls,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ps,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Bs,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:$r.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Qs,priority:100},blockquote:{category:"node",extension:ti,priority:100},horizontalRule:{category:"node",extension:ni,priority:100},hardBreak:{category:"node",extension:ri,priority:100},undo:{category:"extension",extension:Ee,priority:50},redo:{category:"extension",extension:Ee,priority:50},textAlign:{category:"extension",extension:Jr.TextAlign,defaultOptions:{types:["heading","paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:Ee,priority:50},clearNodes:{category:"extension",extension:Ee,priority:50}},So=[hi,pi,zn,Ds,Fs,qr.TaskItem,Ee,yi,Co];function Ao(n){const e=[],t=new Set,r=new Set;So.forEach(l=>{l&&(e.push(l),r.add(l.name),l.name==="history"&&(t.add("undo"),t.add("redo")))});const s=n.map(l=>we(l)),i=new Set;return s.forEach(l=>{const a=Ae[l];a?.requiredExtensions&&a.requiredExtensions.forEach(c=>{i.add(c)})}),i.forEach(l=>{if(t.has(l))return;const a=Ae[l];if(!a||a.extension===null)return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l)}),s.forEach(l=>{if(t.has(l))return;const a=Ae[l];if(!a||a.extension===null){console.warn(`Extension not found or not installed for modifier: ${l}`);return}if(a.extension.name==="history"&&t.has("undo"))return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l),(l==="undo"||l==="redo")&&(t.add("undo"),t.add("redo"))}),e.sort((l,a)=>{const c=Object.values(Ae).find(p=>p?.extension?.name===l.name),u=Object.values(Ae).find(p=>p?.extension?.name===a.name),d=c?.priority??100;return(u?.priority??100)-d})}const Nr={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks","paragraph",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks","paragraph",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},To=({modifiers:n,zoom:e,onZoomChange:t})=>{const{editor:r}=Ft.useCurrentEditor();return f.jsx(ps,{editor:r,modifiers:n,zoom:e,onZoomChange:t})},Mo=({showCharacterCount:n,showWordCount:e})=>{const{editor:t}=Ft.useCurrentEditor();if(!t||!n&&!e)return null;const r=t.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return f.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[n&&f.jsxs("span",{children:[s," characters"]}),e&&f.jsxs("span",{children:[i," words"]})]})},Bt=T.forwardRef((n,e)=>{const{minRows:t=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Nr.full,variant:c="bordered",initialContent:u,content:d,onContentChange:h,onUpdate:p,isReadOnly:y=!1,isDisabled:g=!1,...x}=n,{zoom:N,setZoom:j}=ds(),B=Qt.lineHeight,V=t*B,Se=s?void 0:r*B,v=T.useMemo(()=>Ao(a),[a]),{Component:lt,label:Fe,shouldLabelBeOutside:Or,getBaseProps:wr,getLabelProps:Ir,getInputWrapperProps:Xt}=b.useInput({...x,variant:c,ref:e,isMultiline:!0}),Dr=Fe?f.jsx("label",{...Ir(),children:Fe}):null,Lr=T.useCallback(({editor:at})=>{const ct=at.getHTML(),Rr=at.getJSON(),ut=at.getText(),Pr=ut.length,zr=ut.split(/\s+/).filter(dt=>dt.length>0).length,Yt={html:ct,json:Rr,text:ut,characters:Pr,words:zr};if(h?.(Yt),p?.(Yt),"onChange"in x&&typeof x.onChange=="function"){const dt={target:{value:ct},currentTarget:{value:ct}};x.onChange(dt)}},[h,p,x]);return f.jsxs(lt,{...wr(),children:[Or?Dr:null,f.jsx("div",{...Xt(),className:b.cn(Xt().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:Se?`${Se+Qt.toolbarHeight}px`:void 0,overflow:Se?"auto":void 0},children:f.jsx(Ft.EditorProvider,{editable:!y&&!g,slotBefore:l?f.jsx(To,{modifiers:a,zoom:N,onZoomChange:j}):void 0,slotAfter:f.jsx(Mo,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${V}px`,fontSize:`${N}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:v,content:d||u||n.defaultValue||"",onUpdate:Lr})})]})});Bt.displayName="TipTapEditor";const vr=T.forwardRef((n,e)=>{const{adapter:t="tiptap",variant:r="bordered",...s}=n;return t==="tiptap"?f.jsx(Bt,{...s,variant:r,ref:e}):(console.warn(`Adapter "${t}" is not supported. Using TipTap.`),f.jsx(Bt,{...s,variant:r,ref:e}))});vr.displayName="RichTextArea";function Eo(n){return f.jsx("div",{className:"min-h-screen flex flex-col",children:f.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:f.jsx(b.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}function No(n){return f.jsx("div",{className:"min-h-screen flex flex-col",children:f.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:f.jsx(b.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}exports.Button=Zr;exports.ConfirmationPageTemplate=Eo;exports.EventDetailsTemplate=No;exports.Footer=Qr;exports.HeroUIProvider=Wr;exports.Navbar=_r;exports.RICH_TEXT_PRESETS=Nr;exports.RichTextArea=vr;exports.Stepper=Ln;exports.colors=Me;exports.spacing=Kr;exports.theme=Ur;exports.typography=Vr;Object.keys(b).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>b[n]})});
|
|
20
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('.ProseMirror{flex:1;width:100%;min-height:100%;height:100%;cursor:text;background-color:#fff;padding:1rem;overflow-y:auto;box-sizing:border-box}.ProseMirror p{min-height:1.5em}.dark .ProseMirror{background-color:rgb(var(--nextui-background))}.ProseMirror ul{list-style-type:disc!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ol{list-style-type:decimal!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ul li,.ProseMirror ol li{display:list-item!important;list-style:inherit!important;margin:.25rem 0!important}.ProseMirror ul li p,.ProseMirror ol li p{margin:0!important;display:inline!important}.ProseMirror ul[data-type=taskList]{list-style:none!important;padding-left:0!important;margin:1rem 0!important}.ProseMirror ul[data-type=taskList] li{display:flex!important;align-items:flex-start!important;margin:.5rem 0!important}.ProseMirror ul[data-type=taskList] li label{margin-right:.5rem;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ProseMirror ul[data-type=taskList] li input[type=checkbox]{cursor:pointer;margin-top:.25rem}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.2!important;margin:1rem 0 .5rem!important;font-weight:600!important}.ProseMirror h1{font-size:2rem!important}.ProseMirror h2{font-size:1.5rem!important}.ProseMirror h3{font-size:1.25rem!important}.ProseMirror h4{font-size:1.1rem!important}.ProseMirror h5{font-size:1rem!important;font-weight:600!important}.ProseMirror h6{font-size:.9rem!important;font-weight:600!important}.ProseMirror code{background-color:rgb(var(--nextui-default-100));border-radius:.4rem;color:rgb(var(--nextui-default-800));font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:rgb(var(--nextui-default-900));border-radius:.5rem;color:rgb(var(--nextui-default-50));font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem;overflow-x:auto}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror mark{background-color:#faf594;border-radius:.4rem;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:.1rem .3rem}.ProseMirror blockquote{border-left:3px solid rgb(var(--nextui-default-300));margin:1.5rem 0;padding-left:1rem;color:rgb(var(--nextui-default-600))}.ProseMirror hr{border:none;border-top:1px solid rgb(var(--nextui-divider));margin:2rem 0}.ProseMirror a{color:rgb(var(--nextui-primary));text-decoration:underline;cursor:pointer}.ProseMirror a:hover{text-decoration:none}.ProseMirror strong{font-weight:700!important}.ProseMirror em{font-style:italic!important}.ProseMirror s{text-decoration:line-through!important}.ProseMirror u{text-decoration:underline!important}.ProseMirror .has-text-align-left,.ProseMirror [style*="text-align: left"]{text-align:left!important}.ProseMirror .has-text-align-center,.ProseMirror [style*="text-align: center"]{text-align:center!important}.ProseMirror .has-text-align-right,.ProseMirror [style*="text-align: right"]{text-align:right!important}.ProseMirror .has-text-align-justify,.ProseMirror [style*="text-align: justify"]{text-align:justify!important}.ProseMirror p.is-editor-empty:first-child:before{color:rgb(var(--nextui-default-400));content:attr(data-placeholder);float:left;height:0;pointer-events:none}')),document.head.appendChild(r)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|