@veevarts/design-system 1.0.0-dev.20 → 1.0.0-dev.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.js +820 -817
- package/dist/patterns/Stepper/Stepper.d.ts +12 -0
- package/dist/test/framer-motion-mock.d.ts +92 -0
- package/dist/test/heroui-dom-animation-mock.d.ts +4 -0
- package/dist/test/heroui-framer-utils-mock.d.ts +102 -0
- package/package.json +1 -1
- package/dist/test/setup.motion.d.ts +0 -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"),_=require("lucide-react"),Re=require("framer-motion"),hr=require("@tiptap/react"),R=require("@tiptap/core"),Fo=require("@tiptap/extension-underline"),Po=require("@tiptap/extension-color"),$o=require("@tiptap/extension-highlight"),Vo=require("@tiptap/extension-link"),Bo=require("@tiptap/extension-task-list"),zo=require("@tiptap/extension-task-item"),_o=require("@tiptap/extension-text-align");function Ho({children:t}){return c.jsx(y.HeroUIProvider,{children:t})}const oe=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}));oe.displayName="Button";const Uo={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function qo({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(_.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(_.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 Ko({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(oe,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(oe,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Jo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...Uo,...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(qo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Ko,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}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, 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 Mn;const Go=typeof document<"u"?(Mn=k.useInsertionEffect)!==null&&Mn!==void 0?Mn:k.useLayoutEffect:()=>{};function pr(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;Go(()=>{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 Zo(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx(Re.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 Zs=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]=pr(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(Re.LazyMotion,{features:Re.domAnimation,children:c.jsx(Re.m.div,{animate:S,className:"relative",children:c.jsx(Re.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(Zo,{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)})})]})});Zs.displayName="Stepper";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, 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 Xo(){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 Yo=t=>{const e=k.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(el,{...t},e)},el=({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 $=Math.min(M,F),B=Math.max(M,F);return P.slice($,B+1)},O=(P,M,F)=>{if(F&&u!==null){o(L(x,u,M)),a([]),d(M);return}const $=i.includes(P);o($?i.filter(B=>B!==P):[...i,P]),a([]),d(M)},z=(P,M,F)=>{if(F&&f!==null){a(L(e,f,M)),o([]),p(M);return}const $=l.includes(P);a($?l.filter(B=>B!==P):[...l,P]),o([]),p(M)},H=(P,M,F)=>{const $=F==="available"?i.includes(M)?i:[M]:l.includes(M)?l:[M];P.dataTransfer.setData("text/plain",JSON.stringify({source:F,items:$})),P.dataTransfer.effectAllowed="move"},U=(P,M)=>{P.preventDefault();const F=P.dataTransfer.getData("text/plain");if(F)try{const $=JSON.parse(F),B=($.items||[]).filter(Y=>v.has(Y));if(B.length===0||$.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:$=>{O(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,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(oe,{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(oe,{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(oe,{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(oe,{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:$=>{z(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,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 Rt(t){return typeof t=="string"?t:t.type}function nt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(y.Divider,{orientation:"vertical"})})}function We({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(oe,{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 He={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"}},tl={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function nl({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=He.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(oe,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(_.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(_.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:tl[o]},o))})]})}const On={bulletList:{label:"Bullet List",icon:_.List},orderedList:{label:"Numbered List",icon:_.ListOrdered},taskList:{label:"Task List",icon:_.ListTodo}};function rl({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?On[s].icon:_.List,o=l=>{const u=He[l];u&&u.execute({editor:t})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(oe,{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=On[l].icon;return c.jsx(y.DropdownItem,{startContent:c.jsx(a,{size:16}),children:On[l].label},l)})})]})}function sl({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"),v=require("react"),_=require("lucide-react"),Re=require("framer-motion"),hr=require("@tiptap/react"),R=require("@tiptap/core"),Fo=require("@tiptap/extension-underline"),Po=require("@tiptap/extension-color"),$o=require("@tiptap/extension-highlight"),Vo=require("@tiptap/extension-link"),Bo=require("@tiptap/extension-task-list"),zo=require("@tiptap/extension-task-item"),_o=require("@tiptap/extension-text-align");function Ho({children:t}){return c.jsx(y.HeroUIProvider,{children:t})}const oe=v.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}));oe.displayName="Button";const Uo={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function qo({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(_.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(_.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 Ko({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(oe,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(oe,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Jo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...Uo,...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(qo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Ko,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}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, 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 Mn;const Go=typeof document<"u"?(Mn=v.useInsertionEffect)!==null&&Mn!==void 0?Mn:v.useLayoutEffect:()=>{};function pr(t,e,n){let[r,s]=v.useState(t||e),i=v.useRef(r),o=v.useRef(t!==void 0),l=t!==void 0;v.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;Go(()=>{i.current=a});let[,u]=v.useReducer(()=>({}),{}),d=v.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 Zo(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx(Re.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 Zs=v.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,isDisabled:u=!1,...d},f)=>{const[p,m]=pr(i,n,s),C=v.useMemo(()=>{let b,k;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":b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",k="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",k="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",k="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",k="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",k="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(k),S.unshift(b),S},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:y.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...d,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",C,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((b,k)=>{const S=p===k?"active":p<k?"inactive":"complete";return c.jsx("li",{className:"relative flex w-full items-center pr-12","data-testid":`stepper-step-${k}`,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",{"cursor-not-allowed opacity-50":u},l),onClick:()=>!u&&m(k),disabled:u,"data-testid":`stepper-step-btn-${k}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx(Re.LazyMotion,{features:Re.domAnimation,children:c.jsx(Re.m.div,{animate:S,className:"relative",children:c.jsx(Re.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(Zo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${k}`}):c.jsx("span",{})})})})})}),k<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":k},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":k<p})})})]},k)},k)})})]})});Zs.displayName="Stepper";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, 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 Xo(){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 Yo=t=>{const e=v.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(el,{...t},e)},el=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=v.useState([]),[l,a]=v.useState([]),[u,d]=v.useState(null),[f,p]=v.useState(null),m=v.useMemo(()=>new Set(e),[e]),C=v.useMemo(()=>new Set(t),[t]),b=v.useMemo(()=>t.filter(P=>!m.has(P)),[t,m]),k=P=>{if(P.length===0)return;const M=Array.from(new Set([...e,...P]));n(M)},S=P=>{if(P.length===0)return;const M=new Set(P);n(e.filter(F=>!M.has(F)))},w=()=>{i.length!==0&&(k(i),o([]))},j=()=>{l.length!==0&&(S(l),a([]))},N=()=>{b.length!==0&&(k(b),o([]))},D=()=>{e.length!==0&&(n([]),a([]))},L=(P,M,F)=>{const $=Math.min(M,F),B=Math.max(M,F);return P.slice($,B+1)},O=(P,M,F)=>{if(F&&u!==null){o(L(b,u,M)),a([]),d(M);return}const $=i.includes(P);o($?i.filter(B=>B!==P):[...i,P]),a([]),d(M)},z=(P,M,F)=>{if(F&&f!==null){a(L(e,f,M)),o([]),p(M);return}const $=l.includes(P);a($?l.filter(B=>B!==P):[...l,P]),o([]),p(M)},H=(P,M,F)=>{const $=F==="available"?i.includes(M)?i:[M]:l.includes(M)?l:[M];P.dataTransfer.setData("text/plain",JSON.stringify({source:F,items:$})),P.dataTransfer.effectAllowed="move"},U=(P,M)=>{P.preventDefault();const F=P.dataTransfer.getData("text/plain");if(F)try{const $=JSON.parse(F),B=($.items||[]).filter(Y=>C.has(Y));if(B.length===0||$.source===M)return;M==="selected"?(k(B),o([])):(S(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:b.map((P,M)=>{const F=i.includes(P);return c.jsx("button",{type:"button",onClick:$=>{O(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,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(oe,{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(oe,{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(oe,{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:b.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(oe,{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:$=>{z(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,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 Rt(t){return typeof t=="string"?t:t.type}function nt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(y.Divider,{orientation:"vertical"})})}function We({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(oe,{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 He={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"}},tl={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function nl({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=v.useState(0);v.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=He.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(oe,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(_.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(_.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:tl[o]},o))})]})}const On={bulletList:{label:"Bullet List",icon:_.List},orderedList:{label:"Numbered List",icon:_.ListOrdered},taskList:{label:"Task List",icon:_.ListTodo}};function rl({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=v.useState(0);v.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?On[s].icon:_.List,o=l=>{const u=He[l];u&&u.execute({editor:t})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(oe,{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=On[l].icon;return c.jsx(y.DropdownItem,{startContent:c.jsx(a,{size:16}),children:On[l].label},l)})})]})}function sl({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 il=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],ol=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function In(t){return/^#([0-9A-F]{3}){1,2}$/i.test(t)}const me={min:50,max:200,step:10,default:100},Jr={lineHeight:24,toolbarHeight:60},ll={bold:_.Bold,italic:_.Italic,strike:_.Strikethrough,underline:_.Underline,code:_.Code,textColor:_.Palette,highlight:_.Highlighter,link:_.Link2,paragraph:_.FileText,heading:_.Heading,bulletList:_.List,orderedList:_.ListOrdered,taskList:_.ListTodo,codeBlock:_.CodeSquare,blockquote:_.Quote,horizontalRule:_.Minus,clearMarks:_.Eraser,clearNodes:_.Eraser,undo:_.Undo2,redo:_.Redo2,hardBreak:_.CornerDownLeft,textAlign:_.AlignLeft},al={left:_.AlignLeft,center:_.AlignCenter,right:_.AlignRight,justify:_.AlignJustify};function rt(t){return ll[t]}function cl({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=
|
|
7
|
+
`,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const il=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],ol=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function In(t){return/^#([0-9A-F]{3}){1,2}$/i.test(t)}const me={min:50,max:200,step:10,default:100},Jr={lineHeight:24,toolbarHeight:60},ll={bold:_.Bold,italic:_.Italic,strike:_.Strikethrough,underline:_.Underline,code:_.Code,textColor:_.Palette,highlight:_.Highlighter,link:_.Link2,paragraph:_.FileText,heading:_.Heading,bulletList:_.List,orderedList:_.ListOrdered,taskList:_.ListTodo,codeBlock:_.CodeSquare,blockquote:_.Quote,horizontalRule:_.Minus,clearMarks:_.Eraser,clearNodes:_.Eraser,undo:_.Undo2,redo:_.Redo2,hardBreak:_.CornerDownLeft,textAlign:_.AlignLeft},al={left:_.AlignLeft,center:_.AlignCenter,right:_.AlignRight,justify:_.AlignJustify};function rt(t){return ll[t]}function cl({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=v.useState(""),o=u=>{const d=u.target.value;e(d),s&&i("")},l=()=>{if(!t){i("Please enter a color");return}if(!In(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:In(t)?t:"transparent"}})}),c.jsx(oe,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!t||!In(t),children:c.jsx(_.Check,{size:16})})]}),c.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Wr({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=v.useState(!1),[l,a]=v.useState(""),u=e==="textColor"?il:ol,d=b=>{const k=He[e];k&&k.execute({editor:t,config:{type:e,color:b}}),o(!1),a("")},f=b=>{d(b)},p=()=>{const b=He[e];b&&b.execute({editor:t,config:{type:e,color:""}}),o(!1)},m=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),C=e==="textColor"?_.Palette:_.Highlighter;return c.jsxs(y.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(y.PopoverTrigger,{children:c.jsx(oe,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(C,{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(oe,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:c.jsx(_.X,{size:16})})]}),c.jsx(sl,{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(cl,{value:l,onChange:a,onApply:f})]})]})]})})]})}function ul({zoom:t,onZoomChange:e,min:n=me.min,max:r=me.max,step:s=me.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},l=()=>{e(me.default)},a=t<=n,u=t>=r,d=t===me.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(oe,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:a,onPress:i,"aria-label":"Zoom out",children:c.jsx(_.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(oe,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(_.ZoomIn,{size:16})})})]})}function dl({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 Qs(t,e){const n=k.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const a=He[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=>Rt(a)))).forEach(a=>{const u=He[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 Xs(t,e){const n=k.useCallback((o,l)=>{if(!t)return;const a=He[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=He[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=He[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 fl(t=me.default){const[e,n]=k.useState(t),r=k.useCallback((l=me.step)=>{n(a=>Math.min(me.max,a+l))},[]),s=k.useCallback((l=me.step)=>{n(a=>Math.max(me.min,a-l))},[]),i=k.useCallback(()=>{n(me.default)},[]),o=k.useCallback(l=>{const a=Math.max(me.min,Math.min(me.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=me.min,isMaxZoom:e>=me.max,isDefaultZoom:e===me.default}}const hl=["bold","italic","strike","underline","code"];function pl({editor:t,modifiers:e,onToolbarAction:n}){const r=Qs(t,e),{toggleModifier:s}=Xs(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>hl.includes(o));return i.length===0?null:c.jsx(dl,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=rt(o);return c.jsx(We,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function ml({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=Qs(t,e),{toggleModifier:a,executeCommand:u}=Xs(t,o);if(!t)return null;const d=e.map(O=>Rt(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(pl,{editor:t,modifiers:e,onToolbarAction:o}),(p||m||v||x||S||C||w||j||N||D)&&c.jsx(nt,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(Wr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(Wr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||v||x||S||C||w||j||N||D)&&c.jsx(nt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsx(nl,{editor:t}),(v||x||S||C||w||j||N||D)&&c.jsx(nt,{})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(O=>{const z=al[O],H=t.isActive({textAlign:O});return c.jsx(We,{icon:z,label:`Align ${O}`,isActive:H,onClick:()=>u("textAlign",{type:"textAlign",alignment:O})},O)})}),(x||S||C||w||j||N||D)&&c.jsx(nt,{})]}),x&&c.jsxs(c.Fragment,{children:[c.jsx(rl,{editor:t,types:d.filter(O=>["bulletList","orderedList","taskList"].includes(O))}),(S||C||w||j||N||D)&&c.jsx(nt,{})]}),(S||C||w||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[S&&c.jsx(We,{icon:rt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),C&&c.jsx(We,{icon:rt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),w&&c.jsx(We,{icon:rt("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(We,{icon:rt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(N||D)&&c.jsx(nt,{})]}),N&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(We,{icon:rt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(We,{icon:rt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),D&&c.jsx(nt,{})]}),D&&c.jsx(ul,{zoom:n,onZoomChange:O=>{r?.(O),o?.({type:"zoom",modifier:`${O}%`})}})]})})}const gl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,yl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,xl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kl=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:gl,type:this.type}),R.markInputRule({find:xl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:yl,type:this.type}),R.markPasteRule({find:bl,type:this.type})]}}),vl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Sl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Cl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,wl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Al=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:vl,type:this.type}),R.markInputRule({find:Cl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Sl,type:this.type}),R.markPasteRule({find:wl,type:this.type})]}}),Nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,El=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Tl=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:Nl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:El,type:this.type})]}}),Ml=/(^|[^`])`([^`]+)`(?!`)/,Ol=/(^|[^`])`([^`]+)`(?!`)/g,Il=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:Ml,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Ol,type:this.type})]}}),Dl=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}`)})},jl=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Dl(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}}}}),Ll=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}}))}}),Rl=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()}}}),Fl="listItem",Gr="textStyle",Zr=/^\s*([-+*])\s$/,Pl=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(Fl,this.editor.getAttributes(Gr)).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:Zr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Zr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gr),editor:this.editor})),[t]}}),$l="listItem",Qr="textStyle",Xr=/^(\d+)\.\s$/,Vl=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($l,this.editor.getAttributes(Qr)).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:Xr,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:Xr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Bl=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 Ys(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=Ys(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function ei(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=ei(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 Ys(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ei(this,e,n,r)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(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?qt(n+1,i):qt(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 Dn={index:0,offset:0};function qt(t,e){return Dn.index=t,Dn.offset=e,Dn}function Wn(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(!Wn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Oe{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&&Wn(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 Oe.none;if(e instanceof Oe)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class zl 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=ni(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(ti(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 ti(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(ti(i.content,e-s-1,n-s-1)))}function ni(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=ni(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function _l(t){return t.tag!=null}function Hl(t){return t.style!=null}class tn{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(Hl(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 es(this,n,!1);return r.addAll(e,Oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new es(this,n,!0);return r.addAll(e,Oe.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(Kl(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=ts(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=ts(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tn(e,tn.schemaRules(e)))}}const ri={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},Ul={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},si={ol:!0,ul:!0},Ft=1,Gn=2,Mt=4;function Yr(t,e,n){return e!=null?(e?Ft:0)|(e==="full"?Gn:0):t&&t.whitespace=="pre"?Ft|Gn:n&~Mt}class Kt{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=Oe.none,this.match=i||(o&Mt?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&Ft)){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&&!ri.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class es{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=Yr(null,n.preserveWhitespace,0)|(r?Mt:0);s?i=new Kt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Kt(null,null,Oe.none,!0,null,o):i=new Kt(e.schema.topNodeType,null,Oe.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&Gn?"full":this.localPreserveWS||(s.options&Ft)>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,`
|
|
10
|
+
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(y.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(oe,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(_.ZoomIn,{size:16})})})]})}function dl({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 Qs(t,e){const n=v.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const a=He[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]=v.useState(n);return v.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const u=He[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 Xs(t,e){const n=v.useCallback((o,l)=>{if(!t)return;const a=He[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=v.useCallback(o=>{n(o)},[n]),s=v.useCallback((o,l)=>{if(!t)return!1;const a=He[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=v.useCallback((o,l)=>{if(!t)return!1;const a=He[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 fl(t=me.default){const[e,n]=v.useState(t),r=v.useCallback((l=me.step)=>{n(a=>Math.min(me.max,a+l))},[]),s=v.useCallback((l=me.step)=>{n(a=>Math.max(me.min,a-l))},[]),i=v.useCallback(()=>{n(me.default)},[]),o=v.useCallback(l=>{const a=Math.max(me.min,Math.min(me.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=me.min,isMaxZoom:e>=me.max,isDefaultZoom:e===me.default}}const hl=["bold","italic","strike","underline","code"];function pl({editor:t,modifiers:e,onToolbarAction:n}){const r=Qs(t,e),{toggleModifier:s}=Xs(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>hl.includes(o));return i.length===0?null:c.jsx(dl,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=rt(o);return c.jsx(We,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function ml({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=Qs(t,e),{toggleModifier:a,executeCommand:u}=Xs(t,o);if(!t)return null;const d=e.map(O=>Rt(O)),f=d.some(O=>["bold","italic","strike","underline","code"].includes(O)),p=d.some(O=>["textColor","highlight"].includes(O)),m=d.includes("heading"),C=d.includes("textAlign"),b=d.some(O=>["bulletList","orderedList","taskList"].includes(O)),k=d.includes("blockquote"),S=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(pl,{editor:t,modifiers:e,onToolbarAction:o}),(p||m||C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(Wr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(Wr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsx(nl,{editor:t}),(C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),C&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(O=>{const z=al[O],H=t.isActive({textAlign:O});return c.jsx(We,{icon:z,label:`Align ${O}`,isActive:H,onClick:()=>u("textAlign",{type:"textAlign",alignment:O})},O)})}),(b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),b&&c.jsxs(c.Fragment,{children:[c.jsx(rl,{editor:t,types:d.filter(O=>["bulletList","orderedList","taskList"].includes(O))}),(k||S||w||j||N||D)&&c.jsx(nt,{})]}),(k||S||w||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[k&&c.jsx(We,{icon:rt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),S&&c.jsx(We,{icon:rt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),w&&c.jsx(We,{icon:rt("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(We,{icon:rt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(N||D)&&c.jsx(nt,{})]}),N&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(We,{icon:rt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(We,{icon:rt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),D&&c.jsx(nt,{})]}),D&&c.jsx(ul,{zoom:n,onZoomChange:O=>{r?.(O),o?.({type:"zoom",modifier:`${O}%`})}})]})})}const gl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,yl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,xl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kl=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:gl,type:this.type}),R.markInputRule({find:xl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:yl,type:this.type}),R.markPasteRule({find:bl,type:this.type})]}}),vl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Sl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Cl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,wl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Al=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:vl,type:this.type}),R.markInputRule({find:Cl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Sl,type:this.type}),R.markPasteRule({find:wl,type:this.type})]}}),Nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,El=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Tl=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:Nl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:El,type:this.type})]}}),Ml=/(^|[^`])`([^`]+)`(?!`)/,Ol=/(^|[^`])`([^`]+)`(?!`)/g,Il=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:Ml,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Ol,type:this.type})]}}),Dl=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}`)})},jl=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Dl(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}}}}),Ll=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}}))}}),Rl=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()}}}),Fl="listItem",Gr="textStyle",Zr=/^\s*([-+*])\s$/,Pl=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(Fl,this.editor.getAttributes(Gr)).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:Zr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Zr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gr),editor:this.editor})),[t]}}),$l="listItem",Qr="textStyle",Xr=/^(\d+)\.\s$/,Vl=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($l,this.editor.getAttributes(Qr)).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:Xr,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:Xr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Bl=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 Ys(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=Ys(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function ei(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=ei(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 Ys(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ei(this,e,n,r)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(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?qt(n+1,i):qt(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 Dn={index:0,offset:0};function qt(t,e){return Dn.index=t,Dn.offset=e,Dn}function Wn(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(!Wn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Oe{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&&Wn(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 Oe.none;if(e instanceof Oe)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class zl 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=ni(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(ti(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 ti(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(ti(i.content,e-s-1,n-s-1)))}function ni(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=ni(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function _l(t){return t.tag!=null}function Hl(t){return t.style!=null}class tn{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(Hl(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 es(this,n,!1);return r.addAll(e,Oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new es(this,n,!0);return r.addAll(e,Oe.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(Kl(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=ts(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=ts(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tn(e,tn.schemaRules(e)))}}const ri={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},Ul={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},si={ol:!0,ul:!0},Ft=1,Gn=2,Mt=4;function Yr(t,e,n){return e!=null?(e?Ft:0)|(e==="full"?Gn:0):t&&t.whitespace=="pre"?Ft|Gn:n&~Mt}class Kt{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=Oe.none,this.match=i||(o&Mt?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&Ft)){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&&!ri.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class es{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=Yr(null,n.preserveWhitespace,0)|(r?Mt:0);s?i=new Kt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Kt(null,null,Oe.none,!0,null,o):i=new Kt(e.schema.topNodeType,null,Oe.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&Gn?"full":this.localPreserveWS||(s.options&Ft)>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
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;si.hasOwnProperty(o)&&this.parser.normalizeLists&&ql(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ul.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(ri.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=Oe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):ns(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=Yr(e,i,o.options);o.options&Mt&&o.content.length==0&&(l|=Mt);let a=Oe.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):ns(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Kt(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|=Ft)}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 ql(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&si.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Kl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ts(t){let e={};for(let n in t)e[n]=t[n];return e}function ns(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 gn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=jn(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}=Zt(jn(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&&Zt(jn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Zt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=rs(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return rs(e.marks)}}function rs(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function jn(t){return t.document||window.document}const ss=new WeakMap;function Jl(t){let e=ss.get(t);return e===void 0&&ss.set(t,e=Wl(t)),e}function Wl(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 Zt(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=Jl(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}=Zt(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 ii=65535,oi=Math.pow(2,16);function Gl(t,e){return t+e*oi}function is(t){return t&ii}function Zl(t){return(t-(t&ii))/oi}const li=1,ai=2,Qt=4,ci=8;class Zn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ci)>0}get deletedBefore(){return(this.delInfo&(li|Qt))>0}get deletedAfter(){return(this.delInfo&(ai|Qt))>0}get deletedAcross(){return(this.delInfo&Qt)>0}}class Ne{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ne.empty)return Ne.empty}recover(e){let n=0,r=is(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+Zl(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:Gl(l/3,e-a),x=e==a?ai:e==f?li:Qt;return(n<0?e!=a:e!=f)&&(x|=ci),new Zn(m,x,v)}s+=d-u}return r?e+s:new Zn(e+s,0,null)}touches(e,n){let r=0,s=is(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 Ne(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ne.empty:new Ne(e<0?[0,-e,0]:[0,0,e])}}Ne.empty=new Ne([]);class nn{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 nn(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 nn;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 Zn(e,s,null)}}const Ln=Object.create(null);class ge{getMap(){return Ne.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ln[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 Ln)throw new RangeError("Duplicate use of step JSON ID "+e);return Ln[e]=n,n.prototype.jsonID=e,n}}class ce{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ce(e,null)}static fail(e){return new ce(null,e)}static fromReplace(e,n,r,s){try{return ce.ok(e.replace(n,r,s))}catch(i){if(i instanceof zl)return ce.fail(i.message);throw i}}}function mr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(mr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class it extends ge{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(mr(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 ce.fromReplace(e,this.from,this.to,i)}invert(){return new ot(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 it(n.pos,r.pos,this.mark)}merge(e){return e instanceof it&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new it(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 it(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("addMark",it);class ot extends ge{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(mr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,r)}invert(){return new it(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 ot(n.pos,r.pos,this.mark)}merge(e){return e instanceof ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ot(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 ot(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("removeMark",ot);class lt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ce.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 lt(this.pos,n.marks[s]);return new lt(this.pos,this.mark)}}return new Pt(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:"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 lt(n.pos,e.markFromJSON(n.mark))}}ge.jsonID("addNodeMark",lt);class Pt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ce.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 lt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pt(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 Pt(n.pos,e.markFromJSON(n.mark))}}ge.jsonID("removeNodeMark",Pt);class _e extends ge{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Qn(e,this.from,this.to)?ce.fail("Structure replace would overwrite content"):ce.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ne([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?K.empty:new K(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?K.empty:new K(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,K.fromJSON(e,n.slice),!!n.structure)}}ge.jsonID("replace",_e);class kt extends ge{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&&(Qn(e,this.from,this.gapFrom)||Qn(e,this.gapTo,this.to)))return ce.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ce.fromReplace(e,this.from,this.to,r):ce.fail("Content does not fit in gap")}getMap(){return new Ne([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 kt(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 kt(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 kt(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}ge.jsonID("replaceAround",kt);function Qn(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 ui(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 Ot extends ge{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 ce.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 ce.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return Ne.empty}invert(e){return new Ot(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 Ot(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 Ot(n.pos,n.attr,n.value)}}ge.jsonID("attr",Ot);class rn extends ge{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 ce.ok(r)}getMap(){return Ne.empty}invert(e){return new rn(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 rn(n.attr,n.value)}}ge.jsonID("docAttr",rn);let $t=class extends Error{};$t=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";const Rn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ql(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&&as(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),as(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):yt(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?yt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):yt(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 Ve(e.node(0))}static atStart(e){return yt(e,e,0,0,1)||new Ve(e)}static atEnd(e){return yt(e,e,e.content.size,e.childCount,-1)||new Ve(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rn[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 Rn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Ql{constructor(e,n){this.$from=e,this.$to=n}}let os=!1;function ls(t){!os&&!t.parent.inlineContent&&(os=!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){ls(e),ls(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 yn(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 yn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new yn(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 gr(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 gr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new yn(r,r):new gr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):X.near(n)}}class Ve 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 Ve(e)}map(e){return new Ve(e)}eq(e){return e instanceof Ve}getBookmark(){return Xl}}X.jsonID("all",Ve);const Xl={map(){return this},resolve(t){return new Ve(t)}};function yt(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=yt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function as(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _e||s instanceof kt))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 cs(t,e){return!e||!t?t:t.bind(e)}class Jt{constructor(e,n,r){this.name=e,this.init=cs(n.init,r),this.apply=cs(n.apply,r)}}new Jt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Jt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Jt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function di(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=di(s,e,{})),n[r]=s}return n}class xn{constructor(e){this.spec=e,this.props={},e.props&&di(e.props,this,this.props),this.key=e.key?e.key.key:fi("plugin")}getState(e){return e[this.key]}}const Fn=Object.create(null);function fi(t){return t in Fn?t+"$"+ ++Fn[t]:(Fn[t]=0,t+"$")}class yr{constructor(e="key"){this.key=fi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Yl=/^```([a-z]+)?[\s\n]$/,ea=/^~~~([a-z]+)?[\s\n]$/,ta=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(`
|
|
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=Oe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):ns(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=Yr(e,i,o.options);o.options&Mt&&o.content.length==0&&(l|=Mt);let a=Oe.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):ns(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Kt(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|=Ft)}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 ql(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&si.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Kl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ts(t){let e={};for(let n in t)e[n]=t[n];return e}function ns(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 gn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=jn(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}=Zt(jn(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&&Zt(jn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Zt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=rs(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return rs(e.marks)}}function rs(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function jn(t){return t.document||window.document}const ss=new WeakMap;function Jl(t){let e=ss.get(t);return e===void 0&&ss.set(t,e=Wl(t)),e}function Wl(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 Zt(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=Jl(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:C}=Zt(t,p,n,r);if(a.appendChild(m),C){if(l)throw new RangeError("Multiple content holes");l=C}}}return{dom:a,contentDOM:l}}const ii=65535,oi=Math.pow(2,16);function Gl(t,e){return t+e*oi}function is(t){return t&ii}function Zl(t){return(t-(t&ii))/oi}const li=1,ai=2,Qt=4,ci=8;class Zn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ci)>0}get deletedBefore(){return(this.delInfo&(li|Qt))>0}get deletedAfter(){return(this.delInfo&(ai|Qt))>0}get deletedAcross(){return(this.delInfo&Qt)>0}}class Ne{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ne.empty)return Ne.empty}recover(e){let n=0,r=is(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+Zl(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 C=e==(n<0?a:f)?null:Gl(l/3,e-a),b=e==a?ai:e==f?li:Qt;return(n<0?e!=a:e!=f)&&(b|=ci),new Zn(m,b,C)}s+=d-u}return r?e+s:new Zn(e+s,0,null)}touches(e,n){let r=0,s=is(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 Ne(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ne.empty:new Ne(e<0?[0,-e,0]:[0,0,e])}}Ne.empty=new Ne([]);class nn{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 nn(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 nn;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 Zn(e,s,null)}}const Ln=Object.create(null);class ge{getMap(){return Ne.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ln[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 Ln)throw new RangeError("Duplicate use of step JSON ID "+e);return Ln[e]=n,n.prototype.jsonID=e,n}}class ce{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ce(e,null)}static fail(e){return new ce(null,e)}static fromReplace(e,n,r,s){try{return ce.ok(e.replace(n,r,s))}catch(i){if(i instanceof zl)return ce.fail(i.message);throw i}}}function mr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(mr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class it extends ge{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(mr(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 ce.fromReplace(e,this.from,this.to,i)}invert(){return new ot(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 it(n.pos,r.pos,this.mark)}merge(e){return e instanceof it&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new it(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 it(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("addMark",it);class ot extends ge{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(mr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,r)}invert(){return new it(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 ot(n.pos,r.pos,this.mark)}merge(e){return e instanceof ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ot(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 ot(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("removeMark",ot);class lt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ce.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 lt(this.pos,n.marks[s]);return new lt(this.pos,this.mark)}}return new Pt(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:"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 lt(n.pos,e.markFromJSON(n.mark))}}ge.jsonID("addNodeMark",lt);class Pt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ce.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 lt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pt(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 Pt(n.pos,e.markFromJSON(n.mark))}}ge.jsonID("removeNodeMark",Pt);class _e extends ge{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Qn(e,this.from,this.to)?ce.fail("Structure replace would overwrite content"):ce.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ne([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?K.empty:new K(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?K.empty:new K(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,K.fromJSON(e,n.slice),!!n.structure)}}ge.jsonID("replace",_e);class kt extends ge{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&&(Qn(e,this.from,this.gapFrom)||Qn(e,this.gapTo,this.to)))return ce.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ce.fromReplace(e,this.from,this.to,r):ce.fail("Content does not fit in gap")}getMap(){return new Ne([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 kt(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 kt(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 kt(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}ge.jsonID("replaceAround",kt);function Qn(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 ui(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 Ot extends ge{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 ce.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 ce.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return Ne.empty}invert(e){return new Ot(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 Ot(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 Ot(n.pos,n.attr,n.value)}}ge.jsonID("attr",Ot);class rn extends ge{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 ce.ok(r)}getMap(){return Ne.empty}invert(e){return new rn(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 rn(n.attr,n.value)}}ge.jsonID("docAttr",rn);let $t=class extends Error{};$t=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";const Rn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ql(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&&as(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),as(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):yt(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?yt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):yt(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 Ve(e.node(0))}static atStart(e){return yt(e,e,0,0,1)||new Ve(e)}static atEnd(e){return yt(e,e,e.content.size,e.childCount,-1)||new Ve(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rn[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 Rn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Ql{constructor(e,n){this.$from=e,this.$to=n}}let os=!1;function ls(t){!os&&!t.parent.inlineContent&&(os=!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){ls(e),ls(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 yn(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 yn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new yn(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 gr(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 gr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new yn(r,r):new gr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):X.near(n)}}class Ve 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 Ve(e)}map(e){return new Ve(e)}eq(e){return e instanceof Ve}getBookmark(){return Xl}}X.jsonID("all",Ve);const Xl={map(){return this},resolve(t){return new Ve(t)}};function yt(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=yt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function as(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _e||s instanceof kt))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 cs(t,e){return!e||!t?t:t.bind(e)}class Jt{constructor(e,n,r){this.name=e,this.init=cs(n.init,r),this.apply=cs(n.apply,r)}}new Jt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Jt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Jt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function di(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=di(s,e,{})),n[r]=s}return n}class xn{constructor(e){this.spec=e,this.props={},e.props&&di(e.props,this,this.props),this.key=e.key?e.key.key:fi("plugin")}getState(e){return e[this.key]}}const Fn=Object.create(null);function fi(t){return t in Fn?t+"$"+ ++Fn[t]:(Fn[t]=0,t+"$")}class yr{constructor(e="key"){this.key=fi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Yl=/^```([a-z]+)?[\s\n]$/,ea=/^~~~([a-z]+)?[\s\n]$/,ta=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
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:Yl,type:this.type,getAttributes:t=>({language:t[1]})}),R.textblockTypeInputRule({find:ea,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xn({key:new yr("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
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}}})]}}),na=/^\s*>\s$/,ra=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:na,type:this.type})]}}),sa=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})]}}),ia=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 sn=200,he=function(){};he.prototype.append=function(e){return e.length?(e=he.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this};he.prototype.prepend=function(e){return e.length?he.from(e).append(this):this};he.prototype.appendInner=function(e){return new oa(this,e)};he.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?he.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};he.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};he.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)};he.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};he.from=function(e){return e instanceof he?e:e&&e.length?new hi(e):he.empty};var hi=(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<=sn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=sn)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})(he);he.empty=new hi([]);var oa=(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})(he);const la=500;class De{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 Pe(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 Pe(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 De(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 Pe(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>ca&&(l=aa(l,u),o-=u),new De(l.append(i),o)}remapping(e,n){let r=new nn;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 De(this.items.append(e.map(n=>new Pe(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 Pe(v,x,S))}else r.push(new Pe(v))},s);let u=[];for(let p=n;p<o;p++)u.push(new Pe(i.maps[p]));let d=this.items.slice(0,s).append(u).append(r),f=new De(d,l);return f.emptyItemCount()>la&&(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 Pe(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 De(he.from(s.reverse()),i)}}De.empty=new De(he.empty,0);function aa(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Pe{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 Pe(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ca=20;function ua(t,e,n,r){let s=n.getMeta(ct),i;if(s)return s.historyState;n.getMeta(ha)&&(t=new Ge(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ct))return o.getMeta(ct).redo?new Ge(t.done.addTransform(n,void 0,r,Xt(e)),t.undone,us(n.mapping.maps),t.prevTime,t.prevComposition):new Ge(t.done,t.undone.addTransform(n,void 0,r,Xt(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||!da(n,t.prevRanges)),u=o?Pn(t.prevRanges,n.mapping):us(n.mapping.maps);return new Ge(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Xt(e)),De.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(t.done.rebased(n,i),t.undone.rebased(n,i),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ge(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function da(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 us(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 Pn(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 fa(t,e,n){let r=Xt(e),s=ct.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 Ge(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ct,{redo:n,historyState:a})}let $n=!1,ds=null;function Xt(t){let e=t.plugins;if(ds!=e){$n=!1,ds=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){$n=!0;break}}return $n}const ct=new yr("history"),ha=new yr("closeHistory");function pa(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xn({key:ct,state:{init(){return new Ge(De.empty,De.empty,null,0,-1)},apply(e,n,r){return ua(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?mi:r=="historyRedo"?gi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function pi(t,e){return(n,r)=>{let s=ct.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=fa(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const mi=pi(!1,!0),gi=pi(!0,!0),fs=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>mi(t,e),redo:()=>({state:t,dispatch:e})=>gi(t,e)}},addProseMirrorPlugins(){return[pa(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()}}}),ma=R.Node.create({name:"doc",topNode:!0,content:"block+"}),ga=R.Node.create({name:"text",group:"inline"});function ya(t={}){return new xn({view(e){return new xa(e,t)}})}class xa{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=ui(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 ba=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ya(this.options)]}});var Ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},on={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ka=typeof navigator<"u"&&/Mac/.test(navigator.platform),va=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pe=0;pe<10;pe++)Ye[48+pe]=Ye[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)Ye[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)Ye[pe]=String.fromCharCode(pe+32),on[pe]=String.fromCharCode(pe);for(var Vn in Ye)on.hasOwnProperty(Vn)||(on[Vn]=Ye[Vn]);function Sa(t){var e=ka&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||va&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?on:Ye)[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 Ca=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),wa=typeof navigator<"u"&&/Win/.test(navigator.platform);function Aa(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))Ca?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 Na(t){let e=Object.create(null);for(let n in t)e[Aa(n)]=t[n];return e}function Bn(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 Ea(t){let e=Na(t);return function(n,r){let s=Sa(r),i,o=e[Bn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Bn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(wa&&r.ctrlKey&&r.altKey)&&(i=Ye[r.keyCode])&&i!=s){let l=e[Bn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ft=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},yi=function(t,e,n,r){return n&&(hs(t,e,n,r,-1)||hs(t,e,n,r,1))},Ta=/^(img|br|input|textarea|hr)$/i;function hs(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ln(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xr(t)||Ta.test(t.nodeName)||t.contentEditable=="false")return!1;e=ft(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?ln(t):0}else return!1}}function ln(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ma(t,e,n){for(let r=e==0,s=e==ln(t);r||s;){if(t==n)return!0;let i=ft(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ln(t)}}function xr(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 xi=function(t){return t.focusNode&&yi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function bi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Be=typeof navigator<"u"?navigator:null,ps=typeof document<"u"?document:null,et=Be&&Be.userAgent||"",Xn=/Edge\/(\d+)/.exec(et),ki=/MSIE \d/.exec(et),Yn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et),_t=!!(ki||Yn||Xn),vi=ki?document.documentMode:Yn?+Yn[1]:Xn?+Xn[1]:0,bn=!_t&&/gecko\/(\d+)/i.test(et);bn&&+(/Firefox\/(\d+)/.exec(et)||[0,0])[1];const er=!_t&&/Chrome\/(\d+)/.exec(et),Ue=!!er,Si=er?+er[1]:0,ht=!_t&&!!Be&&/Apple Computer/.test(Be.vendor),br=ht&&(/Mobile\/\w+/.test(et)||!!Be&&Be.maxTouchPoints>2),Me=br||(Be?/Mac/.test(Be.platform):!1),Ci=Be?/Win/.test(Be.platform):!1,Ht=/Android \d/.test(et),kr=!!ps&&"webkitFontSmoothing"in ps.documentElement.style,Oa=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ia(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(xi(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&&Ma(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=Ai(t,d,l,f)}return u}function wi(t){return t.editable?t.hasFocus():Ra(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vr(t,e=!1){let n=t.state.selection;if(La(t,n),!!wi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ue){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&yi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ja(t);else{let{anchor:r,head:s}=n,i,o;ms&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=gs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=gs(t,n.to))),t.docView.setSelection(r,s,t,e),ms&&(i&&ys(i),o&&ys(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Da(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ms=ht||Ue&&Si<63;function gs(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(ht&&s&&s.contentEditable=="false")return zn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return zn(s);if(i)return zn(i)}}function zn(t){return t.contentEditable="true",ht&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ys(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Da(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(()=>{(!wi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ja(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ft(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_t&&vi<=11&&(n.disabled=!0,n.disabled=!1)}function La(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(xs(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else xs(t)}function xs(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ai(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Ra(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 tr(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 Ze(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function bs(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 Ze(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=tr(t.state,e);return s&&s instanceof J?Ze(t,s):!1}else if(!(Me&&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)?Ze(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):kr?Ze(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 Ze(t,new Q(e>0?r.$to:r.$from));{let s=tr(t.state,e);return s?Ze(t,s):!1}}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function It(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mt(t,e){return e<0?Fa(t):Pa(t)}function Fa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(bn&&n.nodeType==1&&r<an(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(It(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ni(n))break;{let l=n.previousSibling;for(;l&&It(l,-1);)s=n.parentNode,i=ft(l),l=l.previousSibling;if(l)n=l,r=an(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?nr(t,n,r):s&&nr(t,s,i)}function Pa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=an(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(It(l,1))i=n,o=++r;else break}else{if(Ni(n))break;{let l=n.nextSibling;for(;l&&It(l,1);)i=l.parentNode,o=ft(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=an(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&nr(t,i,o)}function Ni(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $a(t,e){for(;t&&e==t.childNodes.length&&!xr(t);)e=ft(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 Va(t,e){for(;t&&!e&&!xr(t);)e=ft(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 nr(t,e,n){if(e.nodeType!=3){let i,o;(o=$a(e,n))?(e=o,n=0):(i=Va(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xi(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&&vr(t)},50)}function ks(t,e){let n=t.state.doc.resolve(e);if(!(Ue||Ci)&&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 vs(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Me&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=tr(t.state,e);if(o&&o instanceof J)return Ze(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Ve?X.near(o,e):X.findFrom(o,e);return l?Ze(t,l):!1}return!1}function Ss(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 Cs(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ba(t){if(!ht||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;Cs(t,r,"true"),setTimeout(()=>Cs(t,r,"false"),20)}return!1}function za(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=za(e);if(n==8||Me&&n==72&&r=="c")return Ss(t,-1)||mt(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r=="c")return Ss(t,1)||mt(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r=="c"){let s=n==37?ks(t,t.state.selection.from)=="ltr"?-1:1:-1;return bs(t,s,r)||mt(t,s)}else if(n==39||Me&&n==70&&r=="c"){let s=n==39?ks(t,t.state.selection.from)=="ltr"?1:-1:1;return bs(t,s,r)||mt(t,s)}else{if(n==38||Me&&n==80&&r=="c")return vs(t,-1,r)||mt(t,-1);if(n==40||Me&&n==78&&r=="c")return Ba(t)||vs(t,1,r)||mt(t,1);if(r==(Me?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ei(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")||gn.fromSchema(t.state.schema),l=ji(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Di[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,`
|
|
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 sn=200,he=function(){};he.prototype.append=function(e){return e.length?(e=he.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this};he.prototype.prepend=function(e){return e.length?he.from(e).append(this):this};he.prototype.appendInner=function(e){return new oa(this,e)};he.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?he.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};he.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};he.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)};he.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};he.from=function(e){return e instanceof he?e:e&&e.length?new hi(e):he.empty};var hi=(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<=sn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=sn)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})(he);he.empty=new hi([]);var oa=(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})(he);const la=500;class De{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 Pe(f.map));let m=f.step.map(s.slice(i)),C;m&&o.maybeStep(m).doc&&(C=o.mapping.maps[o.mapping.maps.length-1],u.push(new Pe(C,void 0,void 0,u.length+d.length))),i--,C&&s.appendMap(C,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new De(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 Pe(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>ca&&(l=aa(l,u),o-=u),new De(l.append(i),o)}remapping(e,n){let r=new nn;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 De(this.items.append(e.map(n=>new Pe(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 C=i.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),k=p.selection&&p.selection.map(i.slice(a+1,m));k&&l++,r.push(new Pe(C,b,k))}else r.push(new Pe(C))},s);let u=[];for(let p=n;p<o;p++)u.push(new Pe(i.maps[p]));let d=this.items.slice(0,s).append(u).append(r),f=new De(d,l);return f.emptyItemCount()>la&&(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 Pe(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 De(he.from(s.reverse()),i)}}De.empty=new De(he.empty,0);function aa(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Pe{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 Pe(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ca=20;function ua(t,e,n,r){let s=n.getMeta(ct),i;if(s)return s.historyState;n.getMeta(ha)&&(t=new Ge(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ct))return o.getMeta(ct).redo?new Ge(t.done.addTransform(n,void 0,r,Xt(e)),t.undone,us(n.mapping.maps),t.prevTime,t.prevComposition):new Ge(t.done,t.undone.addTransform(n,void 0,r,Xt(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||!da(n,t.prevRanges)),u=o?Pn(t.prevRanges,n.mapping):us(n.mapping.maps);return new Ge(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Xt(e)),De.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(t.done.rebased(n,i),t.undone.rebased(n,i),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ge(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function da(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 us(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 Pn(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 fa(t,e,n){let r=Xt(e),s=ct.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 Ge(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ct,{redo:n,historyState:a})}let $n=!1,ds=null;function Xt(t){let e=t.plugins;if(ds!=e){$n=!1,ds=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){$n=!0;break}}return $n}const ct=new yr("history"),ha=new yr("closeHistory");function pa(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xn({key:ct,state:{init(){return new Ge(De.empty,De.empty,null,0,-1)},apply(e,n,r){return ua(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?mi:r=="historyRedo"?gi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function pi(t,e){return(n,r)=>{let s=ct.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=fa(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const mi=pi(!1,!0),gi=pi(!0,!0),fs=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>mi(t,e),redo:()=>({state:t,dispatch:e})=>gi(t,e)}},addProseMirrorPlugins(){return[pa(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()}}}),ma=R.Node.create({name:"doc",topNode:!0,content:"block+"}),ga=R.Node.create({name:"text",group:"inline"});function ya(t={}){return new xn({view(e){return new xa(e,t)}})}class xa{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 C=m.getBoundingClientRect(),b=f?C.bottom:C.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*l;r={left:C.left,right:C.right,top:b-k,bottom:b+k}}}}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=ui(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 ba=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ya(this.options)]}});var Ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},on={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ka=typeof navigator<"u"&&/Mac/.test(navigator.platform),va=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pe=0;pe<10;pe++)Ye[48+pe]=Ye[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)Ye[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)Ye[pe]=String.fromCharCode(pe+32),on[pe]=String.fromCharCode(pe);for(var Vn in Ye)on.hasOwnProperty(Vn)||(on[Vn]=Ye[Vn]);function Sa(t){var e=ka&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||va&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?on:Ye)[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 Ca=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),wa=typeof navigator<"u"&&/Win/.test(navigator.platform);function Aa(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))Ca?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 Na(t){let e=Object.create(null);for(let n in t)e[Aa(n)]=t[n];return e}function Bn(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 Ea(t){let e=Na(t);return function(n,r){let s=Sa(r),i,o=e[Bn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Bn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(wa&&r.ctrlKey&&r.altKey)&&(i=Ye[r.keyCode])&&i!=s){let l=e[Bn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ft=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},yi=function(t,e,n,r){return n&&(hs(t,e,n,r,-1)||hs(t,e,n,r,1))},Ta=/^(img|br|input|textarea|hr)$/i;function hs(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ln(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xr(t)||Ta.test(t.nodeName)||t.contentEditable=="false")return!1;e=ft(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?ln(t):0}else return!1}}function ln(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ma(t,e,n){for(let r=e==0,s=e==ln(t);r||s;){if(t==n)return!0;let i=ft(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ln(t)}}function xr(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 xi=function(t){return t.focusNode&&yi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function bi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Be=typeof navigator<"u"?navigator:null,ps=typeof document<"u"?document:null,et=Be&&Be.userAgent||"",Xn=/Edge\/(\d+)/.exec(et),ki=/MSIE \d/.exec(et),Yn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et),_t=!!(ki||Yn||Xn),vi=ki?document.documentMode:Yn?+Yn[1]:Xn?+Xn[1]:0,bn=!_t&&/gecko\/(\d+)/i.test(et);bn&&+(/Firefox\/(\d+)/.exec(et)||[0,0])[1];const er=!_t&&/Chrome\/(\d+)/.exec(et),Ue=!!er,Si=er?+er[1]:0,ht=!_t&&!!Be&&/Apple Computer/.test(Be.vendor),br=ht&&(/Mobile\/\w+/.test(et)||!!Be&&Be.maxTouchPoints>2),Me=br||(Be?/Mac/.test(Be.platform):!1),Ci=Be?/Win/.test(Be.platform):!1,Ht=/Android \d/.test(et),kr=!!ps&&"webkitFontSmoothing"in ps.documentElement.style,Oa=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ia(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(xi(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&&Ma(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 C=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(C.startContainer,C.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(C.endContainer,C.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=Ai(t,d,l,f)}return u}function wi(t){return t.editable?t.hasFocus():Ra(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vr(t,e=!1){let n=t.state.selection;if(La(t,n),!!wi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ue){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&yi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ja(t);else{let{anchor:r,head:s}=n,i,o;ms&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=gs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=gs(t,n.to))),t.docView.setSelection(r,s,t,e),ms&&(i&&ys(i),o&&ys(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Da(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ms=ht||Ue&&Si<63;function gs(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(ht&&s&&s.contentEditable=="false")return zn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return zn(s);if(i)return zn(i)}}function zn(t){return t.contentEditable="true",ht&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ys(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Da(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(()=>{(!wi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ja(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ft(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_t&&vi<=11&&(n.disabled=!0,n.disabled=!1)}function La(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(xs(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else xs(t)}function xs(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ai(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Ra(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 tr(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 Ze(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function bs(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 Ze(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=tr(t.state,e);return s&&s instanceof J?Ze(t,s):!1}else if(!(Me&&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)?Ze(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):kr?Ze(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 Ze(t,new Q(e>0?r.$to:r.$from));{let s=tr(t.state,e);return s?Ze(t,s):!1}}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function It(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mt(t,e){return e<0?Fa(t):Pa(t)}function Fa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(bn&&n.nodeType==1&&r<an(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(It(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ni(n))break;{let l=n.previousSibling;for(;l&&It(l,-1);)s=n.parentNode,i=ft(l),l=l.previousSibling;if(l)n=l,r=an(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?nr(t,n,r):s&&nr(t,s,i)}function Pa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=an(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(It(l,1))i=n,o=++r;else break}else{if(Ni(n))break;{let l=n.nextSibling;for(;l&&It(l,1);)i=l.parentNode,o=ft(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=an(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&nr(t,i,o)}function Ni(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $a(t,e){for(;t&&e==t.childNodes.length&&!xr(t);)e=ft(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 Va(t,e){for(;t&&!e&&!xr(t);)e=ft(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 nr(t,e,n){if(e.nodeType!=3){let i,o;(o=$a(e,n))?(e=o,n=0):(i=Va(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xi(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&&vr(t)},50)}function ks(t,e){let n=t.state.doc.resolve(e);if(!(Ue||Ci)&&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 vs(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Me&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=tr(t.state,e);if(o&&o instanceof J)return Ze(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Ve?X.near(o,e):X.findFrom(o,e);return l?Ze(t,l):!1}return!1}function Ss(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 Cs(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ba(t){if(!ht||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;Cs(t,r,"true"),setTimeout(()=>Cs(t,r,"false"),20)}return!1}function za(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=za(e);if(n==8||Me&&n==72&&r=="c")return Ss(t,-1)||mt(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r=="c")return Ss(t,1)||mt(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r=="c"){let s=n==37?ks(t,t.state.selection.from)=="ltr"?-1:1:-1;return bs(t,s,r)||mt(t,s)}else if(n==39||Me&&n==70&&r=="c"){let s=n==39?ks(t,t.state.selection.from)=="ltr"?1:-1:1;return bs(t,s,r)||mt(t,s)}else{if(n==38||Me&&n==80&&r=="c")return vs(t,-1,r)||mt(t,-1);if(n==40||Me&&n==78&&r=="c")return Ba(t)||vs(t,1,r)||mt(t,1);if(r==(Me?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ei(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")||gn.fromSchema(t.state.schema),l=ji(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Di[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let C=l.createElement(d[m]);for(;a.firstChild;)C.appendChild(a.firstChild);a.appendChild(C),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
18
|
`);return{dom:a,text:p,slice:e}}function Ti(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=gn.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=Ka(n),kr&&Ja(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")||tn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Ha.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Wa(ws(l,+d[1],+d[2]),d[4]);else if(l=K.maxOpen(Ua(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=ws(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Ha=/^(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 Ua(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&&Oi(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ii(o[o.length-1],i.length));let d=Mi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return q.from(o)}return t}function Mi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function Oi(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Oi(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(Mi(n,t,s+1))))}}function Ii(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ii(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function rr(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=rr(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 ws(t,e,n){return e<t.openStart&&(t=new K(rr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(rr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Di={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 As=null;function ji(){return As||(As=document.implementation.createHTMLDocument("title"))}let _n=null;function qa(t){let e=window.trustedTypes;return e?(_n||(_n=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_n.createHTML(t)):t}function Ka(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ji().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Di[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=qa(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ja(t){let e=t.querySelectorAll(Ue?"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 Wa(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 Fe={},Te={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Te.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ri(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ht&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&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,bi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_a(t,n)?n.preventDefault():Qe(t,"key")};Te.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Te.keypress=(t,e)=>{let n=e;if(Ri(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&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 kn(t){return{left:t.clientX,top:t.clientY}}function Ga(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Sr(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 vt(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 Za(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(vt(t,new J(n)),!0):!1}function Qa(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?(vt(t,J.create(t.state.doc,s)),!0):!1}function Xa(t,e,n,r,s){return Sr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Qa(t,n):Za(t,n))}function Ya(t,e,n,r){return Sr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function ec(t,e,n,r){return Sr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||tc(t,n,r)}function tc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vt(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)vt(t,Q.create(r,l+1,l+1+o.content.size));else if(J.isSelectable(o))vt(t,J.create(r,l));else continue;return!0}}function Cr(t){return cn(t)}const Li=Me?"metaKey":"ctrlKey";Fe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ga(n,t.input.lastClick)&&!n[Li]&&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(kn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new nc(t,o,n,!!r)):(i=="doubleClick"?Ya:ec)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class nc{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[Li],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&&bn&&!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)),Qe(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(()=>vr(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(kn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):Xa(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ht&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!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)?(vt(this.view,X.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Qe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qe(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)}}Fe.touchstart=t=>{t.input.lastTouch=Date.now(),Cr(t),Qe(t,"pointer")};Fe.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Fe.contextmenu=t=>Cr(t);function Ri(t,e){return t.composing?!0:ht&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const rc=Ht?5e3:-1;Te.compositionstart=Te.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)||Ue&&Ci&&sc(t)))t.markCursor=t.state.storedMarks||n.marks(),cn(t,!0),t.markCursor=null;else if(cn(t,!e.selection.empty),bn&&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}Fi(t,rc)};function sc(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"}Te.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++,Fi(t,20))};function Fi(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>cn(t),e))}function ic(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=oc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function oc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function cn(t,e=!1){if(!(Ht&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ic(t),e||t.docView&&t.docView.dirty){let n=Ia(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 lc(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 Vt=_t&&vi<15||br&&Oa<604;Fe.copy=Te.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Vt?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Ei(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):lc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function cc(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?sr(t,r.value,null,s,e):sr(t,r.textContent,r.innerHTML,s,e)},50)}function sr(t,e,n,r,s){let i=Ti(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=ac(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 Pi(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," "):""}Te.paste=(t,e)=>{let n=e;if(t.composing&&!Ht)return;let r=Vt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sr(t,Pi(r),r.getData("text/html"),s,n)?n.preventDefault():cc(t,n)};class uc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const dc=Me?"altKey":"ctrlKey";function $i(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[dc]}Fe.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(kn(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}=Ei(t,l);(!n.dataTransfer.files.length||!Ue||Si>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vt||n.dataTransfer.setData("text/plain",u),t.dragging=new uc(d,$i(t,n),o)};Fe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Te.dragover=Te.dragenter=(t,e)=>e.preventDefault();Te.drop=(t,e)=>{try{fc(t,e,t.dragging)}finally{t.dragging=null}};function fc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kn(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=Ti(t,Pi(e.dataTransfer),Vt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&$i(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?ui(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(Ai(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Fe.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())&&vr(t)},20))};Fe.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)};Fe.beforeinput=(t,e)=>{if(Ue&&Ht&&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,bi(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 Te)Fe[t]=Te[t];function Bt(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 un{constructor(e,n){this.toDOM=e,this.spec=n||ut,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 $e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof un&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xe{constructor(e,n){this.attrs=e,this.spec=n||ut}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 $e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class wr{constructor(e,n){this.attrs=e,this.spec=n||ut}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 $e(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 wr&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class $e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new $e(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 $e(e,e,new un(n,r))}static inline(e,n,r,s){return new $e(e,n,new Xe(r,s))}static node(e,n,r,s){return new $e(e,n,new wr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof un}}const xt=[],ut={};class fe{constructor(e,n){this.local=e.length?e:xt,this.children=n.length?n:xt}static create(e,n){return n.length?dn(n,e,0,ut):ve}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==ve||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}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?hc(this.children,o||[],e,n,r,s,i):o?new fe(o.sort(dt),xt):ve}add(e,n){return n.length?this==ve?fe.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=Bi(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,dn(d,l,u+1,ut)),i+=3}});let o=Vi(i?zi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new fe(o.length?this.local.concat(o).sort(dt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?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!=ve?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 fe(s,r):ve}forChild(e,n){if(this==ve)return this;if(n.isLeaf)return fe.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 Xe){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 fe(s.sort(dt),xt);return r?new st([l,r]):l}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof fe)||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 Ar(this.localsInner(e))}localsInner(e){if(this==ve)return xt;if(e.inlineContent||!this.local.some(Xe.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Xe||n.push(this.local[r]);return n}forEachSet(e){e(this)}}fe.empty=new fe([],[]);fe.removeOverlap=Ar;const ve=fe.empty;class st{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return st.from(r)}forChild(e,n){if(n.isLeaf)return fe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ve&&(i instanceof st?r=r.concat(i.members):r.push(i))}return st.from(r)}eq(e){if(!(e instanceof st)||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?Ar(r?n:n.sort(dt)):xt}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new st(e.every(n=>n instanceof fe)?e:e.reduce((n,r)=>n.concat(r instanceof fe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function hc(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!=ve?(l[u]=f,l[u+1]=m,l[u+2]=C):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=pc(l,t,e,n,s,i,o),d=dn(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 fe(e.sort(dt),l)}function Vi(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 $e(s.from+e,s.to+e,s.type))}return n}function pc(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 Bi(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 zi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function dn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Bi(t,l,a+n);if(u){i=!0;let d=dn(u,l,n+a+1,r);d!=ve&&s.push(a,a+l.nodeSize,d)}});let o=Vi(i?zi(t):t,-n).sort(dt);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 fe(o,s):ve}function dt(t,e){return t.from-e.from||t.to-e.to}function Ar(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),Ns(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),Ns(e,s,r.copy(i.from,r.to)));break}}}return e}function Ns(t,e,n){for(;e<t.length&&dt(n,t[e])>0;)e++;t.splice(e,0,n)}class ie extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ie.valid(r)?new ie(r):X.near(r)}content(){return K.empty}eq(e){return e instanceof ie&&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 ie(e.resolve(n.pos))}getBookmark(){return new Nr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!mc(e)||!gc(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&&ie.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(ie.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(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;X.jsonID("gapcursor",ie);class Nr{constructor(e){this.pos=e}map(e){return new Nr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ie.valid(n)?new ie(n):X.near(n)}}function _i(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function mc(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 gc(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 yc(){return new xn({props:{decorations:vc,createSelectionBetween(t,e,n){return e.pos==n.pos&&ie.valid(n)?new ie(n):null},handleClick:bc,handleKeyDown:xc,handleDOMEvents:{beforeinput:kc}}})}const xc=Ea({ArrowLeft:Wt("horiz",-1),ArrowRight:Wt("horiz",1),ArrowUp:Wt("vert",-1),ArrowDown:Wt("vert",1)});function Wt(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=ie.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new ie(u))),!0):!1}}function bc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ie.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 ie(r))),!0)}function kc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ie))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 vc(t){if(!(t.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",fe.create(t.doc,[$e.widget(t.selection.head,e,{key:"gapcursor"})])}const Sc=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[yc()]},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}}}),At={bold:{category:"mark",extension:kl,priority:100},italic:{category:"mark",extension:Al,priority:100},strike:{category:"mark",extension:Tl,priority:100},underline:{category:"mark",extension:Fo.Underline,priority:100},code:{category:"mark",extension:Il,priority:100},textColor:{category:"mark",extension:Po.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:$o.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Vo.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ll,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Pl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Vl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Bo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ta,priority:100},blockquote:{category:"node",extension:ra,priority:100},horizontalRule:{category:"node",extension:sa,priority:100},hardBreak:{category:"node",extension:ia,priority:100},undo:{category:"extension",extension:fs,priority:50},redo:{category:"extension",extension:fs,priority:50},textAlign:{category:"extension",extension:_o.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},Cc=[ma,ga,Rl,jl.configure({HTMLAttributes:{}}),Bl.configure({HTMLAttributes:{}}),zo.TaskItem.configure({nested:!0}),ba,Sc];function wc(t){const e=[],n=new Set,r=new Set;Cc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Rt(l)),i=new Set;return s.forEach(l=>{const a=At[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=At[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=At[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(At).find(m=>m?.extension?.name===l.name),d=Object.values(At).find(m=>m?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Hi={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"]},se={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Je={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},te={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Ac={h1:`font-size: ${se.fontSize["4xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h2:`font-size: ${se.fontSize["2xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h3:`font-size: ${se.fontSize.xl}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h4:`font-size: ${se.fontSize.lg}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h5:`font-size: ${se.fontSize.base}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h6:`font-size: ${se.fontSize.sm}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,p:`min-height: ${se.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,li:`display: list-item; margin: ${te.xs} 0;`,strong:`font-weight: ${se.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Je.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${se.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${se.fontFamily.mono};`,pre:`background: ${Je.neutral.gray[800]}; border-radius: ${te.sm}; color: ${Je.neutral.gray[100]}; font-family: ${se.fontFamily.mono}; margin: ${te.lg} 0; padding: 0.75rem ${te.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Je.neutral.gray[300]}; margin: ${te.lg} 0; padding-left: ${te.md}; color: ${Je.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Je.neutral.gray[200]}; margin: ${te.xl} 0;`,a:`color: ${Je.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Je.palettes.warning[200]}; border-radius: ${te.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${te.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Nc={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function Ec(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Nc)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");e=e.replace(s,(i,o)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${o} style="${r}">`)}for(const[n,r]of Object.entries(Ac)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");e=e.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return 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 Tc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=hr.useCurrentEditor();return c.jsx(ml,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Mc=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=hr.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"]})]})},ir=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=Hi.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}=fl(),D=Jr.lineHeight,L=n*D,O=s?void 0:r*D,z=k.useMemo(()=>wc(a),[a]),{Component:H,label:U,shouldLabelBeOutside:P,getBaseProps:M,getLabelProps:F,getInputWrapperProps:$}=y.useInput({...w,variant:u,ref:e,isMultiline:!0}),B=U?c.jsx("label",{...F(),children:U}):null,Y=k.useCallback(({editor:W})=>{const ye=W.getHTML(),de=C?Ec(ye):ye,xe=W.getJSON(),qe=W.getText(),pt=qe.length,Ct=qe.split(/\s+/).filter(we=>we.length>0).length,ne={html:de,json:xe,text:qe,characters:pt,words:Ct};if(p?.(ne),m?.(ne),"onChange"in w&&typeof w.onChange=="function"){const we={target:{value:de},currentTarget:{value:de}};w.onChange(we)}},[p,m,w,C]);return c.jsxs(H,{...M(),children:[P?B:null,c.jsx("div",{...$(),className:y.cn($().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:O?`${O+Jr.toolbarHeight}px`:void 0,overflow:O?"auto":void 0},children:c.jsx(hr.EditorProvider,{editable:!x&&!S,slotBefore:l?c.jsx(Tc,{modifiers:a,zoom:j,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:c.jsx(Mc,{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:z,content:f||d||t.defaultValue||"",onUpdate:Y})})]})});ir.displayName="TipTapEditor";const Ui=k.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(ir,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(ir,{...s,variant:r,ref:e}))});Ui.displayName="RichTextArea";function Oc(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 Es=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Ic={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},qi=({presetAmounts:t=Es,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={...Ic,...u},j=Array.isArray(t)?t:Es,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,z]=pr(e,n,r),[H,U]=k.useState(""),P=k.useCallback(B=>{if(p)return;const Y={amount:B.amount,isCustom:!1,presetId:B.id};z(Y),U("")},[p,z]),M=k.useCallback(B=>{if(p)return;if(U(B!==void 0?String(B):""),B===void 0||isNaN(B)){z(null);return}z({amount:B,isCustom:!0})},[p,z]),F=k.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),$=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(oe,{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||Oc(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:$})}):c.jsx("div",{className:y.cn("w-full",S),"data-testid":"donation-amounts-plain",children:$})};qi.displayName="DonationAmounts";const Dc=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`},jc=t=>{switch(t){case"warning":return _.Clock;case"error":return _.AlertCircle;case"success":return _.CheckCircle;default:return _.Clock}},Lc=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"}},Ki=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=Dc,className:p,...m},v)=>{const[x,S]=pr(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||jc(s),N=Lc(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)})})]})})})});Ki.displayName="ExpireCartTimer";function Rc(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 Ji=Object.freeze({left:0,top:0,width:16,height:16}),fn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Er=Object.freeze({...Ji,...fn}),or=Object.freeze({...Er,body:"",hidden:!1});function Fc(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 Ts(t,e){const n=Fc(t,e);for(const r in or)r in fn?r in t&&!(r in n)&&(n[r]=fn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Pc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=Ts(r[l]||s[l],i)}return o(e),n.forEach(o),Ts(t,i)}function Wi(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=Rc(t);for(const s in r){const i=r[s];i&&(e(s,Pc(t,s,i)),n.push(s))}return n}const $c={provider:"",aliases:{},not_found:{},...Ji};function Hn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Gi(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Hn(t,$c))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Hn(i,or))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]||!Hn(i,or))return null}return e}const Ms=Object.create(null);function Vc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function St(t,e){const n=Ms[t]||(Ms[t]=Object.create(null));return n[e]||(n[e]=Vc(t,e))}function Zi(t,e){return Gi(e)?Wi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Bc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Qi=/^[a-z0-9]+(-[a-z0-9]+)*$/,vn=(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&&!Yt(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&&!Yt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Yt(l,n)?null:l}return null},Yt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let zt=!1;function Xi(t){return typeof t=="boolean"&&(zt=t),zt}function Os(t){const e=typeof t=="string"?vn(t,!0,zt):t;if(e){const n=St(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function zc(t,e){const n=vn(t,!0,zt);if(!n)return!1;const r=St(n.provider,n.prefix);return e?Bc(r,n.name,e):(r.missing.add(n.name),!0)}function _c(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),zt&&!e&&!t.prefix){let s=!1;return Gi(t)&&(t.prefix="",Wi(t,(i,o)=>{zc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Yt({prefix:n,name:"a"}))return!1;const r=St(e,n);return!!Zi(r,t)}const Yi=Object.freeze({width:null,height:null}),eo=Object.freeze({...Yi,...fn}),Hc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Uc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(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(Hc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Uc.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 qc(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 Kc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Jc(t,e,n){const r=qc(t);return Kc(r.defs,e+r.content+n)}const Wc=t=>t==="unset"||t==="undefined"||t==="none";function Gc(t,e){const n={...Er,...t},r={...eo,...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=Jc(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=Is(f,a/u)):(d=o==="auto"?a:o,f=l===null?Is(d,u/a):l==="auto"?u:l);const p={},m=(x,S)=>{Wc(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 Zc=/\sid="(\S+)"/g,Qc="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Xc=0;function Yc(t,e=Qc){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+(Xc++).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 lr=Object.create(null);function eu(t,e){lr[t]=e}function ar(t){return lr[t]||lr[""]}function Tr(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 Mr=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],en=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?en.push(Nt.shift()):en.push(Nt.pop());Mr[""]=Tr({resources:["https://api.iconify.design"].concat(en)});function tu(t,e){const n=Tr(e);return n===null?!1:(Mr[t]=n,!0)}function Or(t){return Mr[t]}const nu=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ds=nu();function ru(t,e){const n=Or(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 su(t){return t===404}const iu=(t,e,n)=>{const r=[],s=ru(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 ou(t){if(typeof t=="string"){const e=Or(t);if(e)return e.path}return"/"}const lu=(t,e,n)=>{if(!Ds){n("abort",424);return}let r=ou(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;Ds(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(su(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)})},au={prepare:iu,send:lu};function to(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function cu(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||to([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let uu=0;function du(t,e,n){const r=uu++,s=to.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 fu(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]=St(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 hu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?vn(s,e,n):s;i&&r.push(i)}),r}const pu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function mu(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,z){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=z,w();return}if(H){d=z,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(z)})}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:(z,H)=>{N(O,z,H)}};p.push(O),u++,f=setTimeout(D,t.rotate),n(L,e,O.callback)}return setTimeout(D),C}function no(t){const e={...pu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=mu(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 js(){}const Un=Object.create(null);function gu(t){if(!Un[t]){const e=Or(t);if(!e)return;const n=no(e),r={config:e,redundancy:n};Un[t]=r}return Un[t]}function yu(t,e,n){let r,s;if(typeof t=="string"){const i=ar(t);if(!i)return n(void 0,424),js;s=i.send;const o=gu(t);o&&(r=o.redundancy)}else{const i=Tr(t);if(i){r=no(i);const o=t.resources?t.resources[0]:"",l=ar(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),js):r.query(e,s,n)().abort}function Ls(){}function xu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,cu(t)}))}function bu(t){const e=[],n=[];return t.forEach(r=>{(r.match(Qi)?e:n).push(r)}),{valid:e,invalid:n}}function Et(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(!Zi(t,n).length){r();return}}catch(s){console.error(s)}r(),xu(t)}function Rs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function ku(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)){Rs(t.loadIcons(s,r,n),d=>{Et(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Rs(f,p=>{const m=p?{prefix:r,icons:{[d]:p}}:null;Et(t,[d],m)})});return}const{valid:o,invalid:l}=bu(s);if(l.length&&Et(t,l,null),!o.length)return;const a=r.match(Qi)?ar(n):null;if(!a){Et(t,o,null);return}a.prepare(n,r,o).forEach(d=>{yu(n,d,f=>{Et(t,d.icons,f)})})}))}const vu=(t,e)=>{const n=hu(t,!0,Xi()),r=fu(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Ls)}),()=>{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(St(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=St(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&&ku(a,u)}),e?du(e,r,i):Ls};function Su(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Yi?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Cu=/[\s,]+/;function wu(t,e){e.split(Cu).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Au(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 Nu(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 Eu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Tu(t){return"data:image/svg+xml,"+Eu(t)}function Mu(t){return'url("'+Tu(t)+'")'}let Dt;function Ou(){try{Dt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Dt=null}}function Iu(t){return Dt===void 0&&Ou(),Dt?Dt.createHTML(t):t}const ro={...eo,inline:!1},Du={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ju={display:"inline-block"},cr={backgroundColor:"currentColor"},so={backgroundColor:"transparent"},Fs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ps={WebkitMask:cr,mask:cr,background:so};for(const t in Ps){const e=Ps[t];for(const n in Fs)e[t+n]=Fs[n]}const Lu={...ro,inline:!0};function $s(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Ru=(t,e,n)=>{const r=e.inline?Lu:ro,s=Su(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Du:{}};if(n){const S=vn(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"&&wu(s,C);break;case"color":o.color=C;break;case"rotate":typeof C=="string"?s[S]=Au(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=Gc(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:Iu(Yc(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=Nu(f,{...d,width:p+"",height:m+""});return a.style={...o,"--svg":Mu(x),width:$s(d.width),height:$s(d.height),...ju,...v?cr:so,...l},k.createElement("span",a)};Xi(!0);eu("",au);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"||!_c(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;tu(n,s)||console.error(r)}catch{console.error(r)}}}}function io(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=Os(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=Os(v);if(u({name:v,data:x}))if(x===void 0){const S=vu([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?Ru({...Er,...p},t,f):t.children?t.children:t.fallback?t.fallback:k.createElement("span",{})}const Ie=k.forwardRef((t,e)=>io({...t,_ref:e}));k.forwardRef((t,e)=>io({inline:!0,...t,_ref:e}));const qn=({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(Ie,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Fu=({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(qn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(qn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(qn,{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(oe,{onPress:()=>f(!d),variant:"light",className:y.cn("text-primary",a),startContent:c.jsx(Ie,{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 oo(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 Pu(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 $u={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Gt=t=>typeof t=="number"&&!isNaN(t),Ir=({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={...$u,...o},[j,N]=k.useState(n),D=e!==void 0?e:j,L=de=>{if(a)return;const xe=Math.max(0,D+de);e===void 0&&N(xe),r?.(t.id,xe)},O=k.useMemo(()=>!Gt(t.totalTicketsSold)||!Gt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),z=k.useMemo(()=>O||!Gt(t.ticketsAllowed)?!1:D>=t.ticketsAllowed-(t.totalTicketsSold??0),[O,t.ticketsAllowed,t.totalTicketsSold,D]),H=oo(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||!Gt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const de=t.numberOfPeople===1?w.person:w.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,de,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(Ie,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",de]})},$=()=>{const de=D===0||a,xe=z||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:D,onIncrement:()=>L(1),onDecrement:()=>L(-1),isDecrementDisabled:de,isIncrementDisabled:xe,isDisabled:a}):c.jsxs("div",{className:y.cn("flex items-center gap-2",x.quantitySelector),children:[c.jsx(oe,{"data-testid":"offer-card-decrement-button",onPress:()=>L(-1),isDisabled:de,variant:u,color:D>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Ie,{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(oe,{"data-testid":"offer-card-increment-button",onPress:()=>L(1),isDisabled:xe,variant:u,color:D>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Ie,{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(Ie,{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(Ie,{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():$()})]}),ye=z&&!O&&c.jsx(Re.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(Re.AnimatePresence,{children:ye&&c.jsx(y.CardFooter,{className:y.cn("w-full mt-0 pt-0",x.footer),children:ye})})]}):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(Re.AnimatePresence,{children:ye&&c.jsx("div",{className:y.cn("w-full mt-0 pt-0",x.footer),children:ye})})]})};Ir.displayName="OfferCard";const lo=({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(Ie,{"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})};lo.displayName="OfferCardEmpty";const Vu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ao=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Vu,...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})};ao.displayName="OfferCardError";const Bu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},co=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Bu[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))})};co.displayName="OfferCardSkeleton";const uo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},fo={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"}}},zu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},ho=({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((z,H)=>{const U={...w,[z]:Math.max(0,H)};e===void 0&&C(U),r?.(U),s?.(z,U[z])},[w,e,r,s]),N=[...t].sort((z,H)=>(z.position??0)-(H.position??0)),D=zu[v],L=y.cn("grid mx-auto pt-2",D,x.base),O=z=>c.jsx(Ir,{offer:z,quantity:w[z.id]||0,onQuantityChange:j,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:p,classNames:x.card},z.id);return m?c.jsx(Re.motion.div,{"data-testid":"offer-card-list",className:L,variants:uo,initial:"hidden",animate:"show",children:c.jsx(Re.AnimatePresence,{children:N.map(z=>c.jsx(Re.motion.div,{"data-testid":`offer-card-list-item-${z.id}`,className:x.cardWrapper,variants:fo,exit:{opacity:0,y:-20},transition:{duration:.3},children:O(z)},z.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:L,children:N.map(O)})};ho.displayName="OfferCardList";var Ut=t=>t.type==="checkbox",at=t=>t instanceof Date,Ce=t=>t==null;const po=t=>typeof t=="object";var ue=t=>!Ce(t)&&!Array.isArray(t)&&po(t)&&!at(t),mo=t=>ue(t)&&t.target?Ut(t.target)?t.target.checked:t.target.value:t,_u=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,go=(t,e)=>t.has(_u(e)),Hu=t=>{const e=t.constructor&&t.constructor.prototype;return ue(e)&&e.hasOwnProperty("isPrototypeOf")},Dr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function le(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Dr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(ue(t)&&Hu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=le(t[s]));return r}var Sn=t=>/^\w*$/.test(t),re=t=>t===void 0,jr=t=>Array.isArray(t)?t.filter(Boolean):[],Lr=t=>jr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),T=(t,e,n)=>{if(!e||!ue(t))return n;const r=(Sn(e)?[e]:Lr(e)).reduce((s,i)=>Ce(s)?s:s[i],t);return re(r)||r===t?re(t[e])?n:t[e]:r},Ae=t=>typeof t=="boolean",Se=t=>typeof t=="function",ee=(t,e,n)=>{let r=-1;const s=Sn(e)?[e]:Lr(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=ue(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const hn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},je={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ze={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},yo=k.createContext(null);yo.displayName="HookFormControlContext";const Rr=()=>k.useContext(yo);var xo=(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]!==je.all&&(e._proxyFormState[o]=!r||je.all),n&&(n[o]=!0),t[o]}});return s};const Fr=typeof window<"u"?k.useLayoutEffect:k.useEffect;function Uu(t){const e=Rr(),{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 Fr(()=>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(()=>xo(o,n,a.current,!1),[o,n])}var Ee=t=>typeof t=="string",ur=(t,e,n,r,s)=>Ee(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),dr=t=>Ce(t)||!po(t);function Le(t,e,n=new WeakSet){if(dr(t)||dr(e))return Object.is(t,e);if(at(t)&&at(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(at(o)&&at(l)||ue(o)&&ue(l)||Array.isArray(o)&&Array.isArray(l)?!Le(o,l,n):!Object.is(o,l))return!1}}return!0}function qu(t){const e=Rr(),{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=ur(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=ur(r,n._names,N||n._formValues,!1,a.current);if(u.current){const L=u.current(D);Le(L,d.current)||(v(L),d.current=L)}else v(D)}},[n._formValues,n._names,i,r]);Fr(()=>((f.current!==n||!Le(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&&!Le(w,r);return C||N?x():null},[i,C,r,w,x]);return j!==null?j:m}function Ku(t){const e=Rr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=go(s._names.array,n),u=k.useMemo(()=>T(s._formValues,n,T(s._defaultValues,n,o)),[s,n,o]),d=qu({control:s,name:n,defaultValue:u,exact:l}),f=Uu({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,...Ae(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:mo(N),name:n},type:hn.CHANGE}),[n]),C=k.useCallback(()=>v.current.onBlur({target:{value:T(s._formValues,n),name:n},type:hn.BLUR}),[n,s._formValues]),w=k.useCallback(N=>{const D=T(s._fields,n);D&&D._f&&N&&(D._f.ref={focus:()=>Se(N.focus)&&N.focus(),select:()=>Se(N.select)&&N.select(),setCustomValidity:L=>Se(N.setCustomValidity)&&N.setCustomValidity(L),reportValidity:()=>Se(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),j=k.useMemo(()=>({name:n,value:d,...Ae(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,...Ae(p.current.disabled)?{disabled:p.current.disabled}:{}});const L=(O,z)=>{const H=T(s._fields,O);H&&H._f&&(H._f.mount=z)};if(L(n,!0),N){const O=le(T(s._options.defaultValues,n,p.current.defaultValue));ee(s._defaultValues,n,O),re(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 Ju=k.createContext(null);Ju.displayName="HookFormContext";var Wu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},jt=t=>Array.isArray(t)?t:[t],Vs=()=>{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 bo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&ue(s)&&i){const o=bo(s,i);ue(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ke=t=>ue(t)&&!Object.keys(t).length,Pr=t=>t.type==="file",pn=t=>{if(!Dr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ko=t=>t.type==="select-multiple",$r=t=>t.type==="radio",Gu=t=>$r(t)||Ut(t),Kn=t=>pn(t)&&t.isConnected;function Zu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=re(t)?r++:t[e[r++]];return t}function Qu(t){for(const e in t)if(t.hasOwnProperty(e)&&!re(t[e]))return!1;return!0}function ae(t,e){const n=Array.isArray(e)?e:Sn(e)?[e]:Lr(e),r=n.length===1?t:Zu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ue(r)&&ke(r)||Array.isArray(r)&&Qu(r))&&ae(t,n.slice(0,-1)),t}var Xu=t=>{for(const e in t)if(Se(t[e]))return!0;return!1};function vo(t){return Array.isArray(t)||ue(t)&&!Xu(t)}function fr(t,e={}){for(const n in t){const r=t[n];vo(r)?(e[n]=Array.isArray(r)?[]:{},fr(r,e[n])):re(r)||(e[n]=!0)}return e}function bt(t,e,n){n||(n=fr(e));for(const r in t){const s=t[r];if(vo(s))re(e)||dr(n[r])?n[r]=fr(s,Array.isArray(s)?[]:{}):bt(s,Ce(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Le(s,i)}}return n}const Bs={value:!1,isValid:!1},zs={value:!0,isValid:!0};var So=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&&!re(t[0].attributes.value)?re(t[0].value)||t[0].value===""?zs:{value:t[0].value,isValid:!0}:zs:Bs}return Bs},Co=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>re(t)?t:e?t===""?NaN:t&&+t:n&&Ee(t)?new Date(t):r?r(t):t;const _s={isValid:!1,value:null};var wo=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,_s):_s;function Hs(t){const e=t.ref;return Pr(e)?e.files:$r(e)?wo(t.refs).value:ko(e)?[...e.selectedOptions].map(({value:n})=>n):Ut(e)?So(t.refs).value:Co(re(e.value)?t.ref.value:e.value,t)}var Yu=(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}},mn=t=>t instanceof RegExp,Tt=t=>re(t)?t:mn(t)?t.source:ue(t)?mn(t.value)?t.value.source:t.value:t,Us=t=>({isOnSubmit:!t||t===je.onSubmit,isOnBlur:t===je.onBlur,isOnChange:t===je.onChange,isOnAll:t===je.all,isOnTouch:t===je.onTouched});const qs="AsyncFunction";var ed=t=>!!t&&!!t.validate&&!!(Se(t.validate)&&t.validate.constructor.name===qs||ue(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===qs)),td=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Ks=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Lt=(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(Lt(l,e))break}else if(ue(l)&&Lt(l,e))break}}};function Js(t,e,n){const r=T(t,n);if(r||Sn(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 nd=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ke(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||je.all))},rd=(t,e,n)=>!t||!e||t===e||jt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),sd=(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,id=(t,e)=>!jr(T(t,e)).length&&ae(t,e),od=(t,e,n)=>{const r=jt(T(t,n));return ee(r,"root",e[n]),ee(t,n,r),t};function Ws(t,e,n="validate"){if(Ee(t)||Array.isArray(t)&&t.every(Ee)||Ae(t)&&!t)return{type:n,message:Ee(t)?t:"",ref:e}}var gt=t=>ue(t)&&!mn(t)?t:{value:t,message:""},Gs=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(Ae(M)?"":M||""),j.reportValidity())},D={},L=$r(o),O=Ut(o),z=L||O,H=(S||Pr(o))&&re(o.value)&&re(w)||pn(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,U=Wu.bind(null,x,r,D),P=(M,F,$,B=ze.maxLength,Y=ze.minLength)=>{const W=M?F:$;D[x]={type:M?B:Y,message:W,ref:o,...U(M?B:Y,W)}};if(i?!Array.isArray(w)||!w.length:a&&(!z&&(H||Ce(w))||Ae(w)&&!w||O&&!So(l).isValid||L&&!wo(l).isValid)){const{value:M,message:F}=Ee(a)?{value:!!a,message:a}:gt(a);if(M&&(D[x]={type:ze.required,message:F,ref:j,...U(ze.required,F)},!r))return N(F),D}if(!H&&(!Ce(f)||!Ce(p))){let M,F;const $=gt(p),B=gt(f);if(!Ce(w)&&!isNaN(w)){const Y=o.valueAsNumber||w&&+w;Ce($.value)||(M=Y>$.value),Ce(B.value)||(F=Y<B.value)}else{const Y=o.valueAsDate||new Date(w),W=xe=>new Date(new Date().toDateString()+" "+xe),ye=o.type=="time",de=o.type=="week";Ee($.value)&&w&&(M=ye?W(w)>W($.value):de?w>$.value:Y>new Date($.value)),Ee(B.value)&&w&&(F=ye?W(w)<W(B.value):de?w<B.value:Y<new Date(B.value))}if((M||F)&&(P(!!M,$.message,B.message,ze.max,ze.min),!r))return N(D[x].message),D}if((u||d)&&!H&&(Ee(w)||i&&Array.isArray(w))){const M=gt(u),F=gt(d),$=!Ce(M.value)&&w.length>+M.value,B=!Ce(F.value)&&w.length<+F.value;if(($||B)&&(P($,M.message,F.message),!r))return N(D[x].message),D}if(m&&!H&&Ee(w)){const{value:M,message:F}=gt(m);if(mn(M)&&!w.match(M)&&(D[x]={type:ze.pattern,message:F,ref:o,...U(ze.pattern,F)},!r))return N(F),D}if(v){if(Se(v)){const M=await v(w,n),F=Ws(M,j);if(F&&(D[x]={...F,...U(ze.validate,F.message)},!r))return N(F.message),D}else if(ue(v)){let M={};for(const F in v){if(!ke(M)&&!r)break;const $=Ws(await v[F](w,n),j,F);$&&(M={...$,...U(F,$.message)},N($.message),r&&(D[x]=M))}if(!ke(M)&&(D[x]={ref:j,...M},!r))return D}}return N(!0),D};const ld={mode:je.onSubmit,reValidateMode:je.onChange,shouldFocusError:!0};function ad(t={}){let e={...ld,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Se(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=ue(e.defaultValues)||ue(e.values)?le(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:le(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:Vs(),state:Vs()},v=e.criteriaMode===je.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=ke((await z()).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):ae(n.validatingFields,b))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ke(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 V=b(T(r,h),I.argA,I.argB);E&&ee(r,h,V)}if(A&&Array.isArray(T(n.errors,h))){const V=b(T(n.errors,h),I.argA,I.argB);E&&ee(n.errors,h,V),id(n.errors,h)}if((f.touchedFields||p.touchedFields)&&A&&Array.isArray(T(n.touchedFields,h))){const V=b(T(n.touchedFields,h),I.argA,I.argB);E&&ee(n.touchedFields,h,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=bt(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,re(b)?T(s,h):b);re(A)||I&&I.defaultChecked||g?ee(i,h,g?A:Hs(E._f)):B(h,A),o.mount&&!o.action&&S()}},L=(h,g,b,I,E)=>{let A=!1,V=!1;const G={name:h};if(!e.disabled){if(!b||I){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=G.isDirty=M(),A=V!==G.isDirty);const Z=Le(T(s,h),g);V=!!T(n.dirtyFields,h),Z?ae(n.dirtyFields,h):ee(n.dirtyFields,h,!0),G.dirtyFields=n.dirtyFields,A=A||(f.dirtyFields||p.dirtyFields)&&V!==!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)&&Ae(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):ae(n.errors,h)),(b?!Le(E,b):E)||!ke(I)||A){const V={...I,...A&&Ae(g)?{isValid:g}:{},errors:n.errors,name:h};n={...n,...V},m.state.next(V)}},z=async h=>(C(h,!0),await e.resolver(i,e.context,Yu(h||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),H=async h=>{const{errors:g}=await z(h);if(C(h),h)for(const b of h){const I=T(g,b);I?ee(n.errors,b,I):ae(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,...V}=E;if(A){const G=l.array.has(A.name),Z=E._f&&ed(E._f);Z&&f.validatingFields&&C([A.name],!0);const be=await Gs(E,l.disabled,i,v,e.shouldUseNativeValidation&&!g,G);if(Z&&f.validatingFields&&C([A.name]),be[A.name]&&(b.valid=!1,g||t.shouldUseNativeValidation))break;!g&&(T(be,A.name)?G?od(n.errors,be,A.name):ee(n.errors,A.name,be[A.name]):ae(n.errors,A.name))}!ke(V)&&await U(V,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=>!Kn(b)):!Kn(g._f.ref))&&wn(h)}l.unMount=new Set},M=(h,g)=>!e.disabled&&(h&&g&&ee(i,h,g),!Le(qe(),s)),F=(h,g,b)=>ur(h,l,{...o.mount?i:re(g)?s:Ee(h)?{[h]:g}:g},b,g),$=h=>jr(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,Co(g,A)),E=pn(A.ref)&&Ce(g)?"":g,ko(A.ref)?[...A.ref.options].forEach(V=>V.selected=E.includes(V.value)):A.refs?Ut(A.ref)?A.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(E)?V.checked=!!E.find(G=>G===V.value):V.checked=E===V.value||!!E)}):A.refs.forEach(V=>V.checked=V.value===E):Pr(A.ref)?A.ref.value="":(A.ref.value=E,A.ref.type||m.state.next({name:h,values:le(i)})))}(b.shouldDirty||b.shouldTouch)&&L(h,E,b.shouldTouch,b.shouldDirty,!0),b.shouldValidate&&xe(h)},Y=(h,g,b)=>{for(const I in g){if(!g.hasOwnProperty(I))return;const E=g[I],A=h+"."+I,V=T(r,A);(l.array.has(h)||ue(E)||V&&!V._f)&&!at(E)?Y(A,E,b):B(A,E,b)}},W=(h,g,b={})=>{const I=T(r,h),E=l.array.has(h),A=le(g);ee(i,h,A),E?(m.array.next({name:h,values:le(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&b.shouldDirty&&m.state.next({name:h,dirtyFields:bt(s,i),isDirty:M(h,A)})):I&&!I._f&&!Ce(A)?Y(h,A,b):B(h,A,b),Ks(h,l)?m.state.next({...n,name:h,values:le(i)}):m.state.next({name:o.mount?h:void 0,values:le(i)})},ye=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)||at(Z)&&isNaN(Z.getTime())||Le(Z,T(i,b,Z))},V=Us(e.mode),G=Us(e.reValidateMode);if(E){let Z,be;const tt=g.type?Hs(E._f):mo(h),Ke=h.type===hn.BLUR||h.type===hn.FOCUS_OUT,jo=!td(E._f)&&!e.resolver&&!T(n.errors,b)&&!E._f.deps||sd(Ke,T(n.touchedFields,b),n.isSubmitted,G,V),En=Ks(b,l,Ke);ee(i,b,tt),Ke?(!g||!g.readOnly)&&(E._f.onBlur&&E._f.onBlur(h),a&&a(0)):E._f.onChange&&E._f.onChange(h);const Tn=L(b,tt,Ke),Lo=!ke(Tn)||En;if(!Ke&&m.state.next({name:b,type:h.type,values:le(i)}),jo)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Ke&&S():Ke||S()),Lo&&m.state.next({name:b,...En?{}:Tn});if(!Ke&&En&&m.state.next({...n}),e.resolver){const{errors:qr}=await z([b]);if(C([b]),A(tt),I){const Ro=Js(n.errors,r,b),Kr=Js(qr,r,Ro.name||b);Z=Kr.error,b=Kr.name,be=ke(qr)}}else C([b],!0),Z=(await Gs(E,l.disabled,i,v,e.shouldUseNativeValidation))[b],C([b]),A(tt),I&&(Z?be=!1:(f.isValid||p.isValid)&&(be=await U(r,!0)));I&&(E._f.deps&&(!Array.isArray(E._f.deps)||E._f.deps.length>0)&&xe(E._f.deps),O(b,be,Z,Tn))}},de=(h,g)=>{if(T(n.errors,g)&&h.focus)return h.focus(),1},xe=async(h,g={})=>{let b,I;const E=jt(h);if(e.resolver){const A=await H(re(h)?h:E);b=ke(A),I=h?!E.some(V=>T(A,V)):b}else h?(I=(await Promise.all(E.map(async A=>{const V=T(r,A);return await U(V&&V._f?{[A]:V}:V)}))).every(Boolean),!(!I&&!n.isValid)&&S()):I=b=await U(r);return m.state.next({...!Ee(h)||(f.isValid||p.isValid)&&b!==n.isValid?{}:{name:h},...e.resolver||!h?{isValid:b}:{},errors:n.errors}),g.shouldFocus&&!I&&Lt(r,de,h?E:l.mount),I},qe=(h,g)=>{let b={...o.mount?i:s};return g&&(b=bo(g.dirtyFields?n.dirtyFields:n.touchedFields,b)),re(h)?b:Ee(h)?T(b,h):h.map(I=>T(b,I))},pt=(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)}),Ct=h=>{h&&jt(h).forEach(g=>ae(n.errors,g)),m.state.next({errors:h?n.errors:{}})},ne=(h,g,b)=>{const I=(T(r,h,{_f:{}})._f||{}).ref,E=T(n.errors,h)||{},{ref:A,message:V,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()},we=(h,g)=>Se(h)?m.state.subscribe({next:b=>"values"in b&&h(F(void 0,g),b)}):F(h,g,!0),wt=h=>m.state.subscribe({next:g=>{rd(h.name,g.name,h.exact)&&nd(g,h.formState||f,Do,h.reRenderRoot)&&h.callback({values:{...i},...n,...g,defaultValues:s})}}).unsubscribe,Cn=h=>(o.mount=!0,p={...p,...h.formState},wt({...h,formState:{...d,...h.formState}})),wn=(h,g={})=>{for(const b of h?jt(h):l.mount)l.mount.delete(b),l.array.delete(b),g.keepValue||(ae(r,b),ae(i,b)),!g.keepError&&ae(n.errors,b),!g.keepDirty&&ae(n.dirtyFields,b),!g.keepTouched&&ae(n.touchedFields,b),!g.keepIsValidating&&ae(n.validatingFields,b),!e.shouldUnregister&&!g.keepDefaultValue&&ae(s,b);m.state.next({values:le(i)}),m.state.next({...n,...g.keepDirty?{isDirty:M()}:{}}),!g.keepIsValid&&S()},Br=({disabled:h,name:g})=>{if(Ae(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()}},An=(h,g={})=>{let b=T(r,h);const I=Ae(g.disabled)||Ae(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?Br({disabled:Ae(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:Tt(g.min),max:Tt(g.max),minLength:Tt(g.minLength),maxLength:Tt(g.maxLength),pattern:Tt(g.pattern)}:{},name:h,onChange:ye,onBlur:ye,ref:E=>{if(E){An(h,g),b=T(r,h);const A=re(E.value)&&E.querySelectorAll&&E.querySelectorAll("input,select,textarea")[0]||E,V=Gu(A),G=b._f.refs||[];if(V?G.find(Z=>Z===A):A===b._f.ref)return;ee(r,h,{_f:{...b._f,...V?{refs:[...G.filter(Kn),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)&&!(go(l.array,h)&&o.action)&&l.unMount.add(h)}}},Nn=()=>e.shouldFocusError&&Lt(r,de,l.mount),Mo=h=>{Ae(h)&&(m.state.next({disabled:h}),Lt(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))},zr=(h,g)=>async b=>{let I;b&&(b.preventDefault&&b.preventDefault(),b.persist&&b.persist());let E=le(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:A,values:V}=await z();C(),n.errors=A,E=le(V)}else await U(r);if(l.disabled.size)for(const A of l.disabled)ae(E,A);if(ae(n.errors,"root"),ke(n.errors)){m.state.next({errors:{}});try{await h(E,b)}catch(A){I=A}}else g&&await g({...n.errors},b),Nn(),setTimeout(Nn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ke(n.errors)&&!I,submitCount:n.submitCount+1,errors:n.errors}),I)throw I},Oo=(h,g={})=>{T(r,h)&&(re(g.defaultValue)?W(h,le(T(s,h))):(W(h,g.defaultValue),ee(s,h,le(g.defaultValue))),g.keepTouched||ae(n.touchedFields,h),g.keepDirty||(ae(n.dirtyFields,h),n.isDirty=g.defaultValue?M(h,le(T(s,h))):M()),g.keepError||(ae(n.errors,h),f.isValid&&S()),m.state.next({...n}))},_r=(h,g={})=>{const b=h?le(h):s,I=le(b),E=ke(h),A=E?s:I;if(g.keepDefaultValues||(s=b),!g.keepValues){if(g.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(bt(s,i))]);for(const G of Array.from(V)){const Z=T(n.dirtyFields,G),be=T(i,G),tt=T(A,G);Z&&!re(be)?ee(A,G,be):!Z&&!re(tt)&&W(G,tt)}}else{if(Dr&&re(h))for(const V of l.mount){const G=T(r,V);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(pn(Z)){const be=Z.closest("form");if(be){be.reset();break}}}}if(g.keepFieldsRef)for(const V of l.mount)W(V,T(A,V));else r={}}i=e.shouldUnregister?g.keepDefaultValues?le(s):{}:le(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&&!ke(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&&!Le(h,s)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:E?{}:g.keepDirtyValues?g.keepDefaultValues&&i?bt(s,i):n.dirtyFields:g.keepDefaultValues&&h?bt(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})},Hr=(h,g)=>_r(Se(h)?h(i):h,{...e.resetOptions,...g}),Io=(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&&Se(E.select)&&E.select()})}},Do=h=>{n={...n,...h}},Ur={control:{register:An,unregister:wn,getFieldState:pt,handleSubmit:zr,setError:ne,_subscribe:wt,_runSchema:z,_updateIsValidating:C,_focusError:Nn,_getWatch:F,_getDirty:M,_setValid:S,_setFieldArray:w,_setDisabledField:Br,_setErrors:N,_getFieldArray:$,_reset:_r,_resetDefaultValues:()=>Se(e.defaultValues)&&e.defaultValues().then(h=>{Hr(h,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:Mo,_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:Cn,trigger:xe,register:An,handleSubmit:zr,watch:we,setValue:W,getValues:qe,reset:Hr,resetField:Oo,clearErrors:Ct,unregister:wn,setError:ne,setFocus:Io,getFieldState:pt};return{...Ur,formControl:Ur}}function cd(t={}){const e=k.useRef(void 0),n=k.useRef(void 0),[r,s]=k.useState({isDirty:!1,isValidating:!1,isLoading:Se(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:Se(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!Se(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=ad(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,Fr(()=>{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&&!Le(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(()=>xo(r,i),[i,r]),e.current}function ud(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function dd(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 fd(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 hd(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 pd(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 Vr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Vr();const md={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:"$"},Jn=()=>({id:Vr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ao=({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={...md,...m},N=S!==void 0&&C!==void 0,D=cd({defaultValues:{_internal:e||Jn()}}),L=Ku({control:N?S:D.control,name:N?C:"_internal",rules:N?w:void 0}),[O,z]=k.useState(e||Jn()),H=N?L.field.value??Jn():t??O,U=N&&!!L.fieldState?.error,P=N&&(L.fieldState?.isTouched??!1),M=U||P,F=M&&(!H.amount||H.amount<=0),$=M&&!H.glAccount,[B,Y]=k.useState(H.glAccount?.name||""),W=k.useCallback(ne=>{const we={...H,...ne};N&&L.field.onChange(we),!N&&t===void 0&&z(we),i?.(we)},[H,t,i,N,L]),ye=k.useCallback(ne=>{const we=ne||0;W({amount:we}),o?.(we)},[W,o]),de=k.useCallback(ne=>{Y(ne),s?.(ne)},[s]),xe=k.useCallback(ne=>{if(ne===null){W({glAccount:null}),l?.(null);return}const wt=n.find(Cn=>String(Cn.id)===String(ne))||null;W({glAccount:wt}),l?.(wt)},[n,W,l]),qe=k.useCallback(()=>{Y(""),W({glAccount:null}),l?.(null)},[W,l]),pt=k.useCallback(ne=>{W({isTaxDeductible:ne}),a?.(ne)},[W,a]),Ct=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(Ie,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:H.amount||void 0,onValueChange:ye,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(Ie,{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:$,errorMessage:$?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:de,onSelectionChange:xe,onClear:qe,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:H.isTaxDeductible,onValueChange:pt,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:y.cn("shrink-0 pt-6",v.deleteContainer),children:c.jsx(oe,{"data-testid":`${x||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!d,onPress:Ct,startContent:c.jsx(Ie,{icon:"solar:trash-bin-trash-linear",width:16}),className:y.cn("text-danger",v.deleteButton),children:j.deleteButton})})]})})};Ao.displayName="RevenueDistributionCard";const No=({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(Ie,{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})};No.displayName="RevenueDistributionEmpty";const gd={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Eo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...gd,...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})};Eo.displayName="RevenueDistributionError";const To=({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))})};To.displayName="RevenueDistributionSkeleton";exports.Button=oe;exports.ConfirmationPageTemplate=Wo;exports.DonationAmounts=qi;exports.EventDetails=Fu;exports.EventDetailsTemplate=Qo;exports.ExpireCartTimer=Ki;exports.Footer=Xo;exports.HeroUIProvider=Ho;exports.Multiselect=Yo;exports.Navbar=Jo;exports.OfferCard=Ir;exports.OfferCardEmpty=lo;exports.OfferCardError=ao;exports.OfferCardList=ho;exports.OfferCardSkeleton=co;exports.RICH_TEXT_PRESETS=Hi;exports.RevenueDistributionCard=Ao;exports.RevenueDistributionEmpty=No;exports.RevenueDistributionError=Eo;exports.RevenueDistributionSkeleton=To;exports.RichTextArea=Ui;exports.Stepper=Zs;exports.calculateAllocationDifference=pd;exports.formatOfferCurrency=oo;exports.formatRevenueAmount=ud;exports.formatRevenueCurrency=dd;exports.generateDistributionId=Vr;exports.getCurrencySymbol=fd;exports.offerCardVariants=fo;exports.offerListVariants=uo;exports.parseOfferCurrency=Pu;exports.parseRevenueCurrency=hd;Object.keys(y).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>y[t]})});
|
|
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,C=gn.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let k=o.appendChild(document.createElement("p"));b&&k.appendChild(C.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=Ka(n),kr&&Ja(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")||tn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Ha.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Wa(ws(l,+d[1],+d[2]),d[4]);else if(l=K.maxOpen(Ua(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=ws(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Ha=/^(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 Ua(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&&Oi(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ii(o[o.length-1],i.length));let d=Mi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return q.from(o)}return t}function Mi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function Oi(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Oi(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(Mi(n,t,s+1))))}}function Ii(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ii(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function rr(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=rr(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 ws(t,e,n){return e<t.openStart&&(t=new K(rr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(rr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Di={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 As=null;function ji(){return As||(As=document.implementation.createHTMLDocument("title"))}let _n=null;function qa(t){let e=window.trustedTypes;return e?(_n||(_n=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_n.createHTML(t)):t}function Ka(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ji().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Di[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=qa(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ja(t){let e=t.querySelectorAll(Ue?"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 Wa(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 Fe={},Te={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Te.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ri(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ht&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&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,bi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_a(t,n)?n.preventDefault():Qe(t,"key")};Te.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Te.keypress=(t,e)=>{let n=e;if(Ri(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&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 kn(t){return{left:t.clientX,top:t.clientY}}function Ga(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Sr(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 vt(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 Za(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(vt(t,new J(n)),!0):!1}function Qa(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?(vt(t,J.create(t.state.doc,s)),!0):!1}function Xa(t,e,n,r,s){return Sr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Qa(t,n):Za(t,n))}function Ya(t,e,n,r){return Sr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function ec(t,e,n,r){return Sr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||tc(t,n,r)}function tc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vt(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)vt(t,Q.create(r,l+1,l+1+o.content.size));else if(J.isSelectable(o))vt(t,J.create(r,l));else continue;return!0}}function Cr(t){return cn(t)}const Li=Me?"metaKey":"ctrlKey";Fe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ga(n,t.input.lastClick)&&!n[Li]&&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(kn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new nc(t,o,n,!!r)):(i=="doubleClick"?Ya:ec)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class nc{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[Li],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&&bn&&!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)),Qe(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(()=>vr(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(kn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):Xa(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ht&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!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)?(vt(this.view,X.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Qe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qe(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)}}Fe.touchstart=t=>{t.input.lastTouch=Date.now(),Cr(t),Qe(t,"pointer")};Fe.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Fe.contextmenu=t=>Cr(t);function Ri(t,e){return t.composing?!0:ht&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const rc=Ht?5e3:-1;Te.compositionstart=Te.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)||Ue&&Ci&&sc(t)))t.markCursor=t.state.storedMarks||n.marks(),cn(t,!0),t.markCursor=null;else if(cn(t,!e.selection.empty),bn&&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}Fi(t,rc)};function sc(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"}Te.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++,Fi(t,20))};function Fi(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>cn(t),e))}function ic(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=oc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function oc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function cn(t,e=!1){if(!(Ht&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ic(t),e||t.docView&&t.docView.dirty){let n=Ia(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 lc(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 Vt=_t&&vi<15||br&&Oa<604;Fe.copy=Te.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Vt?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Ei(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):lc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function cc(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?sr(t,r.value,null,s,e):sr(t,r.textContent,r.innerHTML,s,e)},50)}function sr(t,e,n,r,s){let i=Ti(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=ac(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 Pi(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," "):""}Te.paste=(t,e)=>{let n=e;if(t.composing&&!Ht)return;let r=Vt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sr(t,Pi(r),r.getData("text/html"),s,n)?n.preventDefault():cc(t,n)};class uc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const dc=Me?"altKey":"ctrlKey";function $i(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[dc]}Fe.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(kn(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}=Ei(t,l);(!n.dataTransfer.files.length||!Ue||Si>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vt||n.dataTransfer.setData("text/plain",u),t.dragging=new uc(d,$i(t,n),o)};Fe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Te.dragover=Te.dragenter=(t,e)=>e.preventDefault();Te.drop=(t,e)=>{try{fc(t,e,t.dragging)}finally{t.dragging=null}};function fc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kn(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=Ti(t,Pi(e.dataTransfer),Vt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&$i(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?ui(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((C,b,k,S)=>m=S),a.setSelection(Ai(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Fe.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())&&vr(t)},20))};Fe.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)};Fe.beforeinput=(t,e)=>{if(Ue&&Ht&&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,bi(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 Te)Fe[t]=Te[t];function Bt(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 un{constructor(e,n){this.toDOM=e,this.spec=n||ut,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 $e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof un&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xe{constructor(e,n){this.attrs=e,this.spec=n||ut}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 $e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class wr{constructor(e,n){this.attrs=e,this.spec=n||ut}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 $e(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 wr&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class $e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new $e(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 $e(e,e,new un(n,r))}static inline(e,n,r,s){return new $e(e,n,new Xe(r,s))}static node(e,n,r,s){return new $e(e,n,new wr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof un}}const xt=[],ut={};class fe{constructor(e,n){this.local=e.length?e:xt,this.children=n.length?n:xt}static create(e,n){return n.length?dn(n,e,0,ut):ve}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==ve||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}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?hc(this.children,o||[],e,n,r,s,i):o?new fe(o.sort(dt),xt):ve}add(e,n){return n.length?this==ve?fe.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=Bi(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,dn(d,l,u+1,ut)),i+=3}});let o=Vi(i?zi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new fe(o.length?this.local.concat(o).sort(dt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?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!=ve?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 fe(s,r):ve}forChild(e,n){if(this==ve)return this;if(n.isLeaf)return fe.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 Xe){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 fe(s.sort(dt),xt);return r?new st([l,r]):l}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof fe)||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 Ar(this.localsInner(e))}localsInner(e){if(this==ve)return xt;if(e.inlineContent||!this.local.some(Xe.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Xe||n.push(this.local[r]);return n}forEachSet(e){e(this)}}fe.empty=new fe([],[]);fe.removeOverlap=Ar;const ve=fe.empty;class st{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return st.from(r)}forChild(e,n){if(n.isLeaf)return fe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ve&&(i instanceof st?r=r.concat(i.members):r.push(i))}return st.from(r)}eq(e){if(!(e instanceof st)||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?Ar(r?n:n.sort(dt)):xt}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new st(e.every(n=>n instanceof fe)?e:e.reduce((n,r)=>n.concat(r instanceof fe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function hc(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,C,b)=>{let k=b-C-(m-p);for(let S=0;S<l.length;S+=3){let w=l[S+1];if(w<0||p>w+d-f)continue;let j=l[S]+d-f;m>=j?l[S+1]=p<=j?-2:-1:p>=d&&k&&(l[S]+=k,l[S+1]+=k)}f+=k}),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:C,offset:b}=r.content.findIndex(f),k=r.maybeChild(C);if(k&&b==f&&b+k.nodeSize==m){let S=l[u+2].mapInner(n,k,d+1,t[u]+i+1,o);S!=ve?(l[u]=f,l[u+1]=m,l[u+2]=S):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=pc(l,t,e,n,s,i,o),d=dn(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 fe(e.sort(dt),l)}function Vi(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 $e(s.from+e,s.to+e,s.type))}return n}function pc(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 Bi(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 zi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function dn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Bi(t,l,a+n);if(u){i=!0;let d=dn(u,l,n+a+1,r);d!=ve&&s.push(a,a+l.nodeSize,d)}});let o=Vi(i?zi(t):t,-n).sort(dt);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 fe(o,s):ve}function dt(t,e){return t.from-e.from||t.to-e.to}function Ar(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),Ns(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),Ns(e,s,r.copy(i.from,r.to)));break}}}return e}function Ns(t,e,n){for(;e<t.length&&dt(n,t[e])>0;)e++;t.splice(e,0,n)}class ie extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ie.valid(r)?new ie(r):X.near(r)}content(){return K.empty}eq(e){return e instanceof ie&&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 ie(e.resolve(n.pos))}getBookmark(){return new Nr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!mc(e)||!gc(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&&ie.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(ie.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(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;X.jsonID("gapcursor",ie);class Nr{constructor(e){this.pos=e}map(e){return new Nr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ie.valid(n)?new ie(n):X.near(n)}}function _i(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function mc(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 gc(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 yc(){return new xn({props:{decorations:vc,createSelectionBetween(t,e,n){return e.pos==n.pos&&ie.valid(n)?new ie(n):null},handleClick:bc,handleKeyDown:xc,handleDOMEvents:{beforeinput:kc}}})}const xc=Ea({ArrowLeft:Wt("horiz",-1),ArrowRight:Wt("horiz",1),ArrowUp:Wt("vert",-1),ArrowDown:Wt("vert",1)});function Wt(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=ie.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new ie(u))),!0):!1}}function bc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ie.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 ie(r))),!0)}function kc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ie))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 vc(t){if(!(t.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",fe.create(t.doc,[$e.widget(t.selection.head,e,{key:"gapcursor"})])}const Sc=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[yc()]},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}}}),At={bold:{category:"mark",extension:kl,priority:100},italic:{category:"mark",extension:Al,priority:100},strike:{category:"mark",extension:Tl,priority:100},underline:{category:"mark",extension:Fo.Underline,priority:100},code:{category:"mark",extension:Il,priority:100},textColor:{category:"mark",extension:Po.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:$o.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Vo.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ll,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Pl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Vl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Bo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ta,priority:100},blockquote:{category:"node",extension:ra,priority:100},horizontalRule:{category:"node",extension:sa,priority:100},hardBreak:{category:"node",extension:ia,priority:100},undo:{category:"extension",extension:fs,priority:50},redo:{category:"extension",extension:fs,priority:50},textAlign:{category:"extension",extension:_o.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},Cc=[ma,ga,Rl,jl.configure({HTMLAttributes:{}}),Bl.configure({HTMLAttributes:{}}),zo.TaskItem.configure({nested:!0}),ba,Sc];function wc(t){const e=[],n=new Set,r=new Set;Cc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Rt(l)),i=new Set;return s.forEach(l=>{const a=At[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=At[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=At[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(At).find(m=>m?.extension?.name===l.name),d=Object.values(At).find(m=>m?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Hi={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"]},se={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Je={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},te={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Ac={h1:`font-size: ${se.fontSize["4xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h2:`font-size: ${se.fontSize["2xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h3:`font-size: ${se.fontSize.xl}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h4:`font-size: ${se.fontSize.lg}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h5:`font-size: ${se.fontSize.base}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h6:`font-size: ${se.fontSize.sm}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,p:`min-height: ${se.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,li:`display: list-item; margin: ${te.xs} 0;`,strong:`font-weight: ${se.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Je.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${se.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${se.fontFamily.mono};`,pre:`background: ${Je.neutral.gray[800]}; border-radius: ${te.sm}; color: ${Je.neutral.gray[100]}; font-family: ${se.fontFamily.mono}; margin: ${te.lg} 0; padding: 0.75rem ${te.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Je.neutral.gray[300]}; margin: ${te.lg} 0; padding-left: ${te.md}; color: ${Je.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Je.neutral.gray[200]}; margin: ${te.xl} 0;`,a:`color: ${Je.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Je.palettes.warning[200]}; border-radius: ${te.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${te.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Nc={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function Ec(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Nc)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");e=e.replace(s,(i,o)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${o} style="${r}">`)}for(const[n,r]of Object.entries(Ac)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");e=e.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return 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 Tc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=hr.useCurrentEditor();return c.jsx(ml,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Mc=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=hr.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"]})]})},ir=v.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Hi.full,variant:u="bordered",initialContent:d,content:f,onContentChange:p,onUpdate:m,onToolbarAction:C,isReadOnly:b=!1,isDisabled:k=!1,includeInlineStyles:S=!0,...w}=t,{zoom:j,setZoom:N}=fl(),D=Jr.lineHeight,L=n*D,O=s?void 0:r*D,z=v.useMemo(()=>wc(a),[a]),{Component:H,label:U,shouldLabelBeOutside:P,getBaseProps:M,getLabelProps:F,getInputWrapperProps:$}=y.useInput({...w,variant:u,ref:e,isMultiline:!0}),B=U?c.jsx("label",{...F(),children:U}):null,Y=v.useCallback(({editor:W})=>{const ye=W.getHTML(),de=S?Ec(ye):ye,xe=W.getJSON(),qe=W.getText(),pt=qe.length,Ct=qe.split(/\s+/).filter(we=>we.length>0).length,ne={html:de,json:xe,text:qe,characters:pt,words:Ct};if(p?.(ne),m?.(ne),"onChange"in w&&typeof w.onChange=="function"){const we={target:{value:de},currentTarget:{value:de}};w.onChange(we)}},[p,m,w,S]);return c.jsxs(H,{...M(),children:[P?B:null,c.jsx("div",{...$(),className:y.cn($().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:O?`${O+Jr.toolbarHeight}px`:void 0,overflow:O?"auto":void 0},children:c.jsx(hr.EditorProvider,{editable:!b&&!k,slotBefore:l?c.jsx(Tc,{modifiers:a,zoom:j,onZoomChange:N,onToolbarAction:C}):void 0,slotAfter:c.jsx(Mc,{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:z,content:f||d||t.defaultValue||"",onUpdate:Y})})]})});ir.displayName="TipTapEditor";const Ui=v.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(ir,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(ir,{...s,variant:r,ref:e}))});Ui.displayName="RichTextArea";function Oc(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 Es=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Ic={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},qi=({presetAmounts:t=Es,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:C="default",inputVariant:b="bordered",className:k="",showCard:S=!0})=>{const w={...Ic,...u},j=Array.isArray(t)?t:Es,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,z]=pr(e,n,r),[H,U]=v.useState(""),P=v.useCallback(B=>{if(p)return;const Y={amount:B.amount,isCustom:!1,presetId:B.id};z(Y),U("")},[p,z]),M=v.useCallback(B=>{if(p)return;if(U(B!==void 0?String(B):""),B===void 0||isNaN(B)){z(null);return}z({amount:B,isCustom:!0})},[p,z]),F=v.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),$=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(oe,{color:Y?"primary":C,variant:Y?"solid":m,className:"w-full",onPress:()=>P(B),isDisabled:p,"data-testid":`donation-amounts-preset-${B.id}`,children:B.label||Oc(B.amount,i,s)},B.id)})}),o&&c.jsx(y.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,variant:b,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 S?c.jsx(y.Card,{className:y.cn("w-full",k),"data-testid":"donation-amounts-card",children:c.jsx(y.CardBody,{children:$})}):c.jsx("div",{className:y.cn("w-full",k),"data-testid":"donation-amounts-plain",children:$})};qi.displayName="DonationAmounts";const Dc=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`},jc=t=>{switch(t){case"warning":return _.Clock;case"error":return _.AlertCircle;case"success":return _.CheckCircle;default:return _.Clock}},Lc=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"}},Ki=v.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=Dc,className:p,...m},C)=>{const[b,k]=pr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=v.useRef(null),w=v.useRef(!1);v.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),v.useEffect(()=>{if(!d||b<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{k(L=>L<=1?(S.current&&(clearInterval(S.current),S.current=null),w.current||(w.current=!0,r?.()),0):L-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[d,b,k,r]),v.useEffect(()=>{b>0&&(w.current=!1)},[b]);const j=a||jc(s),N=Lc(i),D={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:C,role:"banner","aria-live":"polite","aria-label":`${o} ${f(b)}`,"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(b)}`,"data-testid":"expire-cart-timer-value",children:f(b)})})]})})})});Ki.displayName="ExpireCartTimer";function Rc(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 Ji=Object.freeze({left:0,top:0,width:16,height:16}),fn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Er=Object.freeze({...Ji,...fn}),or=Object.freeze({...Er,body:"",hidden:!1});function Fc(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 Ts(t,e){const n=Fc(t,e);for(const r in or)r in fn?r in t&&!(r in n)&&(n[r]=fn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Pc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=Ts(r[l]||s[l],i)}return o(e),n.forEach(o),Ts(t,i)}function Wi(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=Rc(t);for(const s in r){const i=r[s];i&&(e(s,Pc(t,s,i)),n.push(s))}return n}const $c={provider:"",aliases:{},not_found:{},...Ji};function Hn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Gi(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Hn(t,$c))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Hn(i,or))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]||!Hn(i,or))return null}return e}const Ms=Object.create(null);function Vc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function St(t,e){const n=Ms[t]||(Ms[t]=Object.create(null));return n[e]||(n[e]=Vc(t,e))}function Zi(t,e){return Gi(e)?Wi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Bc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Qi=/^[a-z0-9]+(-[a-z0-9]+)*$/,vn=(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&&!Yt(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&&!Yt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Yt(l,n)?null:l}return null},Yt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let zt=!1;function Xi(t){return typeof t=="boolean"&&(zt=t),zt}function Os(t){const e=typeof t=="string"?vn(t,!0,zt):t;if(e){const n=St(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function zc(t,e){const n=vn(t,!0,zt);if(!n)return!1;const r=St(n.provider,n.prefix);return e?Bc(r,n.name,e):(r.missing.add(n.name),!0)}function _c(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),zt&&!e&&!t.prefix){let s=!1;return Gi(t)&&(t.prefix="",Wi(t,(i,o)=>{zc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Yt({prefix:n,name:"a"}))return!1;const r=St(e,n);return!!Zi(r,t)}const Yi=Object.freeze({width:null,height:null}),eo=Object.freeze({...Yi,...fn}),Hc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Uc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(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(Hc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Uc.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 qc(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 Kc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Jc(t,e,n){const r=qc(t);return Kc(r.defs,e+r.content+n)}const Wc=t=>t==="unset"||t==="undefined"||t==="none";function Gc(t,e){const n={...Er,...t},r={...eo,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const k=[],S=b.hFlip,w=b.vFlip;let j=b.rotate;S?w?j+=2:(k.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),k.push("scale(-1 1)"),s.top=s.left=0):w&&(k.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),k.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,k.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:k.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,k.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)),k.length&&(i=Jc(i,'<g transform="'+k.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=Is(f,a/u)):(d=o==="auto"?a:o,f=l===null?Is(d,u/a):l==="auto"?u:l);const p={},m=(b,k)=>{Wc(k)||(p[b]=k.toString())};m("width",d),m("height",f);const C=[s.left,s.top,a,u];return p.viewBox=C.join(" "),{attributes:p,viewBox:C,body:i}}const Zc=/\sid="(\S+)"/g,Qc="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Xc=0;function Yc(t,e=Qc){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+(Xc++).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 lr=Object.create(null);function eu(t,e){lr[t]=e}function ar(t){return lr[t]||lr[""]}function Tr(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 Mr=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],en=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?en.push(Nt.shift()):en.push(Nt.pop());Mr[""]=Tr({resources:["https://api.iconify.design"].concat(en)});function tu(t,e){const n=Tr(e);return n===null?!1:(Mr[t]=n,!0)}function Or(t){return Mr[t]}const nu=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ds=nu();function ru(t,e){const n=Or(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 su(t){return t===404}const iu=(t,e,n)=>{const r=[],s=ru(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 ou(t){if(typeof t=="string"){const e=Or(t);if(e)return e.path}return"/"}const lu=(t,e,n)=>{if(!Ds){n("abort",424);return}let r=ou(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;Ds(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(su(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)})},au={prepare:iu,send:lu};function to(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function cu(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||to([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let uu=0;function du(t,e,n){const r=uu++,s=to.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 fu(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]=St(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 hu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?vn(s,e,n):s;i&&r.push(i)}),r}const pu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function mu(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 C(){f&&(clearTimeout(f),f=null)}function b(){a==="pending"&&(a="aborted"),C(),p.forEach(L=>{L.status==="pending"&&(L.status="aborted")}),p=[]}function k(L,O){O&&(m=[]),typeof L=="function"&&m.push(L)}function S(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:p.length,subscribe:k,abort:b}}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,z){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=z,w();return}if(H){d=z,p.length||(o.length?D():w());return}if(C(),j(),!t.random){const U=t.resources.indexOf(L.resource);U!==-1&&U!==t.index&&(t.index=U)}a="completed",m.forEach(U=>{U(z)})}function D(){if(a!=="pending")return;C();const L=o.shift();if(L===void 0){if(p.length){f=setTimeout(()=>{C(),a==="pending"&&(j(),w())},t.timeout);return}w();return}const O={status:"pending",resource:L,callback:(z,H)=>{N(O,z,H)}};p.push(O),u++,f=setTimeout(D,t.rotate),n(L,e,O.callback)}return setTimeout(D),S}function no(t){const e={...pu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=mu(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 js(){}const Un=Object.create(null);function gu(t){if(!Un[t]){const e=Or(t);if(!e)return;const n=no(e),r={config:e,redundancy:n};Un[t]=r}return Un[t]}function yu(t,e,n){let r,s;if(typeof t=="string"){const i=ar(t);if(!i)return n(void 0,424),js;s=i.send;const o=gu(t);o&&(r=o.redundancy)}else{const i=Tr(t);if(i){r=no(i);const o=t.resources?t.resources[0]:"",l=ar(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),js):r.query(e,s,n)().abort}function Ls(){}function xu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,cu(t)}))}function bu(t){const e=[],n=[];return t.forEach(r=>{(r.match(Qi)?e:n).push(r)}),{valid:e,invalid:n}}function Et(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(!Zi(t,n).length){r();return}}catch(s){console.error(s)}r(),xu(t)}function Rs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function ku(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)){Rs(t.loadIcons(s,r,n),d=>{Et(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Rs(f,p=>{const m=p?{prefix:r,icons:{[d]:p}}:null;Et(t,[d],m)})});return}const{valid:o,invalid:l}=bu(s);if(l.length&&Et(t,l,null),!o.length)return;const a=r.match(Qi)?ar(n):null;if(!a){Et(t,o,null);return}a.prepare(n,r,o).forEach(d=>{yu(n,d,f=>{Et(t,d.icons,f)})})}))}const vu=(t,e)=>{const n=hu(t,!0,Xi()),r=fu(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Ls)}),()=>{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(St(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=St(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&&ku(a,u)}),e?du(e,r,i):Ls};function Su(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Yi?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Cu=/[\s,]+/;function wu(t,e){e.split(Cu).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Au(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 Nu(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 Eu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Tu(t){return"data:image/svg+xml,"+Eu(t)}function Mu(t){return'url("'+Tu(t)+'")'}let Dt;function Ou(){try{Dt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Dt=null}}function Iu(t){return Dt===void 0&&Ou(),Dt?Dt.createHTML(t):t}const ro={...eo,inline:!1},Du={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ju={display:"inline-block"},cr={backgroundColor:"currentColor"},so={backgroundColor:"transparent"},Fs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ps={WebkitMask:cr,mask:cr,background:so};for(const t in Ps){const e=Ps[t];for(const n in Fs)e[t+n]=Fs[n]}const Lu={...ro,inline:!0};function $s(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Ru=(t,e,n)=>{const r=e.inline?Lu:ro,s=Su(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Du:{}};if(n){const k=vn(n,!1,!0);if(k){const S=["iconify"],w=["provider","prefix"];for(const j of w)k[j]&&S.push("iconify--"+k[j]);a.className=S.join(" ")}}for(let k in e){const S=e[k];if(S!==void 0)switch(k){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=S;break;case"className":a[k]=(a[k]?a[k]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[k]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&wu(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[k]=Au(S):typeof S=="number"&&(s[k]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete a["aria-hidden"];break;default:r[k]===void 0&&(a[k]=S)}}const u=Gc(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let k=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:Iu(Yc(u.body,S?()=>S+"ID"+k++:"iconifyReact"))},v.createElement("svg",a)}const{body:f,width:p,height:m}=t,C=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=Nu(f,{...d,width:p+"",height:m+""});return a.style={...o,"--svg":Mu(b),width:$s(d.width),height:$s(d.height),...ju,...C?cr:so,...l},v.createElement("span",a)};Xi(!0);eu("",au);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"||!_c(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;tu(n,s)||console.error(r)}catch{console.error(r)}}}}function io(t){const[e,n]=v.useState(!!t.ssr),[r,s]=v.useState({});function i(m){if(m){const C=t.icon;if(typeof C=="object")return{name:"",data:C};const b=Os(C);if(b)return{name:C,data:b}}return{name:""}}const[o,l]=v.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 C=t.icon;if(typeof C=="object"){u({name:"",data:C});return}const b=Os(C);if(u({name:C,data:b}))if(b===void 0){const k=vu([C],d);s({callback:k})}else b&&((m=t.onLoad)===null||m===void 0||m.call(t,C))}v.useEffect(()=>(n(!0),a),[]),v.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:p}=o;return p?Ru({...Er,...p},t,f):t.children?t.children:t.fallback?t.fallback:v.createElement("span",{})}const Ie=v.forwardRef((t,e)=>io({...t,_ref:e}));v.forwardRef((t,e)=>io({inline:!0,...t,_ref:e}));const qn=({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(Ie,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Fu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,showMoreButtonClassName:a,labels:u})=>{const[d,f]=v.useState(!1),[p,m]=v.useState(!1),C=v.useRef(null);return v.useEffect(()=>{const b=()=>{if(C.current){const k=C.current.scrollHeight>C.current.clientHeight;m(k)}};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[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(qn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(qn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(qn,{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:C,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(oe,{onPress:()=>f(!d),variant:"light",className:y.cn("text-primary",a),startContent:c.jsx(Ie,{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 oo(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 Pu(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 $u={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Gt=t=>typeof t=="number"&&!isNaN(t),Ir=({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:C=!0,classNames:b={},"data-testid":k,selectedColor:S="default"})=>{const w={...$u,...o},[j,N]=v.useState(n),D=e!==void 0?e:j,L=de=>{if(a)return;const xe=Math.max(0,D+de);e===void 0&&N(xe),r?.(t.id,xe)},O=v.useMemo(()=>!Gt(t.totalTicketsSold)||!Gt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),z=v.useMemo(()=>O||!Gt(t.ticketsAllowed)?!1:D>=t.ticketsAllowed-(t.totalTicketsSold??0),[O,t.ticketsAllowed,t.totalTicketsSold,D]),H=oo(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",b.name),children:t.name}),P=()=>C?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",b.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",b.description),children:t.description}),F=()=>{if(!m||!Gt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const de=t.numberOfPeople===1?w.person:w.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,de,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:y.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[c.jsx(Ie,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",de]})},$=()=>{const de=D===0||a,xe=z||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:D,onIncrement:()=>L(1),onDecrement:()=>L(-1),isDecrementDisabled:de,isIncrementDisabled:xe,isDisabled:a}):c.jsxs("div",{className:y.cn("flex items-center gap-2",b.quantitySelector),children:[c.jsx(oe,{"data-testid":"offer-card-decrement-button",onPress:()=>L(-1),isDisabled:de,variant:u,color:D>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Ie,{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(oe,{"data-testid":"offer-card-increment-button",onPress:()=>L(1),isDisabled:xe,variant:u,color:D>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Ie,{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",b.soldOut),startContent:c.jsx(Ie,{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",b.maxReachedAlert),startContent:c.jsx(Ie,{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():$()})]}),ye=z&&!O&&c.jsx(Re.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",b.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx(y.CardBody,{className:y.cn("pt-1 pb-0",b.body),children:W}),c.jsx(Re.AnimatePresence,{children:ye&&c.jsx(y.CardFooter,{className:y.cn("w-full mt-0 pt-0",b.footer),children:ye})})]}):c.jsxs("div",{className:y.cn("w-full",b.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx("div",{className:y.cn("pt-1 pb-0",b.body),children:W}),c.jsx(Re.AnimatePresence,{children:ye&&c.jsx("div",{className:y.cn("w-full mt-0 pt-0",b.footer),children:ye})})]})};Ir.displayName="OfferCard";const lo=({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(Ie,{"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})};lo.displayName="OfferCardEmpty";const Vu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ao=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Vu,...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})};ao.displayName="OfferCardError";const Bu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},co=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Bu[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))})};co.displayName="OfferCardSkeleton";const uo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},fo={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"}}},zu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},ho=({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:C=2,classNames:b={}})=>{const[k,S]=v.useState(n),w=e!==void 0?e:k,j=v.useCallback((z,H)=>{const U={...w,[z]:Math.max(0,H)};e===void 0&&S(U),r?.(U),s?.(z,U[z])},[w,e,r,s]),N=[...t].sort((z,H)=>(z.position??0)-(H.position??0)),D=zu[C],L=y.cn("grid mx-auto pt-2",D,b.base),O=z=>c.jsx(Ir,{offer:z,quantity:w[z.id]||0,onQuantityChange:j,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:p,classNames:b.card},z.id);return m?c.jsx(Re.motion.div,{"data-testid":"offer-card-list",className:L,variants:uo,initial:"hidden",animate:"show",children:c.jsx(Re.AnimatePresence,{children:N.map(z=>c.jsx(Re.motion.div,{"data-testid":`offer-card-list-item-${z.id}`,className:b.cardWrapper,variants:fo,exit:{opacity:0,y:-20},transition:{duration:.3},children:O(z)},z.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:L,children:N.map(O)})};ho.displayName="OfferCardList";var Ut=t=>t.type==="checkbox",at=t=>t instanceof Date,Ce=t=>t==null;const po=t=>typeof t=="object";var ue=t=>!Ce(t)&&!Array.isArray(t)&&po(t)&&!at(t),mo=t=>ue(t)&&t.target?Ut(t.target)?t.target.checked:t.target.value:t,_u=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,go=(t,e)=>t.has(_u(e)),Hu=t=>{const e=t.constructor&&t.constructor.prototype;return ue(e)&&e.hasOwnProperty("isPrototypeOf")},Dr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function le(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Dr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(ue(t)&&Hu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=le(t[s]));return r}var Sn=t=>/^\w*$/.test(t),re=t=>t===void 0,jr=t=>Array.isArray(t)?t.filter(Boolean):[],Lr=t=>jr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),T=(t,e,n)=>{if(!e||!ue(t))return n;const r=(Sn(e)?[e]:Lr(e)).reduce((s,i)=>Ce(s)?s:s[i],t);return re(r)||r===t?re(t[e])?n:t[e]:r},Ae=t=>typeof t=="boolean",Se=t=>typeof t=="function",ee=(t,e,n)=>{let r=-1;const s=Sn(e)?[e]:Lr(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=ue(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const hn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},je={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ze={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},yo=v.createContext(null);yo.displayName="HookFormControlContext";const Rr=()=>v.useContext(yo);var xo=(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]!==je.all&&(e._proxyFormState[o]=!r||je.all),n&&(n[o]=!0),t[o]}});return s};const Fr=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Uu(t){const e=Rr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=v.useState(n._formState),a=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Fr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),v.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),v.useMemo(()=>xo(o,n,a.current,!1),[o,n])}var Ee=t=>typeof t=="string",ur=(t,e,n,r,s)=>Ee(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),dr=t=>Ce(t)||!po(t);function Le(t,e,n=new WeakSet){if(dr(t)||dr(e))return Object.is(t,e);if(at(t)&&at(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(at(o)&&at(l)||ue(o)&&ue(l)||Array.isArray(o)&&Array.isArray(l)?!Le(o,l,n):!Object.is(o,l))return!1}}return!0}function qu(t){const e=Rr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=v.useRef(s),u=v.useRef(l),d=v.useRef(void 0),f=v.useRef(n),p=v.useRef(r);u.current=l;const[m,C]=v.useState(()=>{const N=n._getWatch(r,a.current);return u.current?u.current(N):N}),b=v.useCallback(N=>{const D=ur(r,n._names,N||n._formValues,!1,a.current);return u.current?u.current(D):D},[n._formValues,n._names,r]),k=v.useCallback(N=>{if(!i){const D=ur(r,n._names,N||n._formValues,!1,a.current);if(u.current){const L=u.current(D);Le(L,d.current)||(C(L),d.current=L)}else C(D)}},[n._formValues,n._names,i,r]);Fr(()=>((f.current!==n||!Le(p.current,r))&&(f.current=n,p.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:N=>{k(N.values)}})),[n,o,r,k]),v.useEffect(()=>n._removeUnmounted());const S=f.current!==n,w=p.current,j=v.useMemo(()=>{if(i)return null;const N=!S&&!Le(w,r);return S||N?b():null},[i,S,r,w,b]);return j!==null?j:m}function Ku(t){const e=Rr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=go(s._names.array,n),u=v.useMemo(()=>T(s._formValues,n,T(s._defaultValues,n,o)),[s,n,o]),d=qu({control:s,name:n,defaultValue:u,exact:l}),f=Uu({control:s,name:n,exact:l}),p=v.useRef(t),m=v.useRef(void 0),C=v.useRef(s.register(n,{...t.rules,value:d,...Ae(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const b=v.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]),k=v.useCallback(N=>C.current.onChange({target:{value:mo(N),name:n},type:hn.CHANGE}),[n]),S=v.useCallback(()=>C.current.onBlur({target:{value:T(s._formValues,n),name:n},type:hn.BLUR}),[n,s._formValues]),w=v.useCallback(N=>{const D=T(s._fields,n);D&&D._f&&N&&(D._f.ref={focus:()=>Se(N.focus)&&N.focus(),select:()=>Se(N.select)&&N.select(),setCustomValidity:L=>Se(N.setCustomValidity)&&N.setCustomValidity(L),reportValidity:()=>Se(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),j=v.useMemo(()=>({name:n,value:d,...Ae(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:k,onBlur:S,ref:w}),[n,r,f.disabled,k,S,w,d]);return v.useEffect(()=>{const N=s._options.shouldUnregister||i,D=m.current;D&&D!==n&&!a&&s.unregister(D),s.register(n,{...p.current.rules,...Ae(p.current.disabled)?{disabled:p.current.disabled}:{}});const L=(O,z)=>{const H=T(s._fields,O);H&&H._f&&(H._f.mount=z)};if(L(n,!0),N){const O=le(T(s._options.defaultValues,n,p.current.defaultValue));ee(s._defaultValues,n,O),re(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]),v.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),v.useMemo(()=>({field:j,formState:f,fieldState:b}),[j,f,b])}const Ju=v.createContext(null);Ju.displayName="HookFormContext";var Wu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},jt=t=>Array.isArray(t)?t:[t],Vs=()=>{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 bo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&ue(s)&&i){const o=bo(s,i);ue(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ke=t=>ue(t)&&!Object.keys(t).length,Pr=t=>t.type==="file",pn=t=>{if(!Dr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ko=t=>t.type==="select-multiple",$r=t=>t.type==="radio",Gu=t=>$r(t)||Ut(t),Kn=t=>pn(t)&&t.isConnected;function Zu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=re(t)?r++:t[e[r++]];return t}function Qu(t){for(const e in t)if(t.hasOwnProperty(e)&&!re(t[e]))return!1;return!0}function ae(t,e){const n=Array.isArray(e)?e:Sn(e)?[e]:Lr(e),r=n.length===1?t:Zu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ue(r)&&ke(r)||Array.isArray(r)&&Qu(r))&&ae(t,n.slice(0,-1)),t}var Xu=t=>{for(const e in t)if(Se(t[e]))return!0;return!1};function vo(t){return Array.isArray(t)||ue(t)&&!Xu(t)}function fr(t,e={}){for(const n in t){const r=t[n];vo(r)?(e[n]=Array.isArray(r)?[]:{},fr(r,e[n])):re(r)||(e[n]=!0)}return e}function bt(t,e,n){n||(n=fr(e));for(const r in t){const s=t[r];if(vo(s))re(e)||dr(n[r])?n[r]=fr(s,Array.isArray(s)?[]:{}):bt(s,Ce(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Le(s,i)}}return n}const Bs={value:!1,isValid:!1},zs={value:!0,isValid:!0};var So=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&&!re(t[0].attributes.value)?re(t[0].value)||t[0].value===""?zs:{value:t[0].value,isValid:!0}:zs:Bs}return Bs},Co=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>re(t)?t:e?t===""?NaN:t&&+t:n&&Ee(t)?new Date(t):r?r(t):t;const _s={isValid:!1,value:null};var wo=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,_s):_s;function Hs(t){const e=t.ref;return Pr(e)?e.files:$r(e)?wo(t.refs).value:ko(e)?[...e.selectedOptions].map(({value:n})=>n):Ut(e)?So(t.refs).value:Co(re(e.value)?t.ref.value:e.value,t)}var Yu=(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}},mn=t=>t instanceof RegExp,Tt=t=>re(t)?t:mn(t)?t.source:ue(t)?mn(t.value)?t.value.source:t.value:t,Us=t=>({isOnSubmit:!t||t===je.onSubmit,isOnBlur:t===je.onBlur,isOnChange:t===je.onChange,isOnAll:t===je.all,isOnTouch:t===je.onTouched});const qs="AsyncFunction";var ed=t=>!!t&&!!t.validate&&!!(Se(t.validate)&&t.validate.constructor.name===qs||ue(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===qs)),td=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Ks=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Lt=(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(Lt(l,e))break}else if(ue(l)&&Lt(l,e))break}}};function Js(t,e,n){const r=T(t,n);if(r||Sn(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 nd=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ke(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||je.all))},rd=(t,e,n)=>!t||!e||t===e||jt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),sd=(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,id=(t,e)=>!jr(T(t,e)).length&&ae(t,e),od=(t,e,n)=>{const r=jt(T(t,n));return ee(r,"root",e[n]),ee(t,n,r),t};function Ws(t,e,n="validate"){if(Ee(t)||Array.isArray(t)&&t.every(Ee)||Ae(t)&&!t)return{type:n,message:Ee(t)?t:"",ref:e}}var gt=t=>ue(t)&&!mn(t)?t:{value:t,message:""},Gs=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:C,name:b,valueAsNumber:k,mount:S}=t._f,w=T(n,b);if(!S||e.has(b))return{};const j=l?l[0]:o,N=M=>{s&&j.reportValidity&&(j.setCustomValidity(Ae(M)?"":M||""),j.reportValidity())},D={},L=$r(o),O=Ut(o),z=L||O,H=(k||Pr(o))&&re(o.value)&&re(w)||pn(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,U=Wu.bind(null,b,r,D),P=(M,F,$,B=ze.maxLength,Y=ze.minLength)=>{const W=M?F:$;D[b]={type:M?B:Y,message:W,ref:o,...U(M?B:Y,W)}};if(i?!Array.isArray(w)||!w.length:a&&(!z&&(H||Ce(w))||Ae(w)&&!w||O&&!So(l).isValid||L&&!wo(l).isValid)){const{value:M,message:F}=Ee(a)?{value:!!a,message:a}:gt(a);if(M&&(D[b]={type:ze.required,message:F,ref:j,...U(ze.required,F)},!r))return N(F),D}if(!H&&(!Ce(f)||!Ce(p))){let M,F;const $=gt(p),B=gt(f);if(!Ce(w)&&!isNaN(w)){const Y=o.valueAsNumber||w&&+w;Ce($.value)||(M=Y>$.value),Ce(B.value)||(F=Y<B.value)}else{const Y=o.valueAsDate||new Date(w),W=xe=>new Date(new Date().toDateString()+" "+xe),ye=o.type=="time",de=o.type=="week";Ee($.value)&&w&&(M=ye?W(w)>W($.value):de?w>$.value:Y>new Date($.value)),Ee(B.value)&&w&&(F=ye?W(w)<W(B.value):de?w<B.value:Y<new Date(B.value))}if((M||F)&&(P(!!M,$.message,B.message,ze.max,ze.min),!r))return N(D[b].message),D}if((u||d)&&!H&&(Ee(w)||i&&Array.isArray(w))){const M=gt(u),F=gt(d),$=!Ce(M.value)&&w.length>+M.value,B=!Ce(F.value)&&w.length<+F.value;if(($||B)&&(P($,M.message,F.message),!r))return N(D[b].message),D}if(m&&!H&&Ee(w)){const{value:M,message:F}=gt(m);if(mn(M)&&!w.match(M)&&(D[b]={type:ze.pattern,message:F,ref:o,...U(ze.pattern,F)},!r))return N(F),D}if(C){if(Se(C)){const M=await C(w,n),F=Ws(M,j);if(F&&(D[b]={...F,...U(ze.validate,F.message)},!r))return N(F.message),D}else if(ue(C)){let M={};for(const F in C){if(!ke(M)&&!r)break;const $=Ws(await C[F](w,n),j,F);$&&(M={...$,...U(F,$.message)},N($.message),r&&(D[b]=M))}if(!ke(M)&&(D[b]={ref:j,...M},!r))return D}}return N(!0),D};const ld={mode:je.onSubmit,reValidateMode:je.onChange,shouldFocusError:!0};function ad(t={}){let e={...ld,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Se(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=ue(e.defaultValues)||ue(e.values)?le(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:le(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:Vs(),state:Vs()},C=e.criteriaMode===je.all,b=h=>g=>{clearTimeout(u),u=setTimeout(h,g)},k=async h=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||h)){let g;e.resolver?(g=ke((await z()).errors),S()):g=await U(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(x=>{x&&(g?ee(n.validatingFields,x,g):ae(n.validatingFields,x))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ke(n.validatingFields)}))},w=(h,g=[],x,I,E=!0,A=!0)=>{if(I&&x&&!e.disabled){if(o.action=!0,A&&Array.isArray(T(r,h))){const V=x(T(r,h),I.argA,I.argB);E&&ee(r,h,V)}if(A&&Array.isArray(T(n.errors,h))){const V=x(T(n.errors,h),I.argA,I.argB);E&&ee(n.errors,h,V),id(n.errors,h)}if((f.touchedFields||p.touchedFields)&&A&&Array.isArray(T(n.touchedFields,h))){const V=x(T(n.touchedFields,h),I.argA,I.argB);E&&ee(n.touchedFields,h,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=bt(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,x,I)=>{const E=T(r,h);if(E){const A=T(i,h,re(x)?T(s,h):x);re(A)||I&&I.defaultChecked||g?ee(i,h,g?A:Hs(E._f)):B(h,A),o.mount&&!o.action&&k()}},L=(h,g,x,I,E)=>{let A=!1,V=!1;const G={name:h};if(!e.disabled){if(!x||I){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=G.isDirty=M(),A=V!==G.isDirty);const Z=Le(T(s,h),g);V=!!T(n.dirtyFields,h),Z?ae(n.dirtyFields,h):ee(n.dirtyFields,h,!0),G.dirtyFields=n.dirtyFields,A=A||(f.dirtyFields||p.dirtyFields)&&V!==!Z}if(x){const Z=T(n.touchedFields,h);Z||(ee(n.touchedFields,h,x),G.touchedFields=n.touchedFields,A=A||(f.touchedFields||p.touchedFields)&&Z!==x)}A&&E&&m.state.next(G)}return A?G:{}},O=(h,g,x,I)=>{const E=T(n.errors,h),A=(f.isValid||p.isValid)&&Ae(g)&&n.isValid!==g;if(e.delayError&&x?(a=b(()=>j(h,x)),a(e.delayError)):(clearTimeout(u),a=null,x?ee(n.errors,h,x):ae(n.errors,h)),(x?!Le(E,x):E)||!ke(I)||A){const V={...I,...A&&Ae(g)?{isValid:g}:{},errors:n.errors,name:h};n={...n,...V},m.state.next(V)}},z=async h=>(S(h,!0),await e.resolver(i,e.context,Yu(h||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),H=async h=>{const{errors:g}=await z(h);if(S(h),h)for(const x of h){const I=T(g,x);I?ee(n.errors,x,I):ae(n.errors,x)}else n.errors=g;return g},U=async(h,g,x={valid:!0})=>{for(const I in h){const E=h[I];if(E){const{_f:A,...V}=E;if(A){const G=l.array.has(A.name),Z=E._f&&ed(E._f);Z&&f.validatingFields&&S([A.name],!0);const be=await Gs(E,l.disabled,i,C,e.shouldUseNativeValidation&&!g,G);if(Z&&f.validatingFields&&S([A.name]),be[A.name]&&(x.valid=!1,g||t.shouldUseNativeValidation))break;!g&&(T(be,A.name)?G?od(n.errors,be,A.name):ee(n.errors,A.name,be[A.name]):ae(n.errors,A.name))}!ke(V)&&await U(V,g,x)}}return x.valid},P=()=>{for(const h of l.unMount){const g=T(r,h);g&&(g._f.refs?g._f.refs.every(x=>!Kn(x)):!Kn(g._f.ref))&&wn(h)}l.unMount=new Set},M=(h,g)=>!e.disabled&&(h&&g&&ee(i,h,g),!Le(qe(),s)),F=(h,g,x)=>ur(h,l,{...o.mount?i:re(g)?s:Ee(h)?{[h]:g}:g},x,g),$=h=>jr(T(o.mount?i:s,h,e.shouldUnregister?T(s,h,[]):[])),B=(h,g,x={})=>{const I=T(r,h);let E=g;if(I){const A=I._f;A&&(!A.disabled&&ee(i,h,Co(g,A)),E=pn(A.ref)&&Ce(g)?"":g,ko(A.ref)?[...A.ref.options].forEach(V=>V.selected=E.includes(V.value)):A.refs?Ut(A.ref)?A.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(E)?V.checked=!!E.find(G=>G===V.value):V.checked=E===V.value||!!E)}):A.refs.forEach(V=>V.checked=V.value===E):Pr(A.ref)?A.ref.value="":(A.ref.value=E,A.ref.type||m.state.next({name:h,values:le(i)})))}(x.shouldDirty||x.shouldTouch)&&L(h,E,x.shouldTouch,x.shouldDirty,!0),x.shouldValidate&&xe(h)},Y=(h,g,x)=>{for(const I in g){if(!g.hasOwnProperty(I))return;const E=g[I],A=h+"."+I,V=T(r,A);(l.array.has(h)||ue(E)||V&&!V._f)&&!at(E)?Y(A,E,x):B(A,E,x)}},W=(h,g,x={})=>{const I=T(r,h),E=l.array.has(h),A=le(g);ee(i,h,A),E?(m.array.next({name:h,values:le(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&x.shouldDirty&&m.state.next({name:h,dirtyFields:bt(s,i),isDirty:M(h,A)})):I&&!I._f&&!Ce(A)?Y(h,A,x):B(h,A,x),Ks(h,l)?m.state.next({...n,name:h,values:le(i)}):m.state.next({name:o.mount?h:void 0,values:le(i)})},ye=async h=>{o.mount=!0;const g=h.target;let x=g.name,I=!0;const E=T(r,x),A=Z=>{I=Number.isNaN(Z)||at(Z)&&isNaN(Z.getTime())||Le(Z,T(i,x,Z))},V=Us(e.mode),G=Us(e.reValidateMode);if(E){let Z,be;const tt=g.type?Hs(E._f):mo(h),Ke=h.type===hn.BLUR||h.type===hn.FOCUS_OUT,jo=!td(E._f)&&!e.resolver&&!T(n.errors,x)&&!E._f.deps||sd(Ke,T(n.touchedFields,x),n.isSubmitted,G,V),En=Ks(x,l,Ke);ee(i,x,tt),Ke?(!g||!g.readOnly)&&(E._f.onBlur&&E._f.onBlur(h),a&&a(0)):E._f.onChange&&E._f.onChange(h);const Tn=L(x,tt,Ke),Lo=!ke(Tn)||En;if(!Ke&&m.state.next({name:x,type:h.type,values:le(i)}),jo)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Ke&&k():Ke||k()),Lo&&m.state.next({name:x,...En?{}:Tn});if(!Ke&&En&&m.state.next({...n}),e.resolver){const{errors:qr}=await z([x]);if(S([x]),A(tt),I){const Ro=Js(n.errors,r,x),Kr=Js(qr,r,Ro.name||x);Z=Kr.error,x=Kr.name,be=ke(qr)}}else S([x],!0),Z=(await Gs(E,l.disabled,i,C,e.shouldUseNativeValidation))[x],S([x]),A(tt),I&&(Z?be=!1:(f.isValid||p.isValid)&&(be=await U(r,!0)));I&&(E._f.deps&&(!Array.isArray(E._f.deps)||E._f.deps.length>0)&&xe(E._f.deps),O(x,be,Z,Tn))}},de=(h,g)=>{if(T(n.errors,g)&&h.focus)return h.focus(),1},xe=async(h,g={})=>{let x,I;const E=jt(h);if(e.resolver){const A=await H(re(h)?h:E);x=ke(A),I=h?!E.some(V=>T(A,V)):x}else h?(I=(await Promise.all(E.map(async A=>{const V=T(r,A);return await U(V&&V._f?{[A]:V}:V)}))).every(Boolean),!(!I&&!n.isValid)&&k()):I=x=await U(r);return m.state.next({...!Ee(h)||(f.isValid||p.isValid)&&x!==n.isValid?{}:{name:h},...e.resolver||!h?{isValid:x}:{},errors:n.errors}),g.shouldFocus&&!I&&Lt(r,de,h?E:l.mount),I},qe=(h,g)=>{let x={...o.mount?i:s};return g&&(x=bo(g.dirtyFields?n.dirtyFields:n.touchedFields,x)),re(h)?x:Ee(h)?T(x,h):h.map(I=>T(x,I))},pt=(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)}),Ct=h=>{h&&jt(h).forEach(g=>ae(n.errors,g)),m.state.next({errors:h?n.errors:{}})},ne=(h,g,x)=>{const I=(T(r,h,{_f:{}})._f||{}).ref,E=T(n.errors,h)||{},{ref:A,message:V,type:G,...Z}=E;ee(n.errors,h,{...Z,...g,ref:I}),m.state.next({name:h,errors:n.errors,isValid:!1}),x&&x.shouldFocus&&I&&I.focus&&I.focus()},we=(h,g)=>Se(h)?m.state.subscribe({next:x=>"values"in x&&h(F(void 0,g),x)}):F(h,g,!0),wt=h=>m.state.subscribe({next:g=>{rd(h.name,g.name,h.exact)&&nd(g,h.formState||f,Do,h.reRenderRoot)&&h.callback({values:{...i},...n,...g,defaultValues:s})}}).unsubscribe,Cn=h=>(o.mount=!0,p={...p,...h.formState},wt({...h,formState:{...d,...h.formState}})),wn=(h,g={})=>{for(const x of h?jt(h):l.mount)l.mount.delete(x),l.array.delete(x),g.keepValue||(ae(r,x),ae(i,x)),!g.keepError&&ae(n.errors,x),!g.keepDirty&&ae(n.dirtyFields,x),!g.keepTouched&&ae(n.touchedFields,x),!g.keepIsValidating&&ae(n.validatingFields,x),!e.shouldUnregister&&!g.keepDefaultValue&&ae(s,x);m.state.next({values:le(i)}),m.state.next({...n,...g.keepDirty?{isDirty:M()}:{}}),!g.keepIsValid&&k()},Br=({disabled:h,name:g})=>{if(Ae(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&&k()}},An=(h,g={})=>{let x=T(r,h);const I=Ae(g.disabled)||Ae(e.disabled);return ee(r,h,{...x||{},_f:{...x&&x._f?x._f:{ref:{name:h}},name:h,mount:!0,...g}}),l.mount.add(h),x?Br({disabled:Ae(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:Tt(g.min),max:Tt(g.max),minLength:Tt(g.minLength),maxLength:Tt(g.maxLength),pattern:Tt(g.pattern)}:{},name:h,onChange:ye,onBlur:ye,ref:E=>{if(E){An(h,g),x=T(r,h);const A=re(E.value)&&E.querySelectorAll&&E.querySelectorAll("input,select,textarea")[0]||E,V=Gu(A),G=x._f.refs||[];if(V?G.find(Z=>Z===A):A===x._f.ref)return;ee(r,h,{_f:{...x._f,...V?{refs:[...G.filter(Kn),A,...Array.isArray(T(s,h))?[{}]:[]],ref:{type:A.type,name:h}}:{ref:A}}}),D(h,!1,void 0,A)}else x=T(r,h,{}),x._f&&(x._f.mount=!1),(e.shouldUnregister||g.shouldUnregister)&&!(go(l.array,h)&&o.action)&&l.unMount.add(h)}}},Nn=()=>e.shouldFocusError&&Lt(r,de,l.mount),Mo=h=>{Ae(h)&&(m.state.next({disabled:h}),Lt(r,(g,x)=>{const I=T(r,x);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))},zr=(h,g)=>async x=>{let I;x&&(x.preventDefault&&x.preventDefault(),x.persist&&x.persist());let E=le(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:A,values:V}=await z();S(),n.errors=A,E=le(V)}else await U(r);if(l.disabled.size)for(const A of l.disabled)ae(E,A);if(ae(n.errors,"root"),ke(n.errors)){m.state.next({errors:{}});try{await h(E,x)}catch(A){I=A}}else g&&await g({...n.errors},x),Nn(),setTimeout(Nn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ke(n.errors)&&!I,submitCount:n.submitCount+1,errors:n.errors}),I)throw I},Oo=(h,g={})=>{T(r,h)&&(re(g.defaultValue)?W(h,le(T(s,h))):(W(h,g.defaultValue),ee(s,h,le(g.defaultValue))),g.keepTouched||ae(n.touchedFields,h),g.keepDirty||(ae(n.dirtyFields,h),n.isDirty=g.defaultValue?M(h,le(T(s,h))):M()),g.keepError||(ae(n.errors,h),f.isValid&&k()),m.state.next({...n}))},_r=(h,g={})=>{const x=h?le(h):s,I=le(x),E=ke(h),A=E?s:I;if(g.keepDefaultValues||(s=x),!g.keepValues){if(g.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(bt(s,i))]);for(const G of Array.from(V)){const Z=T(n.dirtyFields,G),be=T(i,G),tt=T(A,G);Z&&!re(be)?ee(A,G,be):!Z&&!re(tt)&&W(G,tt)}}else{if(Dr&&re(h))for(const V of l.mount){const G=T(r,V);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(pn(Z)){const be=Z.closest("form");if(be){be.reset();break}}}}if(g.keepFieldsRef)for(const V of l.mount)W(V,T(A,V));else r={}}i=e.shouldUnregister?g.keepDefaultValues?le(s):{}:le(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&&!ke(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&&!Le(h,s)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:E?{}:g.keepDirtyValues?g.keepDefaultValues&&i?bt(s,i):n.dirtyFields:g.keepDefaultValues&&h?bt(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})},Hr=(h,g)=>_r(Se(h)?h(i):h,{...e.resetOptions,...g}),Io=(h,g={})=>{const x=T(r,h),I=x&&x._f;if(I){const E=I.refs?I.refs[0]:I.ref;E.focus&&setTimeout(()=>{E.focus(),g.shouldSelect&&Se(E.select)&&E.select()})}},Do=h=>{n={...n,...h}},Ur={control:{register:An,unregister:wn,getFieldState:pt,handleSubmit:zr,setError:ne,_subscribe:wt,_runSchema:z,_updateIsValidating:S,_focusError:Nn,_getWatch:F,_getDirty:M,_setValid:k,_setFieldArray:w,_setDisabledField:Br,_setErrors:N,_getFieldArray:$,_reset:_r,_resetDefaultValues:()=>Se(e.defaultValues)&&e.defaultValues().then(h=>{Hr(h,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:Mo,_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:Cn,trigger:xe,register:An,handleSubmit:zr,watch:we,setValue:W,getValues:qe,reset:Hr,resetField:Oo,clearErrors:Ct,unregister:wn,setError:ne,setFocus:Io,getFieldState:pt};return{...Ur,formControl:Ur}}function cd(t={}){const e=v.useRef(void 0),n=v.useRef(void 0),[r,s]=v.useState({isDirty:!1,isValidating:!1,isLoading:Se(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:Se(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!Se(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=ad(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,Fr(()=>{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]),v.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),v.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),v.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),v.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),v.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),v.useEffect(()=>{var o;t.values&&!Le(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]),v.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=v.useMemo(()=>xo(r,i),[i,r]),e.current}function ud(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function dd(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 fd(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 hd(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 pd(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 Vr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Vr();const md={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:"$"},Jn=()=>({id:Vr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ao=({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:C={},"data-testid":b,control:k,name:S,rules:w})=>{const j={...md,...m},N=k!==void 0&&S!==void 0,D=cd({defaultValues:{_internal:e||Jn()}}),L=Ku({control:N?k:D.control,name:N?S:"_internal",rules:N?w:void 0}),[O,z]=v.useState(e||Jn()),H=N?L.field.value??Jn():t??O,U=N&&!!L.fieldState?.error,P=N&&(L.fieldState?.isTouched??!1),M=U||P,F=M&&(!H.amount||H.amount<=0),$=M&&!H.glAccount,[B,Y]=v.useState(H.glAccount?.name||""),W=v.useCallback(ne=>{const we={...H,...ne};N&&L.field.onChange(we),!N&&t===void 0&&z(we),i?.(we)},[H,t,i,N,L]),ye=v.useCallback(ne=>{const we=ne||0;W({amount:we}),o?.(we)},[W,o]),de=v.useCallback(ne=>{Y(ne),s?.(ne)},[s]),xe=v.useCallback(ne=>{if(ne===null){W({glAccount:null}),l?.(null);return}const wt=n.find(Cn=>String(Cn.id)===String(ne))||null;W({glAccount:wt}),l?.(wt)},[n,W,l]),qe=v.useCallback(()=>{Y(""),W({glAccount:null}),l?.(null)},[W,l]),pt=v.useCallback(ne=>{W({isTaxDeductible:ne}),a?.(ne)},[W,a]),Ct=v.useCallback(()=>{u?.()},[u]);return c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:y.cn(C.base),children:c.jsxs(y.CardBody,{className:y.cn("flex flex-row flex-nowrap items-start gap-4",C.body),children:[c.jsx("div",{className:y.cn("shrink-0",C.amountContainer),children:c.jsx(y.NumberInput,{"data-testid":`${b||"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(Ie,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:H.amount||void 0,onValueChange:ye,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:C.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",C.glAccountContainer),children:c.jsx(y.Autocomplete,{"data-testid":`${b||"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(Ie,{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:$,errorMessage:$?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:de,onSelectionChange:xe,onClear:qe,className:C.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",C.taxDeductibleContainer),children:c.jsx(y.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:H.isTaxDeductible,onValueChange:pt,isDisabled:p||!f,className:C.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:y.cn("shrink-0 pt-6",C.deleteContainer),children:c.jsx(oe,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!d,onPress:Ct,startContent:c.jsx(Ie,{icon:"solar:trash-bin-trash-linear",width:16}),className:y.cn("text-danger",C.deleteButton),children:j.deleteButton})})]})})};Ao.displayName="RevenueDistributionCard";const No=({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(Ie,{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})};No.displayName="RevenueDistributionEmpty";const gd={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Eo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...gd,...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})};Eo.displayName="RevenueDistributionError";const To=({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))})};To.displayName="RevenueDistributionSkeleton";exports.Button=oe;exports.ConfirmationPageTemplate=Wo;exports.DonationAmounts=qi;exports.EventDetails=Fu;exports.EventDetailsTemplate=Qo;exports.ExpireCartTimer=Ki;exports.Footer=Xo;exports.HeroUIProvider=Ho;exports.Multiselect=Yo;exports.Navbar=Jo;exports.OfferCard=Ir;exports.OfferCardEmpty=lo;exports.OfferCardError=ao;exports.OfferCardList=ho;exports.OfferCardSkeleton=co;exports.RICH_TEXT_PRESETS=Hi;exports.RevenueDistributionCard=Ao;exports.RevenueDistributionEmpty=No;exports.RevenueDistributionError=Eo;exports.RevenueDistributionSkeleton=To;exports.RichTextArea=Ui;exports.Stepper=Zs;exports.calculateAllocationDifference=pd;exports.formatOfferCurrency=oo;exports.formatRevenueAmount=ud;exports.formatRevenueCurrency=dd;exports.generateDistributionId=Vr;exports.getCurrencySymbol=fd;exports.offerCardVariants=fo;exports.offerListVariants=uo;exports.parseOfferCurrency=Pu;exports.parseRevenueCurrency=hd;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)}})();
|