@veevarts/design-system 1.0.0-dev.16 → 1.0.0-dev.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -10
- package/dist/index.js +2213 -1959
- package/dist/patterns/Multiselect/Multiselect.d.ts +2 -0
- package/dist/patterns/Multiselect/__test__/Multiselect.test.d.ts +4 -0
- package/dist/patterns/Multiselect/index.d.ts +2 -0
- package/dist/patterns/Multiselect/types.d.ts +7 -0
- package/dist/patterns/RichText/index.d.ts +1 -0
- package/dist/patterns/RichText/types/props.d.ts +11 -0
- package/dist/patterns/RichText/utils/index.d.ts +1 -0
- package/dist/patterns/RichText/utils/inlineStyles.d.ts +29 -0
- package/dist/patterns/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),y=require("@heroui/react"),k=require("react"),F=require("lucide-react"),De=require("framer-motion"),ur=require("@tiptap/react"),L=require("@tiptap/core"),jo=require("@tiptap/extension-underline"),Lo=require("@tiptap/extension-color"),Ro=require("@tiptap/extension-highlight"),Fo=require("@tiptap/extension-link"),Po=require("@tiptap/extension-task-list"),Vo=require("@tiptap/extension-task-item"),Bo=require("@tiptap/extension-text-align");function _o({children:t}){return c.jsx(y.HeroUIProvider,{children:t})}const de=k.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(y.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));de.displayName="Button";const $o={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function zo({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(F.Globe,{className:"absolute left-3 w-5 h-5 pointer-events-none text-black"}),c.jsx(y.Select,{"data-testid":"language-select-desktop","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-40 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(F.Globe,{className:"w-5 h-5 text-black"}),children:t.map(s=>c.jsx(y.SelectItem,{textValue:s.label,"data-testid":`language-select-option-${s.code}`,children:s.label},s.code))}),c.jsx(y.Select,{"aria-label":r,"data-testid":"language-select-mobile",selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-20 inline-flex md:hidden",isDisabled:t.length===0,placeholder:e||"Language",children:t.map(s=>c.jsx(y.SelectItem,{className:"min-w-4",textValue:s.code.toUpperCase(),"data-testid":`language-select-option-mobile-${s.code}`,children:s.code.toUpperCase()},s.code))})]})})}function Ho({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(de,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,children:[c.jsx(F.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(de,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:e,children:[c.jsx(F.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Uo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...$o,...u};return c.jsxs("nav",{"data-testid":"navbar",className:y.cn("w-full px-4 md:px-8 py-4 bg-white border-b border-zinc-100 flex items-center justify-between",d),children:[c.jsx("div",{className:"flex items-center min-w-10",children:t&&c.jsx("a",{href:"/",className:"block",children:c.jsx("img",{"data-testid":"navbar-logo",src:t,alt:"Logo",className:"h-8 max-w-28 md:max-w-40"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||e.length>0)&&c.jsx(zo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Ho,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function qo(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(y.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"})})})}var Nn;const Ko=typeof document<"u"?(Nn=k.useInsertionEffect)!==null&&Nn!==void 0?Nn:k.useLayoutEffect:()=>{};function dr(t,e,n){let[r,s]=k.useState(t||e),i=k.useRef(r),o=k.useRef(t!==void 0),l=t!==void 0;k.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?t:r;Ko(()=>{i.current=a});let[,u]=k.useReducer(()=>({}),{}),d=k.useCallback((f,...p)=>{let m=typeof f=="function"?f(i.current):f;Object.is(i.current,m)||(i.current=m,s(m),u(),n?.(m,...p))},[n]);return[a,d]}function Jo(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx(De.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 Js=k.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,...u},d)=>{const[f,p]=dr(i,n,s),m=k.useMemo(()=>{let v,x;const C=["[--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(t){case"primary":v="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":v="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":v="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":v="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":v="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":v="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:v="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return C.unshift(x),C.unshift(v),C},[t]);return c.jsxs("nav",{ref:d,"aria-label":"Progress",className:y.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...u,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:y.cn("flex flex-row flex-nowrap gap-x-3",m,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((v,x)=>{const C=f===x?"active":f<x?"inactive":"complete";return c.jsx("li",{className:"relative flex w-full items-center pr-12","data-testid":`stepper-step-${x}`,children:c.jsxs("button",{"aria-current":C==="active"?"step":void 0,className:y.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",l),onClick:()=>p(x),"data-testid":`stepper-step-btn-${x}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx(De.LazyMotion,{features:De.domAnimation,children:c.jsx(De.m.div,{animate:C,className:"relative",children:c.jsx(De.m.div,{animate:C,className:y.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":C==="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:c.jsx("div",{className:"flex items-center justify-center",children:C==="complete"?c.jsx(Jo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):c.jsx("span",{})})})})})}),x<e-1&&!o&&c.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":x},children:c.jsx("div",{className:y.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":x<f})})})]},x)},x)})})]})});Js.displayName="Stepper";function Wo(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(y.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"})})})}function Go(){return c.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}function Dt(t){return typeof t=="string"?t:t.type}function et({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(y.Divider,{orientation:"vertical"})})}function Ue({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return c.jsx(y.Tooltip,{content:a,placement:"top",offset:10,children:c.jsx(de,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:c.jsx(t,{size:o})})})}const $e={bold:{execute:({editor:t})=>t.chain().focus().toggleBold().run(),canExecute:t=>t.can().chain().focus().toggleBold().run(),isActive:t=>t.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:t})=>t.chain().focus().toggleItalic().run(),canExecute:t=>t.can().chain().focus().toggleItalic().run(),isActive:t=>t.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:t})=>t.chain().focus().toggleStrike().run(),canExecute:t=>t.can().chain().focus().toggleStrike().run(),isActive:t=>t.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:t})=>t.chain().focus().toggleUnderline().run(),canExecute:t=>t.can().chain().focus().toggleUnderline().run(),isActive:t=>t.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:t})=>t.chain().focus().toggleCode().run(),canExecute:t=>t.can().chain().focus().toggleCode().run(),isActive:t=>t.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:t,config:e})=>{const n=e?.type==="textColor"?e.color:"";n?t.chain().focus().setColor(n).run():t.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:t=>t.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:t,config:e})=>{const n=e?.type==="highlight"?e.color:"";n?t.chain().focus().setHighlight({color:n}).run():t.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:t=>t.isActive("highlight"),label:"Highlight"},link:{execute:({editor:t,config:e})=>{const n=e?.type==="link"?e.href:"";if(n){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;t.chain().focus().setLink({href:n,target:r,rel:s}).run()}else t.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:t=>t.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:t})=>t.chain().focus().setParagraph().run(),canExecute:t=>t.can().chain().focus().setParagraph().run(),isActive:t=>t.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:t,config:e})=>{const n=e?.type==="heading"?e.level:1;t.chain().focus().toggleHeading({level:n}).run()},canExecute:(t,e)=>{const n=e?.type==="heading"?e.level:1;return t.can().chain().focus().toggleHeading({level:n}).run()},isActive:(t,e)=>e?.type==="heading"?t.isActive("heading",{level:e.level}):t.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:t})=>t.chain().focus().toggleBulletList().run(),canExecute:t=>t.can().chain().focus().toggleBulletList().run(),isActive:t=>t.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:t})=>t.chain().focus().toggleOrderedList().run(),canExecute:t=>t.can().chain().focus().toggleOrderedList().run(),isActive:t=>t.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:t})=>t.chain().focus().toggleTaskList().run(),canExecute:t=>t.can().chain().focus().toggleTaskList().run(),isActive:t=>t.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:t})=>t.chain().focus().toggleCodeBlock().run(),canExecute:t=>t.can().chain().focus().toggleCodeBlock().run(),isActive:t=>t.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:t})=>t.chain().focus().toggleBlockquote().run(),canExecute:t=>t.can().chain().focus().toggleBlockquote().run(),isActive:t=>t.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:t})=>t.chain().focus().setHorizontalRule().run(),canExecute:t=>t.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:t})=>t.chain().focus().setHardBreak().run(),canExecute:t=>t.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:t,config:e})=>{const n=e?.type==="textAlign"?e.alignment:"left";t.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(t,e)=>e?.type==="textAlign"?t.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:t})=>t.chain().focus().unsetAllMarks().run(),canExecute:t=>t.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:t})=>t.chain().focus().clearNodes().run(),canExecute:t=>t.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:t})=>t.chain().focus().undo().run(),canExecute:t=>t.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:t})=>t.chain().focus().redo().run(),canExecute:t=>t.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Zo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Qo({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=k.useState(0);k.useEffect(()=>{const o=()=>r(l=>l+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=$e.heading;a&&a.execute({editor:t,config:{type:"heading",level:l}})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(de,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(F.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),c.jsx(y.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(y.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(F.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:Zo[o]},o))})]})}const En={bulletList:{label:"Bullet List",icon:F.List},orderedList:{label:"Numbered List",icon:F.ListOrdered},taskList:{label:"Task List",icon:F.ListTodo}};function Xo({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=k.useState(0);k.useEffect(()=>{const l=()=>r(a=>a+1);return t.on("selectionUpdate",l),t.on("transaction",l),()=>{t.off("selectionUpdate",l),t.off("transaction",l)}},[t]);const s=e.find(l=>t.isActive(l)),i=s?En[s].icon:F.List,o=l=>{const u=$e[l];u&&u.execute({editor:t})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(de,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:c.jsx(i,{size:16})})}),c.jsx(y.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=En[l].icon;return c.jsx(y.DropdownItem,{startContent:c.jsx(a,{size:16}),children:En[l].label},l)})})]})}function Yo({colors:t,selectedColor:e,onColorSelect:n,columns:r=4}){return c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:t.map(s=>{const i=e===s;return c.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),y=require("@heroui/react"),k=require("react"),z=require("lucide-react"),je=require("framer-motion"),ur=require("@tiptap/react"),R=require("@tiptap/core"),jo=require("@tiptap/extension-underline"),Lo=require("@tiptap/extension-color"),Ro=require("@tiptap/extension-highlight"),Fo=require("@tiptap/extension-link"),Po=require("@tiptap/extension-task-list"),Vo=require("@tiptap/extension-task-item"),$o=require("@tiptap/extension-text-align");function Bo({children:t}){return c.jsx(y.HeroUIProvider,{children:t})}const se=k.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(y.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));se.displayName="Button";const _o={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function zo({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(z.Globe,{className:"absolute left-3 w-5 h-5 pointer-events-none text-black"}),c.jsx(y.Select,{"data-testid":"language-select-desktop","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-40 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(z.Globe,{className:"w-5 h-5 text-black"}),children:t.map(s=>c.jsx(y.SelectItem,{textValue:s.label,"data-testid":`language-select-option-${s.code}`,children:s.label},s.code))}),c.jsx(y.Select,{"aria-label":r,"data-testid":"language-select-mobile",selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-20 inline-flex md:hidden",isDisabled:t.length===0,placeholder:e||"Language",children:t.map(s=>c.jsx(y.SelectItem,{className:"min-w-4",textValue:s.code.toUpperCase(),"data-testid":`language-select-option-mobile-${s.code}`,children:s.code.toUpperCase()},s.code))})]})})}function Ho({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(se,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,children:[c.jsx(z.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(se,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:e,children:[c.jsx(z.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Uo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={..._o,...u};return c.jsxs("nav",{"data-testid":"navbar",className:y.cn("w-full px-4 md:px-8 py-4 bg-white border-b border-zinc-100 flex items-center justify-between",d),children:[c.jsx("div",{className:"flex items-center min-w-10",children:t&&c.jsx("a",{href:"/",className:"block",children:c.jsx("img",{"data-testid":"navbar-logo",src:t,alt:"Logo",className:"h-8 max-w-28 md:max-w-40"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||e.length>0)&&c.jsx(zo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Ho,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function qo(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(y.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"})})})}var Nn;const Ko=typeof document<"u"?(Nn=k.useInsertionEffect)!==null&&Nn!==void 0?Nn:k.useLayoutEffect:()=>{};function dr(t,e,n){let[r,s]=k.useState(t||e),i=k.useRef(r),o=k.useRef(t!==void 0),l=t!==void 0;k.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?t:r;Ko(()=>{i.current=a});let[,u]=k.useReducer(()=>({}),{}),d=k.useCallback((f,...p)=>{let m=typeof f=="function"?f(i.current):f;Object.is(i.current,m)||(i.current=m,s(m),u(),n?.(m,...p))},[n]);return[a,d]}function Jo(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx(je.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 Js=k.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,...u},d)=>{const[f,p]=dr(i,n,s),m=k.useMemo(()=>{let v,x;const S=["[--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(t){case"primary":v="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":v="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":v="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":v="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":v="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":v="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:v="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(x),S.unshift(v),S},[t]);return c.jsxs("nav",{ref:d,"aria-label":"Progress",className:y.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...u,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:y.cn("flex flex-row flex-nowrap gap-x-3",m,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((v,x)=>{const S=f===x?"active":f<x?"inactive":"complete";return c.jsx("li",{className:"relative flex w-full items-center pr-12","data-testid":`stepper-step-${x}`,children:c.jsxs("button",{"aria-current":S==="active"?"step":void 0,className:y.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",l),onClick:()=>p(x),"data-testid":`stepper-step-btn-${x}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx(je.LazyMotion,{features:je.domAnimation,children:c.jsx(je.m.div,{animate:S,className:"relative",children:c.jsx(je.m.div,{animate:S,className:y.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":S==="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:c.jsx("div",{className:"flex items-center justify-center",children:S==="complete"?c.jsx(Jo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):c.jsx("span",{})})})})})}),x<e-1&&!o&&c.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":x},children:c.jsx("div",{className:y.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":x<f})})})]},x)},x)})})]})});Js.displayName="Stepper";function Wo(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(y.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"})})})}function Go(){return c.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}const Zo=t=>{const e=k.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(Qo,{...t},e)},Qo=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=k.useState([]),[l,a]=k.useState([]),[u,d]=k.useState(null),[f,p]=k.useState(null),m=k.useMemo(()=>new Set(e),[e]),v=k.useMemo(()=>new Set(t),[t]),x=k.useMemo(()=>t.filter(P=>!m.has(P)),[t,m]),S=P=>{if(P.length===0)return;const M=Array.from(new Set([...e,...P]));n(M)},C=P=>{if(P.length===0)return;const M=new Set(P);n(e.filter(F=>!M.has(F)))},w=()=>{i.length!==0&&(S(i),o([]))},j=()=>{l.length!==0&&(C(l),a([]))},N=()=>{x.length!==0&&(S(x),o([]))},D=()=>{e.length!==0&&(n([]),a([]))},L=(P,M,F)=>{const V=Math.min(M,F),B=Math.max(M,F);return P.slice(V,B+1)},O=(P,M,F)=>{if(F&&u!==null){o(L(x,u,M)),a([]),d(M);return}const V=i.includes(P);o(V?i.filter(B=>B!==P):[...i,P]),a([]),d(M)},_=(P,M,F)=>{if(F&&f!==null){a(L(e,f,M)),o([]),p(M);return}const V=l.includes(P);a(V?l.filter(B=>B!==P):[...l,P]),o([]),p(M)},H=(P,M,F)=>{const V=F==="available"?i.includes(M)?i:[M]:l.includes(M)?l:[M];P.dataTransfer.setData("text/plain",JSON.stringify({source:F,items:V})),P.dataTransfer.effectAllowed="move"},U=(P,M)=>{P.preventDefault();const F=P.dataTransfer.getData("text/plain");if(F)try{const V=JSON.parse(F),B=(V.items||[]).filter(Y=>v.has(Y));if(B.length===0||V.source===M)return;M==="selected"?(S(B),o([])):(C(B),a([]))}catch{return}};return c.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),c.jsx(y.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(y.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:P=>P.preventDefault(),onDrop:P=>U(P,"available"),children:x.map((P,M)=>{const F=i.includes(P);return c.jsx("button",{type:"button",onClick:V=>{O(P,M,V.shiftKey)},onMouseDown:V=>{V.shiftKey&&V.preventDefault()},draggable:!0,onDragStart:V=>H(V,P,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${F?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:P},P)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:w,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:j,isDisabled:l.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:N,isDisabled:x.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:D,"data-testid":"move-all-to-available",isDisabled:e.length===0,"aria-label":"Move all to left",children:"«"})]}),c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),c.jsx(y.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(y.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:P=>P.preventDefault(),onDrop:P=>U(P,"selected"),children:e.map((P,M)=>{const F=l.includes(P);return c.jsx("button",{type:"button",onClick:V=>{_(P,M,V.shiftKey)},onMouseDown:V=>{V.shiftKey&&V.preventDefault()},draggable:!0,onDragStart:V=>H(V,P,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${F?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:P},P)})})})]})]})};function Dt(t){return typeof t=="string"?t:t.type}function Ye({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(y.Divider,{orientation:"vertical"})})}function qe({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return c.jsx(y.Tooltip,{content:a,placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:c.jsx(t,{size:o})})})}const _e={bold:{execute:({editor:t})=>t.chain().focus().toggleBold().run(),canExecute:t=>t.can().chain().focus().toggleBold().run(),isActive:t=>t.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:t})=>t.chain().focus().toggleItalic().run(),canExecute:t=>t.can().chain().focus().toggleItalic().run(),isActive:t=>t.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:t})=>t.chain().focus().toggleStrike().run(),canExecute:t=>t.can().chain().focus().toggleStrike().run(),isActive:t=>t.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:t})=>t.chain().focus().toggleUnderline().run(),canExecute:t=>t.can().chain().focus().toggleUnderline().run(),isActive:t=>t.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:t})=>t.chain().focus().toggleCode().run(),canExecute:t=>t.can().chain().focus().toggleCode().run(),isActive:t=>t.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:t,config:e})=>{const n=e?.type==="textColor"?e.color:"";n?t.chain().focus().setColor(n).run():t.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:t=>t.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:t,config:e})=>{const n=e?.type==="highlight"?e.color:"";n?t.chain().focus().setHighlight({color:n}).run():t.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:t=>t.isActive("highlight"),label:"Highlight"},link:{execute:({editor:t,config:e})=>{const n=e?.type==="link"?e.href:"";if(n){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;t.chain().focus().setLink({href:n,target:r,rel:s}).run()}else t.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:t=>t.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:t})=>t.chain().focus().setParagraph().run(),canExecute:t=>t.can().chain().focus().setParagraph().run(),isActive:t=>t.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:t,config:e})=>{const n=e?.type==="heading"?e.level:1;t.chain().focus().toggleHeading({level:n}).run()},canExecute:(t,e)=>{const n=e?.type==="heading"?e.level:1;return t.can().chain().focus().toggleHeading({level:n}).run()},isActive:(t,e)=>e?.type==="heading"?t.isActive("heading",{level:e.level}):t.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:t})=>t.chain().focus().toggleBulletList().run(),canExecute:t=>t.can().chain().focus().toggleBulletList().run(),isActive:t=>t.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:t})=>t.chain().focus().toggleOrderedList().run(),canExecute:t=>t.can().chain().focus().toggleOrderedList().run(),isActive:t=>t.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:t})=>t.chain().focus().toggleTaskList().run(),canExecute:t=>t.can().chain().focus().toggleTaskList().run(),isActive:t=>t.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:t})=>t.chain().focus().toggleCodeBlock().run(),canExecute:t=>t.can().chain().focus().toggleCodeBlock().run(),isActive:t=>t.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:t})=>t.chain().focus().toggleBlockquote().run(),canExecute:t=>t.can().chain().focus().toggleBlockquote().run(),isActive:t=>t.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:t})=>t.chain().focus().setHorizontalRule().run(),canExecute:t=>t.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:t})=>t.chain().focus().setHardBreak().run(),canExecute:t=>t.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:t,config:e})=>{const n=e?.type==="textAlign"?e.alignment:"left";t.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(t,e)=>e?.type==="textAlign"?t.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:t})=>t.chain().focus().unsetAllMarks().run(),canExecute:t=>t.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:t})=>t.chain().focus().clearNodes().run(),canExecute:t=>t.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:t})=>t.chain().focus().undo().run(),canExecute:t=>t.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:t})=>t.chain().focus().redo().run(),canExecute:t=>t.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Xo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Yo({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=k.useState(0);k.useEffect(()=>{const o=()=>r(l=>l+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=_e.heading;a&&a.execute({editor:t,config:{type:"heading",level:l}})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(z.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),c.jsx(y.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(y.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(z.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:Xo[o]},o))})]})}const En={bulletList:{label:"Bullet List",icon:z.List},orderedList:{label:"Numbered List",icon:z.ListOrdered},taskList:{label:"Task List",icon:z.ListTodo}};function el({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=k.useState(0);k.useEffect(()=>{const l=()=>r(a=>a+1);return t.on("selectionUpdate",l),t.on("transaction",l),()=>{t.off("selectionUpdate",l),t.off("transaction",l)}},[t]);const s=e.find(l=>t.isActive(l)),i=s?En[s].icon:z.List,o=l=>{const u=_e[l];u&&u.execute({editor:t})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:c.jsx(i,{size:16})})}),c.jsx(y.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=En[l].icon;return c.jsx(y.DropdownItem,{startContent:c.jsx(a,{size:16}),children:En[l].label},l)})})]})}function tl({colors:t,selectedColor:e,onColorSelect:n,columns:r=4}){return c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:t.map(s=>{const i=e===s;return c.jsx("button",{type:"button",onClick:()=>n(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
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
|
|
7
|
+
`,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const nl=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],rl=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Tn(t){return/^#([0-9A-F]{3}){1,2}$/i.test(t)}const he={min:50,max:200,step:10,default:100},Ur={lineHeight:24,toolbarHeight:60},sl={bold:z.Bold,italic:z.Italic,strike:z.Strikethrough,underline:z.Underline,code:z.Code,textColor:z.Palette,highlight:z.Highlighter,link:z.Link2,paragraph:z.FileText,heading:z.Heading,bulletList:z.List,orderedList:z.ListOrdered,taskList:z.ListTodo,codeBlock:z.CodeSquare,blockquote:z.Quote,horizontalRule:z.Minus,clearMarks:z.Eraser,clearNodes:z.Eraser,undo:z.Undo2,redo:z.Redo2,hardBreak:z.CornerDownLeft,textAlign:z.AlignLeft},il={left:z.AlignLeft,center:z.AlignCenter,right:z.AlignRight,justify:z.AlignJustify};function et(t){return sl[t]}function ol({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=k.useState(""),o=u=>{const d=u.target.value;e(d),s&&i("")},l=()=>{if(!t){i("Please enter a color");return}if(!Tn(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},a=u=>{u.key==="Enter"&&(u.preventDefault(),l())};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(y.Input,{type:"text",value:t,onChange:o,onKeyDown:a,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:c.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:Tn(t)?t:"transparent"}})}),c.jsx(se,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!t||!Tn(t),children:c.jsx(z.Check,{size:16})})]}),c.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function qr({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=k.useState(!1),[l,a]=k.useState(""),u=e==="textColor"?nl:rl,d=x=>{const S=_e[e];S&&S.execute({editor:t,config:{type:e,color:x}}),o(!1),a("")},f=x=>{d(x)},p=()=>{const x=_e[e];x&&x.execute({editor:t,config:{type:e,color:""}}),o(!1)},m=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),v=e==="textColor"?z.Palette:z.Highlighter;return c.jsxs(y.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(y.PopoverTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(v,{size:16})})}),c.jsx(y.PopoverContent,{className:"w-64",children:c.jsxs("div",{className:"px-2 py-3 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-semibold",children:r}),c.jsx(se,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:c.jsx(z.X,{size:16})})]}),c.jsx(tl,{colors:u,onColorSelect:d}),n&&c.jsxs(c.Fragment,{children:[c.jsx(y.Divider,{}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),c.jsx(ol,{value:l,onChange:a,onApply:f})]})]})]})})]})}function ll({zoom:t,onZoomChange:e,min:n=he.min,max:r=he.max,step:s=he.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},l=()=>{e(he.default)},a=t<=n,u=t>=r,d=t===he.default;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:a,onPress:i,"aria-label":"Zoom out",children:c.jsx(z.ZoomOut,{size:16})})}),c.jsx(y.Tooltip,{content:d?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:c.jsxs("button",{type:"button",onClick:l,disabled:d,className:`
|
|
8
8
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
9
9
|
${d?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
-
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(y.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(de,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(F.ZoomIn,{size:16})})})]})}function ol({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(y.ButtonGroup,{size:"sm",id:e,"aria-label":n,className:r,children:t}):c.jsx("div",{id:e,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:t})}function Ws(t,e){const n=k.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Dt(l)))).forEach(l=>{const a=$e[l];if(a)try{const u=a.canExecute?.(t)??!0,d=a.isActive?.(t)??!1;i[l]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=k.useState(n);return k.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Dt(a)))).forEach(a=>{const u=$e[a];if(u)try{const d=u.canExecute?.(t)??!0,f=u.isActive?.(t)??!1;o[a]={isActive:f,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function Gs(t,e){const n=k.useCallback((o,l)=>{if(!t)return;const a=$e[o];if(a)try{a.execute({editor:t,config:l}),e?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[t,e]),r=k.useCallback(o=>{n(o)},[n]),s=k.useCallback((o,l)=>{if(!t)return!1;const a=$e[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=k.useCallback((o,l)=>{if(!t)return!1;const a=$e[o];try{return a?.isActive?.(t,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function ll(t=fe.default){const[e,n]=k.useState(t),r=k.useCallback((l=fe.step)=>{n(a=>Math.min(fe.max,a+l))},[]),s=k.useCallback((l=fe.step)=>{n(a=>Math.max(fe.min,a-l))},[]),i=k.useCallback(()=>{n(fe.default)},[]),o=k.useCallback(l=>{const a=Math.max(fe.min,Math.min(fe.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=fe.min,isMaxZoom:e>=fe.max,isDefaultZoom:e===fe.default}}const al=["bold","italic","strike","underline","code"];function cl({editor:t,modifiers:e,onToolbarAction:n}){const r=Ws(t,e),{toggleModifier:s}=Gs(t,n);if(!t)return null;const i=e.map(o=>Dt(o)).filter(o=>al.includes(o));return i.length===0?null:c.jsx(ol,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=tt(o);return c.jsx(Ue,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function ul({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=Ws(t,e),{toggleModifier:a,executeCommand:u}=Gs(t,o);if(!t)return null;const d=e.map(I=>Dt(I)),f=d.some(I=>["bold","italic","strike","underline","code"].includes(I)),p=d.some(I=>["textColor","highlight"].includes(I)),m=d.includes("heading"),v=d.includes("textAlign"),x=d.some(I=>["bulletList","orderedList","taskList"].includes(I)),C=d.includes("blockquote"),S=d.includes("codeBlock"),A=d.includes("link"),j=d.includes("horizontalRule"),E=d.some(I=>["undo","redo"].includes(I)),O=n!==void 0&&r!==void 0,D=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${D} ${i||""}`,children:c.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&c.jsxs(c.Fragment,{children:[c.jsx(cl,{editor:t,modifiers:e,onToolbarAction:o}),(p||m||v||x||C||S||A||j||E||O)&&c.jsx(et,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(qr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(qr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||v||x||C||S||A||j||E||O)&&c.jsx(et,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsx(Qo,{editor:t}),(v||x||C||S||A||j||E||O)&&c.jsx(et,{})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(I=>{const V=rl[I],B=t.isActive({textAlign:I});return c.jsx(Ue,{icon:V,label:`Align ${I}`,isActive:B,onClick:()=>u("textAlign",{type:"textAlign",alignment:I})},I)})}),(x||C||S||A||j||E||O)&&c.jsx(et,{})]}),x&&c.jsxs(c.Fragment,{children:[c.jsx(Xo,{editor:t,types:d.filter(I=>["bulletList","orderedList","taskList"].includes(I))}),(C||S||A||j||E||O)&&c.jsx(et,{})]}),(C||S||A||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[C&&c.jsx(Ue,{icon:tt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),S&&c.jsx(Ue,{icon:tt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),A&&c.jsx(Ue,{icon:tt("link"),label:"Link",isActive:l.link?.isActive,isDisabled:l.link?.isDisabled,onClick:()=>{const I=window.prompt("Enter URL:");I&&u("link",{type:"link",href:I})}}),j&&c.jsx(Ue,{icon:tt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(E||O)&&c.jsx(et,{})]}),E&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(Ue,{icon:tt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(Ue,{icon:tt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),O&&c.jsx(et,{})]}),O&&c.jsx(il,{zoom:n,onZoomChange:I=>{r?.(I),o?.({type:"zoom",modifier:`${I}%`})}})]})})}const dl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,pl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,ml=L.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[L.markInputRule({find:dl,type:this.type}),L.markInputRule({find:hl,type:this.type})]},addPasteRules(){return[L.markPasteRule({find:fl,type:this.type}),L.markPasteRule({find:pl,type:this.type})]}}),gl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,yl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,xl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,bl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,kl=L.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[L.markInputRule({find:gl,type:this.type}),L.markInputRule({find:xl,type:this.type})]},addPasteRules(){return[L.markPasteRule({find:yl,type:this.type}),L.markPasteRule({find:bl,type:this.type})]}}),vl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Cl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Sl=L.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[L.markInputRule({find:vl,type:this.type})]},addPasteRules(){return[L.markPasteRule({find:Cl,type:this.type})]}}),wl=/(^|[^`])`([^`]+)`(?!`)/,Al=/(^|[^`])`([^`]+)`(?!`)/g,Nl=L.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[L.markInputRule({find:wl,type:this.type})]},addPasteRules(){return[L.markPasteRule({find:Al,type:this.type})]}}),El=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},Tl=L.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&El(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Ml=L.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,L.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>L.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Ol=L.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Il="listItem",Kr="textStyle",Jr=/^\s*([-+*])\s$/,Dl=L.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:t}){return["ul",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Il,this.editor.getAttributes(Kr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=L.wrappingInputRule({find:Jr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=L.wrappingInputRule({find:Jr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Kr),editor:this.editor})),[t]}}),jl="listItem",Wr="textStyle",Gr=/^(\d+)\.\s$/,Ll=L.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",L.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",L.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jl,this.editor.getAttributes(Wr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=L.wrappingInputRule({find:Gr,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=L.wrappingInputRule({find:Gr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Wr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Rl=L.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",L.mergeAttributes(this.options.HTMLAttributes,t),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 Zs(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=Zs(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function Qs(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=Qs(o.content,l.content,n-1,r-1);if(u)return u}n-=a,r-=a}}class z{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new z(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new z(r,s)}cutByIndex(e,n){return e==n?z.empty:e==0&&n==this.content.length?this:new z(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new z(s,i)}addToStart(e){return new z([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new z(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Zs(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Qs(this,e,n,r)}findIndex(e){if(e==0)return zt(0,e);if(e==this.size)return zt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?zt(n+1,i):zt(n,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,n){if(!n)return z.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new z(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return z.empty;let n,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)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new z(n||e,r)}static from(e){if(!e)return z.empty;if(e instanceof z)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new z([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}z.empty=new z([],0);const Mn={index:0,offset:0};function zt(t,e){return Mn.index=t,Mn.offset=e,Mn}function qn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!qn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!qn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Ee{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,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))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&qn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Ee.none;if(e instanceof Ee)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Ee.none=[];class Fl extends Error{}class H{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ys(this.content,e+this.openStart,n);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,n){return new H(Xs(this.content,e+this.openStart,n+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,n){if(!n)return H.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(z.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new H(e,r,s)}}H.empty=new H(z.empty,0,0);function Xs(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Xs(i.content,e-s-1,n-s-1)))}function Ys(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Ys(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function Pl(t){return t.tag!=null}function Vl(t){return t.style!=null}class Xt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Pl(s))this.tags.push(s);else if(Vl(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,n={}){let r=new Qr(this,n,!1);return r.addAll(e,Ee.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Qr(this,n,!0);return r.addAll(e,Ee.none,n.from,n.to),H.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if($l(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,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)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Xr(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=Xr(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xt(e,Xt.schemaRules(e)))}}const ei={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},Bl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ti={ol:!0,ul:!0},jt=1,Kn=2,Nt=4;function Zr(t,e,n){return e!=null?(e?jt:0)|(e==="full"?Kn:0):t&&t.whitespace=="pre"?jt|Kn:n&~Nt}class Ht{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ee.none,this.match=i||(o&Nt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(z.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);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&jt)){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 n=z.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(z.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ei.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qr{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Zr(null,n.preserveWhitespace,0)|(r?Nt:0);s?i=new Ht(s.type,s.attrs,Ee.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Ht(null,null,Ee.none,!0,null,o):i=new Ht(e.schema.topNodeType,null,Ee.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Kn?"full":this.localPreserveWS||(s.options&jt)>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(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,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;ti.hasOwnProperty(o)&&this.parser.normalizeLists&&
|
|
12
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){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?n=n.filter(u=>!a.clearMark(u)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=a,!u.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++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ee.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Yr(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Zr(e,i,o.options);o.options&Nt&&o.content.length==0&&(l|=Nt);let a=Ee.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Yr(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Ht(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=jt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&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)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=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 u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function _l(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ti.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function $l(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xr(t){let e={};for(let n in t)e[n]=t[n];return e}function Yr(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:d}=l.edge(a);if(u==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class hn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=On(n).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 u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],d=this.serializeMark(u,o.isInline,n);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Jt(On(n),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,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Jt(On(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Jt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=es(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return es(e.marks)}}function es(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function On(t){return t.document||window.document}const ts=new WeakMap;function zl(t){let e=ts.get(t);return e===void 0&&ts.set(t,e=Hl(t)),e}function Hl(t){let e=null;function n(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++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Jt(t,e,n,r){if(typeof e=="string")return{dom:t.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=zl(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&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?a.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:m,contentDOM:v}=Jt(t,p,n,r);if(a.appendChild(m),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:a,contentDOM:l}}const ni=65535,ri=Math.pow(2,16);function Ul(t,e){return t+e*ri}function ns(t){return t&ni}function ql(t){return(t-(t&ni))/ri}const si=1,ii=2,Wt=4,oi=8;class Jn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&oi)>0}get deletedBefore(){return(this.delInfo&(si|Wt))>0}get deletedAfter(){return(this.delInfo&(ii|Wt))>0}get deletedAcross(){return(this.delInfo&Wt)>0}}class Ce{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ce.empty)return Ce.empty}recover(e){let n=0,r=ns(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+ql(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,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 u=this.ranges[l+i],d=this.ranges[l+o],f=a+u;if(e<=f){let p=u?e==a?-1:e==f?1:n:n,m=a+s+(p<0?0:d);if(r)return m;let v=e==(n<0?a:f)?null:Ul(l/3,e-a),x=e==a?ii:e==f?si:Wt;return(n<0?e!=a:e!=f)&&(x|=oi),new Jn(m,x,v)}s+=d-u}return r?e+s:new Jn(e+s,0,null)}touches(e,n){let r=0,s=ns(n),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 u=this.ranges[l+i],d=a+u;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=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),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,a,a+d),i+=d-u}}invert(){return new Ce(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ce.empty:new Ce(e<0?[0,-e,0]:[0,0,e])}}Ce.empty=new Ce([]);class Yt{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Yt(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Yt;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);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 Jn(e,s,null)}}const In=Object.create(null);class he{getMap(){return Ce.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=In[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in In)throw new RangeError("Duplicate use of step JSON ID "+e);return In[e]=n,n.prototype.jsonID=e,n}}class ie{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ie(e,null)}static fail(e){return new ie(null,e)}static fromReplace(e,n,r,s){try{return ie.ok(e.replace(n,r,s))}catch(i){if(i instanceof Fl)return ie.fail(i.message);throw i}}}function fr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(fr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return z.fromArray(r)}class rt extends he{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new H(fr(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return ie.fromReplace(e,this.from,this.to,i)}invert(){return new st(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rt(n.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new rt(n.from,n.to,e.markFromJSON(n.mark))}}he.jsonID("addMark",rt);class st extends he{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new H(fr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ie.fromReplace(e,this.from,this.to,r)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new st(n.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new st(n.from,n.to,e.markFromJSON(n.mark))}}he.jsonID("removeMark",st);class it extends he{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ie.fromReplace(e,this.pos,this.pos+1,new H(z.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new it(this.pos,n.marks[s]);return new it(this.pos,this.mark)}}return new Lt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new it(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(n.pos,e.markFromJSON(n.mark))}}he.jsonID("addNodeMark",it);class Lt extends he{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ie.fromReplace(e,this.pos,this.pos+1,new H(z.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new it(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Lt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Lt(n.pos,e.markFromJSON(n.mark))}}he.jsonID("removeNodeMark",Lt);class _e extends he{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Wn(e,this.from,this.to)?ie.fail("Structure replace would overwrite content"):ie.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ce([this.from,this.to-this.from,this.slice.size])}invert(e){return new _e(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new _e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _e)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _e(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _e(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _e(n.from,n.to,H.fromJSON(e,n.slice),!!n.structure)}}he.jsonID("replace",_e);class xt extends he{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Wn(e,this.from,this.gapFrom)||Wn(e,this.gapTo,this.to)))return ie.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ie.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ie.fromReplace(e,this.from,this.to,r):ie.fail("Content does not fit in gap")}getMap(){return new Ce([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new xt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new xt(n.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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xt(n.from,n.to,n.gapFrom,n.gapTo,H.fromJSON(e,n.slice),n.insert,!!n.structure)}}he.jsonID("replaceAround",xt);function Wn(t,e,n){let r=t.resolve(e),s=n-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 li(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.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),u=r.node(o),d=!1;if(i==1)d=u.canReplace(a,a,s);else{let f=u.contentMatchAt(a).findWrapping(s.firstChild.type);d=f&&u.canReplaceWith(a,a,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class Et extends he{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ie.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ie.fromReplace(e,this.pos,this.pos+1,new H(z.from(s),0,n.isLeaf?0:1))}getMap(){return Ce.empty}invert(e){return new Et(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Et(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Et(n.pos,n.attr,n.value)}}he.jsonID("attr",Et);class en extends he{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ie.ok(r)}getMap(){return Ce.empty}invert(e){return new en(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new en(n.attr,n.value)}}he.jsonID("docAttr",en);let Rt=class extends Error{};Rt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Rt.prototype=Object.create(Error.prototype);Rt.prototype.constructor=Rt;Rt.prototype.name="TransformError";const Dn=Object.create(null);class Q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Kl(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=H.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.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:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(u.pos),l?H.empty:n),l==0&&is(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){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),u=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),is(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Z(e):mt(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?mt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):mt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Fe(e.node(0))}static atStart(e){return mt(e,e,0,0,1)||new Fe(e)}static atEnd(e){return mt(e,e,e.content.size,e.childCount,-1)||new Fe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Dn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Dn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Dn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Z.between(this.$anchor,this.$head).getBookmark()}}Q.prototype.visible=!0;class Kl{constructor(e,n){this.$from=e,this.$to=n}}let rs=!1;function ss(t){!rs&&!t.parent.inlineContent&&(rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Z extends Q{constructor(e,n=e){ss(e),ss(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Q.near(r);let s=e.resolve(n.map(this.anchor));return new Z(s.parent.inlineContent?s:r,r)}replace(e,n=H.empty){if(super.replace(e,n),n==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Z(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Q.findFrom(n,r,!0)||Q.findFrom(n,-r,!0);if(i)n=i.$head;else return Q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Q.findFrom(e,-r,!0)||Q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Z(e,n)}}Q.jsonID("text",Z);class pn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new pn(e.map(this.anchor),e.map(this.head))}resolve(e){return Z.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends Q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Q.near(i):new U(i)}content(){return new H(z.from(this.node),0,0)}eq(e){return e instanceof U&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new hr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new U(e.resolve(n.anchor))}static create(e,n){return new U(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}U.prototype.visible=!1;Q.jsonID("node",U);class hr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new pn(r,r):new hr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&U.isSelectable(r)?new U(n):Q.near(n)}}class Fe extends Q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=H.empty){if(n==H.empty){e.delete(0,e.doc.content.size);let r=Q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Fe(e)}map(e){return new Fe(e)}eq(e){return e instanceof Fe}getBookmark(){return Jl}}Q.jsonID("all",Fe);const Jl={map(){return this},resolve(t){return new Fe(t)}};function mt(t,e,n,r,s,i=!1){if(e.inlineContent)return Z.create(t,n);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&&U.isSelectable(l))return U.create(t,n-(s<0?l.nodeSize:0))}else{let a=mt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function is(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _e||s instanceof xt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,u,d)=>{o==null&&(o=d)}),t.setSelection(Q.near(t.doc.resolve(o),n))}function os(t,e){return!e||!t?t:t.bind(e)}class Ut{constructor(e,n,r){this.name=e,this.init=os(n.init,r),this.apply=os(n.apply,r)}}new Ut("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ut("selection",{init(t,e){return t.selection||Q.atStart(e.doc)},apply(t){return t.selection}}),new Ut("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ut("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function ai(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=ai(s,e,{})),n[r]=s}return n}class mn{constructor(e){this.spec=e,this.props={},e.props&&ai(e.props,this,this.props),this.key=e.key?e.key.key:ci("plugin")}getState(e){return e[this.key]}}const jn=Object.create(null);function ci(t){return t in jn?t+"$"+ ++jn[t]:(jn[t]=0,t+"$")}class pr{constructor(e="key"){this.key=ci(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Wl=/^```([a-z]+)?[\s\n]$/,Gl=/^~~~([a-z]+)?[\s\n]$/,Zl=L.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:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",L.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
10
|
+
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(y.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(z.ZoomIn,{size:16})})})]})}function al({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(y.ButtonGroup,{size:"sm",id:e,"aria-label":n,className:r,children:t}):c.jsx("div",{id:e,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:t})}function Ws(t,e){const n=k.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Dt(l)))).forEach(l=>{const a=_e[l];if(a)try{const u=a.canExecute?.(t)??!0,d=a.isActive?.(t)??!1;i[l]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=k.useState(n);return k.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Dt(a)))).forEach(a=>{const u=_e[a];if(u)try{const d=u.canExecute?.(t)??!0,f=u.isActive?.(t)??!1;o[a]={isActive:f,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function Gs(t,e){const n=k.useCallback((o,l)=>{if(!t)return;const a=_e[o];if(a)try{a.execute({editor:t,config:l}),e?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[t,e]),r=k.useCallback(o=>{n(o)},[n]),s=k.useCallback((o,l)=>{if(!t)return!1;const a=_e[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=k.useCallback((o,l)=>{if(!t)return!1;const a=_e[o];try{return a?.isActive?.(t,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function cl(t=he.default){const[e,n]=k.useState(t),r=k.useCallback((l=he.step)=>{n(a=>Math.min(he.max,a+l))},[]),s=k.useCallback((l=he.step)=>{n(a=>Math.max(he.min,a-l))},[]),i=k.useCallback(()=>{n(he.default)},[]),o=k.useCallback(l=>{const a=Math.max(he.min,Math.min(he.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=he.min,isMaxZoom:e>=he.max,isDefaultZoom:e===he.default}}const ul=["bold","italic","strike","underline","code"];function dl({editor:t,modifiers:e,onToolbarAction:n}){const r=Ws(t,e),{toggleModifier:s}=Gs(t,n);if(!t)return null;const i=e.map(o=>Dt(o)).filter(o=>ul.includes(o));return i.length===0?null:c.jsx(al,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=et(o);return c.jsx(qe,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function fl({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=Ws(t,e),{toggleModifier:a,executeCommand:u}=Gs(t,o);if(!t)return null;const d=e.map(O=>Dt(O)),f=d.some(O=>["bold","italic","strike","underline","code"].includes(O)),p=d.some(O=>["textColor","highlight"].includes(O)),m=d.includes("heading"),v=d.includes("textAlign"),x=d.some(O=>["bulletList","orderedList","taskList"].includes(O)),S=d.includes("blockquote"),C=d.includes("codeBlock"),w=d.includes("link"),j=d.includes("horizontalRule"),N=d.some(O=>["undo","redo"].includes(O)),D=n!==void 0&&r!==void 0,L=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${L} ${i||""}`,children:c.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&c.jsxs(c.Fragment,{children:[c.jsx(dl,{editor:t,modifiers:e,onToolbarAction:o}),(p||m||v||x||S||C||w||j||N||D)&&c.jsx(Ye,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(qr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(qr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||v||x||S||C||w||j||N||D)&&c.jsx(Ye,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsx(Yo,{editor:t}),(v||x||S||C||w||j||N||D)&&c.jsx(Ye,{})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(O=>{const _=il[O],H=t.isActive({textAlign:O});return c.jsx(qe,{icon:_,label:`Align ${O}`,isActive:H,onClick:()=>u("textAlign",{type:"textAlign",alignment:O})},O)})}),(x||S||C||w||j||N||D)&&c.jsx(Ye,{})]}),x&&c.jsxs(c.Fragment,{children:[c.jsx(el,{editor:t,types:d.filter(O=>["bulletList","orderedList","taskList"].includes(O))}),(S||C||w||j||N||D)&&c.jsx(Ye,{})]}),(S||C||w||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[S&&c.jsx(qe,{icon:et("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),C&&c.jsx(qe,{icon:et("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),w&&c.jsx(qe,{icon:et("link"),label:"Link",isActive:l.link?.isActive,isDisabled:l.link?.isDisabled,onClick:()=>{const O=window.prompt("Enter URL:");O&&u("link",{type:"link",href:O})}}),j&&c.jsx(qe,{icon:et("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(N||D)&&c.jsx(Ye,{})]}),N&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(qe,{icon:et("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(qe,{icon:et("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),D&&c.jsx(Ye,{})]}),D&&c.jsx(ll,{zoom:n,onZoomChange:O=>{r?.(O),o?.({type:"zoom",modifier:`${O}%`})}})]})})}const hl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,pl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ml=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,gl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,yl=R.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[R.markInputRule({find:hl,type:this.type}),R.markInputRule({find:ml,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:pl,type:this.type}),R.markPasteRule({find:gl,type:this.type})]}}),xl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,bl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,kl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,vl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Sl=R.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[R.markInputRule({find:xl,type:this.type}),R.markInputRule({find:kl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:bl,type:this.type}),R.markPasteRule({find:vl,type:this.type})]}}),Cl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,wl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Al=R.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[R.markInputRule({find:Cl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:wl,type:this.type})]}}),Nl=/(^|[^`])`([^`]+)`(?!`)/,El=/(^|[^`])`([^`]+)`(?!`)/g,Tl=R.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[R.markInputRule({find:Nl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:El,type:this.type})]}}),Ml=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},Ol=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Ml(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Il=R.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,R.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>R.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Dl=R.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),jl="listItem",Kr="textStyle",Jr=/^\s*([-+*])\s$/,Ll=R.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:t}){return["ul",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jl,this.editor.getAttributes(Kr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=R.wrappingInputRule({find:Jr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Jr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Kr),editor:this.editor})),[t]}}),Rl="listItem",Wr="textStyle",Gr=/^(\d+)\.\s$/,Fl=R.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",R.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rl,this.editor.getAttributes(Wr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=R.wrappingInputRule({find:Gr,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Gr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Wr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Pl=R.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",R.mergeAttributes(this.options.HTMLAttributes,t),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 Zs(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=Zs(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function Qs(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=Qs(o.content,l.content,n-1,r-1);if(u)return u}n-=a,r-=a}}class q{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new q(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new q(r,s)}cutByIndex(e,n){return e==n?q.empty:e==0&&n==this.content.length?this:new q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new q(s,i)}addToStart(e){return new q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Zs(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Qs(this,e,n,r)}findIndex(e){if(e==0)return zt(0,e);if(e==this.size)return zt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?zt(n+1,i):zt(n,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,n){if(!n)return q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new q(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return q.empty;let n,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)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new q(n||e,r)}static from(e){if(!e)return q.empty;if(e instanceof q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new q([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}q.empty=new q([],0);const Mn={index:0,offset:0};function zt(t,e){return Mn.index=t,Mn.offset=e,Mn}function qn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!qn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!qn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Te{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,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))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&qn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Te.none;if(e instanceof Te)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Te.none=[];class Vl extends Error{}class K{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ys(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(Xs(this.content,e+this.openStart,n+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,n){if(!n)return K.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new K(q.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new K(e,r,s)}}K.empty=new K(q.empty,0,0);function Xs(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Xs(i.content,e-s-1,n-s-1)))}function Ys(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Ys(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function $l(t){return t.tag!=null}function Bl(t){return t.style!=null}class Xt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if($l(s))this.tags.push(s);else if(Bl(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,n={}){let r=new Qr(this,n,!1);return r.addAll(e,Te.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Qr(this,n,!0);return r.addAll(e,Te.none,n.from,n.to),K.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Hl(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,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)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Xr(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=Xr(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xt(e,Xt.schemaRules(e)))}}const ei={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},_l={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ti={ol:!0,ul:!0},jt=1,Kn=2,Nt=4;function Zr(t,e,n){return e!=null?(e?jt:0)|(e==="full"?Kn:0):t&&t.whitespace=="pre"?jt|Kn:n&~Nt}class Ht{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Te.none,this.match=i||(o&Nt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);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&jt)){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 n=q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ei.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qr{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Zr(null,n.preserveWhitespace,0)|(r?Nt:0);s?i=new Ht(s.type,s.attrs,Te.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Ht(null,null,Te.none,!0,null,o):i=new Ht(e.schema.topNodeType,null,Te.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Kn?"full":this.localPreserveWS||(s.options&jt)>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(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,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;ti.hasOwnProperty(o)&&this.parser.normalizeLists&&zl(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:_l.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);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 u,d=this.needsBlock;if(ei.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),u=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=a&&a.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(i),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,a,u,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
12
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){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?n=n.filter(u=>!a.clearMark(u)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=a,!u.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++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Te.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Yr(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Zr(e,i,o.options);o.options&Nt&&o.content.length==0&&(l|=Nt);let a=Te.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Yr(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Ht(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=jt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&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)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=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 u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function zl(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ti.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Hl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xr(t){let e={};for(let n in t)e[n]=t[n];return e}function Yr(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:d}=l.edge(a);if(u==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class hn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=On(n).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 u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],d=this.serializeMark(u,o.isInline,n);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Jt(On(n),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,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Jt(On(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Jt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=es(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return es(e.marks)}}function es(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function On(t){return t.document||window.document}const ts=new WeakMap;function Ul(t){let e=ts.get(t);return e===void 0&&ts.set(t,e=ql(t)),e}function ql(t){let e=null;function n(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++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Jt(t,e,n,r){if(typeof e=="string")return{dom:t.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=Ul(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&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?a.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:m,contentDOM:v}=Jt(t,p,n,r);if(a.appendChild(m),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:a,contentDOM:l}}const ni=65535,ri=Math.pow(2,16);function Kl(t,e){return t+e*ri}function ns(t){return t&ni}function Jl(t){return(t-(t&ni))/ri}const si=1,ii=2,Wt=4,oi=8;class Jn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&oi)>0}get deletedBefore(){return(this.delInfo&(si|Wt))>0}get deletedAfter(){return(this.delInfo&(ii|Wt))>0}get deletedAcross(){return(this.delInfo&Wt)>0}}class we{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&we.empty)return we.empty}recover(e){let n=0,r=ns(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Jl(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,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 u=this.ranges[l+i],d=this.ranges[l+o],f=a+u;if(e<=f){let p=u?e==a?-1:e==f?1:n:n,m=a+s+(p<0?0:d);if(r)return m;let v=e==(n<0?a:f)?null:Kl(l/3,e-a),x=e==a?ii:e==f?si:Wt;return(n<0?e!=a:e!=f)&&(x|=oi),new Jn(m,x,v)}s+=d-u}return r?e+s:new Jn(e+s,0,null)}touches(e,n){let r=0,s=ns(n),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 u=this.ranges[l+i],d=a+u;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=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),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,a,a+d),i+=d-u}}invert(){return new we(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?we.empty:new we(e<0?[0,-e,0]:[0,0,e])}}we.empty=new we([]);class Yt{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Yt(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Yt;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);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 Jn(e,s,null)}}const In=Object.create(null);class pe{getMap(){return we.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=In[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in In)throw new RangeError("Duplicate use of step JSON ID "+e);return In[e]=n,n.prototype.jsonID=e,n}}class le{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new le(e,null)}static fail(e){return new le(null,e)}static fromReplace(e,n,r,s){try{return le.ok(e.replace(n,r,s))}catch(i){if(i instanceof Vl)return le.fail(i.message);throw i}}}function fr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(fr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class nt extends pe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new K(fr(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return le.fromReplace(e,this.from,this.to,i)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new nt(n.pos,r.pos,this.mark)}merge(e){return e instanceof nt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new nt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new nt(n.from,n.to,e.markFromJSON(n.mark))}}pe.jsonID("addMark",nt);class rt extends pe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new K(fr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return le.fromReplace(e,this.from,this.to,r)}invert(){return new nt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rt(n.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(n.from,n.to,e.markFromJSON(n.mark))}}pe.jsonID("removeMark",rt);class st extends pe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return le.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return le.fromReplace(e,this.pos,this.pos+1,new K(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new st(this.pos,n.marks[s]);return new st(this.pos,this.mark)}}return new Lt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new st(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new st(n.pos,e.markFromJSON(n.mark))}}pe.jsonID("addNodeMark",st);class Lt extends pe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return le.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return le.fromReplace(e,this.pos,this.pos+1,new K(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new st(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Lt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Lt(n.pos,e.markFromJSON(n.mark))}}pe.jsonID("removeNodeMark",Lt);class Be extends pe{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Wn(e,this.from,this.to)?le.fail("Structure replace would overwrite content"):le.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new we([this.from,this.to-this.from,this.slice.size])}invert(e){return new Be(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Be(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Be)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=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 Be(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=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 Be(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Be(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}}pe.jsonID("replace",Be);class yt extends pe{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Wn(e,this.from,this.gapFrom)||Wn(e,this.gapTo,this.to)))return le.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return le.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?le.fromReplace(e,this.from,this.to,r):le.fail("Content does not fit in gap")}getMap(){return new we([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new yt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new yt(n.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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yt(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}pe.jsonID("replaceAround",yt);function Wn(t,e,n){let r=t.resolve(e),s=n-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 li(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.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),u=r.node(o),d=!1;if(i==1)d=u.canReplace(a,a,s);else{let f=u.contentMatchAt(a).findWrapping(s.firstChild.type);d=f&&u.canReplaceWith(a,a,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class Et extends pe{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return le.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return le.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return we.empty}invert(e){return new Et(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Et(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Et(n.pos,n.attr,n.value)}}pe.jsonID("attr",Et);class en extends pe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return le.ok(r)}getMap(){return we.empty}invert(e){return new en(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new en(n.attr,n.value)}}pe.jsonID("docAttr",en);let Rt=class extends Error{};Rt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Rt.prototype=Object.create(Error.prototype);Rt.prototype.constructor=Rt;Rt.prototype.name="TransformError";const Dn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Wl(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=K.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.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:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(u.pos),l?K.empty:n),l==0&&is(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){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),u=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),is(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):pt(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?pt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):pt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Pe(e.node(0))}static atStart(e){return pt(e,e,0,0,1)||new Pe(e)}static atEnd(e){return pt(e,e,e.content.size,e.childCount,-1)||new Pe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Dn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Dn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Dn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Wl{constructor(e,n){this.$from=e,this.$to=n}}let rs=!1;function ss(t){!rs&&!t.parent.inlineContent&&(rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Q extends X{constructor(e,n=e){ss(e),ss(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return X.near(r);let s=e.resolve(n.map(this.anchor));return new Q(s.parent.inlineContent?s:r,r)}replace(e,n=K.empty){if(super.replace(e,n),n==K.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=X.findFrom(n,r,!0)||X.findFrom(n,-r,!0);if(i)n=i.$head;else return X.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Q(e,n)}}X.jsonID("text",Q);class pn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new pn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class J extends X{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?X.near(i):new J(i)}content(){return new K(q.from(this.node),0,0)}eq(e){return e instanceof J&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new hr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new J(e.resolve(n.anchor))}static create(e,n){return new J(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}J.prototype.visible=!1;X.jsonID("node",J);class hr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new pn(r,r):new hr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):X.near(n)}}class Pe extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=K.empty){if(n==K.empty){e.delete(0,e.doc.content.size);let r=X.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Pe(e)}map(e){return new Pe(e)}eq(e){return e instanceof Pe}getBookmark(){return Gl}}X.jsonID("all",Pe);const Gl={map(){return this},resolve(t){return new Pe(t)}};function pt(t,e,n,r,s,i=!1){if(e.inlineContent)return Q.create(t,n);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&&J.isSelectable(l))return J.create(t,n-(s<0?l.nodeSize:0))}else{let a=pt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function is(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Be||s instanceof yt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,u,d)=>{o==null&&(o=d)}),t.setSelection(X.near(t.doc.resolve(o),n))}function os(t,e){return!e||!t?t:t.bind(e)}class Ut{constructor(e,n,r){this.name=e,this.init=os(n.init,r),this.apply=os(n.apply,r)}}new Ut("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ut("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Ut("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ut("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function ai(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=ai(s,e,{})),n[r]=s}return n}class mn{constructor(e){this.spec=e,this.props={},e.props&&ai(e.props,this,this.props),this.key=e.key?e.key.key:ci("plugin")}getState(e){return e[this.key]}}const jn=Object.create(null);function ci(t){return t in jn?t+"$"+ ++jn[t]:(jn[t]=0,t+"$")}class pr{constructor(e="key"){this.key=ci(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zl=/^```([a-z]+)?[\s\n]$/,Ql=/^~~~([a-z]+)?[\s\n]$/,Xl=R.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:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",R.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
13
13
|
|
|
14
|
-
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;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)?t.commands.command(({tr:u})=>(u.setSelection(
|
|
15
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(
|
|
16
|
-
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;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:u,dispatch:d})=>{if(d&&a&&o){const f=a.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var tn=200,ce=function(){};ce.prototype.append=function(e){return e.length?(e=ce.from(e),!this.length&&e||e.length<tn&&this.leafAppend(e)||this.length<tn&&e.leafPrepend(this)||this.appendInner(e)):this};ce.prototype.prepend=function(e){return e.length?ce.from(e).append(this):this};ce.prototype.appendInner=function(e){return new ta(this,e)};ce.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ce.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ce.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};ce.from=function(e){return e instanceof ce?e:e&&e.length?new ui(e):ce.empty};var ui=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={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<=tn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=tn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ce);ce.empty=new ui([]);var ta=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.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})(ce);const na=500;class Me{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){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;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,d.push(f);return}if(s){d.push(new Le(f.map));let m=f.step.map(s.slice(i)),v;m&&o.maybeStep(m).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],u.push(new Le(v,void 0,void 0,u.length+d.length))),i--,v&&s.appendMap(v,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new Me(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new Le(e.mapping.maps[d],f,n),m;(m=a&&a.merge(p))&&(p=m,d?i.pop():l=l.slice(0,l.length-1)),i.push(p),n&&(o++,n=void 0),s||(a=p)}let u=o-r.depth;return u>sa&&(l=ra(l,u),o-=u),new Me(l.append(i),o)}remapping(e,n){let r=new Yt;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,n),r}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(n=>new Le(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=n;this.items.forEach(p=>{let m=i.getMirror(--a);if(m==null)return;o=Math.min(o,m);let v=i.maps[m];if(p.step){let x=e.steps[m].invert(e.docs[m]),C=p.selection&&p.selection.map(i.slice(a+1,m));C&&l++,r.push(new Le(v,x,C))}else r.push(new Le(v))},s);let u=[];for(let p=n;p<o;p++)u.push(new Le(i.maps[p]));let d=this.items.slice(0,s).append(u).append(r),f=new Me(d,l);return f.emptyItemCount()>na&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.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(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let f=new Le(u.invert(),a,d),p,m=s.length-1;(p=s.length&&s[m].merge(f))?s[m]=p:s.push(f)}}else o.map&&r--},this.items.length,0),new Me(ce.from(s.reverse()),i)}}Me.empty=new Me(ce.empty,0);function ra(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Le{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Le(n.getMap().invert(),n,this.selection)}}}class qe{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const sa=20;function ia(t,e,n,r){let s=n.getMeta(lt),i;if(s)return s.historyState;n.getMeta(aa)&&(t=new qe(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(lt))return o.getMeta(lt).redo?new qe(t.done.addTransform(n,void 0,r,Gt(e)),t.undone,ls(n.mapping.maps),t.prevTime,t.prevComposition):new qe(t.done,t.undone.addTransform(n,void 0,r,Gt(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!oa(n,t.prevRanges)),u=o?Ln(t.prevRanges,n.mapping):ls(n.mapping.maps);return new qe(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Gt(e)),Me.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new qe(t.done.rebased(n,i),t.undone.rebased(n,i),Ln(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new qe(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ln(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function oa(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function ls(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Ln(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function la(t,e,n){let r=Gt(e),s=lt.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new qe(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(lt,{redo:n,historyState:a})}let Rn=!1,as=null;function Gt(t){let e=t.plugins;if(as!=e){Rn=!1,as=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Rn=!0;break}}return Rn}const lt=new pr("history"),aa=new pr("closeHistory");function ca(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new mn({key:lt,state:{init(){return new qe(Me.empty,Me.empty,null,0,-1)},apply(e,n,r){return ia(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?fi:r=="historyRedo"?hi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function di(t,e){return(n,r)=>{let s=lt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=la(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const fi=di(!1,!0),hi=di(!0,!0),cs=L.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>fi(t,e),redo:()=>({state:t,dispatch:e})=>hi(t,e)}},addProseMirrorPlugins(){return[ca(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()}}}),ua=L.Node.create({name:"doc",topNode:!0,content:"block+"}),da=L.Node.create({name:"text",group:"inline"});function fa(t={}){return new mn({view(e){return new ha(e,t)}})}class ha{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.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:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let v=m.getBoundingClientRect(),x=f?v.bottom:v.top;f&&p&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let C=this.width/2*l;r={left:v.left,right:v.right,top:x-C,bottom:x+C}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=a.getBoundingClientRect(),p=f.width/a.offsetWidth,m=f.height/a.offsetHeight;u=f.left-a.scrollLeft*p,d=f.top-a.scrollTop*m}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=li(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 pa=L.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[fa(this.options)]}});var Ge={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:"'"},nn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ma=typeof navigator<"u"&&/Mac/.test(navigator.platform),ga=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ue=0;ue<10;ue++)Ge[48+ue]=Ge[96+ue]=String(ue);for(var ue=1;ue<=24;ue++)Ge[ue+111]="F"+ue;for(var ue=65;ue<=90;ue++)Ge[ue]=String.fromCharCode(ue+32),nn[ue]=String.fromCharCode(ue);for(var Fn in Ge)nn.hasOwnProperty(Fn)||(nn[Fn]=Ge[Fn]);function ya(t){var e=ma&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ga&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nn:Ge)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const xa=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ba=typeof navigator<"u"&&/Win/.test(navigator.platform);function ka(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))xa?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function va(t){let e=Object.create(null);for(let n in t)e[ka(n)]=t[n];return e}function Pn(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Ca(t){let e=va(t);return function(n,r){let s=ya(r),i,o=e[Pn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Pn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ba&&r.ctrlKey&&r.altKey)&&(i=Ge[r.keyCode])&&i!=s){let l=e[Pn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ut=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},pi=function(t,e,n,r){return n&&(us(t,e,n,r,-1)||us(t,e,n,r,1))},Sa=/^(img|br|input|textarea|hr)$/i;function us(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rn(t))){let o=t.parentNode;if(!o||o.nodeType!=1||mr(t)||Sa.test(t.nodeName)||t.contentEditable=="false")return!1;e=ut(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.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 t=o,e=s<0?rn(t):0}else return!1}}function rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wa(t,e,n){for(let r=e==0,s=e==rn(t);r||s;){if(t==n)return!0;let i=ut(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==rn(t)}}function mr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const mi=function(t){return t.focusNode&&pi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function gi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Pe=typeof navigator<"u"?navigator:null,ds=typeof document<"u"?document:null,Ze=Pe&&Pe.userAgent||"",Gn=/Edge\/(\d+)/.exec(Ze),yi=/MSIE \d/.exec(Ze),Zn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ze),Bt=!!(yi||Zn||Gn),xi=yi?document.documentMode:Zn?+Zn[1]:Gn?+Gn[1]:0,gn=!Bt&&/gecko\/(\d+)/i.test(Ze);gn&&+(/Firefox\/(\d+)/.exec(Ze)||[0,0])[1];const Qn=!Bt&&/Chrome\/(\d+)/.exec(Ze),ze=!!Qn,bi=Qn?+Qn[1]:0,dt=!Bt&&!!Pe&&/Apple Computer/.test(Pe.vendor),gr=dt&&(/Mobile\/\w+/.test(Ze)||!!Pe&&Pe.maxTouchPoints>2),Ne=gr||(Pe?/Mac/.test(Pe.platform):!1),ki=Pe?/Win/.test(Pe.platform):!1,_t=/Android \d/.test(Ze),yr=!!ds&&"webkitFontSmoothing"in ds.documentElement.style,Aa=yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Na(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(mi(n)){for(a=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&U.isSelectable(f)&&s.parent&&!(f.isInline&&wa(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;u=new U(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(f<0)return null;[a,o]=p==t.state.selection.anchor?[p,f]:[f,p],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;u=Ci(t,d,l,f)}return u}function vi(t){return t.editable?t.hasFocus():Oa(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function xr(t,e=!1){let n=t.state.selection;if(Ma(t,n),!!vi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ze){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&pi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ta(t);else{let{anchor:r,head:s}=n,i,o;fs&&!(n instanceof Z)&&(n.$from.parent.inlineContent||(i=hs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=hs(t,n.to))),t.docView.setSelection(r,s,t,e),fs&&(i&&ps(i),o&&ps(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ea(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const fs=dt||ze&&bi<63;function hs(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(dt&&s&&s.contentEditable=="false")return Vn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Vn(s);if(i)return Vn(i)}}function Vn(t){return t.contentEditable="true",dt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ps(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ea(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!vi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ta(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ut(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Bt&&xi<=11&&(n.disabled=!0,n.disabled=!1)}function Ma(t,e){if(e instanceof U){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ms(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ms(t)}function ms(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ci(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Z.between(e,n,r)}function Oa(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Xn(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&Q.findFrom(i,e)}function Ke(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function gs(t,e,n){let r=t.state.selection;if(r instanceof Z)if(n.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=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ke(t,new Z(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Xn(t.state,e);return s&&s instanceof U?Ke(t,s):!1}else if(!(Ne&&n.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=t.docView.descAt(l))&&!o.contentDOM?U.isSelectable(i)?Ke(t,new U(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):yr?Ke(t,new Z(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof U&&r.node.isInline)return Ke(t,new Z(e>0?r.$to:r.$from));{let s=Xn(t.state,e);return s?Ke(t,s):!1}}}function sn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Tt(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ht(t,e){return e<0?Ia(t):Da(t)}function Ia(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(gn&&n.nodeType==1&&r<sn(n)&&Tt(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Tt(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Si(n))break;{let l=n.previousSibling;for(;l&&Tt(l,-1);)s=n.parentNode,i=ut(l),l=l.previousSibling;if(l)n=l,r=sn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Yn(t,n,r):s&&Yn(t,s,i)}function Da(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=sn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Tt(l,1))i=n,o=++r;else break}else{if(Si(n))break;{let l=n.nextSibling;for(;l&&Tt(l,1);)i=l.parentNode,o=ut(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=sn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Yn(t,i,o)}function Si(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ja(t,e){for(;t&&e==t.childNodes.length&&!mr(t);)e=ut(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function La(t,e){for(;t&&!e&&!mr(t);)e=ut(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Yn(t,e,n){if(e.nodeType!=3){let i,o;(o=ja(e,n))?(e=o,n=0):(i=La(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(mi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&xr(t)},50)}function ys(t,e){let n=t.state.doc.resolve(e);if(!(ze||ki)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.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<n.end()){let i=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function xs(t,e,n){let r=t.state.selection;if(r instanceof Z&&!r.empty||n.indexOf("s")>-1||Ne&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Xn(t.state,e);if(o&&o instanceof U)return Ke(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Fe?Q.near(o,e):Q.findFrom(o,e);return l?Ke(t,l):!1}return!1}function bs(t,e){if(!(t.state.selection instanceof Z))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function ks(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ra(t){if(!dt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ks(t,r,"true"),setTimeout(()=>ks(t,r,"false"),20)}return!1}function Fa(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Pa(t,e){let n=e.keyCode,r=Fa(e);if(n==8||Ne&&n==72&&r=="c")return bs(t,-1)||ht(t,-1);if(n==46&&!e.shiftKey||Ne&&n==68&&r=="c")return bs(t,1)||ht(t,1);if(n==13||n==27)return!0;if(n==37||Ne&&n==66&&r=="c"){let s=n==37?ys(t,t.state.selection.from)=="ltr"?-1:1:-1;return gs(t,s,r)||ht(t,s)}else if(n==39||Ne&&n==70&&r=="c"){let s=n==39?ys(t,t.state.selection.from)=="ltr"?1:-1:1;return gs(t,s,r)||ht(t,s)}else{if(n==38||Ne&&n==80&&r=="c")return xs(t,-1,r)||ht(t,-1);if(n==40||Ne&&n==78&&r=="c")return Ra(t)||xs(t,1,r)||ht(t,1);if(r==(Ne?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function wi(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||hn.fromSchema(t.state.schema),l=Oi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Mi[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let v=l.createElement(d[m]);for(;a.firstChild;)v.appendChild(a.firstChild);a.appendChild(v),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
|
|
14
|
+
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;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)?t.commands.command(({tr:u})=>(u.setSelection(X.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[R.textblockTypeInputRule({find:Zl,type:this.type,getAttributes:t=>({language:t[1]})}),R.textblockTypeInputRule({find:Ql,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new mn({key:new pr("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
|
|
15
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(Q.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Yl=/^\s*>\s$/,ea=R.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[R.wrappingInputRule({find:Yl,type:this.type})]}}),ta=R.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",R.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!R.canInsertNode(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:s}=n,i=t();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):R.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:u}=o.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(Q.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(J.create(o.doc,u.pos)):o.setSelection(Q.create(o.doc,u.pos));else{const f=(a=u.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(o.insert(d,f),o.setSelection(Q.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[R.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),na=R.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",R.mergeAttributes(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
16
|
+
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;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:u,dispatch:d})=>{if(d&&a&&o){const f=a.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var tn=200,de=function(){};de.prototype.append=function(e){return e.length?(e=de.from(e),!this.length&&e||e.length<tn&&this.leafAppend(e)||this.length<tn&&e.leafPrepend(this)||this.appendInner(e)):this};de.prototype.prepend=function(e){return e.length?de.from(e).append(this):this};de.prototype.appendInner=function(e){return new ra(this,e)};de.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?de.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};de.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};de.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};de.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};de.from=function(e){return e instanceof de?e:e&&e.length?new ui(e):de.empty};var ui=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={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<=tn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=tn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(de);de.empty=new ui([]);var ra=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.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})(de);const sa=500;class Oe{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){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;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,d.push(f);return}if(s){d.push(new Re(f.map));let m=f.step.map(s.slice(i)),v;m&&o.maybeStep(m).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],u.push(new Re(v,void 0,void 0,u.length+d.length))),i--,v&&s.appendMap(v,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new Oe(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new Re(e.mapping.maps[d],f,n),m;(m=a&&a.merge(p))&&(p=m,d?i.pop():l=l.slice(0,l.length-1)),i.push(p),n&&(o++,n=void 0),s||(a=p)}let u=o-r.depth;return u>oa&&(l=ia(l,u),o-=u),new Oe(l.append(i),o)}remapping(e,n){let r=new Yt;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,n),r}addMaps(e){return this.eventCount==0?this:new Oe(this.items.append(e.map(n=>new Re(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=n;this.items.forEach(p=>{let m=i.getMirror(--a);if(m==null)return;o=Math.min(o,m);let v=i.maps[m];if(p.step){let x=e.steps[m].invert(e.docs[m]),S=p.selection&&p.selection.map(i.slice(a+1,m));S&&l++,r.push(new Re(v,x,S))}else r.push(new Re(v))},s);let u=[];for(let p=n;p<o;p++)u.push(new Re(i.maps[p]));let d=this.items.slice(0,s).append(u).append(r),f=new Oe(d,l);return f.emptyItemCount()>sa&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.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(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let f=new Re(u.invert(),a,d),p,m=s.length-1;(p=s.length&&s[m].merge(f))?s[m]=p:s.push(f)}}else o.map&&r--},this.items.length,0),new Oe(de.from(s.reverse()),i)}}Oe.empty=new Oe(de.empty,0);function ia(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Re{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Re(n.getMap().invert(),n,this.selection)}}}class Ke{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const oa=20;function la(t,e,n,r){let s=n.getMeta(ot),i;if(s)return s.historyState;n.getMeta(ua)&&(t=new Ke(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ot))return o.getMeta(ot).redo?new Ke(t.done.addTransform(n,void 0,r,Gt(e)),t.undone,ls(n.mapping.maps),t.prevTime,t.prevComposition):new Ke(t.done,t.undone.addTransform(n,void 0,r,Gt(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!aa(n,t.prevRanges)),u=o?Ln(t.prevRanges,n.mapping):ls(n.mapping.maps);return new Ke(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Gt(e)),Oe.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ke(t.done.rebased(n,i),t.undone.rebased(n,i),Ln(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ke(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ln(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function aa(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function ls(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Ln(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function ca(t,e,n){let r=Gt(e),s=ot.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Ke(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ot,{redo:n,historyState:a})}let Rn=!1,as=null;function Gt(t){let e=t.plugins;if(as!=e){Rn=!1,as=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Rn=!0;break}}return Rn}const ot=new pr("history"),ua=new pr("closeHistory");function da(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new mn({key:ot,state:{init(){return new Ke(Oe.empty,Oe.empty,null,0,-1)},apply(e,n,r){return la(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?fi:r=="historyRedo"?hi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function di(t,e){return(n,r)=>{let s=ot.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=ca(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const fi=di(!1,!0),hi=di(!0,!0),cs=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>fi(t,e),redo:()=>({state:t,dispatch:e})=>hi(t,e)}},addProseMirrorPlugins(){return[da(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()}}}),fa=R.Node.create({name:"doc",topNode:!0,content:"block+"}),ha=R.Node.create({name:"text",group:"inline"});function pa(t={}){return new mn({view(e){return new ma(e,t)}})}class ma{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.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:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let v=m.getBoundingClientRect(),x=f?v.bottom:v.top;f&&p&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let S=this.width/2*l;r={left:v.left,right:v.right,top:x-S,bottom:x+S}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=a.getBoundingClientRect(),p=f.width/a.offsetWidth,m=f.height/a.offsetHeight;u=f.left-a.scrollLeft*p,d=f.top-a.scrollTop*m}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=li(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 ga=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pa(this.options)]}});var Ze={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:"'"},nn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ya=typeof navigator<"u"&&/Mac/.test(navigator.platform),xa=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var fe=0;fe<10;fe++)Ze[48+fe]=Ze[96+fe]=String(fe);for(var fe=1;fe<=24;fe++)Ze[fe+111]="F"+fe;for(var fe=65;fe<=90;fe++)Ze[fe]=String.fromCharCode(fe+32),nn[fe]=String.fromCharCode(fe);for(var Fn in Ze)nn.hasOwnProperty(Fn)||(nn[Fn]=Ze[Fn]);function ba(t){var e=ya&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||xa&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nn:Ze)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const ka=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),va=typeof navigator<"u"&&/Win/.test(navigator.platform);function Sa(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))ka?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Ca(t){let e=Object.create(null);for(let n in t)e[Sa(n)]=t[n];return e}function Pn(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function wa(t){let e=Ca(t);return function(n,r){let s=ba(r),i,o=e[Pn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Pn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(va&&r.ctrlKey&&r.altKey)&&(i=Ze[r.keyCode])&&i!=s){let l=e[Pn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ct=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},pi=function(t,e,n,r){return n&&(us(t,e,n,r,-1)||us(t,e,n,r,1))},Aa=/^(img|br|input|textarea|hr)$/i;function us(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rn(t))){let o=t.parentNode;if(!o||o.nodeType!=1||mr(t)||Aa.test(t.nodeName)||t.contentEditable=="false")return!1;e=ct(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.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 t=o,e=s<0?rn(t):0}else return!1}}function rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Na(t,e,n){for(let r=e==0,s=e==rn(t);r||s;){if(t==n)return!0;let i=ct(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==rn(t)}}function mr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const mi=function(t){return t.focusNode&&pi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function gi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Ve=typeof navigator<"u"?navigator:null,ds=typeof document<"u"?document:null,Qe=Ve&&Ve.userAgent||"",Gn=/Edge\/(\d+)/.exec(Qe),yi=/MSIE \d/.exec(Qe),Zn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qe),$t=!!(yi||Zn||Gn),xi=yi?document.documentMode:Zn?+Zn[1]:Gn?+Gn[1]:0,gn=!$t&&/gecko\/(\d+)/i.test(Qe);gn&&+(/Firefox\/(\d+)/.exec(Qe)||[0,0])[1];const Qn=!$t&&/Chrome\/(\d+)/.exec(Qe),ze=!!Qn,bi=Qn?+Qn[1]:0,ut=!$t&&!!Ve&&/Apple Computer/.test(Ve.vendor),gr=ut&&(/Mobile\/\w+/.test(Qe)||!!Ve&&Ve.maxTouchPoints>2),Ee=gr||(Ve?/Mac/.test(Ve.platform):!1),ki=Ve?/Win/.test(Ve.platform):!1,Bt=/Android \d/.test(Qe),yr=!!ds&&"webkitFontSmoothing"in ds.documentElement.style,Ea=yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ta(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(mi(n)){for(a=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&J.isSelectable(f)&&s.parent&&!(f.isInline&&Na(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;u=new J(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(f<0)return null;[a,o]=p==t.state.selection.anchor?[p,f]:[f,p],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;u=Si(t,d,l,f)}return u}function vi(t){return t.editable?t.hasFocus():Da(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function xr(t,e=!1){let n=t.state.selection;if(Ia(t,n),!!vi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ze){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&pi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Oa(t);else{let{anchor:r,head:s}=n,i,o;fs&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=hs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=hs(t,n.to))),t.docView.setSelection(r,s,t,e),fs&&(i&&ps(i),o&&ps(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ma(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const fs=ut||ze&&bi<63;function hs(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ut&&s&&s.contentEditable=="false")return Vn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Vn(s);if(i)return Vn(i)}}function Vn(t){return t.contentEditable="true",ut&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ps(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ma(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!vi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Oa(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ct(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&$t&&xi<=11&&(n.disabled=!0,n.disabled=!1)}function Ia(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ms(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ms(t)}function ms(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Si(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Da(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Xn(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&X.findFrom(i,e)}function Je(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function gs(t,e,n){let r=t.state.selection;if(r instanceof Q)if(n.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=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Je(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Xn(t.state,e);return s&&s instanceof J?Je(t,s):!1}else if(!(Ee&&n.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=t.docView.descAt(l))&&!o.contentDOM?J.isSelectable(i)?Je(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):yr?Je(t,new Q(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof J&&r.node.isInline)return Je(t,new Q(e>0?r.$to:r.$from));{let s=Xn(t.state,e);return s?Je(t,s):!1}}}function sn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Tt(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ft(t,e){return e<0?ja(t):La(t)}function ja(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(gn&&n.nodeType==1&&r<sn(n)&&Tt(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Tt(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ci(n))break;{let l=n.previousSibling;for(;l&&Tt(l,-1);)s=n.parentNode,i=ct(l),l=l.previousSibling;if(l)n=l,r=sn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Yn(t,n,r):s&&Yn(t,s,i)}function La(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=sn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Tt(l,1))i=n,o=++r;else break}else{if(Ci(n))break;{let l=n.nextSibling;for(;l&&Tt(l,1);)i=l.parentNode,o=ct(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=sn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Yn(t,i,o)}function Ci(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ra(t,e){for(;t&&e==t.childNodes.length&&!mr(t);)e=ct(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Fa(t,e){for(;t&&!e&&!mr(t);)e=ct(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Yn(t,e,n){if(e.nodeType!=3){let i,o;(o=Ra(e,n))?(e=o,n=0):(i=Fa(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(mi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&xr(t)},50)}function ys(t,e){let n=t.state.doc.resolve(e);if(!(ze||ki)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.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<n.end()){let i=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function xs(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Ee&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Xn(t.state,e);if(o&&o instanceof J)return Je(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Pe?X.near(o,e):X.findFrom(o,e);return l?Je(t,l):!1}return!1}function bs(t,e){if(!(t.state.selection instanceof Q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function ks(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Pa(t){if(!ut||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ks(t,r,"true"),setTimeout(()=>ks(t,r,"false"),20)}return!1}function Va(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function $a(t,e){let n=e.keyCode,r=Va(e);if(n==8||Ee&&n==72&&r=="c")return bs(t,-1)||ft(t,-1);if(n==46&&!e.shiftKey||Ee&&n==68&&r=="c")return bs(t,1)||ft(t,1);if(n==13||n==27)return!0;if(n==37||Ee&&n==66&&r=="c"){let s=n==37?ys(t,t.state.selection.from)=="ltr"?-1:1:-1;return gs(t,s,r)||ft(t,s)}else if(n==39||Ee&&n==70&&r=="c"){let s=n==39?ys(t,t.state.selection.from)=="ltr"?1:-1:1;return gs(t,s,r)||ft(t,s)}else{if(n==38||Ee&&n==80&&r=="c")return xs(t,-1,r)||ft(t,-1);if(n==40||Ee&&n==78&&r=="c")return Pa(t)||xs(t,1,r)||ft(t,1);if(r==(Ee?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function wi(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||hn.fromSchema(t.state.schema),l=Oi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Mi[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let v=l.createElement(d[m]);for(;a.firstChild;)v.appendChild(a.firstChild);a.appendChild(v),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
|
|
17
17
|
|
|
18
|
-
`);return{dom:a,text:p,slice:e}}function Ai(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return l=new
|
|
19
|
-
`))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)l=f;else{let p=s.marks(),{schema:m}=t.state,v=hn.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(x=>{let C=o.appendChild(document.createElement("p"));x&&C.appendChild(v.serializeNode(m.text(x,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=$a(n),yr&&za(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Xt.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Va.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Ha(vs(l,+d[1],+d[2]),d[4]);else if(l=H.maxOpen(Ba(l.content,s),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=vs(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Va=/^(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 Ba(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&i.length&&Ei(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ti(o[o.length-1],i.length));let d=Ni(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return z.from(o)}return t}function Ni(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,z.from(t));return t}function Ei(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Ei(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(z.from(Ni(n,t,s+1))))}}function Ti(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ti(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(z.empty,!0);return t.copy(n.append(r))}function er(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=er(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(z.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function vs(t,e,n){return e<t.openStart&&(t=new H(er(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new H(er(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Mi={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 Cs=null;function Oi(){return Cs||(Cs=document.implementation.createHTMLDocument("title"))}let Bn=null;function _a(t){let e=window.trustedTypes;return e?(Bn||(Bn=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Bn.createHTML(t)):t}function $a(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Oi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Mi[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=_a(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function za(t){let e=t.querySelectorAll(ze?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Ha(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=z.from(a.create(r[l+1],s)),i++,o++}return new H(s,i,o)}const je={},we={};function Je(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}we.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Di(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(_t&&ze&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),gr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,gi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Pa(t,n)?n.preventDefault():Je(t,"key")};we.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};we.keypress=(t,e)=>{let n=e;if(Di(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ne&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Z)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function yn(t){return{left:t.clientX,top:t.clientY}}function Ua(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function br(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function bt(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function qa(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(bt(t,new U(n)),!0):!1}function Ka(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof U&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(U.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(bt(t,U.create(t.state.doc,s)),!0):!1}function Ja(t,e,n,r,s){return br(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ka(t,n):qa(t,n))}function Wa(t,e,n,r){return br(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Ga(t,e,n,r){return br(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Za(t,n,r)}function Za(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(bt(t,Z.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)bt(t,Z.create(r,l+1,l+1+o.content.size));else if(U.isSelectable(o))bt(t,U.create(r,l));else continue;return!0}}function kr(t){return on(t)}const Ii=Ne?"metaKey":"ctrlKey";je.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=kr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ua(n,t.input.lastClick)&&!n[Ii]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(yn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Qa(t,o,n,!!r)):(i=="doubleClick"?Wa:Ga)(t,o.pos,o.inside,n)?n.preventDefault():Je(t,"pointer"))};class Qa{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ii],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.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:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof U&&u.from<=o&&u.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gn&&!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)),Je(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(()=>xr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(yn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Je(this.view,"pointer"):Ja(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||dt&&this.mightDrag&&!this.mightDrag.node.isAtom||ze&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(bt(this.view,Q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Je(this.view,"pointer")}move(e){this.updateAllowDefault(e),Je(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)}}je.touchstart=t=>{t.input.lastTouch=Date.now(),kr(t),Je(t,"pointer")};je.touchmove=t=>{t.input.lastTouch=Date.now(),Je(t,"pointer")};je.contextmenu=t=>kr(t);function Di(t,e){return t.composing?!0:dt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Xa=_t?5e3:-1;we.compositionstart=we.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Z&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ze&&ki&&Ya(t)))t.markCursor=t.state.storedMarks||n.marks(),on(t,!0),t.markCursor=null;else if(on(t,!e.selection.empty),gn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}ji(t,Xa)};function Ya(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}we.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,ji(t,20))};function ji(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>on(t),e))}function ec(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=tc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function tc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function on(t,e=!1){if(!(_t&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ec(t),e||t.docView&&t.docView.dirty){let n=Na(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function nc(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ft=Bt&&xi<15||gr&&Aa<604;je.copy=we.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ft?null:n.clipboardData,o=r.content(),{dom:l,text:a}=wi(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):nc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function sc(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?tr(t,r.value,null,s,e):tr(t,r.textContent,r.innerHTML,s,e)},50)}function tr(t,e,n,r,s){let i=Ai(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||H.empty)))return!0;if(!i)return!1;let o=rc(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Li(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}we.paste=(t,e)=>{let n=e;if(t.composing&&!_t)return;let r=Ft?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&tr(t,Li(r),r.getData("text/html"),s,n)?n.preventDefault():sc(t,n)};class ic{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const oc=Ne?"altKey":"ctrlKey";function Ri(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[oc]}je.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(yn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof U?s.to-1:s.to))){if(r&&r.mightDrag)o=U.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=U.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:u,slice:d}=wi(t,l);(!n.dataTransfer.files.length||!ze||bi>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ft?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ft||n.dataTransfer.setData("text/plain",u),t.dragging=new ic(d,Ri(t,n),o)};je.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};we.dragover=we.dragenter=(t,e)=>e.preventDefault();we.drop=(t,e)=>{try{lc(t,e,t.dragging)}finally{t.dragging=null}};function lc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(yn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",m=>{i=m(i,t,!1)}):i=Ai(t,Li(e.dataTransfer),Ft?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Ri(t,e));if(t.someProp("handleDrop",m=>m(t,e,i||H.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?li(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:m}=n;m?m.replace(a):a.deleteSelection()}let u=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(d?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(f))return;let p=a.doc.resolve(u);if(d&&U.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new U(p));else{let m=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((v,x,C,S)=>m=S),a.setSelection(Ci(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}je.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&xr(t)},20))};je.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};je.beforeinput=(t,e)=>{if(ze&&_t&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,gi(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in we)je[t]=we[t];function Pt(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ln{constructor(e,n){this.toDOM=e,this.spec=n||at,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Re(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ln&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class We{constructor(e,n){this.attrs=e,this.spec=n||at}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Re(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof We&&Pt(this.attrs,e.attrs)&&Pt(this.spec,e.spec)}static is(e){return e.type instanceof We}destroy(){}}class vr{constructor(e,n){this.attrs=e,this.spec=n||at}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Re(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof vr&&Pt(this.attrs,e.attrs)&&Pt(this.spec,e.spec)}destroy(){}}class Re{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Re(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Re(e,e,new ln(n,r))}static inline(e,n,r,s){return new Re(e,n,new We(r,s))}static node(e,n,r,s){return new Re(e,n,new vr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof We}get widget(){return this.type instanceof ln}}const gt=[],at={};class ae{constructor(e,n){this.local=e.length?e:gt,this.children=n.length?n:gt}static create(e,n){return n.length?an(n,e,0,at):ye}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&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]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ye||e.maps.length==0?this:this.mapInner(e,n,0,0,r||at)}mapInner(e,n,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(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?ac(this.children,o||[],e,n,r,s,i):o?new ae(o.sort(ct),gt):ye}add(e,n){return n.length?this==ye?ae.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let u=a+r,d;if(d=Pi(n,l,u)){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,d,u+1):s.splice(i,0,a,a+l.nodeSize,an(d,l,u+1,at)),i+=3}});let o=Fi(i?Vi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ae(o.length?this.local.concat(o).sort(ct):this.local,s||this.children)}remove(e){return e.length==0||this==ye?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<a&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(o,l+1);u!=ye?r[i+2]=u:(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,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ae(s,r):ye}forChild(e,n){if(this==ye)return this;if(n.isLeaf)return ae.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+n.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 We){let u=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;u<d&&(s||(s=[])).push(a.copy(u,d))}}if(s){let l=new ae(s.sort(ct),gt);return r?new nt([l,r]):l}return r||ye}eq(e){if(this==e)return!0;if(!(e instanceof ae)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Cr(this.localsInner(e))}localsInner(e){if(this==ye)return gt;if(e.inlineContent||!this.local.some(We.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof We||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ae.empty=new ae([],[]);ae.removeOverlap=Cr;const ye=ae.empty;class nt{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,at));return nt.from(r)}forChild(e,n){if(n.isLeaf)return ae.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ye&&(i instanceof nt?r=r.concat(i.members):r.push(i))}return nt.from(r)}eq(e){if(!(e instanceof nt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Cr(r?n:n.sort(ct)):gt}static from(e){switch(e.length){case 0:return ye;case 1:return e[0];default:return new nt(e.every(n=>n instanceof ae)?e:e.reduce((n,r)=>n.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function ac(t,e,n,r,s,i,o){let l=t.slice();for(let u=0,d=i;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,v,x)=>{let C=x-v-(m-p);for(let S=0;S<l.length;S+=3){let A=l[S+1];if(A<0||p>A+d-f)continue;let j=l[S]+d-f;m>=j?l[S+1]=p<=j?-2:-1:p>=d&&C&&(l[S]+=C,l[S+1]+=C)}f+=C}),d=n.maps[u].map(d,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let d=n.map(t[u]+i),f=d-s;if(f<0||f>=r.content.size){a=!0;continue}let p=n.map(t[u+1]+i,-1),m=p-s,{index:v,offset:x}=r.content.findIndex(f),C=r.maybeChild(v);if(C&&x==f&&x+C.nodeSize==m){let S=l[u+2].mapInner(n,C,d+1,t[u]+i+1,o);S!=ye?(l[u]=f,l[u+1]=m,l[u+2]=S):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=cc(l,t,e,n,s,i,o),d=an(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new ae(e.sort(ct),l)}function Fi(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Re(s.from+e,s.to+e,s.type))}return n}function cc(t,e,n,r,s,i,o){function l(a,u){for(let d=0;d<a.local.length;d++){let f=a.local[d].map(r,s,u);f?n.push(f):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+u+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Pi(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Vi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function an(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Pi(t,l,a+n);if(u){i=!0;let d=an(u,l,n+a+1,r);d!=ye&&s.push(a,a+l.nodeSize,d)}});let o=Fi(i?Vi(t):t,-n).sort(ct);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 ae(o,s):ye}function ct(t,e){return t.from-e.from||t.to-e.to}function Cr(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Ss(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ss(e,s,r.copy(i.from,r.to)));break}}}return e}function Ss(t,e,n){for(;e<t.length&&ct(n,t[e])>0;)e++;t.splice(e,0,n)}class te extends Q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return te.valid(r)?new te(r):Q.near(r)}content(){return H.empty}eq(e){return e instanceof te&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new te(e.resolve(n.pos))}getBookmark(){return new Sr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!uc(e)||!dc(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&te.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(te.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!U.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(te.valid(l))return l}return null}}}te.prototype.visible=!1;te.findFrom=te.findGapCursorFrom;Q.jsonID("gapcursor",te);class Sr{constructor(e){this.pos=e}map(e){return new Sr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return te.valid(n)?new te(n):Q.near(n)}}function Bi(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function uc(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bi(s.type))return!0;if(s.inlineContent)return!1}}return!0}function dc(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bi(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fc(){return new mn({props:{decorations:gc,createSelectionBetween(t,e,n){return e.pos==n.pos&&te.valid(n)?new te(n):null},handleClick:pc,handleKeyDown:hc,handleDOMEvents:{beforeinput:mc}}})}const hc=Ca({ArrowLeft:qt("horiz",-1),ArrowRight:qt("horiz",1),ArrowUp:qt("vert",-1),ArrowDown:qt("vert",1)});function qt(t,e){const n=t=="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 Z){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=te.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new te(u))),!0):!1}}function pc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!te.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&U.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new te(r))),!0)}function mc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof te))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=z.empty;for(let o=r.length-1;o>=0;o--)s=z.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new H(s,0,0));return i.setSelection(Z.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function gc(t){if(!(t.selection instanceof te))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(t.doc,[Re.widget(t.selection.head,e,{key:"gapcursor"})])}const yc=L.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[fc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=L.callOrReturn(L.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Ct={bold:{category:"mark",extension:ml,priority:100},italic:{category:"mark",extension:kl,priority:100},strike:{category:"mark",extension:Sl,priority:100},underline:{category:"mark",extension:jo.Underline,priority:100},code:{category:"mark",extension:Nl,priority:100},textColor:{category:"mark",extension:Lo.Color,defaultOptions:{types:["textStyle"]},priority:90},highlight:{category:"mark",extension:Ro.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Fo.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ml,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Dl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Ll,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Po.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Zl,priority:100},blockquote:{category:"node",extension:Xl,priority:100},horizontalRule:{category:"node",extension:Yl,priority:100},hardBreak:{category:"node",extension:ea,priority:100},undo:{category:"extension",extension:cs,priority:50},redo:{category:"extension",extension:cs,priority:50},textAlign:{category:"extension",extension:Bo.TextAlign,defaultOptions:{types:["heading","paragraph","listItem"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},xc=[ua,da,Ol,Tl,Rl,Vo.TaskItem,pa,yc];function bc(t){const e=[],n=new Set,r=new Set;xc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Dt(l)),i=new Set;return s.forEach(l=>{const a=Ct[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=Ct[l];if(!a||a.extension===null)return;const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),s.forEach(l=>{if(n.has(l))return;const a=Ct[l];if(!a){console.warn(`Extension config not found for modifier: ${l}`);return}if(a.extension===null){n.add(l);return}const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),e.sort((l,a)=>{const u=Object.values(Ct).find(m=>m?.extension?.name===l.name),d=Object.values(Ct).find(m=>m?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const _i={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",{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",{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"]},kc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=ur.useCurrentEditor();return c.jsx(ul,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},vc=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=ur.useCurrentEditor();if(!n||!t&&!e)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return c.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[t&&c.jsxs("span",{children:[s," characters"]}),e&&c.jsxs("span",{children:[i," words"]})]})},nr=k.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=_i.full,variant:u="bordered",initialContent:d,content:f,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:x=!1,isDisabled:C=!1,...S}=t,{zoom:A,setZoom:j}=ll(),E=Ur.lineHeight,O=n*E,D=s?void 0:r*E,I=k.useMemo(()=>bc(a),[a]),{Component:V,label:B,shouldLabelBeOutside:q,getBaseProps:Ae,getLabelProps:P,getInputWrapperProps:_}=y.useInput({...S,variant:u,ref:e,isMultiline:!0}),J=B?c.jsx("label",{...P(),children:B}):null,$=k.useCallback(({editor:X})=>{const K=X.getHTML(),be=X.getJSON(),le=X.getText(),pe=le.length,ft=le.split(/\s+/).filter(Xe=>Xe.length>0).length,Qe={html:K,json:be,text:le,characters:pe,words:ft};if(p?.(Qe),m?.(Qe),"onChange"in S&&typeof S.onChange=="function"){const Xe={target:{value:K},currentTarget:{value:K}};S.onChange(Xe)}},[p,m,S]);return c.jsxs(V,{...Ae(),children:[q?J:null,c.jsx("div",{..._(),className:y.cn(_().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:D?`${D+Ur.toolbarHeight}px`:void 0,overflow:D?"auto":void 0},children:c.jsx(ur.EditorProvider,{editable:!x&&!C,slotBefore:l?c.jsx(kc,{modifiers:a,zoom:A,onZoomChange:j,onToolbarAction:v}):void 0,slotAfter:c.jsx(vc,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${O}px`,fontSize:`${A}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:I,content:f||d||t.defaultValue||"",onUpdate:$})})]})});nr.displayName="TipTapEditor";const $i=k.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(nr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(nr,{...s,variant:r,ref:e}))});$i.displayName="RichTextArea";function Cc(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}const ws=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Sc={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},zi=({presetAmounts:t=ws,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,currency:s="USD",locale:i="en-US",showCustomAmount:o=!0,minCustomAmount:l=.5,maxCustomAmount:a=1e6,labels:u,mobileColumns:d=2,desktopColumns:f=3,isDisabled:p=!1,buttonVariant:m="bordered",buttonColor:v="default",inputVariant:x="bordered",className:C="",showCard:S=!0})=>{const A={...Sc,...u},j=Array.isArray(t)?t:ws,E={2:"grid-cols-2",3:"grid-cols-3"},O={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},D=`${E[d]} ${O[f]}`,[I,V]=dr(e,n,r),[B,q]=k.useState(""),Ae=k.useCallback($=>{if(p)return;const X={amount:$.amount,isCustom:!1,presetId:$.id};V(X),q("")},[p,V]),P=k.useCallback($=>{if(p)return;if(q($!==void 0?String($):""),$===void 0||isNaN($)){V(null);return}V({amount:$,isCustom:!0})},[p,V]),_=k.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),J=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[A.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:A.title}),j.length>0&&c.jsx("div",{className:y.cn("grid gap-3",D),"data-testid":"donation-amounts-presets",children:j.map($=>{const X=I!==null&&!I.isCustom&&I.presetId===$.id;return c.jsx(de,{color:X?"primary":v,variant:X?"solid":m,className:"w-full",onPress:()=>Ae($),isDisabled:p,"data-testid":`donation-amounts-preset-${$.id}`,children:$.label||Cc($.amount,i,s)},$.id)})}),o&&c.jsx(y.NumberInput,{placeholder:A.customAmountPlaceholder,"aria-label":A.customAmountAriaLabel,variant:x,radius:"md",minValue:l,maxValue:a,step:.01,formatOptions:_,value:B!==""?parseFloat(B):void 0,onValueChange:P,isDisabled:p,"data-testid":"donation-amounts-custom-input"},I?.isCustom===!1?I.presetId:"custom")]});return S?c.jsx(y.Card,{className:y.cn("w-full",C),"data-testid":"donation-amounts-card",children:c.jsx(y.CardBody,{children:J})}):c.jsx("div",{className:y.cn("w-full",C),"data-testid":"donation-amounts-plain",children:J})};zi.displayName="DonationAmounts";const wc=t=>{const e=Math.max(0,t),n=Math.floor(e/60).toString().padStart(2,"0"),r=(e%60).toString().padStart(2,"0");return`${n}:${r} minutes`},Ac=t=>{switch(t){case"warning":return F.Clock;case"error":return F.AlertCircle;case"success":return F.CheckCircle;default:return F.Clock}},Nc=t=>{switch(t){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},Hi=k.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:a,position:u="fixed",autoStart:d=!0,formatTime:f=wc,className:p,...m},v)=>{const[x,C]=dr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=k.useRef(null),A=k.useRef(!1);k.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),k.useEffect(()=>{if(!d||x<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{C(D=>D<=1?(S.current&&(clearInterval(S.current),S.current=null),A.current||(A.current=!0,r?.()),0):D-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[d,x,C,r]),k.useEffect(()=>{x>0&&(A.current=!1)},[x]);const j=a||Ac(s),E=Nc(i),O={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${o} ${f(x)}`,"data-testid":"expire-cart-timer",className:y.cn("w-full text-white z-50",E,O[u],p),...m,children:c.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:c.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&c.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:c.jsx(j,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),c.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:o})]}),c.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:c.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${f(x)}`,"data-testid":"expire-cart-timer-value",children:f(x)})})]})})})});Hi.displayName="ExpireCartTimer";function Ec(t,e){const n=t.icons,r=t.aliases||Object.create(null),s=Object.create(null);function i(o){if(n[o])return s[o]=[];if(!(o in s)){s[o]=null;const l=r[o]&&r[o].parent,a=l&&i(l);a&&(s[o]=[l].concat(a))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ui=Object.freeze({left:0,top:0,width:16,height:16}),cn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),wr=Object.freeze({...Ui,...cn}),rr=Object.freeze({...wr,body:"",hidden:!1});function Tc(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}function As(t,e){const n=Tc(t,e);for(const r in rr)r in cn?r in t&&!(r in n)&&(n[r]=cn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Mc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=As(r[l]||s[l],i)}return o(e),n.forEach(o),As(t,i)}function qi(t,e){const n=[];if(typeof t!="object"||typeof t.icons!="object")return n;t.not_found instanceof Array&&t.not_found.forEach(s=>{e(s,null),n.push(s)});const r=Ec(t);for(const s in r){const i=r[s];i&&(e(s,Mc(t,s,i)),n.push(s))}return n}const Oc={provider:"",aliases:{},not_found:{},...Ui};function _n(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Ki(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!_n(t,Oc))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!_n(i,rr))return null}const r=e.aliases||Object.create(null);for(const s in r){const i=r[s],o=i.parent;if(!s||typeof o!="string"||!n[o]&&!r[o]||!_n(i,rr))return null}return e}const Ns=Object.create(null);function Ic(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function kt(t,e){const n=Ns[t]||(Ns[t]=Object.create(null));return n[e]||(n[e]=Ic(t,e))}function Ji(t,e){return Ki(e)?qi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Dc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Wi=/^[a-z0-9]+(-[a-z0-9]+)*$/,xn=(t,e,n,r="")=>{const s=t.split(":");if(t.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),a=s.pop(),u={provider:s.length>0?s[0]:r,prefix:a,name:l};return e&&!Zt(u)?null:u}const i=s[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!Zt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Zt(l,n)?null:l}return null},Zt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Vt=!1;function Gi(t){return typeof t=="boolean"&&(Vt=t),Vt}function Es(t){const e=typeof t=="string"?xn(t,!0,Vt):t;if(e){const n=kt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function jc(t,e){const n=xn(t,!0,Vt);if(!n)return!1;const r=kt(n.provider,n.prefix);return e?Dc(r,n.name,e):(r.missing.add(n.name),!0)}function Lc(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Vt&&!e&&!t.prefix){let s=!1;return Ki(t)&&(t.prefix="",qi(t,(i,o)=>{jc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Zt({prefix:n,name:"a"}))return!1;const r=kt(e,n);return!!Ji(r,t)}const Zi=Object.freeze({width:null,height:null}),Qi=Object.freeze({...Zi,...cn}),Rc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Fc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ts(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;const r=t.split(Rc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Fc.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function Pc(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const s=t.indexOf(">",r),i=t.indexOf("</"+e);if(s===-1||i===-1)break;const o=t.indexOf(">",i);if(o===-1)break;n+=t.slice(s+1,i).trim(),t=t.slice(0,r).trim()+t.slice(o+1)}return{defs:n,content:t}}function Vc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Bc(t,e,n){const r=Pc(t);return Vc(r.defs,e+r.content+n)}const _c=t=>t==="unset"||t==="undefined"||t==="none";function $c(t,e){const n={...wr,...t},r={...Qi,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(x=>{const C=[],S=x.hFlip,A=x.vFlip;let j=x.rotate;S?A?j+=2:(C.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),C.push("scale(-1 1)"),s.top=s.left=0):A&&(C.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),C.push("scale(1 -1)"),s.top=s.left=0);let E;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:E=s.height/2+s.top,C.unshift("rotate(90 "+E.toString()+" "+E.toString()+")");break;case 2:C.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:E=s.width/2+s.left,C.unshift("rotate(-90 "+E.toString()+" "+E.toString()+")");break}j%2===1&&(s.left!==s.top&&(E=s.left,s.left=s.top,s.top=E),s.width!==s.height&&(E=s.width,s.width=s.height,s.height=E)),C.length&&(i=Bc(i,'<g transform="'+C.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,a=s.width,u=s.height;let d,f;o===null?(f=l===null?"1em":l==="auto"?u:l,d=Ts(f,a/u)):(d=o==="auto"?a:o,f=l===null?Ts(d,u/a):l==="auto"?u:l);const p={},m=(x,C)=>{_c(C)||(p[x]=C.toString())};m("width",d),m("height",f);const v=[s.left,s.top,a,u];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const zc=/\sid="(\S+)"/g,Hc="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Uc=0;function qc(t,e=Hc){const n=[];let r;for(;r=zc.exec(t);)n.push(r[1]);if(!n.length)return t;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const o=typeof e=="function"?e(i):e+(Uc++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const sr=Object.create(null);function Kc(t,e){sr[t]=e}function ir(t){return sr[t]||sr[""]}function Ar(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const Nr=Object.create(null),St=["https://api.simplesvg.com","https://api.unisvg.com"],Qt=[];for(;St.length>0;)St.length===1||Math.random()>.5?Qt.push(St.shift()):Qt.push(St.pop());Nr[""]=Ar({resources:["https://api.iconify.design"].concat(Qt)});function Jc(t,e){const n=Ar(e);return n===null?!1:(Nr[t]=n,!0)}function Er(t){return Nr[t]}const Wc=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ms=Wc();function Gc(t,e){const n=Er(t);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(o=>{s=Math.max(s,o.length)});const i=e+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Zc(t){return t===404}const Qc=(t,e,n)=>{const r=[],s=Gc(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,u)=>{l+=a.length+1,l>=s&&u>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},l=a.length),o.icons.push(a)}),r.push(o),r};function Xc(t){if(typeof t=="string"){const e=Er(t);if(e)return e.path}return"/"}const Yc=(t,e,n)=>{if(!Ms){n("abort",424);return}let r=Xc(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});r+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;Ms(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(Zc(o)?"abort":"next",o)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},eu={prepare:Qc,send:Yc};function Xi(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function tu(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(a=>{if(a.prefix!==s)return!0;const u=a.name;if(t.icons[u])o.loaded.push({provider:r,prefix:s,name:u});else if(t.missing.has(u))o.missing.push({provider:r,prefix:s,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||Xi([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let nu=0;function ru(t,e,n){const r=nu++,s=Xi.bind(null,n,r);if(!e.pending.length)return s;const i={id:r,icons:e,callback:t,abort:s};return n.forEach(o=>{(o.loaderCallbacks||(o.loaderCallbacks=[])).push(i)}),s}function su(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return t.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,o=s.prefix,l=s.name,a=n[i]||(n[i]=Object.create(null)),u=a[o]||(a[o]=kt(i,o));let d;l in u.icons?d=e.loaded:o===""||u.missing.has(l)?d=e.missing:d=e.pending;const f={provider:i,prefix:o,name:l};d.push(f)}),e}function iu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?xn(s,e,n):s;i&&r.push(i)}),r}const ou={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function lu(t,e,n,r){const s=t.resources.length,i=t.random?Math.floor(Math.random()*s):t.index;let o;if(t.random){let D=t.resources.slice(0);for(o=[];D.length>1;){const I=Math.floor(Math.random()*D.length);o.push(D[I]),D=D.slice(0,I).concat(D.slice(I+1))}o=o.concat(D)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",u=0,d,f=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){f&&(clearTimeout(f),f=null)}function x(){a==="pending"&&(a="aborted"),v(),p.forEach(D=>{D.status==="pending"&&(D.status="aborted")}),p=[]}function C(D,I){I&&(m=[]),typeof D=="function"&&m.push(D)}function S(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:p.length,subscribe:C,abort:x}}function A(){a="failed",m.forEach(D=>{D(void 0,d)})}function j(){p.forEach(D=>{D.status==="pending"&&(D.status="aborted")}),p=[]}function E(D,I,V){const B=I!=="success";switch(p=p.filter(q=>q!==D),a){case"pending":break;case"failed":if(B||!t.dataAfterTimeout)return;break;default:return}if(I==="abort"){d=V,A();return}if(B){d=V,p.length||(o.length?O():A());return}if(v(),j(),!t.random){const q=t.resources.indexOf(D.resource);q!==-1&&q!==t.index&&(t.index=q)}a="completed",m.forEach(q=>{q(V)})}function O(){if(a!=="pending")return;v();const D=o.shift();if(D===void 0){if(p.length){f=setTimeout(()=>{v(),a==="pending"&&(j(),A())},t.timeout);return}A();return}const I={status:"pending",resource:D,callback:(V,B)=>{E(I,V,B)}};p.push(I),u++,f=setTimeout(O,t.rotate),n(D,e,I.callback)}return setTimeout(O),S}function Yi(t){const e={...ou,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=lu(e,l,a,(f,p)=>{r(),u&&u(f,p)});return n.push(d),d}function i(l){return n.find(a=>l(a))||null}return{query:s,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:r}}function Os(){}const $n=Object.create(null);function au(t){if(!$n[t]){const e=Er(t);if(!e)return;const n=Yi(e),r={config:e,redundancy:n};$n[t]=r}return $n[t]}function cu(t,e,n){let r,s;if(typeof t=="string"){const i=ir(t);if(!i)return n(void 0,424),Os;s=i.send;const o=au(t);o&&(r=o.redundancy)}else{const i=Ar(t);if(i){r=Yi(i);const o=t.resources?t.resources[0]:"",l=ir(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),Os):r.query(e,s,n)().abort}function Is(){}function uu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,tu(t)}))}function du(t){const e=[],n=[];return t.forEach(r=>{(r.match(Wi)?e:n).push(r)}),{valid:e,invalid:n}}function wt(t,e,n){function r(){const s=t.pendingIcons;e.forEach(i=>{s&&s.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ji(t,n).length){r();return}}catch(s){console.error(s)}r(),uu(t)}function Ds(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function fu(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:n,prefix:r}=t,s=t.iconsToLoad;if(delete t.iconsToLoad,!s||!s.length)return;const i=t.loadIcon;if(t.loadIcons&&(s.length>1||!i)){Ds(t.loadIcons(s,r,n),d=>{wt(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Ds(f,p=>{const m=p?{prefix:r,icons:{[d]:p}}:null;wt(t,[d],m)})});return}const{valid:o,invalid:l}=du(s);if(l.length&&wt(t,l,null),!o.length)return;const a=r.match(Wi)?ir(n):null;if(!a){wt(t,o,null);return}a.prepare(n,r,o).forEach(d=>{cu(n,d,f=>{wt(t,d.icons,f)})})}))}const hu=(t,e)=>{const n=iu(t,!0,Gi()),r=su(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Is)}),()=>{a=!1}}const s=Object.create(null),i=[];let o,l;return r.pending.forEach(a=>{const{provider:u,prefix:d}=a;if(d===l&&u===o)return;o=u,l=d,i.push(kt(u,d));const f=s[u]||(s[u]=Object.create(null));f[d]||(f[d]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:d,name:f}=a,p=kt(u,d),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),s[u][d].push(f))}),i.forEach(a=>{const u=s[a.provider][a.prefix];u.length&&fu(a,u)}),e?ru(e,r,i):Is};function pu(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Zi?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const mu=/[\s,]+/;function gu(t,e){e.split(mu).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function yu(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(t);return isNaN(s)?0:r(s)}else if(n!==t){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(t.slice(0,t.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return e}function xu(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in e)n+=" "+r+'="'+e[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function bu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function ku(t){return"data:image/svg+xml,"+bu(t)}function vu(t){return'url("'+ku(t)+'")'}let Mt;function Cu(){try{Mt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Mt=null}}function Su(t){return Mt===void 0&&Cu(),Mt?Mt.createHTML(t):t}const eo={...Qi,inline:!1},wu={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Au={display:"inline-block"},or={backgroundColor:"currentColor"},to={backgroundColor:"transparent"},js={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ls={WebkitMask:or,mask:or,background:to};for(const t in Ls){const e=Ls[t];for(const n in js)e[t+n]=js[n]}const Nu={...eo,inline:!0};function Rs(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Eu=(t,e,n)=>{const r=e.inline?Nu:eo,s=pu(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?wu:{}};if(n){const C=xn(n,!1,!0);if(C){const S=["iconify"],A=["provider","prefix"];for(const j of A)C[j]&&S.push("iconify--"+C[j]);a.className=S.join(" ")}}for(let C in e){const S=e[C];if(S!==void 0)switch(C){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=S;break;case"className":a[C]=(a[C]?a[C]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[C]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&gu(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[C]=yu(S):typeof S=="number"&&(s[C]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete a["aria-hidden"];break;default:r[C]===void 0&&(a[C]=S)}}const u=$c(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let C=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:Su(qc(u.body,S?()=>S+"ID"+C++:"iconifyReact"))},k.createElement("svg",a)}const{body:f,width:p,height:m}=t,v=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),x=xu(f,{...d,width:p+"",height:m+""});return a.style={...o,"--svg":vu(x),width:Rs(d.width),height:Rs(d.height),...Au,...v?or:to,...l},k.createElement("span",a)};Gi(!0);Kc("",eu);if(typeof document<"u"&&typeof window<"u"){const t=window;if(t.IconifyPreload!==void 0){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof e=="object"&&e!==null&&(e instanceof Array?e:[e]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Lc(r))&&console.error(n)}catch{console.error(n)}})}if(t.IconifyProviders!==void 0){const e=t.IconifyProviders;if(typeof e=="object"&&e!==null)for(let n in e){const r="IconifyProviders["+n+"] is invalid.";try{const s=e[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Jc(n,s)||console.error(r)}catch{console.error(r)}}}}function no(t){const[e,n]=k.useState(!!t.ssr),[r,s]=k.useState({});function i(m){if(m){const v=t.icon;if(typeof v=="object")return{name:"",data:v};const x=Es(v);if(x)return{name:v,data:x}}return{name:""}}const[o,l]=k.useState(i(!!t.ssr));function a(){const m=r.callback;m&&(m(),s({}))}function u(m){if(JSON.stringify(o)!==JSON.stringify(m))return a(),l(m),!0}function d(){var m;const v=t.icon;if(typeof v=="object"){u({name:"",data:v});return}const x=Es(v);if(u({name:v,data:x}))if(x===void 0){const C=hu([v],d);s({callback:C})}else x&&((m=t.onLoad)===null||m===void 0||m.call(t,v))}k.useEffect(()=>(n(!0),a),[]),k.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:p}=o;return p?Eu({...wr,...p},t,f):t.children?t.children:t.fallback?t.fallback:k.createElement("span",{})}const Te=k.forwardRef((t,e)=>no({...t,_ref:e}));k.forwardRef((t,e)=>no({inline:!0,...t,_ref:e}));const zn=({icon:t,children:e,testId:n})=>c.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[c.jsx(Te,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Tu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,showMoreButtonClassName:a,labels:u})=>{const[d,f]=k.useState(!1),[p,m]=k.useState(!1),v=k.useRef(null);return k.useEffect(()=>{const x=()=>{if(v.current){const C=v.current.scrollHeight>v.current.clientHeight;m(C)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[o]),c.jsxs(y.Card,{className:y.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(y.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(y.Image,{alt:`Event image for ${e}`,className:"w-full h-full object-cover",src:n,"data-testid":"event-details-image"})}),c.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:e})]}),c.jsxs(y.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[c.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),c.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&c.jsx(zn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(zn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(zn,{icon:"solar:point-on-map-outline",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsx("p",{ref:v,className:y.cn("text-sm text-gray-700 leading-relaxed transition-all",!d&&"line-clamp-2"),"data-testid":"event-details-description",children:o}),(p||d)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(de,{onPress:()=>f(!d),variant:"light",className:y.cn("text-primary",a),startContent:c.jsx(Te,{icon:d?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:d?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function ro(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function Mu(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const Ou={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Kt=t=>typeof t=="number"&&!isNaN(t),Tr=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:l,isDisabled:a=!1,buttonVariant:u="bordered",buttonColor:d="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:x={},"data-testid":C,selectedColor:S="default"})=>{const A={...Ou,...o},[j,E]=k.useState(n),O=e!==void 0?e:j,D=le=>{if(a)return;const pe=Math.max(0,O+le);e===void 0&&E(pe),r?.(t.id,pe)},I=k.useMemo(()=>!Kt(t.totalTicketsSold)||!Kt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),V=k.useMemo(()=>I||!Kt(t.ticketsAllowed)?!1:O>=t.ticketsAllowed-(t.totalTicketsSold??0),[I,t.ticketsAllowed,t.totalTicketsSold,O]),B=ro(t.price,i,s),q=()=>l?.renderName?l.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:y.cn("text-base font-medium",x.name),children:t.name}),Ae=()=>v?l?.renderPrice?l.renderPrice(t.price,B,t):c.jsx("p",{"data-testid":"offer-card-price",className:y.cn("text-primary text-base mt-1",x.price),children:B}):null,P=()=>!p||!t.description?null:l?.renderDescription?l.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:y.cn("mb-4 text-sm text-gray-700 leading-relaxed",x.description),children:t.description}),_=()=>{if(!m||!Kt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const le=t.numberOfPeople===1?A.person:A.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,le,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:y.cn("text-sm text-gray-600 flex items-center mt-2",x.peopleCount),children:[c.jsx(Te,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",le]})},J=()=>{const le=O===0||a,pe=V||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:O,onIncrement:()=>D(1),onDecrement:()=>D(-1),isDecrementDisabled:le,isIncrementDisabled:pe,isDisabled:a}):c.jsxs("div",{className:y.cn("flex items-center gap-2",x.quantitySelector),children:[c.jsx(de,{"data-testid":"offer-card-decrement-button",onPress:()=>D(-1),isDisabled:le,variant:u,color:O>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Te,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:y.cn("min-w-[2rem] text-center font-medium"),children:O}),c.jsx(de,{"data-testid":"offer-card-increment-button",onPress:()=>D(1),isDisabled:pe,variant:u,color:O>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Te,{icon:"gravity-ui:plus",width:16})})]})},$=()=>l?.renderSoldOut?l.renderSoldOut(A.soldOut):c.jsx(y.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:y.cn("gap-2 px-4 h-8",x.soldOut),startContent:c.jsx(Te,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:A.soldOut})}),X=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(A.maxReached):c.jsx(y.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:y.cn(" text-black! gap-2 px-4 h-10",x.maxReachedAlert),startContent:c.jsx(Te,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:A.maxReached})}),K=c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:y.cn("h-full col-span-2",I?"opacity-50 pointer-events-none select-none":""),children:[q(),Ae(),c.jsxs("div",{className:y.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",I?"opacity-50 pointer-events-none select-none":""),children:[_(),P()]})]}),c.jsx("div",{className:"space-x-2 p-2 h-full flex items-center justify-start md:justify-start lg:justify-end ",children:I?$():J()})]}),be=V&&!I&&c.jsx(De.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:X()});return f?c.jsxs(y.Card,{className:y.cn("w-full",x.base),"data-testid":C||`offer-card-${t.id}`,children:[c.jsx(y.CardBody,{className:y.cn("pt-1 pb-0",x.body),children:K}),c.jsx(De.AnimatePresence,{children:be&&c.jsx(y.CardFooter,{className:y.cn("w-full mt-0 pt-0",x.footer),children:be})})]}):c.jsxs("div",{className:y.cn("w-full",x.base),"data-testid":C||`offer-card-${t.id}`,children:[c.jsx("div",{className:y.cn("pt-1 pb-0",x.body),children:K}),c.jsx(De.AnimatePresence,{children:be&&c.jsx("div",{className:y.cn("w-full mt-0 pt-0",x.footer),children:be})})]})};Tr.displayName="OfferCard";const so=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:l})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:y.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(Te,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:y.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:y.cn("text-lg",s.message),children:t})]});return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:o})};so.displayName="OfferCardEmpty";const Iu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},io=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Iu,...e},o=c.jsx(y.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:o})};io.displayName="OfferCardError";const Du={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},oo=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Du[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:y.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(y.Card,{"data-testid":`offer-card-skeleton-${i}`,className:y.cn("w-full",n.card),children:[c.jsx(y.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:c.jsxs("div",{className:"space-y-2 w-full",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),c.jsx(y.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:c.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),c.jsx("div",{className:"flex items-start justify-end",children:c.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};oo.displayName="OfferCardSkeleton";const lo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},ao={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},ju={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},co=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:l,slots:a,isDisabled:u=!1,buttonVariant:d="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:v=2,classNames:x={}})=>{const[C,S]=k.useState(n),A=e!==void 0?e:C,j=k.useCallback((V,B)=>{const q={...A,[V]:Math.max(0,B)};e===void 0&&S(q),r?.(q),s?.(V,q[V])},[A,e,r,s]),E=[...t].sort((V,B)=>(V.position??0)-(B.position??0)),O=ju[v],D=y.cn("grid mx-auto pt-2",O,x.base),I=V=>c.jsx(Tr,{offer:V,quantity:A[V.id]||0,onQuantityChange:j,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:p,classNames:x.card},V.id);return m?c.jsx(De.motion.div,{"data-testid":"offer-card-list",className:D,variants:lo,initial:"hidden",animate:"show",children:c.jsx(De.AnimatePresence,{children:E.map(V=>c.jsx(De.motion.div,{"data-testid":`offer-card-list-item-${V.id}`,className:x.cardWrapper,variants:ao,exit:{opacity:0,y:-20},transition:{duration:.3},children:I(V)},V.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:D,children:E.map(I)})};co.displayName="OfferCardList";var $t=t=>t.type==="checkbox",ot=t=>t instanceof Date,ke=t=>t==null;const uo=t=>typeof t=="object";var oe=t=>!ke(t)&&!Array.isArray(t)&&uo(t)&&!ot(t),fo=t=>oe(t)&&t.target?$t(t.target)?t.target.checked:t.target.value:t,Lu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,ho=(t,e)=>t.has(Lu(e)),Ru=t=>{const e=t.constructor&&t.constructor.prototype;return oe(e)&&e.hasOwnProperty("isPrototypeOf")},Mr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function re(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Mr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(oe(t)&&Ru(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=re(t[s]));return r}var bn=t=>/^\w*$/.test(t),ee=t=>t===void 0,Or=t=>Array.isArray(t)?t.filter(Boolean):[],Ir=t=>Or(t.replace(/["|']|\]/g,"").split(/\.|\[/)),T=(t,e,n)=>{if(!e||!oe(t))return n;const r=(bn(e)?[e]:Ir(e)).reduce((s,i)=>ke(s)?s:s[i],t);return ee(r)||r===t?ee(t[e])?n:t[e]:r},ve=t=>typeof t=="boolean",xe=t=>typeof t=="function",Y=(t,e,n)=>{let r=-1;const s=bn(e)?[e]:Ir(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let a=n;if(r!==o){const u=t[l];a=oe(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const un={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Oe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Be={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},po=k.createContext(null);po.displayName="HookFormControlContext";const Dr=()=>k.useContext(po);var mo=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Oe.all&&(e._proxyFormState[o]=!r||Oe.all),n&&(n[o]=!0),t[o]}});return s};const jr=typeof window<"u"?k.useLayoutEffect:k.useEffect;function Fu(t){const e=Dr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=k.useState(n._formState),a=k.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return jr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),k.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),k.useMemo(()=>mo(o,n,a.current,!1),[o,n])}var Se=t=>typeof t=="string",lr=(t,e,n,r,s)=>Se(t)?(r&&e.watch.add(t),T(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),T(n,i))):(r&&(e.watchAll=!0),n),ar=t=>ke(t)||!uo(t);function Ie(t,e,n=new WeakSet){if(ar(t)||ar(e))return Object.is(t,e);if(ot(t)&&ot(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const i of r){const o=t[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=e[i];if(ot(o)&&ot(l)||oe(o)&&oe(l)||Array.isArray(o)&&Array.isArray(l)?!Ie(o,l,n):!Object.is(o,l))return!1}}return!0}function Pu(t){const e=Dr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=k.useRef(s),u=k.useRef(l),d=k.useRef(void 0),f=k.useRef(n),p=k.useRef(r);u.current=l;const[m,v]=k.useState(()=>{const E=n._getWatch(r,a.current);return u.current?u.current(E):E}),x=k.useCallback(E=>{const O=lr(r,n._names,E||n._formValues,!1,a.current);return u.current?u.current(O):O},[n._formValues,n._names,r]),C=k.useCallback(E=>{if(!i){const O=lr(r,n._names,E||n._formValues,!1,a.current);if(u.current){const D=u.current(O);Ie(D,d.current)||(v(D),d.current=D)}else v(O)}},[n._formValues,n._names,i,r]);jr(()=>((f.current!==n||!Ie(p.current,r))&&(f.current=n,p.current=r,C()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:E=>{C(E.values)}})),[n,o,r,C]),k.useEffect(()=>n._removeUnmounted());const S=f.current!==n,A=p.current,j=k.useMemo(()=>{if(i)return null;const E=!S&&!Ie(A,r);return S||E?x():null},[i,S,r,A,x]);return j!==null?j:m}function Vu(t){const e=Dr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=ho(s._names.array,n),u=k.useMemo(()=>T(s._formValues,n,T(s._defaultValues,n,o)),[s,n,o]),d=Pu({control:s,name:n,defaultValue:u,exact:l}),f=Fu({control:s,name:n,exact:l}),p=k.useRef(t),m=k.useRef(void 0),v=k.useRef(s.register(n,{...t.rules,value:d,...ve(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const x=k.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!T(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!T(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!T(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!T(f.validatingFields,n)},error:{enumerable:!0,get:()=>T(f.errors,n)}}),[f,n]),C=k.useCallback(E=>v.current.onChange({target:{value:fo(E),name:n},type:un.CHANGE}),[n]),S=k.useCallback(()=>v.current.onBlur({target:{value:T(s._formValues,n),name:n},type:un.BLUR}),[n,s._formValues]),A=k.useCallback(E=>{const O=T(s._fields,n);O&&O._f&&E&&(O._f.ref={focus:()=>xe(E.focus)&&E.focus(),select:()=>xe(E.select)&&E.select(),setCustomValidity:D=>xe(E.setCustomValidity)&&E.setCustomValidity(D),reportValidity:()=>xe(E.reportValidity)&&E.reportValidity()})},[s._fields,n]),j=k.useMemo(()=>({name:n,value:d,...ve(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:C,onBlur:S,ref:A}),[n,r,f.disabled,C,S,A,d]);return k.useEffect(()=>{const E=s._options.shouldUnregister||i,O=m.current;O&&O!==n&&!a&&s.unregister(O),s.register(n,{...p.current.rules,...ve(p.current.disabled)?{disabled:p.current.disabled}:{}});const D=(I,V)=>{const B=T(s._fields,I);B&&B._f&&(B._f.mount=V)};if(D(n,!0),E){const I=re(T(s._options.defaultValues,n,p.current.defaultValue));Y(s._defaultValues,n,I),ee(T(s._formValues,n))&&Y(s._formValues,n,I)}return!a&&s.register(n),m.current=n,()=>{(a?E&&!s._state.action:E)?s.unregister(n):D(n,!1)}},[n,s,a,i]),k.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),k.useMemo(()=>({field:j,formState:f,fieldState:x}),[j,f,x])}const Bu=k.createContext(null);Bu.displayName="HookFormContext";var _u=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Ot=t=>Array.isArray(t)?t:[t],Fs=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function go(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&oe(s)&&i){const o=go(s,i);oe(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ge=t=>oe(t)&&!Object.keys(t).length,Lr=t=>t.type==="file",dn=t=>{if(!Mr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},yo=t=>t.type==="select-multiple",Rr=t=>t.type==="radio",$u=t=>Rr(t)||$t(t),Hn=t=>dn(t)&&t.isConnected;function zu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=ee(t)?r++:t[e[r++]];return t}function Hu(t){for(const e in t)if(t.hasOwnProperty(e)&&!ee(t[e]))return!1;return!0}function se(t,e){const n=Array.isArray(e)?e:bn(e)?[e]:Ir(e),r=n.length===1?t:zu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(oe(r)&&ge(r)||Array.isArray(r)&&Hu(r))&&se(t,n.slice(0,-1)),t}var Uu=t=>{for(const e in t)if(xe(t[e]))return!0;return!1};function xo(t){return Array.isArray(t)||oe(t)&&!Uu(t)}function cr(t,e={}){for(const n in t){const r=t[n];xo(r)?(e[n]=Array.isArray(r)?[]:{},cr(r,e[n])):ee(r)||(e[n]=!0)}return e}function yt(t,e,n){n||(n=cr(e));for(const r in t){const s=t[r];if(xo(s))ee(e)||ar(n[r])?n[r]=cr(s,Array.isArray(s)?[]:{}):yt(s,ke(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Ie(s,i)}}return n}const Ps={value:!1,isValid:!1},Vs={value:!0,isValid:!0};var bo=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!ee(t[0].attributes.value)?ee(t[0].value)||t[0].value===""?Vs:{value:t[0].value,isValid:!0}:Vs:Ps}return Ps},ko=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>ee(t)?t:e?t===""?NaN:t&&+t:n&&Se(t)?new Date(t):r?r(t):t;const Bs={isValid:!1,value:null};var vo=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Bs):Bs;function _s(t){const e=t.ref;return Lr(e)?e.files:Rr(e)?vo(t.refs).value:yo(e)?[...e.selectedOptions].map(({value:n})=>n):$t(e)?bo(t.refs).value:ko(ee(e.value)?t.ref.value:e.value,t)}var qu=(t,e,n,r)=>{const s={};for(const i of t){const o=T(e,i);o&&Y(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},fn=t=>t instanceof RegExp,At=t=>ee(t)?t:fn(t)?t.source:oe(t)?fn(t.value)?t.value.source:t.value:t,$s=t=>({isOnSubmit:!t||t===Oe.onSubmit,isOnBlur:t===Oe.onBlur,isOnChange:t===Oe.onChange,isOnAll:t===Oe.all,isOnTouch:t===Oe.onTouched});const zs="AsyncFunction";var Ku=t=>!!t&&!!t.validate&&!!(xe(t.validate)&&t.validate.constructor.name===zs||oe(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===zs)),Ju=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Hs=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const It=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=T(t,s);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(It(l,e))break}else if(oe(l)&&It(l,e))break}}};function Us(t,e,n){const r=T(t,n);if(r||bn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=T(e,i),l=T(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var Wu=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ge(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Oe.all))},Gu=(t,e,n)=>!t||!e||t===e||Ot(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),Zu=(t,e,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(e||t):(n?r.isOnBlur:s.isOnBlur)?!t:(n?r.isOnChange:s.isOnChange)?t:!0,Qu=(t,e)=>!Or(T(t,e)).length&&se(t,e),Xu=(t,e,n)=>{const r=Ot(T(t,n));return Y(r,"root",e[n]),Y(t,n,r),t};function qs(t,e,n="validate"){if(Se(t)||Array.isArray(t)&&t.every(Se)||ve(t)&&!t)return{type:n,message:Se(t)?t:"",ref:e}}var pt=t=>oe(t)&&!fn(t)?t:{value:t,message:""},Ks=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:a,maxLength:u,minLength:d,min:f,max:p,pattern:m,validate:v,name:x,valueAsNumber:C,mount:S}=t._f,A=T(n,x);if(!S||e.has(x))return{};const j=l?l[0]:o,E=P=>{s&&j.reportValidity&&(j.setCustomValidity(ve(P)?"":P||""),j.reportValidity())},O={},D=Rr(o),I=$t(o),V=D||I,B=(C||Lr(o))&&ee(o.value)&&ee(A)||dn(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,q=_u.bind(null,x,r,O),Ae=(P,_,J,$=Be.maxLength,X=Be.minLength)=>{const K=P?_:J;O[x]={type:P?$:X,message:K,ref:o,...q(P?$:X,K)}};if(i?!Array.isArray(A)||!A.length:a&&(!V&&(B||ke(A))||ve(A)&&!A||I&&!bo(l).isValid||D&&!vo(l).isValid)){const{value:P,message:_}=Se(a)?{value:!!a,message:a}:pt(a);if(P&&(O[x]={type:Be.required,message:_,ref:j,...q(Be.required,_)},!r))return E(_),O}if(!B&&(!ke(f)||!ke(p))){let P,_;const J=pt(p),$=pt(f);if(!ke(A)&&!isNaN(A)){const X=o.valueAsNumber||A&&+A;ke(J.value)||(P=X>J.value),ke($.value)||(_=X<$.value)}else{const X=o.valueAsDate||new Date(A),K=pe=>new Date(new Date().toDateString()+" "+pe),be=o.type=="time",le=o.type=="week";Se(J.value)&&A&&(P=be?K(A)>K(J.value):le?A>J.value:X>new Date(J.value)),Se($.value)&&A&&(_=be?K(A)<K($.value):le?A<$.value:X<new Date($.value))}if((P||_)&&(Ae(!!P,J.message,$.message,Be.max,Be.min),!r))return E(O[x].message),O}if((u||d)&&!B&&(Se(A)||i&&Array.isArray(A))){const P=pt(u),_=pt(d),J=!ke(P.value)&&A.length>+P.value,$=!ke(_.value)&&A.length<+_.value;if((J||$)&&(Ae(J,P.message,_.message),!r))return E(O[x].message),O}if(m&&!B&&Se(A)){const{value:P,message:_}=pt(m);if(fn(P)&&!A.match(P)&&(O[x]={type:Be.pattern,message:_,ref:o,...q(Be.pattern,_)},!r))return E(_),O}if(v){if(xe(v)){const P=await v(A,n),_=qs(P,j);if(_&&(O[x]={..._,...q(Be.validate,_.message)},!r))return E(_.message),O}else if(oe(v)){let P={};for(const _ in v){if(!ge(P)&&!r)break;const J=qs(await v[_](A,n),j,_);J&&(P={...J,...q(_,J.message)},E(J.message),r&&(O[x]=P))}if(!ge(P)&&(O[x]={ref:j,...P},!r))return O}}return E(!0),O};const Yu={mode:Oe.onSubmit,reValidateMode:Oe.onChange,shouldFocusError:!0};function ed(t={}){let e={...Yu,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:xe(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=oe(e.defaultValues)||oe(e.values)?re(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:re(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},a,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let p={...f};const m={array:Fs(),state:Fs()},v=e.criteriaMode===Oe.all,x=h=>g=>{clearTimeout(u),u=setTimeout(h,g)},C=async h=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||h)){let g;e.resolver?(g=ge((await V()).errors),S()):g=await q(r,!0),g!==n.isValid&&m.state.next({isValid:g})}},S=(h,g)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((h||Array.from(l.mount)).forEach(b=>{b&&(g?Y(n.validatingFields,b,g):se(n.validatingFields,b))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ge(n.validatingFields)}))},A=(h,g=[],b,M,N=!0,w=!0)=>{if(M&&b&&!e.disabled){if(o.action=!0,w&&Array.isArray(T(r,h))){const R=b(T(r,h),M.argA,M.argB);N&&Y(r,h,R)}if(w&&Array.isArray(T(n.errors,h))){const R=b(T(n.errors,h),M.argA,M.argB);N&&Y(n.errors,h,R),Qu(n.errors,h)}if((f.touchedFields||p.touchedFields)&&w&&Array.isArray(T(n.touchedFields,h))){const R=b(T(n.touchedFields,h),M.argA,M.argB);N&&Y(n.touchedFields,h,R)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=yt(s,i)),m.state.next({name:h,isDirty:P(h,g),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Y(i,h,g)},j=(h,g)=>{Y(n.errors,h,g),m.state.next({errors:n.errors})},E=h=>{n.errors=h,m.state.next({errors:n.errors,isValid:!1})},O=(h,g,b,M)=>{const N=T(r,h);if(N){const w=T(i,h,ee(b)?T(s,h):b);ee(w)||M&&M.defaultChecked||g?Y(i,h,g?w:_s(N._f)):$(h,w),o.mount&&!o.action&&C()}},D=(h,g,b,M,N)=>{let w=!1,R=!1;const W={name:h};if(!e.disabled){if(!b||M){(f.isDirty||p.isDirty)&&(R=n.isDirty,n.isDirty=W.isDirty=P(),w=R!==W.isDirty);const G=Ie(T(s,h),g);R=!!T(n.dirtyFields,h),G?se(n.dirtyFields,h):Y(n.dirtyFields,h,!0),W.dirtyFields=n.dirtyFields,w=w||(f.dirtyFields||p.dirtyFields)&&R!==!G}if(b){const G=T(n.touchedFields,h);G||(Y(n.touchedFields,h,b),W.touchedFields=n.touchedFields,w=w||(f.touchedFields||p.touchedFields)&&G!==b)}w&&N&&m.state.next(W)}return w?W:{}},I=(h,g,b,M)=>{const N=T(n.errors,h),w=(f.isValid||p.isValid)&&ve(g)&&n.isValid!==g;if(e.delayError&&b?(a=x(()=>j(h,b)),a(e.delayError)):(clearTimeout(u),a=null,b?Y(n.errors,h,b):se(n.errors,h)),(b?!Ie(N,b):N)||!ge(M)||w){const R={...M,...w&&ve(g)?{isValid:g}:{},errors:n.errors,name:h};n={...n,...R},m.state.next(R)}},V=async h=>(S(h,!0),await e.resolver(i,e.context,qu(h||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),B=async h=>{const{errors:g}=await V(h);if(S(h),h)for(const b of h){const M=T(g,b);M?Y(n.errors,b,M):se(n.errors,b)}else n.errors=g;return g},q=async(h,g,b={valid:!0})=>{for(const M in h){const N=h[M];if(N){const{_f:w,...R}=N;if(w){const W=l.array.has(w.name),G=N._f&&Ku(N._f);G&&f.validatingFields&&S([w.name],!0);const me=await Ks(N,l.disabled,i,v,e.shouldUseNativeValidation&&!g,W);if(G&&f.validatingFields&&S([w.name]),me[w.name]&&(b.valid=!1,g||t.shouldUseNativeValidation))break;!g&&(T(me,w.name)?W?Xu(n.errors,me,w.name):Y(n.errors,w.name,me[w.name]):se(n.errors,w.name))}!ge(R)&&await q(R,g,b)}}return b.valid},Ae=()=>{for(const h of l.unMount){const g=T(r,h);g&&(g._f.refs?g._f.refs.every(b=>!Hn(b)):!Hn(g._f.ref))&&vn(h)}l.unMount=new Set},P=(h,g)=>!e.disabled&&(h&&g&&Y(i,h,g),!Ie(ft(),s)),_=(h,g,b)=>lr(h,l,{...o.mount?i:ee(g)?s:Se(h)?{[h]:g}:g},b,g),J=h=>Or(T(o.mount?i:s,h,e.shouldUnregister?T(s,h,[]):[])),$=(h,g,b={})=>{const M=T(r,h);let N=g;if(M){const w=M._f;w&&(!w.disabled&&Y(i,h,ko(g,w)),N=dn(w.ref)&&ke(g)?"":g,yo(w.ref)?[...w.ref.options].forEach(R=>R.selected=N.includes(R.value)):w.refs?$t(w.ref)?w.refs.forEach(R=>{(!R.defaultChecked||!R.disabled)&&(Array.isArray(N)?R.checked=!!N.find(W=>W===R.value):R.checked=N===R.value||!!N)}):w.refs.forEach(R=>R.checked=R.value===N):Lr(w.ref)?w.ref.value="":(w.ref.value=N,w.ref.type||m.state.next({name:h,values:re(i)})))}(b.shouldDirty||b.shouldTouch)&&D(h,N,b.shouldTouch,b.shouldDirty,!0),b.shouldValidate&&pe(h)},X=(h,g,b)=>{for(const M in g){if(!g.hasOwnProperty(M))return;const N=g[M],w=h+"."+M,R=T(r,w);(l.array.has(h)||oe(N)||R&&!R._f)&&!ot(N)?X(w,N,b):$(w,N,b)}},K=(h,g,b={})=>{const M=T(r,h),N=l.array.has(h),w=re(g);Y(i,h,w),N?(m.array.next({name:h,values:re(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&b.shouldDirty&&m.state.next({name:h,dirtyFields:yt(s,i),isDirty:P(h,w)})):M&&!M._f&&!ke(w)?X(h,w,b):$(h,w,b),Hs(h,l)?m.state.next({...n,name:h,values:re(i)}):m.state.next({name:o.mount?h:void 0,values:re(i)})},be=async h=>{o.mount=!0;const g=h.target;let b=g.name,M=!0;const N=T(r,b),w=G=>{M=Number.isNaN(G)||ot(G)&&isNaN(G.getTime())||Ie(G,T(i,b,G))},R=$s(e.mode),W=$s(e.reValidateMode);if(N){let G,me;const Ye=g.type?_s(N._f):fo(h),He=h.type===un.BLUR||h.type===un.FOCUS_OUT,Oo=!Ju(N._f)&&!e.resolver&&!T(n.errors,b)&&!N._f.deps||Zu(He,T(n.touchedFields,b),n.isSubmitted,W,R),wn=Hs(b,l,He);Y(i,b,Ye),He?(!g||!g.readOnly)&&(N._f.onBlur&&N._f.onBlur(h),a&&a(0)):N._f.onChange&&N._f.onChange(h);const An=D(b,Ye,He),Io=!ge(An)||wn;if(!He&&m.state.next({name:b,type:h.type,values:re(i)}),Oo)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?He&&C():He||C()),Io&&m.state.next({name:b,...wn?{}:An});if(!He&&wn&&m.state.next({...n}),e.resolver){const{errors:zr}=await V([b]);if(S([b]),w(Ye),M){const Do=Us(n.errors,r,b),Hr=Us(zr,r,Do.name||b);G=Hr.error,b=Hr.name,me=ge(zr)}}else S([b],!0),G=(await Ks(N,l.disabled,i,v,e.shouldUseNativeValidation))[b],S([b]),w(Ye),M&&(G?me=!1:(f.isValid||p.isValid)&&(me=await q(r,!0)));M&&(N._f.deps&&(!Array.isArray(N._f.deps)||N._f.deps.length>0)&&pe(N._f.deps),I(b,me,G,An))}},le=(h,g)=>{if(T(n.errors,g)&&h.focus)return h.focus(),1},pe=async(h,g={})=>{let b,M;const N=Ot(h);if(e.resolver){const w=await B(ee(h)?h:N);b=ge(w),M=h?!N.some(R=>T(w,R)):b}else h?(M=(await Promise.all(N.map(async w=>{const R=T(r,w);return await q(R&&R._f?{[w]:R}:R)}))).every(Boolean),!(!M&&!n.isValid)&&C()):M=b=await q(r);return m.state.next({...!Se(h)||(f.isValid||p.isValid)&&b!==n.isValid?{}:{name:h},...e.resolver||!h?{isValid:b}:{},errors:n.errors}),g.shouldFocus&&!M&&It(r,le,h?N:l.mount),M},ft=(h,g)=>{let b={...o.mount?i:s};return g&&(b=go(g.dirtyFields?n.dirtyFields:n.touchedFields,b)),ee(h)?b:Se(h)?T(b,h):h.map(M=>T(b,M))},Qe=(h,g)=>({invalid:!!T((g||n).errors,h),isDirty:!!T((g||n).dirtyFields,h),error:T((g||n).errors,h),isValidating:!!T(n.validatingFields,h),isTouched:!!T((g||n).touchedFields,h)}),Xe=h=>{h&&Ot(h).forEach(g=>se(n.errors,g)),m.state.next({errors:h?n.errors:{}})},ne=(h,g,b)=>{const M=(T(r,h,{_f:{}})._f||{}).ref,N=T(n.errors,h)||{},{ref:w,message:R,type:W,...G}=N;Y(n.errors,h,{...G,...g,ref:M}),m.state.next({name:h,errors:n.errors,isValid:!1}),b&&b.shouldFocus&&M&&M.focus&&M.focus()},Ve=(h,g)=>xe(h)?m.state.subscribe({next:b=>"values"in b&&h(_(void 0,g),b)}):_(h,g,!0),vt=h=>m.state.subscribe({next:g=>{Gu(h.name,g.name,h.exact)&&Wu(g,h.formState||f,Mo,h.reRenderRoot)&&h.callback({values:{...i},...n,...g,defaultValues:s})}}).unsubscribe,kn=h=>(o.mount=!0,p={...p,...h.formState},vt({...h,formState:{...d,...h.formState}})),vn=(h,g={})=>{for(const b of h?Ot(h):l.mount)l.mount.delete(b),l.array.delete(b),g.keepValue||(se(r,b),se(i,b)),!g.keepError&&se(n.errors,b),!g.keepDirty&&se(n.dirtyFields,b),!g.keepTouched&&se(n.touchedFields,b),!g.keepIsValidating&&se(n.validatingFields,b),!e.shouldUnregister&&!g.keepDefaultValue&&se(s,b);m.state.next({values:re(i)}),m.state.next({...n,...g.keepDirty?{isDirty:P()}:{}}),!g.keepIsValid&&C()},Pr=({disabled:h,name:g})=>{if(ve(h)&&o.mount||h||l.disabled.has(g)){const N=l.disabled.has(g)!==!!h;h?l.disabled.add(g):l.disabled.delete(g),N&&o.mount&&!o.action&&C()}},Cn=(h,g={})=>{let b=T(r,h);const M=ve(g.disabled)||ve(e.disabled);return Y(r,h,{...b||{},_f:{...b&&b._f?b._f:{ref:{name:h}},name:h,mount:!0,...g}}),l.mount.add(h),b?Pr({disabled:ve(g.disabled)?g.disabled:e.disabled,name:h}):O(h,!0,g.value),{...M?{disabled:g.disabled||e.disabled}:{},...e.progressive?{required:!!g.required,min:At(g.min),max:At(g.max),minLength:At(g.minLength),maxLength:At(g.maxLength),pattern:At(g.pattern)}:{},name:h,onChange:be,onBlur:be,ref:N=>{if(N){Cn(h,g),b=T(r,h);const w=ee(N.value)&&N.querySelectorAll&&N.querySelectorAll("input,select,textarea")[0]||N,R=$u(w),W=b._f.refs||[];if(R?W.find(G=>G===w):w===b._f.ref)return;Y(r,h,{_f:{...b._f,...R?{refs:[...W.filter(Hn),w,...Array.isArray(T(s,h))?[{}]:[]],ref:{type:w.type,name:h}}:{ref:w}}}),O(h,!1,void 0,w)}else b=T(r,h,{}),b._f&&(b._f.mount=!1),(e.shouldUnregister||g.shouldUnregister)&&!(ho(l.array,h)&&o.action)&&l.unMount.add(h)}}},Sn=()=>e.shouldFocusError&&It(r,le,l.mount),No=h=>{ve(h)&&(m.state.next({disabled:h}),It(r,(g,b)=>{const M=T(r,b);M&&(g.disabled=M._f.disabled||h,Array.isArray(M._f.refs)&&M._f.refs.forEach(N=>{N.disabled=M._f.disabled||h}))},0,!1))},Vr=(h,g)=>async b=>{let M;b&&(b.preventDefault&&b.preventDefault(),b.persist&&b.persist());let N=re(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:w,values:R}=await V();S(),n.errors=w,N=re(R)}else await q(r);if(l.disabled.size)for(const w of l.disabled)se(N,w);if(se(n.errors,"root"),ge(n.errors)){m.state.next({errors:{}});try{await h(N,b)}catch(w){M=w}}else g&&await g({...n.errors},b),Sn(),setTimeout(Sn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ge(n.errors)&&!M,submitCount:n.submitCount+1,errors:n.errors}),M)throw M},Eo=(h,g={})=>{T(r,h)&&(ee(g.defaultValue)?K(h,re(T(s,h))):(K(h,g.defaultValue),Y(s,h,re(g.defaultValue))),g.keepTouched||se(n.touchedFields,h),g.keepDirty||(se(n.dirtyFields,h),n.isDirty=g.defaultValue?P(h,re(T(s,h))):P()),g.keepError||(se(n.errors,h),f.isValid&&C()),m.state.next({...n}))},Br=(h,g={})=>{const b=h?re(h):s,M=re(b),N=ge(h),w=N?s:M;if(g.keepDefaultValues||(s=b),!g.keepValues){if(g.keepDirtyValues){const R=new Set([...l.mount,...Object.keys(yt(s,i))]);for(const W of Array.from(R)){const G=T(n.dirtyFields,W),me=T(i,W),Ye=T(w,W);G&&!ee(me)?Y(w,W,me):!G&&!ee(Ye)&&K(W,Ye)}}else{if(Mr&&ee(h))for(const R of l.mount){const W=T(r,R);if(W&&W._f){const G=Array.isArray(W._f.refs)?W._f.refs[0]:W._f.ref;if(dn(G)){const me=G.closest("form");if(me){me.reset();break}}}}if(g.keepFieldsRef)for(const R of l.mount)K(R,T(w,R));else r={}}i=e.shouldUnregister?g.keepDefaultValues?re(s):{}:re(w),m.array.next({values:{...w}}),m.state.next({values:{...w}})}l={mount:g.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!g.keepIsValid||!!g.keepDirtyValues||!e.shouldUnregister&&!ge(w),o.watch=!!e.shouldUnregister,o.keepIsValid=!!g.keepIsValid,o.action=!1,g.keepErrors||(n.errors={}),m.state.next({submitCount:g.keepSubmitCount?n.submitCount:0,isDirty:N?!1:g.keepDirty?n.isDirty:!!(g.keepDefaultValues&&!Ie(h,s)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:N?{}:g.keepDirtyValues?g.keepDefaultValues&&i?yt(s,i):n.dirtyFields:g.keepDefaultValues&&h?yt(s,h):g.keepDirty?n.dirtyFields:{},touchedFields:g.keepTouched?n.touchedFields:{},errors:g.keepErrors?n.errors:{},isSubmitSuccessful:g.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},_r=(h,g)=>Br(xe(h)?h(i):h,{...e.resetOptions,...g}),To=(h,g={})=>{const b=T(r,h),M=b&&b._f;if(M){const N=M.refs?M.refs[0]:M.ref;N.focus&&setTimeout(()=>{N.focus(),g.shouldSelect&&xe(N.select)&&N.select()})}},Mo=h=>{n={...n,...h}},$r={control:{register:Cn,unregister:vn,getFieldState:Qe,handleSubmit:Vr,setError:ne,_subscribe:vt,_runSchema:V,_updateIsValidating:S,_focusError:Sn,_getWatch:_,_getDirty:P,_setValid:C,_setFieldArray:A,_setDisabledField:Pr,_setErrors:E,_getFieldArray:J,_reset:Br,_resetDefaultValues:()=>xe(e.defaultValues)&&e.defaultValues().then(h=>{_r(h,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:Ae,_disableForm:No,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(h){o=h},get _defaultValues(){return s},get _names(){return l},set _names(h){l=h},get _formState(){return n},get _options(){return e},set _options(h){e={...e,...h}}},subscribe:kn,trigger:pe,register:Cn,handleSubmit:Vr,watch:Ve,setValue:K,getValues:ft,reset:_r,resetField:Eo,clearErrors:Xe,unregister:vn,setError:ne,setFocus:To,getFieldState:Qe};return{...$r,formControl:$r}}function td(t={}){const e=k.useRef(void 0),n=k.useRef(void 0),[r,s]=k.useState({isDirty:!1,isValidating:!1,isLoading:xe(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:xe(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!xe(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=ed(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,jr(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),k.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),k.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),k.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),k.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),k.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),k.useEffect(()=>{var o;t.values&&!Ie(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=t.values,s(l=>({...l}))):i._resetDefaultValues()},[i,t.values]),k.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=k.useMemo(()=>mo(r,i),[i,r]),e.current}function nd(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function rd(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function sd(t="USD",e="en-US"){try{return new Intl.NumberFormat(e,{style:"currency",currency:t}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function id(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function od(t,e,n=.001){const r=t-e,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function Fr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Fr();const ld={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Un=()=>({id:Fr(),amount:0,glAccount:null,isTaxDeductible:!1}),Co=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:a,onDelete:u,canDelete:d=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":x,control:C,name:S,rules:A})=>{const j={...ld,...m},E=C!==void 0&&S!==void 0,O=td({defaultValues:{_internal:e||Un()}}),D=Vu({control:E?C:O.control,name:E?S:"_internal",rules:E?A:void 0}),[I,V]=k.useState(e||Un()),B=E?D.field.value??Un():t??I,q=E&&!!D.fieldState?.error,Ae=E&&(D.fieldState?.isTouched??!1),P=q||Ae,_=P&&(!B.amount||B.amount<=0),J=P&&!B.glAccount,[$,X]=k.useState(B.glAccount?.name||""),K=k.useCallback(ne=>{const Ve={...B,...ne};E&&D.field.onChange(Ve),!E&&t===void 0&&V(Ve),i?.(Ve)},[B,t,i,E,D]),be=k.useCallback(ne=>{const Ve=ne||0;K({amount:Ve}),o?.(Ve)},[K,o]),le=k.useCallback(ne=>{X(ne),s?.(ne)},[s]),pe=k.useCallback(ne=>{if(ne===null){K({glAccount:null}),l?.(null);return}const vt=n.find(kn=>String(kn.id)===String(ne))||null;K({glAccount:vt}),l?.(vt)},[n,K,l]),ft=k.useCallback(()=>{X(""),K({glAccount:null}),l?.(null)},[K,l]),Qe=k.useCallback(ne=>{K({isTaxDeductible:ne}),a?.(ne)},[K,a]),Xe=k.useCallback(()=>{u?.()},[u]);return c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":x||"revenue-distribution-card",className:y.cn(v.base),children:c.jsxs(y.CardBody,{className:y.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[c.jsx("div",{className:y.cn("shrink-0",v.amountContainer),children:c.jsx(y.NumberInput,{"data-testid":`${x||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(y.Tooltip,{content:j.amountTooltip,children:c.jsx(Te,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:B.amount||void 0,onValueChange:be,labelPlacement:"outside",placeholder:j.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:_,errorMessage:_?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:c.jsx("div",{className:"pointer-events-none flex items-center",children:c.jsx("span",{className:"text-default-400 text-small",children:j.currencySymbol})})})}),c.jsx("div",{className:y.cn("grow",v.glAccountContainer),children:c.jsx(y.Autocomplete,{"data-testid":`${x||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.glAccount,c.jsx(y.Tooltip,{content:j.glAccountTooltip,children:c.jsx(Te,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:B.glAccount?.name??$,selectedKey:B.glAccount?.id??null,isDisabled:p,isInvalid:J,errorMessage:J?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:le,onSelectionChange:pe,onClear:ft,className:v.glAccountInput,children:ne=>c.jsx(y.AutocompleteItem,{textValue:ne.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:ne.name}),ne.code&&c.jsx("span",{className:"text-xs text-default-400",children:ne.code})]})},ne.id)})}),c.jsx("div",{className:y.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:c.jsx(y.Checkbox,{radius:"full","data-testid":`${x||"revenue-distribution-card"}-tax-deductible`,isSelected:B.isTaxDeductible,onValueChange:Qe,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:y.cn("shrink-0 pt-6",v.deleteContainer),children:c.jsx(de,{"data-testid":`${x||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!d,onPress:Xe,startContent:c.jsx(Te,{icon:"solar:trash-bin-trash-linear",width:16}),className:y.cn("text-danger",v.deleteButton),children:j.deleteButton})})]})})};Co.displayName="RevenueDistributionCard";const So=({message:t="No distributions configured",icon:e="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return c.jsx(c.Fragment,{children:i()});const o=c.jsxs("div",{className:y.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(Te,{icon:e,width:n,className:y.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:y.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:o})};So.displayName="RevenueDistributionEmpty";const ad={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},wo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...ad,...e},o=c.jsx(y.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:o})};wo.displayName="RevenueDistributionError";const Ao=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:y.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[c.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),c.jsxs("div",{className:"grow flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(y.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(y.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(y.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(y.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Ao.displayName="RevenueDistributionSkeleton";exports.Button=de;exports.ConfirmationPageTemplate=qo;exports.DonationAmounts=zi;exports.EventDetails=Tu;exports.EventDetailsTemplate=Wo;exports.ExpireCartTimer=Hi;exports.Footer=Go;exports.HeroUIProvider=_o;exports.Navbar=Uo;exports.OfferCard=Tr;exports.OfferCardEmpty=so;exports.OfferCardError=io;exports.OfferCardList=co;exports.OfferCardSkeleton=oo;exports.RICH_TEXT_PRESETS=_i;exports.RevenueDistributionCard=Co;exports.RevenueDistributionEmpty=So;exports.RevenueDistributionError=wo;exports.RevenueDistributionSkeleton=Ao;exports.RichTextArea=$i;exports.Stepper=Js;exports.calculateAllocationDifference=od;exports.formatOfferCurrency=ro;exports.formatRevenueAmount=nd;exports.formatRevenueCurrency=rd;exports.generateDistributionId=Fr;exports.getCurrencySymbol=sd;exports.offerCardVariants=ao;exports.offerListVariants=lo;exports.parseOfferCurrency=Mu;exports.parseRevenueCurrency=id;Object.keys(y).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>y[t]})});
|
|
18
|
+
`);return{dom:a,text:p,slice:e}}function Ai(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return l=new K(q.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
19
|
+
`))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)l=f;else{let p=s.marks(),{schema:m}=t.state,v=hn.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(x=>{let S=o.appendChild(document.createElement("p"));x&&S.appendChild(v.serializeNode(m.text(x,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=Ha(n),yr&&Ua(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Xt.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Ba.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=qa(vs(l,+d[1],+d[2]),d[4]);else if(l=K.maxOpen(_a(l.content,s),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=vs(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Ba=/^(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 _a(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&i.length&&Ei(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ti(o[o.length-1],i.length));let d=Ni(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return q.from(o)}return t}function Ni(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function Ei(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Ei(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(q.from(Ni(n,t,s+1))))}}function Ti(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ti(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function er(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=er(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function vs(t,e,n){return e<t.openStart&&(t=new K(er(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(er(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Mi={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 Ss=null;function Oi(){return Ss||(Ss=document.implementation.createHTMLDocument("title"))}let $n=null;function za(t){let e=window.trustedTypes;return e?($n||($n=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),$n.createHTML(t)):t}function Ha(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Oi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Mi[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=za(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ua(t){let e=t.querySelectorAll(ze?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function qa(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=q.from(a.create(r[l+1],s)),i++,o++}return new K(s,i,o)}const Le={},Ne={};function We(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Ne.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Di(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Bt&&ze&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),gr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,gi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||$a(t,n)?n.preventDefault():We(t,"key")};Ne.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ne.keypress=(t,e)=>{let n=e;if(Di(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ee&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function yn(t){return{left:t.clientX,top:t.clientY}}function Ka(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function br(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function xt(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Ja(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(xt(t,new J(n)),!0):!1}function Wa(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof J&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(J.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(xt(t,J.create(t.state.doc,s)),!0):!1}function Ga(t,e,n,r,s){return br(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Wa(t,n):Ja(t,n))}function Za(t,e,n,r){return br(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Qa(t,e,n,r){return br(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Xa(t,n,r)}function Xa(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(xt(t,Q.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)xt(t,Q.create(r,l+1,l+1+o.content.size));else if(J.isSelectable(o))xt(t,J.create(r,l));else continue;return!0}}function kr(t){return on(t)}const Ii=Ee?"metaKey":"ctrlKey";Le.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=kr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ka(n,t.input.lastClick)&&!n[Ii]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(yn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Ya(t,o,n,!!r)):(i=="doubleClick"?Za:Qa)(t,o.pos,o.inside,n)?n.preventDefault():We(t,"pointer"))};class Ya{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ii],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.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:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof J&&u.from<=o&&u.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gn&&!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)),We(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(()=>xr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(yn(e))),this.updateAllowDefault(e),this.allowDefault||!n?We(this.view,"pointer"):Ga(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ut&&this.mightDrag&&!this.mightDrag.node.isAtom||ze&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(xt(this.view,X.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):We(this.view,"pointer")}move(e){this.updateAllowDefault(e),We(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)}}Le.touchstart=t=>{t.input.lastTouch=Date.now(),kr(t),We(t,"pointer")};Le.touchmove=t=>{t.input.lastTouch=Date.now(),We(t,"pointer")};Le.contextmenu=t=>kr(t);function Di(t,e){return t.composing?!0:ut&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const ec=Bt?5e3:-1;Ne.compositionstart=Ne.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ze&&ki&&tc(t)))t.markCursor=t.state.storedMarks||n.marks(),on(t,!0),t.markCursor=null;else if(on(t,!e.selection.empty),gn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}ji(t,ec)};function tc(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ne.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,ji(t,20))};function ji(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>on(t),e))}function nc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=rc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function rc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function on(t,e=!1){if(!(Bt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),nc(t),e||t.docView&&t.docView.dirty){let n=Ta(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function sc(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ft=$t&&xi<15||gr&&Ea<604;Le.copy=Ne.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ft?null:n.clipboardData,o=r.content(),{dom:l,text:a}=wi(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):sc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ic(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function oc(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?tr(t,r.value,null,s,e):tr(t,r.textContent,r.innerHTML,s,e)},50)}function tr(t,e,n,r,s){let i=Ai(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||K.empty)))return!0;if(!i)return!1;let o=ic(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Li(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ne.paste=(t,e)=>{let n=e;if(t.composing&&!Bt)return;let r=Ft?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&tr(t,Li(r),r.getData("text/html"),s,n)?n.preventDefault():oc(t,n)};class lc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const ac=Ee?"altKey":"ctrlKey";function Ri(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[ac]}Le.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(yn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof J?s.to-1:s.to))){if(r&&r.mightDrag)o=J.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=J.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:u,slice:d}=wi(t,l);(!n.dataTransfer.files.length||!ze||bi>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ft?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ft||n.dataTransfer.setData("text/plain",u),t.dragging=new lc(d,Ri(t,n),o)};Le.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ne.dragover=Ne.dragenter=(t,e)=>e.preventDefault();Ne.drop=(t,e)=>{try{cc(t,e,t.dragging)}finally{t.dragging=null}};function cc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(yn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",m=>{i=m(i,t,!1)}):i=Ai(t,Li(e.dataTransfer),Ft?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Ri(t,e));if(t.someProp("handleDrop",m=>m(t,e,i||K.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?li(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:m}=n;m?m.replace(a):a.deleteSelection()}let u=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(d?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(f))return;let p=a.doc.resolve(u);if(d&&J.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new J(p));else{let m=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((v,x,S,C)=>m=C),a.setSelection(Si(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Le.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&xr(t)},20))};Le.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Le.beforeinput=(t,e)=>{if(ze&&Bt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,gi(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Ne)Le[t]=Ne[t];function Pt(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ln{constructor(e,n){this.toDOM=e,this.spec=n||lt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Fe(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ln&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ge{constructor(e,n){this.attrs=e,this.spec=n||lt}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Fe(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ge&&Pt(this.attrs,e.attrs)&&Pt(this.spec,e.spec)}static is(e){return e.type instanceof Ge}destroy(){}}class vr{constructor(e,n){this.attrs=e,this.spec=n||lt}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Fe(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof vr&&Pt(this.attrs,e.attrs)&&Pt(this.spec,e.spec)}destroy(){}}class Fe{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Fe(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Fe(e,e,new ln(n,r))}static inline(e,n,r,s){return new Fe(e,n,new Ge(r,s))}static node(e,n,r,s){return new Fe(e,n,new vr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ge}get widget(){return this.type instanceof ln}}const mt=[],lt={};class ue{constructor(e,n){this.local=e.length?e:mt,this.children=n.length?n:mt}static create(e,n){return n.length?an(n,e,0,lt):be}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&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]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==be||e.maps.length==0?this:this.mapInner(e,n,0,0,r||lt)}mapInner(e,n,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(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?uc(this.children,o||[],e,n,r,s,i):o?new ue(o.sort(at),mt):be}add(e,n){return n.length?this==be?ue.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let u=a+r,d;if(d=Pi(n,l,u)){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,d,u+1):s.splice(i,0,a,a+l.nodeSize,an(d,l,u+1,lt)),i+=3}});let o=Fi(i?Vi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ue(o.length?this.local.concat(o).sort(at):this.local,s||this.children)}remove(e){return e.length==0||this==be?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<a&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(o,l+1);u!=be?r[i+2]=u:(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,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ue(s,r):be}forChild(e,n){if(this==be)return this;if(n.isLeaf)return ue.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+n.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 Ge){let u=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;u<d&&(s||(s=[])).push(a.copy(u,d))}}if(s){let l=new ue(s.sort(at),mt);return r?new tt([l,r]):l}return r||be}eq(e){if(this==e)return!0;if(!(e instanceof ue)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Sr(this.localsInner(e))}localsInner(e){if(this==be)return mt;if(e.inlineContent||!this.local.some(Ge.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ge||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Sr;const be=ue.empty;class tt{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,lt));return tt.from(r)}forChild(e,n){if(n.isLeaf)return ue.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=be&&(i instanceof tt?r=r.concat(i.members):r.push(i))}return tt.from(r)}eq(e){if(!(e instanceof tt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Sr(r?n:n.sort(at)):mt}static from(e){switch(e.length){case 0:return be;case 1:return e[0];default:return new tt(e.every(n=>n instanceof ue)?e:e.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function uc(t,e,n,r,s,i,o){let l=t.slice();for(let u=0,d=i;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,v,x)=>{let S=x-v-(m-p);for(let C=0;C<l.length;C+=3){let w=l[C+1];if(w<0||p>w+d-f)continue;let j=l[C]+d-f;m>=j?l[C+1]=p<=j?-2:-1:p>=d&&S&&(l[C]+=S,l[C+1]+=S)}f+=S}),d=n.maps[u].map(d,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let d=n.map(t[u]+i),f=d-s;if(f<0||f>=r.content.size){a=!0;continue}let p=n.map(t[u+1]+i,-1),m=p-s,{index:v,offset:x}=r.content.findIndex(f),S=r.maybeChild(v);if(S&&x==f&&x+S.nodeSize==m){let C=l[u+2].mapInner(n,S,d+1,t[u]+i+1,o);C!=be?(l[u]=f,l[u+1]=m,l[u+2]=C):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=dc(l,t,e,n,s,i,o),d=an(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new ue(e.sort(at),l)}function Fi(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Fe(s.from+e,s.to+e,s.type))}return n}function dc(t,e,n,r,s,i,o){function l(a,u){for(let d=0;d<a.local.length;d++){let f=a.local[d].map(r,s,u);f?n.push(f):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+u+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Pi(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Vi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function an(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Pi(t,l,a+n);if(u){i=!0;let d=an(u,l,n+a+1,r);d!=be&&s.push(a,a+l.nodeSize,d)}});let o=Fi(i?Vi(t):t,-n).sort(at);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 ue(o,s):be}function at(t,e){return t.from-e.from||t.to-e.to}function Sr(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Cs(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Cs(e,s,r.copy(i.from,r.to)));break}}}return e}function Cs(t,e,n){for(;e<t.length&&at(n,t[e])>0;)e++;t.splice(e,0,n)}class re extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return re.valid(r)?new re(r):X.near(r)}content(){return K.empty}eq(e){return e instanceof re&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new re(e.resolve(n.pos))}getBookmark(){return new Cr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!fc(e)||!hc(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&re.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(re.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!J.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(re.valid(l))return l}return null}}}re.prototype.visible=!1;re.findFrom=re.findGapCursorFrom;X.jsonID("gapcursor",re);class Cr{constructor(e){this.pos=e}map(e){return new Cr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return re.valid(n)?new re(n):X.near(n)}}function $i(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function fc(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||$i(s.type))return!0;if(s.inlineContent)return!1}}return!0}function hc(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||$i(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pc(){return new mn({props:{decorations:xc,createSelectionBetween(t,e,n){return e.pos==n.pos&&re.valid(n)?new re(n):null},handleClick:gc,handleKeyDown:mc,handleDOMEvents:{beforeinput:yc}}})}const mc=wa({ArrowLeft:qt("horiz",-1),ArrowRight:qt("horiz",1),ArrowUp:qt("vert",-1),ArrowDown:qt("vert",1)});function qt(t,e){const n=t=="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 Q){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=re.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new re(u))),!0):!1}}function gc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!re.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&J.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new re(r))),!0)}function yc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof re))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=q.empty;for(let o=r.length-1;o>=0;o--)s=q.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new K(s,0,0));return i.setSelection(Q.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function xc(t){if(!(t.selection instanceof re))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ue.create(t.doc,[Fe.widget(t.selection.head,e,{key:"gapcursor"})])}const bc=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[pc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=R.callOrReturn(R.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),St={bold:{category:"mark",extension:yl,priority:100},italic:{category:"mark",extension:Sl,priority:100},strike:{category:"mark",extension:Al,priority:100},underline:{category:"mark",extension:jo.Underline,priority:100},code:{category:"mark",extension:Tl,priority:100},textColor:{category:"mark",extension:Lo.Color,defaultOptions:{types:["textStyle","heading","paragraph"]},priority:90},highlight:{category:"mark",extension:Ro.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Fo.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Il,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ll,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Fl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Po.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Xl,priority:100},blockquote:{category:"node",extension:ea,priority:100},horizontalRule:{category:"node",extension:ta,priority:100},hardBreak:{category:"node",extension:na,priority:100},undo:{category:"extension",extension:cs,priority:50},redo:{category:"extension",extension:cs,priority:50},textAlign:{category:"extension",extension:$o.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},kc=[fa,ha,Dl,Ol.configure({HTMLAttributes:{}}),Pl.configure({HTMLAttributes:{}}),Vo.TaskItem.configure({nested:!0}),ga,bc];function vc(t){const e=[],n=new Set,r=new Set;kc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Dt(l)),i=new Set;return s.forEach(l=>{const a=St[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=St[l];if(!a||a.extension===null)return;const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),s.forEach(l=>{if(n.has(l))return;const a=St[l];if(!a){console.warn(`Extension config not found for modifier: ${l}`);return}if(a.extension===null){n.add(l);return}const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),e.sort((l,a)=>{const u=Object.values(St).find(m=>m?.extension?.name===l.name),d=Object.values(St).find(m=>m?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Bi={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",{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",{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"]},Sc={h1:"font-size: 2rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",h2:"font-size: 1.5rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",h3:"font-size: 1.25rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",h4:"font-size: 1.1rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",h5:"font-size: 1rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",h6:"font-size: 0.9rem; font-weight: 600; line-height: 1.2; margin: 1rem 0 0.5rem 0;",p:"min-height: 1.5em; margin: 0;",ul:"list-style-type: disc; list-style-position: outside; padding-left: 2rem; margin: 1rem 0;",ol:"list-style-type: decimal; list-style-position: outside; padding-left: 2rem; margin: 1rem 0;",li:"display: list-item; margin: 0.25rem 0;",strong:"font-weight: 700;",em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:"background-color: #f3f4f6; border-radius: 0.4rem; font-size: 0.85rem; padding: 0.25em 0.3em; font-family: monospace;",pre:"background: #1f2937; border-radius: 0.5rem; color: #f3f4f6; font-family: monospace; margin: 1.5rem 0; padding: 0.75rem 1rem; overflow-x: auto;",blockquote:"border-left: 3px solid #d1d5db; margin: 1.5rem 0; padding-left: 1rem; color: #6b7280;",hr:"border: none; border-top: 1px solid #e5e7eb; margin: 2rem 0;",a:"color: #3b82f6; text-decoration: underline; cursor: pointer;",mark:"background-color: #faf594; border-radius: 0.25rem; padding: 0 0.125rem;"};function Cc(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Sc)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");e=e.replace(s,i=>{if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const o=i.indexOf(">");return`${i.slice(0,o)} style="${r}"${i.slice(o)}`}})}return e}const wc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=ur.useCurrentEditor();return c.jsx(fl,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Ac=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=ur.useCurrentEditor();if(!n||!t&&!e)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return c.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[t&&c.jsxs("span",{children:[s," characters"]}),e&&c.jsxs("span",{children:[i," words"]})]})},nr=k.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Bi.full,variant:u="bordered",initialContent:d,content:f,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:x=!1,isDisabled:S=!1,includeInlineStyles:C=!0,...w}=t,{zoom:j,setZoom:N}=cl(),D=Ur.lineHeight,L=n*D,O=s?void 0:r*D,_=k.useMemo(()=>vc(a),[a]),{Component:H,label:U,shouldLabelBeOutside:P,getBaseProps:M,getLabelProps:F,getInputWrapperProps:V}=y.useInput({...w,variant:u,ref:e,isMultiline:!0}),B=U?c.jsx("label",{...F(),children:U}):null,Y=k.useCallback(({editor:W})=>{const me=W.getHTML(),ce=C?Cc(me):me,ge=W.getJSON(),He=W.getText(),dt=He.length,kt=He.split(/\s+/).filter(Se=>Se.length>0).length,te={html:ce,json:ge,text:He,characters:dt,words:kt};if(p?.(te),m?.(te),"onChange"in w&&typeof w.onChange=="function"){const Se={target:{value:ce},currentTarget:{value:ce}};w.onChange(Se)}},[p,m,w,C]);return c.jsxs(H,{...M(),children:[P?B:null,c.jsx("div",{...V(),className:y.cn(V().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:O?`${O+Ur.toolbarHeight}px`:void 0,overflow:O?"auto":void 0},children:c.jsx(ur.EditorProvider,{editable:!x&&!S,slotBefore:l?c.jsx(wc,{modifiers:a,zoom:j,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:c.jsx(Ac,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${L}px`,fontSize:`${j}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:_,content:f||d||t.defaultValue||"",onUpdate:Y})})]})});nr.displayName="TipTapEditor";const _i=k.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(nr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(nr,{...s,variant:r,ref:e}))});_i.displayName="RichTextArea";function Nc(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}const ws=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Ec={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},zi=({presetAmounts:t=ws,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,currency:s="USD",locale:i="en-US",showCustomAmount:o=!0,minCustomAmount:l=.5,maxCustomAmount:a=1e6,labels:u,mobileColumns:d=2,desktopColumns:f=3,isDisabled:p=!1,buttonVariant:m="bordered",buttonColor:v="default",inputVariant:x="bordered",className:S="",showCard:C=!0})=>{const w={...Ec,...u},j=Array.isArray(t)?t:ws,N={2:"grid-cols-2",3:"grid-cols-3"},D={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},L=`${N[d]} ${D[f]}`,[O,_]=dr(e,n,r),[H,U]=k.useState(""),P=k.useCallback(B=>{if(p)return;const Y={amount:B.amount,isCustom:!1,presetId:B.id};_(Y),U("")},[p,_]),M=k.useCallback(B=>{if(p)return;if(U(B!==void 0?String(B):""),B===void 0||isNaN(B)){_(null);return}_({amount:B,isCustom:!0})},[p,_]),F=k.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),V=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[w.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:w.title}),j.length>0&&c.jsx("div",{className:y.cn("grid gap-3",L),"data-testid":"donation-amounts-presets",children:j.map(B=>{const Y=O!==null&&!O.isCustom&&O.presetId===B.id;return c.jsx(se,{color:Y?"primary":v,variant:Y?"solid":m,className:"w-full",onPress:()=>P(B),isDisabled:p,"data-testid":`donation-amounts-preset-${B.id}`,children:B.label||Nc(B.amount,i,s)},B.id)})}),o&&c.jsx(y.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,variant:x,radius:"md",minValue:l,maxValue:a,step:.01,formatOptions:F,value:H!==""?parseFloat(H):void 0,onValueChange:M,isDisabled:p,"data-testid":"donation-amounts-custom-input"},O?.isCustom===!1?O.presetId:"custom")]});return C?c.jsx(y.Card,{className:y.cn("w-full",S),"data-testid":"donation-amounts-card",children:c.jsx(y.CardBody,{children:V})}):c.jsx("div",{className:y.cn("w-full",S),"data-testid":"donation-amounts-plain",children:V})};zi.displayName="DonationAmounts";const Tc=t=>{const e=Math.max(0,t),n=Math.floor(e/60).toString().padStart(2,"0"),r=(e%60).toString().padStart(2,"0");return`${n}:${r} minutes`},Mc=t=>{switch(t){case"warning":return z.Clock;case"error":return z.AlertCircle;case"success":return z.CheckCircle;default:return z.Clock}},Oc=t=>{switch(t){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},Hi=k.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:a,position:u="fixed",autoStart:d=!0,formatTime:f=Tc,className:p,...m},v)=>{const[x,S]=dr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),C=k.useRef(null),w=k.useRef(!1);k.useEffect(()=>()=>{C.current&&clearInterval(C.current)},[]),k.useEffect(()=>{if(!d||x<=0){C.current&&(clearInterval(C.current),C.current=null);return}return C.current=setInterval(()=>{S(L=>L<=1?(C.current&&(clearInterval(C.current),C.current=null),w.current||(w.current=!0,r?.()),0):L-1)},1e3),()=>{C.current&&(clearInterval(C.current),C.current=null)}},[d,x,S,r]),k.useEffect(()=>{x>0&&(w.current=!1)},[x]);const j=a||Mc(s),N=Oc(i),D={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${o} ${f(x)}`,"data-testid":"expire-cart-timer",className:y.cn("w-full text-white z-50",N,D[u],p),...m,children:c.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:c.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&c.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:c.jsx(j,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),c.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:o})]}),c.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:c.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${f(x)}`,"data-testid":"expire-cart-timer-value",children:f(x)})})]})})})});Hi.displayName="ExpireCartTimer";function Ic(t,e){const n=t.icons,r=t.aliases||Object.create(null),s=Object.create(null);function i(o){if(n[o])return s[o]=[];if(!(o in s)){s[o]=null;const l=r[o]&&r[o].parent,a=l&&i(l);a&&(s[o]=[l].concat(a))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ui=Object.freeze({left:0,top:0,width:16,height:16}),cn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),wr=Object.freeze({...Ui,...cn}),rr=Object.freeze({...wr,body:"",hidden:!1});function Dc(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}function As(t,e){const n=Dc(t,e);for(const r in rr)r in cn?r in t&&!(r in n)&&(n[r]=cn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function jc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=As(r[l]||s[l],i)}return o(e),n.forEach(o),As(t,i)}function qi(t,e){const n=[];if(typeof t!="object"||typeof t.icons!="object")return n;t.not_found instanceof Array&&t.not_found.forEach(s=>{e(s,null),n.push(s)});const r=Ic(t);for(const s in r){const i=r[s];i&&(e(s,jc(t,s,i)),n.push(s))}return n}const Lc={provider:"",aliases:{},not_found:{},...Ui};function Bn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Ki(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Bn(t,Lc))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Bn(i,rr))return null}const r=e.aliases||Object.create(null);for(const s in r){const i=r[s],o=i.parent;if(!s||typeof o!="string"||!n[o]&&!r[o]||!Bn(i,rr))return null}return e}const Ns=Object.create(null);function Rc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function bt(t,e){const n=Ns[t]||(Ns[t]=Object.create(null));return n[e]||(n[e]=Rc(t,e))}function Ji(t,e){return Ki(e)?qi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Fc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Wi=/^[a-z0-9]+(-[a-z0-9]+)*$/,xn=(t,e,n,r="")=>{const s=t.split(":");if(t.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),a=s.pop(),u={provider:s.length>0?s[0]:r,prefix:a,name:l};return e&&!Zt(u)?null:u}const i=s[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!Zt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Zt(l,n)?null:l}return null},Zt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Vt=!1;function Gi(t){return typeof t=="boolean"&&(Vt=t),Vt}function Es(t){const e=typeof t=="string"?xn(t,!0,Vt):t;if(e){const n=bt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Pc(t,e){const n=xn(t,!0,Vt);if(!n)return!1;const r=bt(n.provider,n.prefix);return e?Fc(r,n.name,e):(r.missing.add(n.name),!0)}function Vc(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Vt&&!e&&!t.prefix){let s=!1;return Ki(t)&&(t.prefix="",qi(t,(i,o)=>{Pc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Zt({prefix:n,name:"a"}))return!1;const r=bt(e,n);return!!Ji(r,t)}const Zi=Object.freeze({width:null,height:null}),Qi=Object.freeze({...Zi,...cn}),$c=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Bc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ts(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;const r=t.split($c);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Bc.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function _c(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const s=t.indexOf(">",r),i=t.indexOf("</"+e);if(s===-1||i===-1)break;const o=t.indexOf(">",i);if(o===-1)break;n+=t.slice(s+1,i).trim(),t=t.slice(0,r).trim()+t.slice(o+1)}return{defs:n,content:t}}function zc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Hc(t,e,n){const r=_c(t);return zc(r.defs,e+r.content+n)}const Uc=t=>t==="unset"||t==="undefined"||t==="none";function qc(t,e){const n={...wr,...t},r={...Qi,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(x=>{const S=[],C=x.hFlip,w=x.vFlip;let j=x.rotate;C?w?j+=2:(S.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),S.push("scale(-1 1)"),s.top=s.left=0):w&&(S.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),S.push("scale(1 -1)"),s.top=s.left=0);let N;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:N=s.height/2+s.top,S.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:S.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,S.unshift("rotate(-90 "+N.toString()+" "+N.toString()+")");break}j%2===1&&(s.left!==s.top&&(N=s.left,s.left=s.top,s.top=N),s.width!==s.height&&(N=s.width,s.width=s.height,s.height=N)),S.length&&(i=Hc(i,'<g transform="'+S.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,a=s.width,u=s.height;let d,f;o===null?(f=l===null?"1em":l==="auto"?u:l,d=Ts(f,a/u)):(d=o==="auto"?a:o,f=l===null?Ts(d,u/a):l==="auto"?u:l);const p={},m=(x,S)=>{Uc(S)||(p[x]=S.toString())};m("width",d),m("height",f);const v=[s.left,s.top,a,u];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const Kc=/\sid="(\S+)"/g,Jc="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Wc=0;function Gc(t,e=Jc){const n=[];let r;for(;r=Kc.exec(t);)n.push(r[1]);if(!n.length)return t;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const o=typeof e=="function"?e(i):e+(Wc++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const sr=Object.create(null);function Zc(t,e){sr[t]=e}function ir(t){return sr[t]||sr[""]}function Ar(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const Nr=Object.create(null),Ct=["https://api.simplesvg.com","https://api.unisvg.com"],Qt=[];for(;Ct.length>0;)Ct.length===1||Math.random()>.5?Qt.push(Ct.shift()):Qt.push(Ct.pop());Nr[""]=Ar({resources:["https://api.iconify.design"].concat(Qt)});function Qc(t,e){const n=Ar(e);return n===null?!1:(Nr[t]=n,!0)}function Er(t){return Nr[t]}const Xc=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ms=Xc();function Yc(t,e){const n=Er(t);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(o=>{s=Math.max(s,o.length)});const i=e+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function eu(t){return t===404}const tu=(t,e,n)=>{const r=[],s=Yc(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,u)=>{l+=a.length+1,l>=s&&u>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},l=a.length),o.icons.push(a)}),r.push(o),r};function nu(t){if(typeof t=="string"){const e=Er(t);if(e)return e.path}return"/"}const ru=(t,e,n)=>{if(!Ms){n("abort",424);return}let r=nu(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});r+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;Ms(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(eu(o)?"abort":"next",o)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},su={prepare:tu,send:ru};function Xi(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function iu(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(a=>{if(a.prefix!==s)return!0;const u=a.name;if(t.icons[u])o.loaded.push({provider:r,prefix:s,name:u});else if(t.missing.has(u))o.missing.push({provider:r,prefix:s,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||Xi([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let ou=0;function lu(t,e,n){const r=ou++,s=Xi.bind(null,n,r);if(!e.pending.length)return s;const i={id:r,icons:e,callback:t,abort:s};return n.forEach(o=>{(o.loaderCallbacks||(o.loaderCallbacks=[])).push(i)}),s}function au(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return t.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,o=s.prefix,l=s.name,a=n[i]||(n[i]=Object.create(null)),u=a[o]||(a[o]=bt(i,o));let d;l in u.icons?d=e.loaded:o===""||u.missing.has(l)?d=e.missing:d=e.pending;const f={provider:i,prefix:o,name:l};d.push(f)}),e}function cu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?xn(s,e,n):s;i&&r.push(i)}),r}const uu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function du(t,e,n,r){const s=t.resources.length,i=t.random?Math.floor(Math.random()*s):t.index;let o;if(t.random){let L=t.resources.slice(0);for(o=[];L.length>1;){const O=Math.floor(Math.random()*L.length);o.push(L[O]),L=L.slice(0,O).concat(L.slice(O+1))}o=o.concat(L)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",u=0,d,f=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){f&&(clearTimeout(f),f=null)}function x(){a==="pending"&&(a="aborted"),v(),p.forEach(L=>{L.status==="pending"&&(L.status="aborted")}),p=[]}function S(L,O){O&&(m=[]),typeof L=="function"&&m.push(L)}function C(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:p.length,subscribe:S,abort:x}}function w(){a="failed",m.forEach(L=>{L(void 0,d)})}function j(){p.forEach(L=>{L.status==="pending"&&(L.status="aborted")}),p=[]}function N(L,O,_){const H=O!=="success";switch(p=p.filter(U=>U!==L),a){case"pending":break;case"failed":if(H||!t.dataAfterTimeout)return;break;default:return}if(O==="abort"){d=_,w();return}if(H){d=_,p.length||(o.length?D():w());return}if(v(),j(),!t.random){const U=t.resources.indexOf(L.resource);U!==-1&&U!==t.index&&(t.index=U)}a="completed",m.forEach(U=>{U(_)})}function D(){if(a!=="pending")return;v();const L=o.shift();if(L===void 0){if(p.length){f=setTimeout(()=>{v(),a==="pending"&&(j(),w())},t.timeout);return}w();return}const O={status:"pending",resource:L,callback:(_,H)=>{N(O,_,H)}};p.push(O),u++,f=setTimeout(D,t.rotate),n(L,e,O.callback)}return setTimeout(D),C}function Yi(t){const e={...uu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=du(e,l,a,(f,p)=>{r(),u&&u(f,p)});return n.push(d),d}function i(l){return n.find(a=>l(a))||null}return{query:s,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:r}}function Os(){}const _n=Object.create(null);function fu(t){if(!_n[t]){const e=Er(t);if(!e)return;const n=Yi(e),r={config:e,redundancy:n};_n[t]=r}return _n[t]}function hu(t,e,n){let r,s;if(typeof t=="string"){const i=ir(t);if(!i)return n(void 0,424),Os;s=i.send;const o=fu(t);o&&(r=o.redundancy)}else{const i=Ar(t);if(i){r=Yi(i);const o=t.resources?t.resources[0]:"",l=ir(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),Os):r.query(e,s,n)().abort}function Is(){}function pu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,iu(t)}))}function mu(t){const e=[],n=[];return t.forEach(r=>{(r.match(Wi)?e:n).push(r)}),{valid:e,invalid:n}}function wt(t,e,n){function r(){const s=t.pendingIcons;e.forEach(i=>{s&&s.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ji(t,n).length){r();return}}catch(s){console.error(s)}r(),pu(t)}function Ds(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function gu(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:n,prefix:r}=t,s=t.iconsToLoad;if(delete t.iconsToLoad,!s||!s.length)return;const i=t.loadIcon;if(t.loadIcons&&(s.length>1||!i)){Ds(t.loadIcons(s,r,n),d=>{wt(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Ds(f,p=>{const m=p?{prefix:r,icons:{[d]:p}}:null;wt(t,[d],m)})});return}const{valid:o,invalid:l}=mu(s);if(l.length&&wt(t,l,null),!o.length)return;const a=r.match(Wi)?ir(n):null;if(!a){wt(t,o,null);return}a.prepare(n,r,o).forEach(d=>{hu(n,d,f=>{wt(t,d.icons,f)})})}))}const yu=(t,e)=>{const n=cu(t,!0,Gi()),r=au(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Is)}),()=>{a=!1}}const s=Object.create(null),i=[];let o,l;return r.pending.forEach(a=>{const{provider:u,prefix:d}=a;if(d===l&&u===o)return;o=u,l=d,i.push(bt(u,d));const f=s[u]||(s[u]=Object.create(null));f[d]||(f[d]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:d,name:f}=a,p=bt(u,d),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),s[u][d].push(f))}),i.forEach(a=>{const u=s[a.provider][a.prefix];u.length&&gu(a,u)}),e?lu(e,r,i):Is};function xu(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Zi?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const bu=/[\s,]+/;function ku(t,e){e.split(bu).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function vu(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(t);return isNaN(s)?0:r(s)}else if(n!==t){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(t.slice(0,t.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return e}function Su(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in e)n+=" "+r+'="'+e[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function Cu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function wu(t){return"data:image/svg+xml,"+Cu(t)}function Au(t){return'url("'+wu(t)+'")'}let Mt;function Nu(){try{Mt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Mt=null}}function Eu(t){return Mt===void 0&&Nu(),Mt?Mt.createHTML(t):t}const eo={...Qi,inline:!1},Tu={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Mu={display:"inline-block"},or={backgroundColor:"currentColor"},to={backgroundColor:"transparent"},js={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ls={WebkitMask:or,mask:or,background:to};for(const t in Ls){const e=Ls[t];for(const n in js)e[t+n]=js[n]}const Ou={...eo,inline:!0};function Rs(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Iu=(t,e,n)=>{const r=e.inline?Ou:eo,s=xu(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Tu:{}};if(n){const S=xn(n,!1,!0);if(S){const C=["iconify"],w=["provider","prefix"];for(const j of w)S[j]&&C.push("iconify--"+S[j]);a.className=C.join(" ")}}for(let S in e){const C=e[S];if(C!==void 0)switch(S){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=C;break;case"className":a[S]=(a[S]?a[S]+" ":"")+C;break;case"inline":case"hFlip":case"vFlip":s[S]=C===!0||C==="true"||C===1;break;case"flip":typeof C=="string"&&ku(s,C);break;case"color":o.color=C;break;case"rotate":typeof C=="string"?s[S]=vu(C):typeof C=="number"&&(s[S]=C);break;case"ariaHidden":case"aria-hidden":C!==!0&&C!=="true"&&delete a["aria-hidden"];break;default:r[S]===void 0&&(a[S]=C)}}const u=qc(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let S=0,C=e.id;return typeof C=="string"&&(C=C.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:Eu(Gc(u.body,C?()=>C+"ID"+S++:"iconifyReact"))},k.createElement("svg",a)}const{body:f,width:p,height:m}=t,v=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),x=Su(f,{...d,width:p+"",height:m+""});return a.style={...o,"--svg":Au(x),width:Rs(d.width),height:Rs(d.height),...Mu,...v?or:to,...l},k.createElement("span",a)};Gi(!0);Zc("",su);if(typeof document<"u"&&typeof window<"u"){const t=window;if(t.IconifyPreload!==void 0){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof e=="object"&&e!==null&&(e instanceof Array?e:[e]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Vc(r))&&console.error(n)}catch{console.error(n)}})}if(t.IconifyProviders!==void 0){const e=t.IconifyProviders;if(typeof e=="object"&&e!==null)for(let n in e){const r="IconifyProviders["+n+"] is invalid.";try{const s=e[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Qc(n,s)||console.error(r)}catch{console.error(r)}}}}function no(t){const[e,n]=k.useState(!!t.ssr),[r,s]=k.useState({});function i(m){if(m){const v=t.icon;if(typeof v=="object")return{name:"",data:v};const x=Es(v);if(x)return{name:v,data:x}}return{name:""}}const[o,l]=k.useState(i(!!t.ssr));function a(){const m=r.callback;m&&(m(),s({}))}function u(m){if(JSON.stringify(o)!==JSON.stringify(m))return a(),l(m),!0}function d(){var m;const v=t.icon;if(typeof v=="object"){u({name:"",data:v});return}const x=Es(v);if(u({name:v,data:x}))if(x===void 0){const S=yu([v],d);s({callback:S})}else x&&((m=t.onLoad)===null||m===void 0||m.call(t,v))}k.useEffect(()=>(n(!0),a),[]),k.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:p}=o;return p?Iu({...wr,...p},t,f):t.children?t.children:t.fallback?t.fallback:k.createElement("span",{})}const Me=k.forwardRef((t,e)=>no({...t,_ref:e}));k.forwardRef((t,e)=>no({inline:!0,...t,_ref:e}));const zn=({icon:t,children:e,testId:n})=>c.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[c.jsx(Me,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Du=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,showMoreButtonClassName:a,labels:u})=>{const[d,f]=k.useState(!1),[p,m]=k.useState(!1),v=k.useRef(null);return k.useEffect(()=>{const x=()=>{if(v.current){const S=v.current.scrollHeight>v.current.clientHeight;m(S)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[o]),c.jsxs(y.Card,{className:y.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(y.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(y.Image,{alt:`Event image for ${e}`,className:"w-full h-full object-cover",src:n,"data-testid":"event-details-image"})}),c.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:e})]}),c.jsxs(y.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[c.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),c.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&c.jsx(zn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(zn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(zn,{icon:"solar:point-on-map-outline",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsx("div",{ref:v,className:y.cn("text-sm text-gray-700 leading-relaxed transition-all",!d&&"line-clamp-2"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),(p||d)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(se,{onPress:()=>f(!d),variant:"light",className:y.cn("text-primary",a),startContent:c.jsx(Me,{icon:d?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:d?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function ro(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function ju(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const Lu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Kt=t=>typeof t=="number"&&!isNaN(t),Tr=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:l,isDisabled:a=!1,buttonVariant:u="bordered",buttonColor:d="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:x={},"data-testid":S,selectedColor:C="default"})=>{const w={...Lu,...o},[j,N]=k.useState(n),D=e!==void 0?e:j,L=ce=>{if(a)return;const ge=Math.max(0,D+ce);e===void 0&&N(ge),r?.(t.id,ge)},O=k.useMemo(()=>!Kt(t.totalTicketsSold)||!Kt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),_=k.useMemo(()=>O||!Kt(t.ticketsAllowed)?!1:D>=t.ticketsAllowed-(t.totalTicketsSold??0),[O,t.ticketsAllowed,t.totalTicketsSold,D]),H=ro(t.price,i,s),U=()=>l?.renderName?l.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:y.cn("text-base font-medium",x.name),children:t.name}),P=()=>v?l?.renderPrice?l.renderPrice(t.price,H,t):c.jsx("p",{"data-testid":"offer-card-price",className:y.cn("text-primary text-base mt-1",x.price),children:H}):null,M=()=>!p||!t.description?null:l?.renderDescription?l.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:y.cn("mb-4 text-sm text-gray-700 leading-relaxed",x.description),children:t.description}),F=()=>{if(!m||!Kt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ce=t.numberOfPeople===1?w.person:w.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,ce,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:y.cn("text-sm text-gray-600 flex items-center mt-2",x.peopleCount),children:[c.jsx(Me,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ce]})},V=()=>{const ce=D===0||a,ge=_||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:D,onIncrement:()=>L(1),onDecrement:()=>L(-1),isDecrementDisabled:ce,isIncrementDisabled:ge,isDisabled:a}):c.jsxs("div",{className:y.cn("flex items-center gap-2",x.quantitySelector),children:[c.jsx(se,{"data-testid":"offer-card-decrement-button",onPress:()=>L(-1),isDisabled:ce,variant:u,color:D>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Me,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:y.cn("min-w-[2rem] text-center font-medium"),children:D}),c.jsx(se,{"data-testid":"offer-card-increment-button",onPress:()=>L(1),isDisabled:ge,variant:u,color:D>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Me,{icon:"gravity-ui:plus",width:16})})]})},B=()=>l?.renderSoldOut?l.renderSoldOut(w.soldOut):c.jsx(y.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:y.cn("gap-2 px-4 h-8",x.soldOut),startContent:c.jsx(Me,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:w.soldOut})}),Y=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(w.maxReached):c.jsx(y.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:y.cn(" text-black! gap-2 px-4 h-10",x.maxReachedAlert),startContent:c.jsx(Me,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:w.maxReached})}),W=c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:y.cn("h-full col-span-2",O?"opacity-50 pointer-events-none select-none":""),children:[U(),P(),c.jsxs("div",{className:y.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",O?"opacity-50 pointer-events-none select-none":""),children:[F(),M()]})]}),c.jsx("div",{className:"space-x-2 p-2 h-full flex items-center justify-start md:justify-start lg:justify-end ",children:O?B():V()})]}),me=_&&!O&&c.jsx(je.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Y()});return f?c.jsxs(y.Card,{className:y.cn("w-full",x.base),"data-testid":S||`offer-card-${t.id}`,children:[c.jsx(y.CardBody,{className:y.cn("pt-1 pb-0",x.body),children:W}),c.jsx(je.AnimatePresence,{children:me&&c.jsx(y.CardFooter,{className:y.cn("w-full mt-0 pt-0",x.footer),children:me})})]}):c.jsxs("div",{className:y.cn("w-full",x.base),"data-testid":S||`offer-card-${t.id}`,children:[c.jsx("div",{className:y.cn("pt-1 pb-0",x.body),children:W}),c.jsx(je.AnimatePresence,{children:me&&c.jsx("div",{className:y.cn("w-full mt-0 pt-0",x.footer),children:me})})]})};Tr.displayName="OfferCard";const so=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:l})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:y.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(Me,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:y.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:y.cn("text-lg",s.message),children:t})]});return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:o})};so.displayName="OfferCardEmpty";const Ru={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},io=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Ru,...e},o=c.jsx(y.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:o})};io.displayName="OfferCardError";const Fu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},oo=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Fu[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:y.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(y.Card,{"data-testid":`offer-card-skeleton-${i}`,className:y.cn("w-full",n.card),children:[c.jsx(y.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:c.jsxs("div",{className:"space-y-2 w-full",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),c.jsx(y.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:c.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),c.jsx("div",{className:"flex items-start justify-end",children:c.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};oo.displayName="OfferCardSkeleton";const lo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},ao={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},Pu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},co=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:l,slots:a,isDisabled:u=!1,buttonVariant:d="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:v=2,classNames:x={}})=>{const[S,C]=k.useState(n),w=e!==void 0?e:S,j=k.useCallback((_,H)=>{const U={...w,[_]:Math.max(0,H)};e===void 0&&C(U),r?.(U),s?.(_,U[_])},[w,e,r,s]),N=[...t].sort((_,H)=>(_.position??0)-(H.position??0)),D=Pu[v],L=y.cn("grid mx-auto pt-2",D,x.base),O=_=>c.jsx(Tr,{offer:_,quantity:w[_.id]||0,onQuantityChange:j,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:p,classNames:x.card},_.id);return m?c.jsx(je.motion.div,{"data-testid":"offer-card-list",className:L,variants:lo,initial:"hidden",animate:"show",children:c.jsx(je.AnimatePresence,{children:N.map(_=>c.jsx(je.motion.div,{"data-testid":`offer-card-list-item-${_.id}`,className:x.cardWrapper,variants:ao,exit:{opacity:0,y:-20},transition:{duration:.3},children:O(_)},_.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:L,children:N.map(O)})};co.displayName="OfferCardList";var _t=t=>t.type==="checkbox",it=t=>t instanceof Date,ve=t=>t==null;const uo=t=>typeof t=="object";var ae=t=>!ve(t)&&!Array.isArray(t)&&uo(t)&&!it(t),fo=t=>ae(t)&&t.target?_t(t.target)?t.target.checked:t.target.value:t,Vu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,ho=(t,e)=>t.has(Vu(e)),$u=t=>{const e=t.constructor&&t.constructor.prototype;return ae(e)&&e.hasOwnProperty("isPrototypeOf")},Mr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ie(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Mr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(ae(t)&&$u(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=ie(t[s]));return r}var bn=t=>/^\w*$/.test(t),ne=t=>t===void 0,Or=t=>Array.isArray(t)?t.filter(Boolean):[],Ir=t=>Or(t.replace(/["|']|\]/g,"").split(/\.|\[/)),T=(t,e,n)=>{if(!e||!ae(t))return n;const r=(bn(e)?[e]:Ir(e)).reduce((s,i)=>ve(s)?s:s[i],t);return ne(r)||r===t?ne(t[e])?n:t[e]:r},Ce=t=>typeof t=="boolean",ke=t=>typeof t=="function",ee=(t,e,n)=>{let r=-1;const s=bn(e)?[e]:Ir(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let a=n;if(r!==o){const u=t[l];a=ae(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const un={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ie={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},$e={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},po=k.createContext(null);po.displayName="HookFormControlContext";const Dr=()=>k.useContext(po);var mo=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Ie.all&&(e._proxyFormState[o]=!r||Ie.all),n&&(n[o]=!0),t[o]}});return s};const jr=typeof window<"u"?k.useLayoutEffect:k.useEffect;function Bu(t){const e=Dr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=k.useState(n._formState),a=k.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return jr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),k.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),k.useMemo(()=>mo(o,n,a.current,!1),[o,n])}var Ae=t=>typeof t=="string",lr=(t,e,n,r,s)=>Ae(t)?(r&&e.watch.add(t),T(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),T(n,i))):(r&&(e.watchAll=!0),n),ar=t=>ve(t)||!uo(t);function De(t,e,n=new WeakSet){if(ar(t)||ar(e))return Object.is(t,e);if(it(t)&&it(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const i of r){const o=t[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=e[i];if(it(o)&&it(l)||ae(o)&&ae(l)||Array.isArray(o)&&Array.isArray(l)?!De(o,l,n):!Object.is(o,l))return!1}}return!0}function _u(t){const e=Dr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=k.useRef(s),u=k.useRef(l),d=k.useRef(void 0),f=k.useRef(n),p=k.useRef(r);u.current=l;const[m,v]=k.useState(()=>{const N=n._getWatch(r,a.current);return u.current?u.current(N):N}),x=k.useCallback(N=>{const D=lr(r,n._names,N||n._formValues,!1,a.current);return u.current?u.current(D):D},[n._formValues,n._names,r]),S=k.useCallback(N=>{if(!i){const D=lr(r,n._names,N||n._formValues,!1,a.current);if(u.current){const L=u.current(D);De(L,d.current)||(v(L),d.current=L)}else v(D)}},[n._formValues,n._names,i,r]);jr(()=>((f.current!==n||!De(p.current,r))&&(f.current=n,p.current=r,S()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:N=>{S(N.values)}})),[n,o,r,S]),k.useEffect(()=>n._removeUnmounted());const C=f.current!==n,w=p.current,j=k.useMemo(()=>{if(i)return null;const N=!C&&!De(w,r);return C||N?x():null},[i,C,r,w,x]);return j!==null?j:m}function zu(t){const e=Dr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=ho(s._names.array,n),u=k.useMemo(()=>T(s._formValues,n,T(s._defaultValues,n,o)),[s,n,o]),d=_u({control:s,name:n,defaultValue:u,exact:l}),f=Bu({control:s,name:n,exact:l}),p=k.useRef(t),m=k.useRef(void 0),v=k.useRef(s.register(n,{...t.rules,value:d,...Ce(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const x=k.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!T(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!T(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!T(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!T(f.validatingFields,n)},error:{enumerable:!0,get:()=>T(f.errors,n)}}),[f,n]),S=k.useCallback(N=>v.current.onChange({target:{value:fo(N),name:n},type:un.CHANGE}),[n]),C=k.useCallback(()=>v.current.onBlur({target:{value:T(s._formValues,n),name:n},type:un.BLUR}),[n,s._formValues]),w=k.useCallback(N=>{const D=T(s._fields,n);D&&D._f&&N&&(D._f.ref={focus:()=>ke(N.focus)&&N.focus(),select:()=>ke(N.select)&&N.select(),setCustomValidity:L=>ke(N.setCustomValidity)&&N.setCustomValidity(L),reportValidity:()=>ke(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),j=k.useMemo(()=>({name:n,value:d,...Ce(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:S,onBlur:C,ref:w}),[n,r,f.disabled,S,C,w,d]);return k.useEffect(()=>{const N=s._options.shouldUnregister||i,D=m.current;D&&D!==n&&!a&&s.unregister(D),s.register(n,{...p.current.rules,...Ce(p.current.disabled)?{disabled:p.current.disabled}:{}});const L=(O,_)=>{const H=T(s._fields,O);H&&H._f&&(H._f.mount=_)};if(L(n,!0),N){const O=ie(T(s._options.defaultValues,n,p.current.defaultValue));ee(s._defaultValues,n,O),ne(T(s._formValues,n))&&ee(s._formValues,n,O)}return!a&&s.register(n),m.current=n,()=>{(a?N&&!s._state.action:N)?s.unregister(n):L(n,!1)}},[n,s,a,i]),k.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),k.useMemo(()=>({field:j,formState:f,fieldState:x}),[j,f,x])}const Hu=k.createContext(null);Hu.displayName="HookFormContext";var Uu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Ot=t=>Array.isArray(t)?t:[t],Fs=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function go(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&ae(s)&&i){const o=go(s,i);ae(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var xe=t=>ae(t)&&!Object.keys(t).length,Lr=t=>t.type==="file",dn=t=>{if(!Mr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},yo=t=>t.type==="select-multiple",Rr=t=>t.type==="radio",qu=t=>Rr(t)||_t(t),Hn=t=>dn(t)&&t.isConnected;function Ku(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=ne(t)?r++:t[e[r++]];return t}function Ju(t){for(const e in t)if(t.hasOwnProperty(e)&&!ne(t[e]))return!1;return!0}function oe(t,e){const n=Array.isArray(e)?e:bn(e)?[e]:Ir(e),r=n.length===1?t:Ku(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ae(r)&&xe(r)||Array.isArray(r)&&Ju(r))&&oe(t,n.slice(0,-1)),t}var Wu=t=>{for(const e in t)if(ke(t[e]))return!0;return!1};function xo(t){return Array.isArray(t)||ae(t)&&!Wu(t)}function cr(t,e={}){for(const n in t){const r=t[n];xo(r)?(e[n]=Array.isArray(r)?[]:{},cr(r,e[n])):ne(r)||(e[n]=!0)}return e}function gt(t,e,n){n||(n=cr(e));for(const r in t){const s=t[r];if(xo(s))ne(e)||ar(n[r])?n[r]=cr(s,Array.isArray(s)?[]:{}):gt(s,ve(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!De(s,i)}}return n}const Ps={value:!1,isValid:!1},Vs={value:!0,isValid:!0};var bo=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!ne(t[0].attributes.value)?ne(t[0].value)||t[0].value===""?Vs:{value:t[0].value,isValid:!0}:Vs:Ps}return Ps},ko=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>ne(t)?t:e?t===""?NaN:t&&+t:n&&Ae(t)?new Date(t):r?r(t):t;const $s={isValid:!1,value:null};var vo=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,$s):$s;function Bs(t){const e=t.ref;return Lr(e)?e.files:Rr(e)?vo(t.refs).value:yo(e)?[...e.selectedOptions].map(({value:n})=>n):_t(e)?bo(t.refs).value:ko(ne(e.value)?t.ref.value:e.value,t)}var Gu=(t,e,n,r)=>{const s={};for(const i of t){const o=T(e,i);o&&ee(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},fn=t=>t instanceof RegExp,At=t=>ne(t)?t:fn(t)?t.source:ae(t)?fn(t.value)?t.value.source:t.value:t,_s=t=>({isOnSubmit:!t||t===Ie.onSubmit,isOnBlur:t===Ie.onBlur,isOnChange:t===Ie.onChange,isOnAll:t===Ie.all,isOnTouch:t===Ie.onTouched});const zs="AsyncFunction";var Zu=t=>!!t&&!!t.validate&&!!(ke(t.validate)&&t.validate.constructor.name===zs||ae(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===zs)),Qu=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Hs=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const It=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=T(t,s);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(It(l,e))break}else if(ae(l)&&It(l,e))break}}};function Us(t,e,n){const r=T(t,n);if(r||bn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=T(e,i),l=T(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var Xu=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return xe(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Ie.all))},Yu=(t,e,n)=>!t||!e||t===e||Ot(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),ed=(t,e,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(e||t):(n?r.isOnBlur:s.isOnBlur)?!t:(n?r.isOnChange:s.isOnChange)?t:!0,td=(t,e)=>!Or(T(t,e)).length&&oe(t,e),nd=(t,e,n)=>{const r=Ot(T(t,n));return ee(r,"root",e[n]),ee(t,n,r),t};function qs(t,e,n="validate"){if(Ae(t)||Array.isArray(t)&&t.every(Ae)||Ce(t)&&!t)return{type:n,message:Ae(t)?t:"",ref:e}}var ht=t=>ae(t)&&!fn(t)?t:{value:t,message:""},Ks=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:a,maxLength:u,minLength:d,min:f,max:p,pattern:m,validate:v,name:x,valueAsNumber:S,mount:C}=t._f,w=T(n,x);if(!C||e.has(x))return{};const j=l?l[0]:o,N=M=>{s&&j.reportValidity&&(j.setCustomValidity(Ce(M)?"":M||""),j.reportValidity())},D={},L=Rr(o),O=_t(o),_=L||O,H=(S||Lr(o))&&ne(o.value)&&ne(w)||dn(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,U=Uu.bind(null,x,r,D),P=(M,F,V,B=$e.maxLength,Y=$e.minLength)=>{const W=M?F:V;D[x]={type:M?B:Y,message:W,ref:o,...U(M?B:Y,W)}};if(i?!Array.isArray(w)||!w.length:a&&(!_&&(H||ve(w))||Ce(w)&&!w||O&&!bo(l).isValid||L&&!vo(l).isValid)){const{value:M,message:F}=Ae(a)?{value:!!a,message:a}:ht(a);if(M&&(D[x]={type:$e.required,message:F,ref:j,...U($e.required,F)},!r))return N(F),D}if(!H&&(!ve(f)||!ve(p))){let M,F;const V=ht(p),B=ht(f);if(!ve(w)&&!isNaN(w)){const Y=o.valueAsNumber||w&&+w;ve(V.value)||(M=Y>V.value),ve(B.value)||(F=Y<B.value)}else{const Y=o.valueAsDate||new Date(w),W=ge=>new Date(new Date().toDateString()+" "+ge),me=o.type=="time",ce=o.type=="week";Ae(V.value)&&w&&(M=me?W(w)>W(V.value):ce?w>V.value:Y>new Date(V.value)),Ae(B.value)&&w&&(F=me?W(w)<W(B.value):ce?w<B.value:Y<new Date(B.value))}if((M||F)&&(P(!!M,V.message,B.message,$e.max,$e.min),!r))return N(D[x].message),D}if((u||d)&&!H&&(Ae(w)||i&&Array.isArray(w))){const M=ht(u),F=ht(d),V=!ve(M.value)&&w.length>+M.value,B=!ve(F.value)&&w.length<+F.value;if((V||B)&&(P(V,M.message,F.message),!r))return N(D[x].message),D}if(m&&!H&&Ae(w)){const{value:M,message:F}=ht(m);if(fn(M)&&!w.match(M)&&(D[x]={type:$e.pattern,message:F,ref:o,...U($e.pattern,F)},!r))return N(F),D}if(v){if(ke(v)){const M=await v(w,n),F=qs(M,j);if(F&&(D[x]={...F,...U($e.validate,F.message)},!r))return N(F.message),D}else if(ae(v)){let M={};for(const F in v){if(!xe(M)&&!r)break;const V=qs(await v[F](w,n),j,F);V&&(M={...V,...U(F,V.message)},N(V.message),r&&(D[x]=M))}if(!xe(M)&&(D[x]={ref:j,...M},!r))return D}}return N(!0),D};const rd={mode:Ie.onSubmit,reValidateMode:Ie.onChange,shouldFocusError:!0};function sd(t={}){let e={...rd,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:ke(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=ae(e.defaultValues)||ae(e.values)?ie(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:ie(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},a,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let p={...f};const m={array:Fs(),state:Fs()},v=e.criteriaMode===Ie.all,x=h=>g=>{clearTimeout(u),u=setTimeout(h,g)},S=async h=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||h)){let g;e.resolver?(g=xe((await _()).errors),C()):g=await U(r,!0),g!==n.isValid&&m.state.next({isValid:g})}},C=(h,g)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((h||Array.from(l.mount)).forEach(b=>{b&&(g?ee(n.validatingFields,b,g):oe(n.validatingFields,b))}),m.state.next({validatingFields:n.validatingFields,isValidating:!xe(n.validatingFields)}))},w=(h,g=[],b,I,E=!0,A=!0)=>{if(I&&b&&!e.disabled){if(o.action=!0,A&&Array.isArray(T(r,h))){const $=b(T(r,h),I.argA,I.argB);E&&ee(r,h,$)}if(A&&Array.isArray(T(n.errors,h))){const $=b(T(n.errors,h),I.argA,I.argB);E&&ee(n.errors,h,$),td(n.errors,h)}if((f.touchedFields||p.touchedFields)&&A&&Array.isArray(T(n.touchedFields,h))){const $=b(T(n.touchedFields,h),I.argA,I.argB);E&&ee(n.touchedFields,h,$)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=gt(s,i)),m.state.next({name:h,isDirty:M(h,g),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ee(i,h,g)},j=(h,g)=>{ee(n.errors,h,g),m.state.next({errors:n.errors})},N=h=>{n.errors=h,m.state.next({errors:n.errors,isValid:!1})},D=(h,g,b,I)=>{const E=T(r,h);if(E){const A=T(i,h,ne(b)?T(s,h):b);ne(A)||I&&I.defaultChecked||g?ee(i,h,g?A:Bs(E._f)):B(h,A),o.mount&&!o.action&&S()}},L=(h,g,b,I,E)=>{let A=!1,$=!1;const G={name:h};if(!e.disabled){if(!b||I){(f.isDirty||p.isDirty)&&($=n.isDirty,n.isDirty=G.isDirty=M(),A=$!==G.isDirty);const Z=De(T(s,h),g);$=!!T(n.dirtyFields,h),Z?oe(n.dirtyFields,h):ee(n.dirtyFields,h,!0),G.dirtyFields=n.dirtyFields,A=A||(f.dirtyFields||p.dirtyFields)&&$!==!Z}if(b){const Z=T(n.touchedFields,h);Z||(ee(n.touchedFields,h,b),G.touchedFields=n.touchedFields,A=A||(f.touchedFields||p.touchedFields)&&Z!==b)}A&&E&&m.state.next(G)}return A?G:{}},O=(h,g,b,I)=>{const E=T(n.errors,h),A=(f.isValid||p.isValid)&&Ce(g)&&n.isValid!==g;if(e.delayError&&b?(a=x(()=>j(h,b)),a(e.delayError)):(clearTimeout(u),a=null,b?ee(n.errors,h,b):oe(n.errors,h)),(b?!De(E,b):E)||!xe(I)||A){const $={...I,...A&&Ce(g)?{isValid:g}:{},errors:n.errors,name:h};n={...n,...$},m.state.next($)}},_=async h=>(C(h,!0),await e.resolver(i,e.context,Gu(h||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),H=async h=>{const{errors:g}=await _(h);if(C(h),h)for(const b of h){const I=T(g,b);I?ee(n.errors,b,I):oe(n.errors,b)}else n.errors=g;return g},U=async(h,g,b={valid:!0})=>{for(const I in h){const E=h[I];if(E){const{_f:A,...$}=E;if(A){const G=l.array.has(A.name),Z=E._f&&Zu(E._f);Z&&f.validatingFields&&C([A.name],!0);const ye=await Ks(E,l.disabled,i,v,e.shouldUseNativeValidation&&!g,G);if(Z&&f.validatingFields&&C([A.name]),ye[A.name]&&(b.valid=!1,g||t.shouldUseNativeValidation))break;!g&&(T(ye,A.name)?G?nd(n.errors,ye,A.name):ee(n.errors,A.name,ye[A.name]):oe(n.errors,A.name))}!xe($)&&await U($,g,b)}}return b.valid},P=()=>{for(const h of l.unMount){const g=T(r,h);g&&(g._f.refs?g._f.refs.every(b=>!Hn(b)):!Hn(g._f.ref))&&vn(h)}l.unMount=new Set},M=(h,g)=>!e.disabled&&(h&&g&&ee(i,h,g),!De(He(),s)),F=(h,g,b)=>lr(h,l,{...o.mount?i:ne(g)?s:Ae(h)?{[h]:g}:g},b,g),V=h=>Or(T(o.mount?i:s,h,e.shouldUnregister?T(s,h,[]):[])),B=(h,g,b={})=>{const I=T(r,h);let E=g;if(I){const A=I._f;A&&(!A.disabled&&ee(i,h,ko(g,A)),E=dn(A.ref)&&ve(g)?"":g,yo(A.ref)?[...A.ref.options].forEach($=>$.selected=E.includes($.value)):A.refs?_t(A.ref)?A.refs.forEach($=>{(!$.defaultChecked||!$.disabled)&&(Array.isArray(E)?$.checked=!!E.find(G=>G===$.value):$.checked=E===$.value||!!E)}):A.refs.forEach($=>$.checked=$.value===E):Lr(A.ref)?A.ref.value="":(A.ref.value=E,A.ref.type||m.state.next({name:h,values:ie(i)})))}(b.shouldDirty||b.shouldTouch)&&L(h,E,b.shouldTouch,b.shouldDirty,!0),b.shouldValidate&&ge(h)},Y=(h,g,b)=>{for(const I in g){if(!g.hasOwnProperty(I))return;const E=g[I],A=h+"."+I,$=T(r,A);(l.array.has(h)||ae(E)||$&&!$._f)&&!it(E)?Y(A,E,b):B(A,E,b)}},W=(h,g,b={})=>{const I=T(r,h),E=l.array.has(h),A=ie(g);ee(i,h,A),E?(m.array.next({name:h,values:ie(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&b.shouldDirty&&m.state.next({name:h,dirtyFields:gt(s,i),isDirty:M(h,A)})):I&&!I._f&&!ve(A)?Y(h,A,b):B(h,A,b),Hs(h,l)?m.state.next({...n,name:h,values:ie(i)}):m.state.next({name:o.mount?h:void 0,values:ie(i)})},me=async h=>{o.mount=!0;const g=h.target;let b=g.name,I=!0;const E=T(r,b),A=Z=>{I=Number.isNaN(Z)||it(Z)&&isNaN(Z.getTime())||De(Z,T(i,b,Z))},$=_s(e.mode),G=_s(e.reValidateMode);if(E){let Z,ye;const Xe=g.type?Bs(E._f):fo(h),Ue=h.type===un.BLUR||h.type===un.FOCUS_OUT,Oo=!Qu(E._f)&&!e.resolver&&!T(n.errors,b)&&!E._f.deps||ed(Ue,T(n.touchedFields,b),n.isSubmitted,G,$),wn=Hs(b,l,Ue);ee(i,b,Xe),Ue?(!g||!g.readOnly)&&(E._f.onBlur&&E._f.onBlur(h),a&&a(0)):E._f.onChange&&E._f.onChange(h);const An=L(b,Xe,Ue),Io=!xe(An)||wn;if(!Ue&&m.state.next({name:b,type:h.type,values:ie(i)}),Oo)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Ue&&S():Ue||S()),Io&&m.state.next({name:b,...wn?{}:An});if(!Ue&&wn&&m.state.next({...n}),e.resolver){const{errors:zr}=await _([b]);if(C([b]),A(Xe),I){const Do=Us(n.errors,r,b),Hr=Us(zr,r,Do.name||b);Z=Hr.error,b=Hr.name,ye=xe(zr)}}else C([b],!0),Z=(await Ks(E,l.disabled,i,v,e.shouldUseNativeValidation))[b],C([b]),A(Xe),I&&(Z?ye=!1:(f.isValid||p.isValid)&&(ye=await U(r,!0)));I&&(E._f.deps&&(!Array.isArray(E._f.deps)||E._f.deps.length>0)&&ge(E._f.deps),O(b,ye,Z,An))}},ce=(h,g)=>{if(T(n.errors,g)&&h.focus)return h.focus(),1},ge=async(h,g={})=>{let b,I;const E=Ot(h);if(e.resolver){const A=await H(ne(h)?h:E);b=xe(A),I=h?!E.some($=>T(A,$)):b}else h?(I=(await Promise.all(E.map(async A=>{const $=T(r,A);return await U($&&$._f?{[A]:$}:$)}))).every(Boolean),!(!I&&!n.isValid)&&S()):I=b=await U(r);return m.state.next({...!Ae(h)||(f.isValid||p.isValid)&&b!==n.isValid?{}:{name:h},...e.resolver||!h?{isValid:b}:{},errors:n.errors}),g.shouldFocus&&!I&&It(r,ce,h?E:l.mount),I},He=(h,g)=>{let b={...o.mount?i:s};return g&&(b=go(g.dirtyFields?n.dirtyFields:n.touchedFields,b)),ne(h)?b:Ae(h)?T(b,h):h.map(I=>T(b,I))},dt=(h,g)=>({invalid:!!T((g||n).errors,h),isDirty:!!T((g||n).dirtyFields,h),error:T((g||n).errors,h),isValidating:!!T(n.validatingFields,h),isTouched:!!T((g||n).touchedFields,h)}),kt=h=>{h&&Ot(h).forEach(g=>oe(n.errors,g)),m.state.next({errors:h?n.errors:{}})},te=(h,g,b)=>{const I=(T(r,h,{_f:{}})._f||{}).ref,E=T(n.errors,h)||{},{ref:A,message:$,type:G,...Z}=E;ee(n.errors,h,{...Z,...g,ref:I}),m.state.next({name:h,errors:n.errors,isValid:!1}),b&&b.shouldFocus&&I&&I.focus&&I.focus()},Se=(h,g)=>ke(h)?m.state.subscribe({next:b=>"values"in b&&h(F(void 0,g),b)}):F(h,g,!0),vt=h=>m.state.subscribe({next:g=>{Yu(h.name,g.name,h.exact)&&Xu(g,h.formState||f,Mo,h.reRenderRoot)&&h.callback({values:{...i},...n,...g,defaultValues:s})}}).unsubscribe,kn=h=>(o.mount=!0,p={...p,...h.formState},vt({...h,formState:{...d,...h.formState}})),vn=(h,g={})=>{for(const b of h?Ot(h):l.mount)l.mount.delete(b),l.array.delete(b),g.keepValue||(oe(r,b),oe(i,b)),!g.keepError&&oe(n.errors,b),!g.keepDirty&&oe(n.dirtyFields,b),!g.keepTouched&&oe(n.touchedFields,b),!g.keepIsValidating&&oe(n.validatingFields,b),!e.shouldUnregister&&!g.keepDefaultValue&&oe(s,b);m.state.next({values:ie(i)}),m.state.next({...n,...g.keepDirty?{isDirty:M()}:{}}),!g.keepIsValid&&S()},Pr=({disabled:h,name:g})=>{if(Ce(h)&&o.mount||h||l.disabled.has(g)){const E=l.disabled.has(g)!==!!h;h?l.disabled.add(g):l.disabled.delete(g),E&&o.mount&&!o.action&&S()}},Sn=(h,g={})=>{let b=T(r,h);const I=Ce(g.disabled)||Ce(e.disabled);return ee(r,h,{...b||{},_f:{...b&&b._f?b._f:{ref:{name:h}},name:h,mount:!0,...g}}),l.mount.add(h),b?Pr({disabled:Ce(g.disabled)?g.disabled:e.disabled,name:h}):D(h,!0,g.value),{...I?{disabled:g.disabled||e.disabled}:{},...e.progressive?{required:!!g.required,min:At(g.min),max:At(g.max),minLength:At(g.minLength),maxLength:At(g.maxLength),pattern:At(g.pattern)}:{},name:h,onChange:me,onBlur:me,ref:E=>{if(E){Sn(h,g),b=T(r,h);const A=ne(E.value)&&E.querySelectorAll&&E.querySelectorAll("input,select,textarea")[0]||E,$=qu(A),G=b._f.refs||[];if($?G.find(Z=>Z===A):A===b._f.ref)return;ee(r,h,{_f:{...b._f,...$?{refs:[...G.filter(Hn),A,...Array.isArray(T(s,h))?[{}]:[]],ref:{type:A.type,name:h}}:{ref:A}}}),D(h,!1,void 0,A)}else b=T(r,h,{}),b._f&&(b._f.mount=!1),(e.shouldUnregister||g.shouldUnregister)&&!(ho(l.array,h)&&o.action)&&l.unMount.add(h)}}},Cn=()=>e.shouldFocusError&&It(r,ce,l.mount),No=h=>{Ce(h)&&(m.state.next({disabled:h}),It(r,(g,b)=>{const I=T(r,b);I&&(g.disabled=I._f.disabled||h,Array.isArray(I._f.refs)&&I._f.refs.forEach(E=>{E.disabled=I._f.disabled||h}))},0,!1))},Vr=(h,g)=>async b=>{let I;b&&(b.preventDefault&&b.preventDefault(),b.persist&&b.persist());let E=ie(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:A,values:$}=await _();C(),n.errors=A,E=ie($)}else await U(r);if(l.disabled.size)for(const A of l.disabled)oe(E,A);if(oe(n.errors,"root"),xe(n.errors)){m.state.next({errors:{}});try{await h(E,b)}catch(A){I=A}}else g&&await g({...n.errors},b),Cn(),setTimeout(Cn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:xe(n.errors)&&!I,submitCount:n.submitCount+1,errors:n.errors}),I)throw I},Eo=(h,g={})=>{T(r,h)&&(ne(g.defaultValue)?W(h,ie(T(s,h))):(W(h,g.defaultValue),ee(s,h,ie(g.defaultValue))),g.keepTouched||oe(n.touchedFields,h),g.keepDirty||(oe(n.dirtyFields,h),n.isDirty=g.defaultValue?M(h,ie(T(s,h))):M()),g.keepError||(oe(n.errors,h),f.isValid&&S()),m.state.next({...n}))},$r=(h,g={})=>{const b=h?ie(h):s,I=ie(b),E=xe(h),A=E?s:I;if(g.keepDefaultValues||(s=b),!g.keepValues){if(g.keepDirtyValues){const $=new Set([...l.mount,...Object.keys(gt(s,i))]);for(const G of Array.from($)){const Z=T(n.dirtyFields,G),ye=T(i,G),Xe=T(A,G);Z&&!ne(ye)?ee(A,G,ye):!Z&&!ne(Xe)&&W(G,Xe)}}else{if(Mr&&ne(h))for(const $ of l.mount){const G=T(r,$);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(dn(Z)){const ye=Z.closest("form");if(ye){ye.reset();break}}}}if(g.keepFieldsRef)for(const $ of l.mount)W($,T(A,$));else r={}}i=e.shouldUnregister?g.keepDefaultValues?ie(s):{}:ie(A),m.array.next({values:{...A}}),m.state.next({values:{...A}})}l={mount:g.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!g.keepIsValid||!!g.keepDirtyValues||!e.shouldUnregister&&!xe(A),o.watch=!!e.shouldUnregister,o.keepIsValid=!!g.keepIsValid,o.action=!1,g.keepErrors||(n.errors={}),m.state.next({submitCount:g.keepSubmitCount?n.submitCount:0,isDirty:E?!1:g.keepDirty?n.isDirty:!!(g.keepDefaultValues&&!De(h,s)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:E?{}:g.keepDirtyValues?g.keepDefaultValues&&i?gt(s,i):n.dirtyFields:g.keepDefaultValues&&h?gt(s,h):g.keepDirty?n.dirtyFields:{},touchedFields:g.keepTouched?n.touchedFields:{},errors:g.keepErrors?n.errors:{},isSubmitSuccessful:g.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Br=(h,g)=>$r(ke(h)?h(i):h,{...e.resetOptions,...g}),To=(h,g={})=>{const b=T(r,h),I=b&&b._f;if(I){const E=I.refs?I.refs[0]:I.ref;E.focus&&setTimeout(()=>{E.focus(),g.shouldSelect&&ke(E.select)&&E.select()})}},Mo=h=>{n={...n,...h}},_r={control:{register:Sn,unregister:vn,getFieldState:dt,handleSubmit:Vr,setError:te,_subscribe:vt,_runSchema:_,_updateIsValidating:C,_focusError:Cn,_getWatch:F,_getDirty:M,_setValid:S,_setFieldArray:w,_setDisabledField:Pr,_setErrors:N,_getFieldArray:V,_reset:$r,_resetDefaultValues:()=>ke(e.defaultValues)&&e.defaultValues().then(h=>{Br(h,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:No,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(h){o=h},get _defaultValues(){return s},get _names(){return l},set _names(h){l=h},get _formState(){return n},get _options(){return e},set _options(h){e={...e,...h}}},subscribe:kn,trigger:ge,register:Sn,handleSubmit:Vr,watch:Se,setValue:W,getValues:He,reset:Br,resetField:Eo,clearErrors:kt,unregister:vn,setError:te,setFocus:To,getFieldState:dt};return{..._r,formControl:_r}}function id(t={}){const e=k.useRef(void 0),n=k.useRef(void 0),[r,s]=k.useState({isDirty:!1,isValidating:!1,isLoading:ke(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:ke(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!ke(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=sd(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,jr(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),k.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),k.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),k.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),k.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),k.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),k.useEffect(()=>{var o;t.values&&!De(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=t.values,s(l=>({...l}))):i._resetDefaultValues()},[i,t.values]),k.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=k.useMemo(()=>mo(r,i),[i,r]),e.current}function od(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function ld(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function ad(t="USD",e="en-US"){try{return new Intl.NumberFormat(e,{style:"currency",currency:t}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function cd(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function ud(t,e,n=.001){const r=t-e,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function Fr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Fr();const dd={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Un=()=>({id:Fr(),amount:0,glAccount:null,isTaxDeductible:!1}),So=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:a,onDelete:u,canDelete:d=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":x,control:S,name:C,rules:w})=>{const j={...dd,...m},N=S!==void 0&&C!==void 0,D=id({defaultValues:{_internal:e||Un()}}),L=zu({control:N?S:D.control,name:N?C:"_internal",rules:N?w:void 0}),[O,_]=k.useState(e||Un()),H=N?L.field.value??Un():t??O,U=N&&!!L.fieldState?.error,P=N&&(L.fieldState?.isTouched??!1),M=U||P,F=M&&(!H.amount||H.amount<=0),V=M&&!H.glAccount,[B,Y]=k.useState(H.glAccount?.name||""),W=k.useCallback(te=>{const Se={...H,...te};N&&L.field.onChange(Se),!N&&t===void 0&&_(Se),i?.(Se)},[H,t,i,N,L]),me=k.useCallback(te=>{const Se=te||0;W({amount:Se}),o?.(Se)},[W,o]),ce=k.useCallback(te=>{Y(te),s?.(te)},[s]),ge=k.useCallback(te=>{if(te===null){W({glAccount:null}),l?.(null);return}const vt=n.find(kn=>String(kn.id)===String(te))||null;W({glAccount:vt}),l?.(vt)},[n,W,l]),He=k.useCallback(()=>{Y(""),W({glAccount:null}),l?.(null)},[W,l]),dt=k.useCallback(te=>{W({isTaxDeductible:te}),a?.(te)},[W,a]),kt=k.useCallback(()=>{u?.()},[u]);return c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":x||"revenue-distribution-card",className:y.cn(v.base),children:c.jsxs(y.CardBody,{className:y.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[c.jsx("div",{className:y.cn("shrink-0",v.amountContainer),children:c.jsx(y.NumberInput,{"data-testid":`${x||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(y.Tooltip,{content:j.amountTooltip,children:c.jsx(Me,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:H.amount||void 0,onValueChange:me,labelPlacement:"outside",placeholder:j.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:F,errorMessage:F?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:c.jsx("div",{className:"pointer-events-none flex items-center",children:c.jsx("span",{className:"text-default-400 text-small",children:j.currencySymbol})})})}),c.jsx("div",{className:y.cn("grow",v.glAccountContainer),children:c.jsx(y.Autocomplete,{"data-testid":`${x||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.glAccount,c.jsx(y.Tooltip,{content:j.glAccountTooltip,children:c.jsx(Me,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:H.glAccount?.name??B,selectedKey:H.glAccount?.id??null,isDisabled:p,isInvalid:V,errorMessage:V?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:ce,onSelectionChange:ge,onClear:He,className:v.glAccountInput,children:te=>c.jsx(y.AutocompleteItem,{textValue:te.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:te.name}),te.code&&c.jsx("span",{className:"text-xs text-default-400",children:te.code})]})},te.id)})}),c.jsx("div",{className:y.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:c.jsx(y.Checkbox,{radius:"full","data-testid":`${x||"revenue-distribution-card"}-tax-deductible`,isSelected:H.isTaxDeductible,onValueChange:dt,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:y.cn("shrink-0 pt-6",v.deleteContainer),children:c.jsx(se,{"data-testid":`${x||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!d,onPress:kt,startContent:c.jsx(Me,{icon:"solar:trash-bin-trash-linear",width:16}),className:y.cn("text-danger",v.deleteButton),children:j.deleteButton})})]})})};So.displayName="RevenueDistributionCard";const Co=({message:t="No distributions configured",icon:e="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return c.jsx(c.Fragment,{children:i()});const o=c.jsxs("div",{className:y.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(Me,{icon:e,width:n,className:y.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:y.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:o})};Co.displayName="RevenueDistributionEmpty";const fd={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},wo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...fd,...e},o=c.jsx(y.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:o})};wo.displayName="RevenueDistributionError";const Ao=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:y.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[c.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),c.jsxs("div",{className:"grow flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(y.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(y.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(y.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(y.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Ao.displayName="RevenueDistributionSkeleton";exports.Button=se;exports.ConfirmationPageTemplate=qo;exports.DonationAmounts=zi;exports.EventDetails=Du;exports.EventDetailsTemplate=Wo;exports.ExpireCartTimer=Hi;exports.Footer=Go;exports.HeroUIProvider=Bo;exports.Multiselect=Zo;exports.Navbar=Uo;exports.OfferCard=Tr;exports.OfferCardEmpty=so;exports.OfferCardError=io;exports.OfferCardList=co;exports.OfferCardSkeleton=oo;exports.RICH_TEXT_PRESETS=Bi;exports.RevenueDistributionCard=So;exports.RevenueDistributionEmpty=Co;exports.RevenueDistributionError=wo;exports.RevenueDistributionSkeleton=Ao;exports.RichTextArea=_i;exports.Stepper=Js;exports.calculateAllocationDifference=ud;exports.formatOfferCurrency=ro;exports.formatRevenueAmount=od;exports.formatRevenueCurrency=ld;exports.generateDistributionId=Fr;exports.getCurrencySymbol=ad;exports.offerCardVariants=ao;exports.offerListVariants=lo;exports.parseOfferCurrency=ju;exports.parseRevenueCurrency=cd;Object.keys(y).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>y[t]})});
|
|
20
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 ul li[style*="text-align: left"],.ProseMirror ol li[style*="text-align: left"]{text-align:left!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: center"],.ProseMirror ol li[style*="text-align: center"]{text-align:center!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: right"],.ProseMirror ol li[style*="text-align: right"]{text-align:right!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: justify"],.ProseMirror ol li[style*="text-align: justify"]{text-align:justify!important;list-style-position:inside!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: left"]{justify-content:flex-start!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: center"]{justify-content:center!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: right"]{justify-content:flex-end!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)}})();
|