@veevarts/design-system 1.12.6 → 1.12.7

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 CHANGED
@@ -1,22 +1,22 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("@heroui/react"),x=require("react"),_=require("lucide-react"),$e=require("framer-motion"),yr=require("@tiptap/react"),V=require("@tiptap/core"),ca=require("@tiptap/extension-underline"),da=require("@tiptap/extension-color"),ua=require("@tiptap/extension-highlight"),fa=require("@tiptap/extension-link"),ha=require("@tiptap/extension-task-list"),pa=require("@tiptap/extension-task-item"),ma=require("@tiptap/extension-text-align");function ga({children:t}){return c.jsx(g.HeroUIProvider,{children:t})}const G=x.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(g.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));G.displayName="Button";function xa(t){const e=t?.closest('[role="dialog"]');return e?.parentElement??e??void 0}const wt=x.forwardRef(({popoverProps:t,...e},n)=>{const r=x.useRef(null),[s,i]=x.useState(void 0),o={...t,disableDialogFocus:t?.disableDialogFocus??(s?!0:void 0),portalContainer:t?.portalContainer??s};return x.useEffect(()=>{i(xa(r.current))},[]),c.jsx("span",{ref:r,className:"contents",children:c.jsx(g.Select,{ref:n,...e,popoverProps:o})})});wt.displayName="Select";const ya={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function ba({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){const s=t.find(i=>i.code===e);return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(wt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"min-w-36 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(_.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>c.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),c.jsx(wt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"w-24 inline-flex md:hidden",isDisabled:t.length===0,placeholder:"",startContent:c.jsx(_.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>c.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function va({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(G,{"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,size:"md",children:[c.jsx(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(G,{"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,size:"md",children:[c.jsx(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function ka({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:a,hasAuth:l,labels:d={},className:u}){const f={...ya,...d};return c.jsxs("nav",{"data-testid":"navbar",className:g.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),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 w-auto max-w-28 md:max-w-40 object-contain"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(a||e.length>0)&&c.jsx(ba,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),l&&c.jsx(va,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function Sa(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(g.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 On;const Ca=typeof document<"u"?(On=x.useInsertionEffect)!==null&&On!==void 0?On:x.useLayoutEffect:()=>{};function br(t,e,n){let[r,s]=x.useState(t||e),i=x.useRef(r),o=x.useRef(t!==void 0),a=t!==void 0;x.useEffect(()=>{let f=o.current;f!==a&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),o.current=a},[a]);let l=a?t:r;Ca(()=>{i.current=l});let[,d]=x.useReducer(()=>({}),{}),u=x.useCallback((f,...m)=>{let h=typeof f=="function"?f(i.current):f;Object.is(i.current,h)||(i.current=h,s(h),d(),n?.(h,...m))},[n]);return[l,u]}function wa(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx($e.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const ai=x.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:a,className:l,isDisabled:d=!1,...u},f)=>{const[m,h]=br(i,n,s),k=x.useMemo(()=>{let b,y;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)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",y="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",y="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",y="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",y="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",y="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(y),S.unshift(b),S},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:g.cn("flex max-w-fit items-center overflow-x-auto",l),"data-testid":"stepper-root",...u,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:g.cn("flex flex-row flex-nowrap gap-x-3",k,l),"data-testid":"stepper-list",children:Array.from({length:e})?.map((b,y)=>{const S=m===y?"active":m<y?"inactive":"complete";return c.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${y}`,children:c.jsxs("button",{"aria-current":S==="active"?"step":void 0,className:g.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":d},a),onClick:()=>!d&&h(y),disabled:d,"data-testid":`stepper-step-btn-${y}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx($e.LazyMotion,{features:$e.domAnimation,children:c.jsx($e.m.div,{animate:S,className:"relative",children:c.jsx($e.m.div,{animate:S,className:g.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(wa,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${y}`}):c.jsx("span",{})})})})})}),y<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":y},children:c.jsx("div",{className:g.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":y<m})})})]},y)},y)})})]})});ai.displayName="Stepper";function Na(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(g.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 ht(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}catch{return`${n} ${t.toFixed(2)}`}}function vr(t,e="en-US"){try{const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function li(t,e,n="en-US"){const r=vr(e,n),s=Math.pow(10,r);return Math.round(t*s)/s}function Qn(t,e,n,r){return li(t-e,n,r)}function Aa(){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 ja=t=>{const e=x.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(Ea,{...t},e)},Ea=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=x.useState([]),[a,l]=x.useState([]),[d,u]=x.useState(null),[f,m]=x.useState(null),h=x.useMemo(()=>new Set(e),[e]),k=x.useMemo(()=>new Set(t),[t]),b=x.useMemo(()=>t.filter(D=>!h.has(D)),[t,h]),y=D=>{if(D.length===0)return;const T=Array.from(new Set([...e,...D]));n(T)},S=D=>{if(D.length===0)return;const T=new Set(D);n(e.filter(R=>!T.has(R)))},N=()=>{i.length!==0&&(y(i),o([]))},j=()=>{a.length!==0&&(S(a),l([]))},C=()=>{b.length!==0&&(y(b),o([]))},A=()=>{e.length!==0&&(n([]),l([]))},M=(D,T,R)=>{const B=Math.min(T,R),U=Math.max(T,R);return D.slice(B,U+1)},L=(D,T,R)=>{if(R&&d!==null){o(M(b,d,T)),l([]),u(T);return}const B=i.includes(D);o(B?i.filter(U=>U!==D):[...i,D]),l([]),u(T)},P=(D,T,R)=>{if(R&&f!==null){l(M(e,f,T)),o([]),m(T);return}const B=a.includes(D);l(B?a.filter(U=>U!==D):[...a,D]),o([]),m(T)},$=(D,T,R)=>{const B=R==="available"?i.includes(T)?i:[T]:a.includes(T)?a:[T];D.dataTransfer.setData("text/plain",JSON.stringify({source:R,items:B})),D.dataTransfer.effectAllowed="move"},H=(D,T)=>{D.preventDefault();const R=D.dataTransfer.getData("text/plain");if(R)try{const B=JSON.parse(R),U=(B.items||[]).filter(re=>k.has(re));if(U.length===0||B.source===T)return;T==="selected"?(y(U),o([])):(S(U),l([]))}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(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:D=>D.preventDefault(),onDrop:D=>H(D,"available"),children:b.map((D,T)=>{const R=i.includes(D);return c.jsx("button",{type:"button",onClick:B=>{L(D,T,B.shiftKey)},onMouseDown:B=>{B.shiftKey&&B.preventDefault()},draggable:!0,onDragStart:B=>$(B,D,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${R?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:D},D)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(G,{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:N,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(G,{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:a.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(G,{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:C,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(G,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:A,"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(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:D=>D.preventDefault(),onDrop:D=>H(D,"selected"),children:e.map((D,T)=>{const R=a.includes(D);return c.jsx("button",{type:"button",onClick:B=>{P(D,T,B.shiftKey)},onMouseDown:B=>{B.shiftKey&&B.preventDefault()},draggable:!0,onDragStart:B=>$(B,D,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${R?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:D},D)})})})]})]})};function Rt(t){return typeof t=="string"?t:t.type}function rt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(g.Divider,{orientation:"vertical"})})}function st({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:a}){const l=i?`${e} (${i})`:e;return c.jsx(g.Tooltip,{content:l,placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:a,children:c.jsx(t,{size:o})})})}const Ke={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"}},Ta={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Ma({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const o=()=>r(a=>a+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 a=Number(o),l=Ke.heading;l&&l.execute({editor:t,config:{type:"heading",level:a}})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{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(g.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(g.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(_.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:Ta[o]},o))})]})}const Dn={bulletList:{label:"Bullet List",icon:_.List},orderedList:{label:"Numbered List",icon:_.ListOrdered},taskList:{label:"Task List",icon:_.ListTodo}};function Oa({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const a=()=>r(l=>l+1);return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const s=e.find(a=>t.isActive(a)),i=s?Dn[s].icon:_.List,o=a=>{const d=Ke[a];d&&d.execute({editor:t})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{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(g.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(a=>{const l=Dn[a].icon;return c.jsx(g.DropdownItem,{startContent:c.jsx(l,{size:16}),children:Dn[a].label},a)})})]})}function Da({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"),g=require("@heroui/react"),x=require("react"),H=require("lucide-react"),$e=require("framer-motion"),yr=require("@tiptap/react"),$=require("@tiptap/core"),ca=require("@tiptap/extension-underline"),da=require("@tiptap/extension-color"),ua=require("@tiptap/extension-highlight"),fa=require("@tiptap/extension-link"),ha=require("@tiptap/extension-task-list"),pa=require("@tiptap/extension-task-item"),ma=require("@tiptap/extension-text-align");function ga({children:t}){return c.jsx(g.HeroUIProvider,{children:t})}const G=x.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(g.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));G.displayName="Button";function xa(t){const e=t?.closest('[role="dialog"]');return e?.parentElement??e??void 0}const wt=x.forwardRef(({popoverProps:t,...e},n)=>{const r=x.useRef(null),[s,i]=x.useState(void 0),o={...t,disableDialogFocus:t?.disableDialogFocus??(s?!0:void 0),portalContainer:t?.portalContainer??s};return x.useEffect(()=>{i(xa(r.current))},[]),c.jsx("span",{ref:r,className:"contents",children:c.jsx(g.Select,{ref:n,...e,popoverProps:o})})});wt.displayName="Select";const ya={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function ba({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){const s=t.find(i=>i.code===e);return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(wt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"min-w-36 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(H.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>c.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),c.jsx(wt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"w-24 inline-flex md:hidden",isDisabled:t.length===0,placeholder:"",startContent:c.jsx(H.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>c.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function va({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(G,{"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,size:"md",children:[c.jsx(H.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(G,{"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,size:"md",children:[c.jsx(H.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function ka({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:a,hasAuth:l,labels:d={},className:u}){const f={...ya,...d};return c.jsxs("nav",{"data-testid":"navbar",className:g.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),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 w-auto max-w-28 md:max-w-40 object-contain"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(a||e.length>0)&&c.jsx(ba,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),l&&c.jsx(va,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function Sa(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(g.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 On;const Ca=typeof document<"u"?(On=x.useInsertionEffect)!==null&&On!==void 0?On:x.useLayoutEffect:()=>{};function br(t,e,n){let[r,s]=x.useState(t||e),i=x.useRef(r),o=x.useRef(t!==void 0),a=t!==void 0;x.useEffect(()=>{let f=o.current;f!==a&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),o.current=a},[a]);let l=a?t:r;Ca(()=>{i.current=l});let[,d]=x.useReducer(()=>({}),{}),u=x.useCallback((f,...p)=>{let h=typeof f=="function"?f(i.current):f;Object.is(i.current,h)||(i.current=h,s(h),d(),n?.(h,...p))},[n]);return[l,u]}function wa(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx($e.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const ai=x.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:a,className:l,isDisabled:d=!1,...u},f)=>{const[p,h]=br(i,n,s),k=x.useMemo(()=>{let y,b;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":y="[--step-color:var(--heroui-primary)]",b="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":y="[--step-color:var(--heroui-secondary)]",b="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":y="[--step-color:var(--heroui-success)]",b="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":y="[--step-color:var(--heroui-warning)]",b="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":y="[--step-color:var(--heroui-danger)]",b="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":y="[--step-color:var(--heroui-default)]",b="[--step-fg-color:var(--heroui-default-foreground)]";break;default:y="[--step-color:var(--heroui-primary)]",b="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(b),S.unshift(y),S},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:g.cn("flex max-w-fit items-center overflow-x-auto",l),"data-testid":"stepper-root",...u,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:g.cn("flex flex-row flex-nowrap gap-x-3",k,l),"data-testid":"stepper-list",children:Array.from({length:e})?.map((y,b)=>{const S=p===b?"active":p<b?"inactive":"complete";return c.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${b}`,children:c.jsxs("button",{"aria-current":S==="active"?"step":void 0,className:g.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":d},a),onClick:()=>!d&&h(b),disabled:d,"data-testid":`stepper-step-btn-${b}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx($e.LazyMotion,{features:$e.domAnimation,children:c.jsx($e.m.div,{animate:S,className:"relative",children:c.jsx($e.m.div,{animate:S,className:g.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(wa,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${b}`}):c.jsx("span",{})})})})})}),b<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":b},children:c.jsx("div",{className:g.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":b<p})})})]},b)},b)})})]})});ai.displayName="Stepper";function Na(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(g.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 ht(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}catch{return`${n} ${t.toFixed(2)}`}}function vr(t,e="en-US"){try{const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function li(t,e,n="en-US"){const r=vr(e,n),s=Math.pow(10,r);return Math.round(t*s)/s}function Qn(t,e,n,r){return li(t-e,n,r)}function Aa(){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 ja=t=>{const e=x.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(Ea,{...t},e)},Ea=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=x.useState([]),[a,l]=x.useState([]),[d,u]=x.useState(null),[f,p]=x.useState(null),h=x.useMemo(()=>new Set(e),[e]),k=x.useMemo(()=>new Set(t),[t]),y=x.useMemo(()=>t.filter(R=>!h.has(R)),[t,h]),b=R=>{if(R.length===0)return;const E=Array.from(new Set([...e,...R]));n(E)},S=R=>{if(R.length===0)return;const E=new Set(R);n(e.filter(F=>!E.has(F)))},N=()=>{i.length!==0&&(b(i),o([]))},j=()=>{a.length!==0&&(S(a),l([]))},C=()=>{y.length!==0&&(b(y),o([]))},A=()=>{e.length!==0&&(n([]),l([]))},M=(R,E,F)=>{const V=Math.min(E,F),U=Math.max(E,F);return R.slice(V,U+1)},I=(R,E,F)=>{if(F&&d!==null){o(M(y,d,E)),l([]),u(E);return}const V=i.includes(R);o(V?i.filter(U=>U!==R):[...i,R]),l([]),u(E)},_=(R,E,F)=>{if(F&&f!==null){l(M(e,f,E)),o([]),p(E);return}const V=a.includes(R);l(V?a.filter(U=>U!==R):[...a,R]),o([]),p(E)},P=(R,E,F)=>{const V=F==="available"?i.includes(E)?i:[E]:a.includes(E)?a:[E];R.dataTransfer.setData("text/plain",JSON.stringify({source:F,items:V})),R.dataTransfer.effectAllowed="move"},B=(R,E)=>{R.preventDefault();const F=R.dataTransfer.getData("text/plain");if(F)try{const V=JSON.parse(F),U=(V.items||[]).filter(X=>k.has(X));if(U.length===0||V.source===E)return;E==="selected"?(b(U),o([])):(S(U),l([]))}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(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:R=>R.preventDefault(),onDrop:R=>B(R,"available"),children:y.map((R,E)=>{const F=i.includes(R);return c.jsx("button",{type:"button",onClick:V=>{I(R,E,V.shiftKey)},onMouseDown:V=>{V.shiftKey&&V.preventDefault()},draggable:!0,onDragStart:V=>P(V,R,"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:R},R)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(G,{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:N,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(G,{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:a.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(G,{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:C,isDisabled:y.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(G,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:A,"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(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:R=>R.preventDefault(),onDrop:R=>B(R,"selected"),children:e.map((R,E)=>{const F=a.includes(R);return c.jsx("button",{type:"button",onClick:V=>{_(R,E,V.shiftKey)},onMouseDown:V=>{V.shiftKey&&V.preventDefault()},draggable:!0,onDragStart:V=>P(V,R,"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:R},R)})})})]})]})};function Rt(t){return typeof t=="string"?t:t.type}function rt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(g.Divider,{orientation:"vertical"})})}function st({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:a}){const l=i?`${e} (${i})`:e;return c.jsx(g.Tooltip,{content:l,placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:a,children:c.jsx(t,{size:o})})})}const Ke={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"}},Ta={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Ma({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const o=()=>r(a=>a+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 a=Number(o),l=Ke.heading;l&&l.execute({editor:t,config:{type:"heading",level:a}})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(H.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),c.jsx(g.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(g.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(H.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:Ta[o]},o))})]})}const Dn={bulletList:{label:"Bullet List",icon:H.List},orderedList:{label:"Numbered List",icon:H.ListOrdered},taskList:{label:"Task List",icon:H.ListTodo}};function Oa({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const a=()=>r(l=>l+1);return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const s=e.find(a=>t.isActive(a)),i=s?Dn[s].icon:H.List,o=a=>{const d=Ke[a];d&&d.execute({editor:t})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{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(g.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(a=>{const l=Dn[a].icon;return c.jsx(g.DropdownItem,{startContent:c.jsx(l,{size:16}),children:Dn[a].label},a)})})]})}function Da({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 Ia=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],La=["#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 be={min:50,max:200,step:10,default:100},ts={lineHeight:24,toolbarHeight:60},Fa={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},Pa={left:_.AlignLeft,center:_.AlignCenter,right:_.AlignRight,justify:_.AlignJustify};function yt(t){return Fa[t]}function Ra({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=x.useState(""),o=d=>{const u=d.target.value;e(u),s&&i("")},a=()=>{if(!t){i("Please enter a color");return}if(!In(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},l=d=>{d.key==="Enter"&&(d.preventDefault(),a())};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(g.Input,{type:"text",value:t,onChange:o,onKeyDown:l,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(G,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:a,"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 ns({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=x.useState(!1),[a,l]=x.useState(""),d=e==="textColor"?Ia:La,u=b=>{const y=Ke[e];y&&y.execute({editor:t,config:{type:e,color:b}}),o(!1),l("")},f=b=>{u(b)},m=()=>{const b=Ke[e];b&&b.execute({editor:t,config:{type:e,color:""}}),o(!1)},h=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),k=e==="textColor"?_.Palette:_.Highlighter;return c.jsxs(g.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(g.PopoverTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:h?"solid":"bordered",color:h?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(k,{size:16})})}),c.jsx(g.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(G,{size:"sm",variant:"light",isIconOnly:!0,onPress:m,"aria-label":"Clear color",children:c.jsx(_.X,{size:16})})]}),c.jsx(Da,{colors:d,onColorSelect:u}),n&&c.jsxs(c.Fragment,{children:[c.jsx(g.Divider,{}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),c.jsx(Ra,{value:a,onChange:l,onApply:f})]})]})]})})]})}function $a({zoom:t,onZoomChange:e,min:n=be.min,max:r=be.max,step:s=be.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},a=()=>{e(be.default)},l=t<=n,d=t>=r,u=t===be.default;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(g.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:l,onPress:i,"aria-label":"Zoom out",children:c.jsx(_.ZoomOut,{size:16})})}),c.jsx(g.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:c.jsxs("button",{type:"button",onClick:a,disabled:u,className:`
7
+ `,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const Ia=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],La=["#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 be={min:50,max:200,step:10,default:100},ts={lineHeight:24,toolbarHeight:60},Fa={bold:H.Bold,italic:H.Italic,strike:H.Strikethrough,underline:H.Underline,code:H.Code,textColor:H.Palette,highlight:H.Highlighter,link:H.Link2,paragraph:H.FileText,heading:H.Heading,bulletList:H.List,orderedList:H.ListOrdered,taskList:H.ListTodo,codeBlock:H.CodeSquare,blockquote:H.Quote,horizontalRule:H.Minus,clearMarks:H.Eraser,clearNodes:H.Eraser,undo:H.Undo2,redo:H.Redo2,hardBreak:H.CornerDownLeft,textAlign:H.AlignLeft},Pa={left:H.AlignLeft,center:H.AlignCenter,right:H.AlignRight,justify:H.AlignJustify};function yt(t){return Fa[t]}function Ra({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=x.useState(""),o=d=>{const u=d.target.value;e(u),s&&i("")},a=()=>{if(!t){i("Please enter a color");return}if(!In(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},l=d=>{d.key==="Enter"&&(d.preventDefault(),a())};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(g.Input,{type:"text",value:t,onChange:o,onKeyDown:l,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(G,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:a,"aria-label":"Apply custom color",isDisabled:!t||!In(t),children:c.jsx(H.Check,{size:16})})]}),c.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function ns({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=x.useState(!1),[a,l]=x.useState(""),d=e==="textColor"?Ia:La,u=y=>{const b=Ke[e];b&&b.execute({editor:t,config:{type:e,color:y}}),o(!1),l("")},f=y=>{u(y)},p=()=>{const y=Ke[e];y&&y.execute({editor:t,config:{type:e,color:""}}),o(!1)},h=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),k=e==="textColor"?H.Palette:H.Highlighter;return c.jsxs(g.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(g.PopoverTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:h?"solid":"bordered",color:h?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(k,{size:16})})}),c.jsx(g.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(G,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:c.jsx(H.X,{size:16})})]}),c.jsx(Da,{colors:d,onColorSelect:u}),n&&c.jsxs(c.Fragment,{children:[c.jsx(g.Divider,{}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),c.jsx(Ra,{value:a,onChange:l,onApply:f})]})]})]})})]})}function $a({zoom:t,onZoomChange:e,min:n=be.min,max:r=be.max,step:s=be.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},a=()=>{e(be.default)},l=t<=n,d=t>=r,u=t===be.default;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(g.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:l,onPress:i,"aria-label":"Zoom out",children:c.jsx(H.ZoomOut,{size:16})})}),c.jsx(g.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:c.jsxs("button",{type:"button",onClick:a,disabled:u,className:`
8
8
  text-xs text-default-500 min-w-[3ch] text-center px-2
9
9
  ${u?"cursor-default":"cursor-pointer hover:text-primary"}
10
- `,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(g.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:o,"aria-label":"Zoom in",children:c.jsx(_.ZoomIn,{size:16})})})]})}function Va({editor:t,isDisabled:e=!1}){const[n,r]=x.useState(!1),[s,i]=x.useState(""),[o,a]=x.useState(""),[l,d]=x.useState(!1),u=t.isActive("link"),f=h=>{if(h){const{from:k,to:b}=t.state.selection,y=t.isActive("link");let S="";if(y){const j=t.schema.marks.link,C=t.state.doc.resolve(k),A=V.getMarkRange(C,j);A&&(S=t.state.doc.textBetween(A.from,A.to,""))}else S=t.state.doc.textBetween(k,b,"");const N=t.getAttributes("link").href||"";i(S),a(N),d(y)}r(h)},m=()=>{if(o.trim()){const{from:h,to:k}=t.state.selection,b=t.schema.marks.link,y=t.state.doc.resolve(h),S=V.getMarkRange(y,b),N=S?.from??h,j=S?.to??k,C=t.state.doc.textBetween(N,j,"");s.trim()&&s!==C?t.chain().focus().setTextSelection({from:N,to:j}).deleteSelection().insertContent(`<a href="${o.trim()}">${s.trim()}</a>`).run():t.chain().focus().extendMarkRange("link").updateAttributes("link",{href:o.trim()}).run()}r(!1)};return c.jsxs(g.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[c.jsx(g.PopoverTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:c.jsx(_.Link,{size:16})})}),c.jsx(g.PopoverContent,{children:c.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:o,onChange:h=>a(h.target.value),onKeyDown:h=>h.key==="Enter"&&m(),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(G,{size:"sm",color:"primary",onPress:m,isDisabled:!o.trim(),children:l?"Update":"Apply"})]})})]})}function Ba({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(g.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 ci(t,e){const n=x.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const l=Ke[a];if(l)try{const d=l.canExecute?.(t)??!0,u=l.isActive?.(t)??!1;i[a]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),i[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=x.useState(n);return x.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const d=Ke[l];if(d)try{const u=d.canExecute?.(t)??!0,f=d.isActive?.(t)??!1;o[l]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),o[l]={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 di(t,e){const n=x.useCallback((o,a)=>{if(!t)return;const l=Ke[o];if(l)try{l.execute({editor:t,config:a}),e?.({type:"toggle",modifier:o})}catch(d){console.warn(`Failed to execute command for modifier: ${o}`,d)}},[t,e]),r=x.useCallback(o=>{n(o)},[n]),s=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.canExecute?.(t,a)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${o}`,d),!1}},[t]),i=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.isActive?.(t,a)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${o}`,d),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function za(t=be.default){const[e,n]=x.useState(t),r=x.useCallback((a=be.step)=>{n(l=>Math.min(be.max,l+a))},[]),s=x.useCallback((a=be.step)=>{n(l=>Math.max(be.min,l-a))},[]),i=x.useCallback(()=>{n(be.default)},[]),o=x.useCallback(a=>{const l=Math.max(be.min,Math.min(be.max,a));n(l)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=be.min,isMaxZoom:e>=be.max,isDefaultZoom:e===be.default}}const _a=["bold","italic","strike","underline","code"];function Ha({editor:t,modifiers:e,onToolbarAction:n}){const r=ci(t,e),{toggleModifier:s}=di(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>_a.includes(o));return i.length===0?null:c.jsx(Ba,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const a=r[o],l=yt(o);return c.jsx(st,{icon:l,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:a?.isActive,isDisabled:a?.isDisabled,onClick:()=>s(o)},o)})})}function Ua({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const a=ci(t,e),{toggleModifier:l,executeCommand:d}=di(t,o);if(!t)return null;const u=e.map(L=>Rt(L)),f=u.some(L=>["bold","italic","strike","underline","code"].includes(L)),m=u.some(L=>["textColor","highlight"].includes(L)),h=u.includes("heading"),k=u.includes("textAlign"),b=u.some(L=>["bulletList","orderedList","taskList"].includes(L)),y=u.includes("blockquote"),S=u.includes("codeBlock"),N=u.includes("link"),j=u.includes("horizontalRule"),C=u.some(L=>["undo","redo"].includes(L)),A=n!==void 0&&r!==void 0,M=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${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(Ha,{editor:t,modifiers:e,onToolbarAction:o}),(m||h||k||b||y||S||N||j||C||A)&&c.jsx(rt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&c.jsx(ns,{editor:t,type:"textColor",label:"Text color",isDisabled:a.textColor?.isDisabled}),u.includes("highlight")&&c.jsx(ns,{editor:t,type:"highlight",label:"Highlight",isDisabled:a.highlight?.isDisabled})]}),(h||k||b||y||S||N||j||C||A)&&c.jsx(rt,{})]}),h&&c.jsxs(c.Fragment,{children:[c.jsx(Ma,{editor:t}),(k||b||y||S||N||j||C||A)&&c.jsx(rt,{})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(L=>{const P=Pa[L],$=t.isActive({textAlign:L});return c.jsx(st,{icon:P,label:`Align ${L}`,isActive:$,onClick:()=>d("textAlign",{type:"textAlign",alignment:L})},L)})}),(b||y||S||N||j||C||A)&&c.jsx(rt,{})]}),b&&c.jsxs(c.Fragment,{children:[c.jsx(Oa,{editor:t,types:u.filter(L=>["bulletList","orderedList","taskList"].includes(L))}),(y||S||N||j||C||A)&&c.jsx(rt,{})]}),(y||S||N||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[y&&c.jsx(st,{icon:yt("blockquote"),label:"Blockquote",isActive:a.blockquote?.isActive,isDisabled:a.blockquote?.isDisabled,onClick:()=>l("blockquote")}),S&&c.jsx(st,{icon:yt("codeBlock"),label:"Code block",isActive:a.codeBlock?.isActive,isDisabled:a.codeBlock?.isDisabled,onClick:()=>l("codeBlock")}),N&&c.jsx(Va,{editor:t,isDisabled:a.link?.isDisabled}),j&&c.jsx(st,{icon:yt("horizontalRule"),label:"Horizontal rule",onClick:()=>l("horizontalRule")})]}),(C||A)&&c.jsx(rt,{})]}),C&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&c.jsx(st,{icon:yt("undo"),label:"Undo",isDisabled:a.undo?.isDisabled,onClick:()=>l("undo")}),u.includes("redo")&&c.jsx(st,{icon:yt("redo"),label:"Redo",isDisabled:a.redo?.isDisabled,onClick:()=>l("redo")})]}),A&&c.jsx(rt,{})]}),A&&c.jsx($a,{zoom:n,onZoomChange:L=>{r?.(L),o?.({type:"zoom",modifier:`${L}%`})}})]})})}const qa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ka=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Wa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ja=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ga=V.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",V.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[V.markInputRule({find:qa,type:this.type}),V.markInputRule({find:Wa,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:Ka,type:this.type}),V.markPasteRule({find:Ja,type:this.type})]}}),Za=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ya=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Xa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,el=V.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",V.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[V.markInputRule({find:Za,type:this.type}),V.markInputRule({find:Qa,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:Ya,type:this.type}),V.markPasteRule({find:Xa,type:this.type})]}}),tl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rl=V.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",V.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[V.markInputRule({find:tl,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:nl,type:this.type})]}}),sl=/(^|[^`])`([^`]+)`(?!`)/,il=/(^|[^`])`([^`]+)`(?!`)/g,ol=V.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",V.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[V.markInputRule({find:sl,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:il,type:this.type})]}}),al=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}`)})},ll=V.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&al(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",V.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}}}}),cl=V.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]}`,V.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=>V.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),dl=V.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",V.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ul="listItem",rs="textStyle",ss=/^\s*([-+*])\s$/,fl=V.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",V.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(ul,this.editor.getAttributes(rs)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=V.wrappingInputRule({find:ss,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=V.wrappingInputRule({find:ss,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rs),editor:this.editor})),[t]}}),hl="listItem",is="textStyle",os=/^(\d+)\.\s$/,pl=V.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",V.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",V.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(hl,this.editor.getAttributes(is)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=V.wrappingInputRule({find:os,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=V.wrappingInputRule({find:os,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(is)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ml=V.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",V.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 ui(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=ui(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function fi(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),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let d=0,u=Math.min(o.text.length,a.text.length);for(;d<u&&o.text[o.text.length-d-1]==a.text[a.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let d=fi(o.content,a.content,n-1,r-1);if(d)return d}n-=l,r-=l}}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,a=0;a<n;o++){let l=this.content[o],d=a+l.nodeSize;if(d>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let d=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=d},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 a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}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 ui(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fi(this,e,n,r)}findIndex(e){if(e==0)return Wt(0,e);if(e==this.size)return Wt(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?Wt(n+1,i):Wt(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 Ln={index:0,offset:0};function Wt(t,e){return Ln.index=t,Ln.offset=e,Ln}function Xn(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(!Xn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Xn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Ie{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&&Xn(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 Ie.none;if(e instanceof Ie)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Ie.none=[];class gl 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=pi(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(hi(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 hi(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=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(hi(i.content,e-s-1,n-s-1)))}function pi(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 a=pi(o.content,e-i-1,n,o);return a&&t.replaceChild(s,o.copy(a))}function xl(t){return t.tag!=null}function yl(t){return t.style!=null}class rn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(xl(s))this.tags.push(s);else if(yl(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 ls(this,n,!1);return r.addAll(e,Ie.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ls(this,n,!0);return r.addAll(e,Ie.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],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||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 a=n[o];if((a.priority==null?50:a.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=cs(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=cs(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rn(e,rn.schemaRules(e)))}}const mi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},bl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gi={ol:!0,ul:!0},$t=1,er=2,Ot=4;function as(t,e,n){return e!=null?(e?$t:0)|(e==="full"?er:0):t&&t.whitespace=="pre"?$t|er:n&~Ot}class Jt{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=Ie.none,this.match=i||(o&Ot?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&$t)){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&&!mi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ls{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=as(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Jt(s.type,s.attrs,Ie.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Jt(null,null,Ie.none,!0,null,o):i=new Jt(e.schema.topNodeType,null,Ie.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&er?"full":this.localPreserveWS||(s.options&$t)>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(g.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:o,"aria-label":"Zoom in",children:c.jsx(H.ZoomIn,{size:16})})})]})}function Va({editor:t,isDisabled:e=!1}){const[n,r]=x.useState(!1),[s,i]=x.useState(""),[o,a]=x.useState(""),[l,d]=x.useState(!1),u=t.isActive("link"),f=h=>{if(h){const{from:k,to:y}=t.state.selection,b=t.isActive("link");let S="";if(b){const j=t.schema.marks.link,C=t.state.doc.resolve(k),A=$.getMarkRange(C,j);A&&(S=t.state.doc.textBetween(A.from,A.to,""))}else S=t.state.doc.textBetween(k,y,"");const N=t.getAttributes("link").href||"";i(S),a(N),d(b)}r(h)},p=()=>{if(o.trim()){const{from:h,to:k}=t.state.selection,y=t.schema.marks.link,b=t.state.doc.resolve(h),S=$.getMarkRange(b,y),N=S?.from??h,j=S?.to??k,C=t.state.doc.textBetween(N,j,"");s.trim()&&s!==C?t.chain().focus().setTextSelection({from:N,to:j}).deleteSelection().insertContent(`<a href="${o.trim()}">${s.trim()}</a>`).run():t.chain().focus().extendMarkRange("link").updateAttributes("link",{href:o.trim()}).run()}r(!1)};return c.jsxs(g.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[c.jsx(g.PopoverTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:c.jsx(H.Link,{size:16})})}),c.jsx(g.PopoverContent,{children:c.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:o,onChange:h=>a(h.target.value),onKeyDown:h=>h.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(G,{size:"sm",color:"primary",onPress:p,isDisabled:!o.trim(),children:l?"Update":"Apply"})]})})]})}function Ba({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(g.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 ci(t,e){const n=x.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const l=Ke[a];if(l)try{const d=l.canExecute?.(t)??!0,u=l.isActive?.(t)??!1;i[a]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),i[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=x.useState(n);return x.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const d=Ke[l];if(d)try{const u=d.canExecute?.(t)??!0,f=d.isActive?.(t)??!1;o[l]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),o[l]={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 di(t,e){const n=x.useCallback((o,a)=>{if(!t)return;const l=Ke[o];if(l)try{l.execute({editor:t,config:a}),e?.({type:"toggle",modifier:o})}catch(d){console.warn(`Failed to execute command for modifier: ${o}`,d)}},[t,e]),r=x.useCallback(o=>{n(o)},[n]),s=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.canExecute?.(t,a)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${o}`,d),!1}},[t]),i=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.isActive?.(t,a)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${o}`,d),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function za(t=be.default){const[e,n]=x.useState(t),r=x.useCallback((a=be.step)=>{n(l=>Math.min(be.max,l+a))},[]),s=x.useCallback((a=be.step)=>{n(l=>Math.max(be.min,l-a))},[]),i=x.useCallback(()=>{n(be.default)},[]),o=x.useCallback(a=>{const l=Math.max(be.min,Math.min(be.max,a));n(l)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=be.min,isMaxZoom:e>=be.max,isDefaultZoom:e===be.default}}const _a=["bold","italic","strike","underline","code"];function Ha({editor:t,modifiers:e,onToolbarAction:n}){const r=ci(t,e),{toggleModifier:s}=di(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>_a.includes(o));return i.length===0?null:c.jsx(Ba,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const a=r[o],l=yt(o);return c.jsx(st,{icon:l,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:a?.isActive,isDisabled:a?.isDisabled,onClick:()=>s(o)},o)})})}function Ua({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const a=ci(t,e),{toggleModifier:l,executeCommand:d}=di(t,o);if(!t)return null;const u=e.map(I=>Rt(I)),f=u.some(I=>["bold","italic","strike","underline","code"].includes(I)),p=u.some(I=>["textColor","highlight"].includes(I)),h=u.includes("heading"),k=u.includes("textAlign"),y=u.some(I=>["bulletList","orderedList","taskList"].includes(I)),b=u.includes("blockquote"),S=u.includes("codeBlock"),N=u.includes("link"),j=u.includes("horizontalRule"),C=u.some(I=>["undo","redo"].includes(I)),A=n!==void 0&&r!==void 0,M=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${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(Ha,{editor:t,modifiers:e,onToolbarAction:o}),(p||h||k||y||b||S||N||j||C||A)&&c.jsx(rt,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&c.jsx(ns,{editor:t,type:"textColor",label:"Text color",isDisabled:a.textColor?.isDisabled}),u.includes("highlight")&&c.jsx(ns,{editor:t,type:"highlight",label:"Highlight",isDisabled:a.highlight?.isDisabled})]}),(h||k||y||b||S||N||j||C||A)&&c.jsx(rt,{})]}),h&&c.jsxs(c.Fragment,{children:[c.jsx(Ma,{editor:t}),(k||y||b||S||N||j||C||A)&&c.jsx(rt,{})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(I=>{const _=Pa[I],P=t.isActive({textAlign:I});return c.jsx(st,{icon:_,label:`Align ${I}`,isActive:P,onClick:()=>d("textAlign",{type:"textAlign",alignment:I})},I)})}),(y||b||S||N||j||C||A)&&c.jsx(rt,{})]}),y&&c.jsxs(c.Fragment,{children:[c.jsx(Oa,{editor:t,types:u.filter(I=>["bulletList","orderedList","taskList"].includes(I))}),(b||S||N||j||C||A)&&c.jsx(rt,{})]}),(b||S||N||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[b&&c.jsx(st,{icon:yt("blockquote"),label:"Blockquote",isActive:a.blockquote?.isActive,isDisabled:a.blockquote?.isDisabled,onClick:()=>l("blockquote")}),S&&c.jsx(st,{icon:yt("codeBlock"),label:"Code block",isActive:a.codeBlock?.isActive,isDisabled:a.codeBlock?.isDisabled,onClick:()=>l("codeBlock")}),N&&c.jsx(Va,{editor:t,isDisabled:a.link?.isDisabled}),j&&c.jsx(st,{icon:yt("horizontalRule"),label:"Horizontal rule",onClick:()=>l("horizontalRule")})]}),(C||A)&&c.jsx(rt,{})]}),C&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&c.jsx(st,{icon:yt("undo"),label:"Undo",isDisabled:a.undo?.isDisabled,onClick:()=>l("undo")}),u.includes("redo")&&c.jsx(st,{icon:yt("redo"),label:"Redo",isDisabled:a.redo?.isDisabled,onClick:()=>l("redo")})]}),A&&c.jsx(rt,{})]}),A&&c.jsx($a,{zoom:n,onZoomChange:I=>{r?.(I),o?.({type:"zoom",modifier:`${I}%`})}})]})})}const qa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ka=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Wa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ja=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ga=$.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",$.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[$.markInputRule({find:qa,type:this.type}),$.markInputRule({find:Wa,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:Ka,type:this.type}),$.markPasteRule({find:Ja,type:this.type})]}}),Za=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ya=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Xa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,el=$.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",$.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[$.markInputRule({find:Za,type:this.type}),$.markInputRule({find:Qa,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:Ya,type:this.type}),$.markPasteRule({find:Xa,type:this.type})]}}),tl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rl=$.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",$.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[$.markInputRule({find:tl,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:nl,type:this.type})]}}),sl=/(^|[^`])`([^`]+)`(?!`)/,il=/(^|[^`])`([^`]+)`(?!`)/g,ol=$.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",$.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[$.markInputRule({find:sl,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:il,type:this.type})]}}),al=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}`)})},ll=$.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&al(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",$.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}}}}),cl=$.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]}`,$.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=>$.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),dl=$.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",$.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ul="listItem",rs="textStyle",ss=/^\s*([-+*])\s$/,fl=$.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",$.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(ul,this.editor.getAttributes(rs)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$.wrappingInputRule({find:ss,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$.wrappingInputRule({find:ss,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rs),editor:this.editor})),[t]}}),hl="listItem",is="textStyle",os=/^(\d+)\.\s$/,pl=$.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",$.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",$.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(hl,this.editor.getAttributes(is)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$.wrappingInputRule({find:os,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=$.wrappingInputRule({find:os,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(is)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ml=$.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",$.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 ui(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=ui(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function fi(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),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let d=0,u=Math.min(o.text.length,a.text.length);for(;d<u&&o.text[o.text.length-d-1]==a.text[a.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let d=fi(o.content,a.content,n-1,r-1);if(d)return d}n-=l,r-=l}}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,a=0;a<n;o++){let l=this.content[o],d=a+l.nodeSize;if(d>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let d=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=d},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 a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}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 ui(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fi(this,e,n,r)}findIndex(e){if(e==0)return Wt(0,e);if(e==this.size)return Wt(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?Wt(n+1,i):Wt(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 Ln={index:0,offset:0};function Wt(t,e){return Ln.index=t,Ln.offset=e,Ln}function Xn(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(!Xn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Xn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Ie{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&&Xn(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 Ie.none;if(e instanceof Ie)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Ie.none=[];class gl 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=pi(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(hi(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 hi(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=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(hi(i.content,e-s-1,n-s-1)))}function pi(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 a=pi(o.content,e-i-1,n,o);return a&&t.replaceChild(s,o.copy(a))}function xl(t){return t.tag!=null}function yl(t){return t.style!=null}class rn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(xl(s))this.tags.push(s);else if(yl(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 ls(this,n,!1);return r.addAll(e,Ie.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ls(this,n,!0);return r.addAll(e,Ie.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],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||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 a=n[o];if((a.priority==null?50:a.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=cs(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=cs(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rn(e,rn.schemaRules(e)))}}const mi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},bl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gi={ol:!0,ul:!0},$t=1,er=2,Ot=4;function as(t,e,n){return e!=null?(e?$t:0)|(e==="full"?er:0):t&&t.whitespace=="pre"?$t|er:n&~Ot}class Jt{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=Ie.none,this.match=i||(o&Ot?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&$t)){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&&!mi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ls{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=as(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Jt(s.type,s.attrs,Ie.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Jt(null,null,Ie.none,!0,null,o):i=new Jt(e.schema.topNodeType,null,Ie.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&er?"full":this.localPreserveWS||(s.options&$t)>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 a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));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 a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.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(),a;gi.hasOwnProperty(o)&&this.parser.normalizeLists&&vl(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:bl.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let d,u=this.needsBlock;if(mi.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,l,d,l.consuming===!1?a: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 a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(d=>!l.clearMark(d)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;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 l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=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(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;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,a=0;o>=0;o--){let l=this.nodes[o],d=l.findWrapping(e);if(d&&(!s||s.length>d.length+a)&&(s=d,i=l,!d.length))break;if(l.solid){if(r)break;a+=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=Ie.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):ds(a.type,e.type))&&(o=a.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 a=as(e,i,o.options);o.options&Ot&&o.content.length==0&&(a|=Ot);let l=Ie.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):ds(d.type,e))?(l=d.addToSet(l),!1):!0),this.nodes.push(new Jt(e,n,l,s,null,a)),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|=$t)}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=(a,l)=>{for(;a>=0;a--){let d=n[a];if(d==""){if(a==n.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;l--}}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 vl(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&gi.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 cs(t){let e={};for(let n in t)e[n]=t[n];return e}function ds(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:d,next:u}=a.edge(l);if(d==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class yn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fn(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let d=o.marks[l];if(!this.marks[d.type.name]){l++;continue}if(!d.eq(i[a][0])||d.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let d=o.marks[l++],u=this.serializeMark(d,o.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Qt(Fn(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&&Qt(Fn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Qt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=us(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return us(e.marks)}}function us(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fn(t){return t.document||window.document}const fs=new WeakMap;function Sl(t){let e=fs.get(t);return e===void 0&&fs.set(t,e=Cl(t)),e}function Cl(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 Qt(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=Sl(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 a,l=n?t.createElementNS(n,s):t.createElement(s),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let m=f.indexOf(" ");m>0?l.setAttributeNS(f.slice(0,m),f.slice(m+1),d[f]):f=="style"&&l.style?l.style.cssText=d[f]:l.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:k}=Qt(t,m,n,r);if(l.appendChild(h),k){if(a)throw new RangeError("Multiple content holes");a=k}}}return{dom:l,contentDOM:a}}const xi=65535,yi=Math.pow(2,16);function wl(t,e){return t+e*yi}function hs(t){return t&xi}function Nl(t){return(t-(t&xi))/yi}const bi=1,vi=2,Xt=4,ki=8;class tr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ki)>0}get deletedBefore(){return(this.delInfo&(bi|Xt))>0}get deletedAfter(){return(this.delInfo&(vi|Xt))>0}get deletedAcross(){return(this.delInfo&Xt)>0}}class Ee{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ee.empty)return Ee.empty}recover(e){let n=0,r=hs(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+Nl(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 a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let d=this.ranges[a+i],u=this.ranges[a+o],f=l+d;if(e<=f){let m=d?e==l?-1:e==f?1:n:n,h=l+s+(m<0?0:u);if(r)return h;let k=e==(n<0?l:f)?null:wl(a/3,e-l),b=e==l?vi:e==f?bi:Xt;return(n<0?e!=l:e!=f)&&(b|=ki),new tr(h,b,k)}s+=u-d}return r?e+s:new tr(e+s,0,null)}touches(e,n){let r=0,s=hs(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let d=this.ranges[a+i],u=l+d;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-d}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],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];e(a,a+d,l,l+u),i+=u-d}}invert(){return new Ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ee.empty:new Ee(e<0?[0,-e,0]:[0,0,e])}}Ee.empty=new Ee([]);class sn{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 sn(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 sn;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],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new tr(e,s,null)}}const Pn=Object.create(null);class ve{getMap(){return Ee.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Pn[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 Pn)throw new RangeError("Duplicate use of step JSON ID "+e);return Pn[e]=n,n.prototype.jsonID=e,n}}class fe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,n,r,s){try{return fe.ok(e.replace(n,r,s))}catch(i){if(i instanceof gl)return fe.fail(i.message);throw i}}}function kr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(kr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class ot extends ve{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(kr(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,i)}invert(){return new at(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:"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 ot(n.from,n.to,e.markFromJSON(n.mark))}}ve.jsonID("addMark",ot);class at extends ve{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(kr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,r)}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 at(n.pos,r.pos,this.mark)}merge(e){return e instanceof at&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new at(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 at(n.from,n.to,e.markFromJSON(n.mark))}}ve.jsonID("removeMark",at);class lt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fe.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 Vt(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))}}ve.jsonID("addNodeMark",lt);class Vt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return fe.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 Vt(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 Vt(n.pos,e.markFromJSON(n.mark))}}ve.jsonID("removeNodeMark",Vt);class qe extends ve{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&nr(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ee([this.from,this.to-this.from,this.slice.size])}invert(e){return new qe(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 qe(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof qe)||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 qe(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 qe(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 qe(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}}ve.jsonID("replace",qe);class St extends ve{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(nr(e,this.from,this.gapFrom)||nr(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.fail("Content does not fit in gap")}getMap(){return new Ee([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 St(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 St(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 St(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}ve.jsonID("replaceAround",St);function nr(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 Si(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 a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),d=r.node(o),u=!1;if(i==1)u=d.canReplace(l,l,s);else{let f=d.contentMatchAt(l).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(l,l,f[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}class Dt extends ve{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 fe.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 fe.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return Ee.empty}invert(e){return new Dt(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 Dt(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 Dt(n.pos,n.attr,n.value)}}ve.jsonID("attr",Dt);class on extends ve{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 fe.ok(r)}getMap(){return Ee.empty}invert(e){return new on(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 on(n.attr,n.value)}}ve.jsonID("docAttr",on);let Bt=class extends Error{};Bt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Bt.prototype=Object.create(Error.prototype);Bt.prototype.constructor=Bt;Bt.prototype.name="TransformError";const Rn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Al(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 a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:d}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(d.pos),a?K.empty:n),a==0&&gs(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:a}=s[i],l=e.mapping.slice(r),d=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),gs(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):bt(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?bt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):bt(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 _e(e.node(0))}static atStart(e){return bt(e,e,0,0,1)||new _e(e)}static atEnd(e){return bt(e,e,e.content.size,e.childCount,-1)||new _e(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 Al{constructor(e,n){this.$from=e,this.$to=n}}let ps=!1;function ms(t){!ps&&!t.parent.inlineContent&&(ps=!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){ms(e),ms(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 bn(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 bn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new bn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class W 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 W(i)}content(){return new K(q.from(this.node),0,0)}eq(e){return e instanceof W&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Sr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new W(e.resolve(n.anchor))}static create(e,n){return new W(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}W.prototype.visible=!1;X.jsonID("node",W);class Sr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new bn(r,r):new Sr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&W.isSelectable(r)?new W(n):X.near(n)}}class _e 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 _e(e)}map(e){return new _e(e)}eq(e){return e instanceof _e}getBookmark(){return jl}}X.jsonID("all",_e);const jl={map(){return this},resolve(t){return new _e(t)}};function bt(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 a=e.child(o);if(a.isAtom){if(!i&&W.isSelectable(a))return W.create(t,n-(s<0?a.nodeSize:0))}else{let l=bt(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function gs(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof St))return;let i=t.mapping.maps[r],o;i.forEach((a,l,d,u)=>{o==null&&(o=u)}),t.setSelection(X.near(t.doc.resolve(o),n))}function xs(t,e){return!e||!t?t:t.bind(e)}class Gt{constructor(e,n,r){this.name=e,this.init=xs(n.init,r),this.apply=xs(n.apply,r)}}new Gt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Gt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Ci(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ci(s,e,{})),n[r]=s}return n}class vn{constructor(e){this.spec=e,this.props={},e.props&&Ci(e.props,this,this.props),this.key=e.key?e.key.key:wi("plugin")}getState(e){return e[this.key]}}const $n=Object.create(null);function wi(t){return t in $n?t+"$"+ ++$n[t]:($n[t]=0,t+"$")}class Cr{constructor(e="key"){this.key=wi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const El=/^```([a-z]+)?[\s\n]$/,Tl=/^~~~([a-z]+)?[\s\n]$/,Ml=V.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",V.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 a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(d=>!l.clearMark(d)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;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 l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=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(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;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,a=0;o>=0;o--){let l=this.nodes[o],d=l.findWrapping(e);if(d&&(!s||s.length>d.length+a)&&(s=d,i=l,!d.length))break;if(l.solid){if(r)break;a+=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=Ie.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):ds(a.type,e.type))&&(o=a.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 a=as(e,i,o.options);o.options&Ot&&o.content.length==0&&(a|=Ot);let l=Ie.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):ds(d.type,e))?(l=d.addToSet(l),!1):!0),this.nodes.push(new Jt(e,n,l,s,null,a)),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|=$t)}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=(a,l)=>{for(;a>=0;a--){let d=n[a];if(d==""){if(a==n.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;l--}}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 vl(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&gi.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 cs(t){let e={};for(let n in t)e[n]=t[n];return e}function ds(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:d,next:u}=a.edge(l);if(d==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class yn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fn(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let d=o.marks[l];if(!this.marks[d.type.name]){l++;continue}if(!d.eq(i[a][0])||d.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let d=o.marks[l++],u=this.serializeMark(d,o.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Qt(Fn(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&&Qt(Fn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Qt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=us(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return us(e.marks)}}function us(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fn(t){return t.document||window.document}const fs=new WeakMap;function Sl(t){let e=fs.get(t);return e===void 0&&fs.set(t,e=Cl(t)),e}function Cl(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 Qt(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=Sl(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 a,l=n?t.createElementNS(n,s):t.createElement(s),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&l.style?l.style.cssText=d[f]:l.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:k}=Qt(t,p,n,r);if(l.appendChild(h),k){if(a)throw new RangeError("Multiple content holes");a=k}}}return{dom:l,contentDOM:a}}const xi=65535,yi=Math.pow(2,16);function wl(t,e){return t+e*yi}function hs(t){return t&xi}function Nl(t){return(t-(t&xi))/yi}const bi=1,vi=2,Xt=4,ki=8;class tr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ki)>0}get deletedBefore(){return(this.delInfo&(bi|Xt))>0}get deletedAfter(){return(this.delInfo&(vi|Xt))>0}get deletedAcross(){return(this.delInfo&Xt)>0}}class Ee{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ee.empty)return Ee.empty}recover(e){let n=0,r=hs(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+Nl(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 a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let d=this.ranges[a+i],u=this.ranges[a+o],f=l+d;if(e<=f){let p=d?e==l?-1:e==f?1:n:n,h=l+s+(p<0?0:u);if(r)return h;let k=e==(n<0?l:f)?null:wl(a/3,e-l),y=e==l?vi:e==f?bi:Xt;return(n<0?e!=l:e!=f)&&(y|=ki),new tr(h,y,k)}s+=u-d}return r?e+s:new tr(e+s,0,null)}touches(e,n){let r=0,s=hs(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let d=this.ranges[a+i],u=l+d;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-d}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],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];e(a,a+d,l,l+u),i+=u-d}}invert(){return new Ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ee.empty:new Ee(e<0?[0,-e,0]:[0,0,e])}}Ee.empty=new Ee([]);class sn{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 sn(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 sn;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],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new tr(e,s,null)}}const Pn=Object.create(null);class ve{getMap(){return Ee.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Pn[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 Pn)throw new RangeError("Duplicate use of step JSON ID "+e);return Pn[e]=n,n.prototype.jsonID=e,n}}class fe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,n,r,s){try{return fe.ok(e.replace(n,r,s))}catch(i){if(i instanceof gl)return fe.fail(i.message);throw i}}}function kr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(kr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class ot extends ve{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(kr(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,i)}invert(){return new at(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:"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 ot(n.from,n.to,e.markFromJSON(n.mark))}}ve.jsonID("addMark",ot);class at extends ve{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(kr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,r)}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 at(n.pos,r.pos,this.mark)}merge(e){return e instanceof at&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new at(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 at(n.from,n.to,e.markFromJSON(n.mark))}}ve.jsonID("removeMark",at);class lt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fe.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 Vt(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))}}ve.jsonID("addNodeMark",lt);class Vt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return fe.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 Vt(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 Vt(n.pos,e.markFromJSON(n.mark))}}ve.jsonID("removeNodeMark",Vt);class qe extends ve{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&nr(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ee([this.from,this.to-this.from,this.slice.size])}invert(e){return new qe(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 qe(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof qe)||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 qe(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 qe(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 qe(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}}ve.jsonID("replace",qe);class St extends ve{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(nr(e,this.from,this.gapFrom)||nr(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.fail("Content does not fit in gap")}getMap(){return new Ee([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 St(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 St(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 St(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}ve.jsonID("replaceAround",St);function nr(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 Si(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 a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),d=r.node(o),u=!1;if(i==1)u=d.canReplace(l,l,s);else{let f=d.contentMatchAt(l).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(l,l,f[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}class Dt extends ve{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 fe.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 fe.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return Ee.empty}invert(e){return new Dt(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 Dt(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 Dt(n.pos,n.attr,n.value)}}ve.jsonID("attr",Dt);class on extends ve{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 fe.ok(r)}getMap(){return Ee.empty}invert(e){return new on(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 on(n.attr,n.value)}}ve.jsonID("docAttr",on);let Bt=class extends Error{};Bt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Bt.prototype=Object.create(Error.prototype);Bt.prototype.constructor=Bt;Bt.prototype.name="TransformError";const Rn=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Al(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 a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:d}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(d.pos),a?K.empty:n),a==0&&gs(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:a}=s[i],l=e.mapping.slice(r),d=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),gs(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):bt(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?bt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):bt(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 _e(e.node(0))}static atStart(e){return bt(e,e,0,0,1)||new _e(e)}static atEnd(e){return bt(e,e,e.content.size,e.childCount,-1)||new _e(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()}}ee.prototype.visible=!0;class Al{constructor(e,n){this.$from=e,this.$to=n}}let ps=!1;function ms(t){!ps&&!t.parent.inlineContent&&(ps=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Q extends ee{constructor(e,n=e){ms(e),ms(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 ee.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 bn(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=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Q(e,n)}}ee.jsonID("text",Q);class bn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new bn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class J extends ee{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?ee.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 Sr(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;ee.jsonID("node",J);class Sr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new bn(r,r):new Sr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):ee.near(n)}}class _e extends ee{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=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new _e(e)}map(e){return new _e(e)}eq(e){return e instanceof _e}getBookmark(){return jl}}ee.jsonID("all",_e);const jl={map(){return this},resolve(t){return new _e(t)}};function bt(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 a=e.child(o);if(a.isAtom){if(!i&&J.isSelectable(a))return J.create(t,n-(s<0?a.nodeSize:0))}else{let l=bt(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function gs(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof St))return;let i=t.mapping.maps[r],o;i.forEach((a,l,d,u)=>{o==null&&(o=u)}),t.setSelection(ee.near(t.doc.resolve(o),n))}function xs(t,e){return!e||!t?t:t.bind(e)}class Gt{constructor(e,n,r){this.name=e,this.init=xs(n.init,r),this.apply=xs(n.apply,r)}}new Gt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gt("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new Gt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Ci(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ci(s,e,{})),n[r]=s}return n}class vn{constructor(e){this.spec=e,this.props={},e.props&&Ci(e.props,this,this.props),this.key=e.key?e.key.key:wi("plugin")}getState(e){return e[this.key]}}const $n=Object.create(null);function wi(t){return t in $n?t+"$"+ ++$n[t]:($n[t]=0,t+"$")}class Cr{constructor(e="key"){this.key=wi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const El=/^```([a-z]+)?[\s\n]$/,Tl=/^~~~([a-z]+)?[\s\n]$/,Ml=$.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",$.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
13
13
 
14
- `);return!i||!o?!1:t.chain().command(({tr:a})=>(a.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 a=s.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:d})=>(d.setSelection(X.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[V.textblockTypeInputRule({find:El,type:this.type,getAttributes:t=>({language:t[1]})}),V.textblockTypeInputRule({find:Tl,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vn({key:new Cr("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:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
15
- `));return o.replaceSelectionWith(this.type.create({language:i},l)),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}}})]}}),Ol=/^\s*>\s$/,Dl=V.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",V.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[V.wrappingInputRule({find:Ol,type:this.type})]}}),Il=V.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",V.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!V.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}):V.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:d}=o.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?o.setSelection(Q.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(W.create(o.doc,d.pos)):o.setSelection(Q.create(o.doc,d.pos));else{const f=(l=d.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(o.insert(u,f),o.setSelection(Q.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[V.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ll=V.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",V.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:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&l&&o){const f=l.filter(m=>a.includes(m.type.name));d.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var an=200,me=function(){};me.prototype.append=function(e){return e.length?(e=me.from(e),!this.length&&e||e.length<an&&this.leafAppend(e)||this.length<an&&e.leafPrepend(this)||this.appendInner(e)):this};me.prototype.prepend=function(e){return e.length?me.from(e).append(this):this};me.prototype.appendInner=function(e){return new Fl(this,e)};me.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};me.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)};me.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};me.from=function(e){return e instanceof me?e:e&&e.length?new Ni(e):me.empty};var Ni=(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,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=an)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=an)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})(me);me.empty=new Ni([]);var Fl=(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 a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),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})(me);const Pl=500;class Fe{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,a,l,d=[],u=[];return this.items.forEach((f,m)=>{if(!f.step){s||(s=this.remapping(r,m+1),i=s.maps.length),i--,u.push(f);return}if(s){u.push(new Be(f.map));let h=f.step.map(s.slice(i)),k;h&&o.maybeStep(h).doc&&(k=o.mapping.maps[o.mapping.maps.length-1],d.push(new Be(k,void 0,void 0,d.length+u.length))),i--,k&&s.appendMap(k,i)}else o.maybeStep(f.step);if(f.selection)return a=s?f.selection.map(s.slice(i)):f.selection,l=new Fe(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),m=new Be(e.mapping.maps[u],f,n),h;(h=l&&l.merge(m))&&(m=h,u?i.pop():a=a.slice(0,a.length-1)),i.push(m),n&&(o++,n=void 0),s||(l=m)}let d=o-r.depth;return d>$l&&(a=Rl(a,d),o-=d),new Fe(a.append(i),o)}remapping(e,n){let r=new sn;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 Fe(this.items.append(e.map(n=>new Be(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,a=this.eventCount;this.items.forEach(m=>{m.selection&&a--},s);let l=n;this.items.forEach(m=>{let h=i.getMirror(--l);if(h==null)return;o=Math.min(o,h);let k=i.maps[h];if(m.step){let b=e.steps[h].invert(e.docs[h]),y=m.selection&&m.selection.map(i.slice(l+1,h));y&&a++,r.push(new Be(k,b,y))}else r.push(new Be(k))},s);let d=[];for(let m=n;m<o;m++)d.push(new Be(i.maps[m]));let u=this.items.slice(0,s).append(d).append(r),f=new Fe(u,a);return f.emptyItemCount()>Pl&&(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,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(n.slice(r)),d=l&&l.getMap();if(r--,d&&n.appendMap(d,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let f=new Be(d.invert(),l,u),m,h=s.length-1;(m=s.length&&s[h].merge(f))?s[h]=m:s.push(f)}}else o.map&&r--},this.items.length,0),new Fe(me.from(s.reverse()),i)}}Fe.empty=new Fe(me.empty,0);function Rl(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Be{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 Be(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const $l=20;function Vl(t,e,n,r){let s=n.getMeta(dt),i;if(s)return s.historyState;n.getMeta(_l)&&(t=new Ze(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(dt))return o.getMeta(dt).redo?new Ze(t.done.addTransform(n,void 0,r,en(e)),t.undone,ys(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,en(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Bl(n,t.prevRanges)),d=o?Vn(t.prevRanges,n.mapping):ys(n.mapping.maps);return new Ze(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,en(e)),Fe.empty,d,n.time,a??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Bl(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 ys(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 Vn(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 zl(t,e,n){let r=en(e),s=dt.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),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new Ze(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(dt,{redo:n,historyState:l})}let Bn=!1,bs=null;function en(t){let e=t.plugins;if(bs!=e){Bn=!1,bs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Bn=!0;break}}return Bn}const dt=new Cr("history"),_l=new Cr("closeHistory");function Hl(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new vn({key:dt,state:{init(){return new Ze(Fe.empty,Fe.empty,null,0,-1)},apply(e,n,r){return Vl(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?ji:r=="historyRedo"?Ei:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Ai(t,e){return(n,r)=>{let s=dt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=zl(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const ji=Ai(!1,!0),Ei=Ai(!0,!0),vs=V.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ji(t,e),redo:()=>({state:t,dispatch:e})=>Ei(t,e)}},addProseMirrorPlugins(){return[Hl(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()}}}),Ul=V.Node.create({name:"doc",topNode:!0,content:"block+"}),ql=V.Node.create({name:"text",group:"inline"});function Kl(t={}){return new vn({view(e){return new Wl(e,t)}})}class Wl{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,a=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let k=h.getBoundingClientRect(),b=f?k.bottom:k.top;f&&m&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;r={left:k.left,right:k.right,top:b-y,bottom:b+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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 d,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),m=f.width/l.offsetWidth,h=f.height/l.offsetHeight;d=f.left-l.scrollLeft*m,u=f.top-l.scrollTop*h}this.element.style.left=(r.left-d)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"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 a=Si(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}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 Jl=V.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Kl(this.options)]}});var et={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:"'"},ln={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gl=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zl=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ye=0;ye<10;ye++)et[48+ye]=et[96+ye]=String(ye);for(var ye=1;ye<=24;ye++)et[ye+111]="F"+ye;for(var ye=65;ye<=90;ye++)et[ye]=String.fromCharCode(ye+32),ln[ye]=String.fromCharCode(ye);for(var zn in et)ln.hasOwnProperty(zn)||(ln[zn]=et[zn]);function Yl(t){var e=Gl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ln:et)[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 Ql=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Xl=typeof navigator<"u"&&/Win/.test(navigator.platform);function ec(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ql?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function tc(t){let e=Object.create(null);for(let n in t)e[ec(n)]=t[n];return e}function _n(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 nc(t){let e=tc(t);return function(n,r){let s=Yl(r),i,o=e[_n(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[_n(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Xl&&r.ctrlKey&&r.altKey)&&(i=et[r.keyCode])&&i!=s){let a=e[_n(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const pt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ti=function(t,e,n,r){return n&&(ks(t,e,n,r,-1)||ks(t,e,n,r,1))},rc=/^(img|br|input|textarea|hr)$/i;function ks(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:cn(t))){let o=t.parentNode;if(!o||o.nodeType!=1||wr(t)||rc.test(t.nodeName)||t.contentEditable=="false")return!1;e=pt(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?cn(t):0}else return!1}}function cn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sc(t,e,n){for(let r=e==0,s=e==cn(t);r||s;){if(t==n)return!0;let i=pt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==cn(t)}}function wr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Mi=function(t){return t.focusNode&&Ti(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Oi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const He=typeof navigator<"u"?navigator:null,Ss=typeof document<"u"?document:null,tt=He&&He.userAgent||"",rr=/Edge\/(\d+)/.exec(tt),Di=/MSIE \d/.exec(tt),sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),Ut=!!(Di||sr||rr),Ii=Di?document.documentMode:sr?+sr[1]:rr?+rr[1]:0,kn=!Ut&&/gecko\/(\d+)/i.test(tt);kn&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];const ir=!Ut&&/Chrome\/(\d+)/.exec(tt),We=!!ir,Li=ir?+ir[1]:0,mt=!Ut&&!!He&&/Apple Computer/.test(He.vendor),Nr=mt&&(/Mobile\/\w+/.test(tt)||!!He&&He.maxTouchPoints>2),De=Nr||(He?/Mac/.test(He.platform):!1),Fi=He?/Win/.test(He.platform):!1,qt=/Android \d/.test(tt),Ar=!!Ss&&"webkitFontSmoothing"in Ss.documentElement.style,ic=Ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function oc(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 a=r.resolve(o),l,d;if(Mi(n)){for(l=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&W.isSelectable(f)&&s.parent&&!(f.isInline&&sc(n.focusNode,n.focusOffset,s.dom))){let m=s.posBefore;d=new W(o==m?a:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let h=0;h<n.rangeCount;h++){let k=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(k.startContainer,k.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(k.endContainer,k.endOffset,-1))}if(f<0)return null;[l,o]=m==t.state.selection.anchor?[m,f]:[f,m],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!d){let f=e=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;d=Ri(t,u,a,f)}return d}function Pi(t){return t.editable?t.hasFocus():dc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function jr(t,e=!1){let n=t.state.selection;if(cc(t,n),!!Pi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&We){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ti(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)lc(t);else{let{anchor:r,head:s}=n,i,o;Cs&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=ws(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ws(t,n.to))),t.docView.setSelection(r,s,t,e),Cs&&(i&&Ns(i),o&&Ns(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ac(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Cs=mt||We&&Li<63;function ws(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(mt&&s&&s.contentEditable=="false")return Hn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hn(s);if(i)return Hn(i)}}function Hn(t){return t.contentEditable="true",mt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ns(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function ac(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(()=>{(!Pi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function lc(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ut&&Ii<=11&&(n.disabled=!0,n.disabled=!1)}function cc(t,e){if(e instanceof W){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(As(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else As(t)}function As(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ri(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function dc(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 or(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 Ye(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function js(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 Ye(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=or(t.state,e);return s&&s instanceof W?Ye(t,s):!1}else if(!(De&&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 a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?W.isSelectable(i)?Ye(t,new W(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Ar?Ye(t,new Q(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof W&&r.node.isInline)return Ye(t,new Q(e>0?r.$to:r.$from));{let s=or(t.state,e);return s?Ye(t,s):!1}}}function dn(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 gt(t,e){return e<0?uc(t):fc(t)}function uc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(kn&&n.nodeType==1&&r<dn(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(It(a,-1))s=n,i=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if($i(n))break;{let a=n.previousSibling;for(;a&&It(a,-1);)s=n.parentNode,i=pt(a),a=a.previousSibling;if(a)n=a,r=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ar(t,n,r):s&&ar(t,s,i)}function fc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=dn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(It(a,1))i=n,o=++r;else break}else{if($i(n))break;{let a=n.nextSibling;for(;a&&It(a,1);)i=a.parentNode,o=pt(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&ar(t,i,o)}function $i(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function hc(t,e){for(;t&&e==t.childNodes.length&&!wr(t);)e=pt(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 pc(t,e){for(;t&&!e&&!wr(t);)e=pt(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 ar(t,e,n){if(e.nodeType!=3){let i,o;(o=hc(e,n))?(e=o,n=0):(i=pc(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Mi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&jr(t)},50)}function Es(t,e){let n=t.state.doc.resolve(e);if(!(We||Fi)&&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 Ts(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||De&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=or(t.state,e);if(o&&o instanceof W)return Ye(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof _e?X.near(o,e):X.findFrom(o,e);return a?Ye(t,a):!1}return!1}function Ms(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 Os(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mc(t){if(!mt||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;Os(t,r,"true"),setTimeout(()=>Os(t,r,"false"),20)}return!1}function gc(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function xc(t,e){let n=e.keyCode,r=gc(e);if(n==8||De&&n==72&&r=="c")return Ms(t,-1)||gt(t,-1);if(n==46&&!e.shiftKey||De&&n==68&&r=="c")return Ms(t,1)||gt(t,1);if(n==13||n==27)return!0;if(n==37||De&&n==66&&r=="c"){let s=n==37?Es(t,t.state.selection.from)=="ltr"?-1:1:-1;return js(t,s,r)||gt(t,s)}else if(n==39||De&&n==70&&r=="c"){let s=n==39?Es(t,t.state.selection.from)=="ltr"?1:-1:1;return js(t,s,r)||gt(t,s)}else{if(n==38||De&&n==80&&r=="c")return Ts(t,-1,r)||gt(t,-1);if(n==40||De&&n==78&&r=="c")return mc(t)||Ts(t,1,r)||gt(t,1);if(r==(De?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Vi(t,e){t.someProp("transformCopied",h=>{e=h(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 h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||yn.fromSchema(t.state.schema),a=qi(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Ui[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let k=a.createElement(u[h]);for(;l.firstChild;)k.appendChild(l.firstChild);l.appendChild(k),f++}d=l.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
14
+ `);return!i||!o?!1:t.chain().command(({tr:a})=>(a.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 a=s.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:d})=>(d.setSelection(ee.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[$.textblockTypeInputRule({find:El,type:this.type,getAttributes:t=>({language:t[1]})}),$.textblockTypeInputRule({find:Tl,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vn({key:new Cr("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:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
15
+ `));return o.replaceSelectionWith(this.type.create({language:i},l)),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}}})]}}),Ol=/^\s*>\s$/,Dl=$.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",$.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[$.wrappingInputRule({find:Ol,type:this.type})]}}),Il=$.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",$.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!$.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}):$.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:d}=o.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?o.setSelection(Q.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(J.create(o.doc,d.pos)):o.setSelection(Q.create(o.doc,d.pos));else{const f=(l=d.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(o.insert(u,f),o.setSelection(Q.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[$.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ll=$.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",$.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:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&l&&o){const f=l.filter(p=>a.includes(p.type.name));d.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var an=200,me=function(){};me.prototype.append=function(e){return e.length?(e=me.from(e),!this.length&&e||e.length<an&&this.leafAppend(e)||this.length<an&&e.leafPrepend(this)||this.appendInner(e)):this};me.prototype.prepend=function(e){return e.length?me.from(e).append(this):this};me.prototype.appendInner=function(e){return new Fl(this,e)};me.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};me.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)};me.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};me.from=function(e){return e instanceof me?e:e&&e.length?new Ni(e):me.empty};var Ni=(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,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=an)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=an)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})(me);me.empty=new Ni([]);var Fl=(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 a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),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})(me);const Pl=500;class Fe{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,a,l,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(f);return}if(s){u.push(new Be(f.map));let h=f.step.map(s.slice(i)),k;h&&o.maybeStep(h).doc&&(k=o.mapping.maps[o.mapping.maps.length-1],d.push(new Be(k,void 0,void 0,d.length+u.length))),i--,k&&s.appendMap(k,i)}else o.maybeStep(f.step);if(f.selection)return a=s?f.selection.map(s.slice(i)):f.selection,l=new Fe(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Be(e.mapping.maps[u],f,n),h;(h=l&&l.merge(p))&&(p=h,u?i.pop():a=a.slice(0,a.length-1)),i.push(p),n&&(o++,n=void 0),s||(l=p)}let d=o-r.depth;return d>$l&&(a=Rl(a,d),o-=d),new Fe(a.append(i),o)}remapping(e,n){let r=new sn;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 Fe(this.items.append(e.map(n=>new Be(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,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},s);let l=n;this.items.forEach(p=>{let h=i.getMirror(--l);if(h==null)return;o=Math.min(o,h);let k=i.maps[h];if(p.step){let y=e.steps[h].invert(e.docs[h]),b=p.selection&&p.selection.map(i.slice(l+1,h));b&&a++,r.push(new Be(k,y,b))}else r.push(new Be(k))},s);let d=[];for(let p=n;p<o;p++)d.push(new Be(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),f=new Fe(u,a);return f.emptyItemCount()>Pl&&(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,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(n.slice(r)),d=l&&l.getMap();if(r--,d&&n.appendMap(d,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let f=new Be(d.invert(),l,u),p,h=s.length-1;(p=s.length&&s[h].merge(f))?s[h]=p:s.push(f)}}else o.map&&r--},this.items.length,0),new Fe(me.from(s.reverse()),i)}}Fe.empty=new Fe(me.empty,0);function Rl(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Be{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 Be(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const $l=20;function Vl(t,e,n,r){let s=n.getMeta(dt),i;if(s)return s.historyState;n.getMeta(_l)&&(t=new Ze(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(dt))return o.getMeta(dt).redo?new Ze(t.done.addTransform(n,void 0,r,en(e)),t.undone,ys(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,en(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Bl(n,t.prevRanges)),d=o?Vn(t.prevRanges,n.mapping):ys(n.mapping.maps);return new Ze(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,en(e)),Fe.empty,d,n.time,a??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Bl(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 ys(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 Vn(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 zl(t,e,n){let r=en(e),s=dt.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),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new Ze(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(dt,{redo:n,historyState:l})}let Bn=!1,bs=null;function en(t){let e=t.plugins;if(bs!=e){Bn=!1,bs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Bn=!0;break}}return Bn}const dt=new Cr("history"),_l=new Cr("closeHistory");function Hl(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new vn({key:dt,state:{init(){return new Ze(Fe.empty,Fe.empty,null,0,-1)},apply(e,n,r){return Vl(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?ji:r=="historyRedo"?Ei:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Ai(t,e){return(n,r)=>{let s=dt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=zl(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const ji=Ai(!1,!0),Ei=Ai(!0,!0),vs=$.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ji(t,e),redo:()=>({state:t,dispatch:e})=>Ei(t,e)}},addProseMirrorPlugins(){return[Hl(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()}}}),Ul=$.Node.create({name:"doc",topNode:!0,content:"block+"}),ql=$.Node.create({name:"text",group:"inline"});function Kl(t={}){return new vn({view(e){return new Wl(e,t)}})}class Wl{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,a=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let k=h.getBoundingClientRect(),y=f?k.bottom:k.top;f&&p&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*a;r={left:k.left,right:k.right,top:y-b,bottom:y+b}}}}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 l=this.editorView.dom.offsetParent;this.element||(this.element=l.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 d,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),p=f.width/l.offsetWidth,h=f.height/l.offsetHeight;d=f.left-l.scrollLeft*p,u=f.top-l.scrollTop*h}this.element.style.left=(r.left-d)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"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 a=Si(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}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 Jl=$.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Kl(this.options)]}});var et={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:"'"},ln={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gl=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zl=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ye=0;ye<10;ye++)et[48+ye]=et[96+ye]=String(ye);for(var ye=1;ye<=24;ye++)et[ye+111]="F"+ye;for(var ye=65;ye<=90;ye++)et[ye]=String.fromCharCode(ye+32),ln[ye]=String.fromCharCode(ye);for(var zn in et)ln.hasOwnProperty(zn)||(ln[zn]=et[zn]);function Yl(t){var e=Gl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ln:et)[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 Ql=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Xl=typeof navigator<"u"&&/Win/.test(navigator.platform);function ec(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ql?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function tc(t){let e=Object.create(null);for(let n in t)e[ec(n)]=t[n];return e}function _n(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 nc(t){let e=tc(t);return function(n,r){let s=Yl(r),i,o=e[_n(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[_n(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Xl&&r.ctrlKey&&r.altKey)&&(i=et[r.keyCode])&&i!=s){let a=e[_n(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const pt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ti=function(t,e,n,r){return n&&(ks(t,e,n,r,-1)||ks(t,e,n,r,1))},rc=/^(img|br|input|textarea|hr)$/i;function ks(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:cn(t))){let o=t.parentNode;if(!o||o.nodeType!=1||wr(t)||rc.test(t.nodeName)||t.contentEditable=="false")return!1;e=pt(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?cn(t):0}else return!1}}function cn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sc(t,e,n){for(let r=e==0,s=e==cn(t);r||s;){if(t==n)return!0;let i=pt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==cn(t)}}function wr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Mi=function(t){return t.focusNode&&Ti(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Oi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const He=typeof navigator<"u"?navigator:null,Ss=typeof document<"u"?document:null,tt=He&&He.userAgent||"",rr=/Edge\/(\d+)/.exec(tt),Di=/MSIE \d/.exec(tt),sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),Ut=!!(Di||sr||rr),Ii=Di?document.documentMode:sr?+sr[1]:rr?+rr[1]:0,kn=!Ut&&/gecko\/(\d+)/i.test(tt);kn&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];const ir=!Ut&&/Chrome\/(\d+)/.exec(tt),We=!!ir,Li=ir?+ir[1]:0,mt=!Ut&&!!He&&/Apple Computer/.test(He.vendor),Nr=mt&&(/Mobile\/\w+/.test(tt)||!!He&&He.maxTouchPoints>2),De=Nr||(He?/Mac/.test(He.platform):!1),Fi=He?/Win/.test(He.platform):!1,qt=/Android \d/.test(tt),Ar=!!Ss&&"webkitFontSmoothing"in Ss.documentElement.style,ic=Ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function oc(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 a=r.resolve(o),l,d;if(Mi(n)){for(l=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&J.isSelectable(f)&&s.parent&&!(f.isInline&&sc(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new J(o==p?a:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let h=0;h<n.rangeCount;h++){let k=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(k.startContainer,k.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(k.endContainer,k.endOffset,-1))}if(f<0)return null;[l,o]=p==t.state.selection.anchor?[p,f]:[f,p],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!d){let f=e=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;d=Ri(t,u,a,f)}return d}function Pi(t){return t.editable?t.hasFocus():dc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function jr(t,e=!1){let n=t.state.selection;if(cc(t,n),!!Pi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&We){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ti(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)lc(t);else{let{anchor:r,head:s}=n,i,o;Cs&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=ws(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ws(t,n.to))),t.docView.setSelection(r,s,t,e),Cs&&(i&&Ns(i),o&&Ns(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ac(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Cs=mt||We&&Li<63;function ws(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(mt&&s&&s.contentEditable=="false")return Hn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hn(s);if(i)return Hn(i)}}function Hn(t){return t.contentEditable="true",mt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ns(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function ac(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(()=>{(!Pi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function lc(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ut&&Ii<=11&&(n.disabled=!0,n.disabled=!1)}function cc(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(As(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else As(t)}function As(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ri(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function dc(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 or(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&&ee.findFrom(i,e)}function Ye(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function js(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 Ye(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=or(t.state,e);return s&&s instanceof J?Ye(t,s):!1}else if(!(De&&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 a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?J.isSelectable(i)?Ye(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Ar?Ye(t,new Q(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof J&&r.node.isInline)return Ye(t,new Q(e>0?r.$to:r.$from));{let s=or(t.state,e);return s?Ye(t,s):!1}}}function dn(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 gt(t,e){return e<0?uc(t):fc(t)}function uc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(kn&&n.nodeType==1&&r<dn(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(It(a,-1))s=n,i=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if($i(n))break;{let a=n.previousSibling;for(;a&&It(a,-1);)s=n.parentNode,i=pt(a),a=a.previousSibling;if(a)n=a,r=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ar(t,n,r):s&&ar(t,s,i)}function fc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=dn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(It(a,1))i=n,o=++r;else break}else{if($i(n))break;{let a=n.nextSibling;for(;a&&It(a,1);)i=a.parentNode,o=pt(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&ar(t,i,o)}function $i(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function hc(t,e){for(;t&&e==t.childNodes.length&&!wr(t);)e=pt(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 pc(t,e){for(;t&&!e&&!wr(t);)e=pt(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 ar(t,e,n){if(e.nodeType!=3){let i,o;(o=hc(e,n))?(e=o,n=0):(i=pc(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Mi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&jr(t)},50)}function Es(t,e){let n=t.state.doc.resolve(e);if(!(We||Fi)&&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 Ts(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||De&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=or(t.state,e);if(o&&o instanceof J)return Ye(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof _e?ee.near(o,e):ee.findFrom(o,e);return a?Ye(t,a):!1}return!1}function Ms(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 Os(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mc(t){if(!mt||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;Os(t,r,"true"),setTimeout(()=>Os(t,r,"false"),20)}return!1}function gc(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function xc(t,e){let n=e.keyCode,r=gc(e);if(n==8||De&&n==72&&r=="c")return Ms(t,-1)||gt(t,-1);if(n==46&&!e.shiftKey||De&&n==68&&r=="c")return Ms(t,1)||gt(t,1);if(n==13||n==27)return!0;if(n==37||De&&n==66&&r=="c"){let s=n==37?Es(t,t.state.selection.from)=="ltr"?-1:1:-1;return js(t,s,r)||gt(t,s)}else if(n==39||De&&n==70&&r=="c"){let s=n==39?Es(t,t.state.selection.from)=="ltr"?1:-1:1;return js(t,s,r)||gt(t,s)}else{if(n==38||De&&n==80&&r=="c")return Ts(t,-1,r)||gt(t,-1);if(n==40||De&&n==78&&r=="c")return mc(t)||Ts(t,1,r)||gt(t,1);if(r==(De?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Vi(t,e){t.someProp("transformCopied",h=>{e=h(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 h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||yn.fromSchema(t.state.schema),a=qi(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Ui[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let k=a.createElement(u[h]);for(;l.firstChild;)k.appendChild(l.firstChild);l.appendChild(k),f++}d=l.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
17
17
 
18
- `);return{dom:l,text:m,slice:e}}function Bi(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",m=>{e=m(e,i||r,t)}),i)return a=new K(q.from(t.state.schema.text(e.replace(/\r\n?/g,`
19
- `))),0,0),t.someProp("transformPasted",m=>{a=m(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",m=>m(e,s,r,t));if(f)a=f;else{let m=s.marks(),{schema:h}=t.state,k=yn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=o.appendChild(document.createElement("p"));b&&y.appendChild(k.serializeNode(h.text(b,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=kc(n),Ar&&Sc(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||rn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!yc.test(m.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Cc(Ds(a,+u[1],+u[2]),u[4]);else if(a=K.maxOpen(bc(a.content,s),!0),a.openStart||a.openEnd){let f=0,m=0;for(let h=a.content.firstChild;f<a.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=a.content.lastChild;m<a.openEnd&&!h.type.spec.isolating;m++,h=h.lastChild);a=Ds(a,f,m)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const yc=/^(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 bc(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(a=>{if(!o)return;let l=s.findWrapping(a.type),d;if(!l)return o=null;if(d=o.length&&i.length&&_i(l,i,a,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Hi(o[o.length-1],i.length));let u=zi(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return q.from(o)}return t}function zi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function _i(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=_i(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(zi(n,t,s+1))))}}function Hi(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hi(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function lr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=lr(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Ds(t,e,n){return e<t.openStart&&(t=new K(lr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(lr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ui={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 Is=null;function qi(){return Is||(Is=document.implementation.createHTMLDocument("title"))}let Un=null;function vc(t){let e=window.trustedTypes;return e?(Un||(Un=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Un.createHTML(t)):t}function kc(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Ui[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=vc(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Sc(t){let e=t.querySelectorAll(We?"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 Cc(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 a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=q.from(l.create(r[a+1],s)),i++,o++}return new K(s,i,o)}const Ve={},Me={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wi(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qt&&We&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Nr&&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,Oi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||xc(t,n)?n.preventDefault():Qe(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(Wi(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||De&&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 Sn(t){return{left:t.clientX,top:t.clientY}}function wc(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Er(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,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Ct(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 Nc(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&W.isSelectable(r)?(Ct(t,new W(n)),!0):!1}function Ac(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof W&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(W.isSelectable(a)){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?(Ct(t,W.create(t.state.doc,s)),!0):!1}function jc(t,e,n,r,s){return Er(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ac(t,n):Nc(t,n))}function Ec(t,e,n,r){return Er(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Tc(t,e,n,r){return Er(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Mc(t,n,r)}function Mc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ct(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),a=s.before(i);if(o.inlineContent)Ct(t,Q.create(r,a+1,a+1+o.content.size));else if(W.isSelectable(o))Ct(t,W.create(r,a));else continue;return!0}}function Tr(t){return un(t)}const Ki=De?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Tr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&wc(n,t.input.lastClick)&&!n[Ki]&&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(Sn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Oc(t,o,n,!!r)):(i=="doubleClick"?Ec:Tc)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class Oc{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[Ki],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:d}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof W&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kn&&!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(()=>jr(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(Sn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):jc(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||mt&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!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)?(Ct(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)}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),Tr(t),Qe(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Ve.contextmenu=t=>Tr(t);function Wi(t,e){return t.composing?!0:mt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Dc=qt?5e3:-1;Me.compositionstart=Me.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)||We&&Fi&&Ic(t)))t.markCursor=t.state.storedMarks||n.marks(),un(t,!0),t.markCursor=null;else if(un(t,!e.selection.empty),kn&&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 a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Ji(t,Dc)};function Ic(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"}Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Ji(t,20))};function Ji(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>un(t),e))}function Lc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Fc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Fc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function un(t,e=!1){if(!(qt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Lc(t),e||t.docView&&t.docView.dirty){let n=oc(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 Pc(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 zt=Ut&&Ii<15||Nr&&ic<604;Ve.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=zt?null:n.clipboardData,o=r.content(),{dom:a,text:l}=Vi(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Pc(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Rc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $c(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?cr(t,r.value,null,s,e):cr(t,r.textContent,r.innerHTML,s,e)},50)}function cr(t,e,n,r,s){let i=Bi(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||K.empty)))return!0;if(!i)return!1;let o=Rc(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gi(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," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!qt)return;let r=zt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&cr(t,Gi(r),r.getData("text/html"),s,n)?n.preventDefault():$c(t,n)};class Vc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Bc=De?"altKey":"ctrlKey";function Zi(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Bc]}Ve.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(Sn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof W?s.to-1:s.to))){if(r&&r.mightDrag)o=W.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=W.create(t.state.doc,f.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:d,slice:u}=Vi(t,a);(!n.dataTransfer.files.length||!We||Li>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zt?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",zt||n.dataTransfer.setData("text/plain",d),t.dragging=new Vc(u,Zi(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{zc(t,e,t.dragging)}finally{t.dragging=null}};function zc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Sn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Bi(t,Gi(e.dataTransfer),zt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Zi(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||K.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?Si(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let d=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=l.doc;if(u?l.replaceRangeWith(d,d,i.content.firstChild):l.replaceRange(d,d,i),l.doc.eq(f))return;let m=l.doc.resolve(d);if(u&&W.isSelectable(i.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new W(m));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((k,b,y,S)=>h=S),l.setSelection(Ri(t,m,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Ve.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())&&jr(t)},20))};Ve.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)};Ve.beforeinput=(t,e)=>{if(We&&qt&&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,Oi(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 Me)Ve[t]=Me[t];function _t(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 fn{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 ze(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_t(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 ze(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class Mr{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 ze(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 Mr&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}destroy(){}}class ze{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ze(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 ze(e,e,new fn(n,r))}static inline(e,n,r,s){return new ze(e,n,new Xe(r,s))}static node(e,n,r,s){return new ze(e,n,new Mr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof fn}}const vt=[],ut={};class pe{constructor(e,n){this.local=e.length?e:vt,this.children=n.length?n:vt}static create(e,n){return n.length?hn(n,e,0,ut):Ce}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 a=this.local[o];a.from<=n&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==Ce||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}mapInner(e,n,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?_c(this.children,o||[],e,n,r,s,i):o?new pe(o.sort(ft),vt):Ce}add(e,n){return n.length?this==Ce?pe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let d=l+r,u;if(u=Qi(n,a,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,d+1):s.splice(i,0,l,l+a.nodeSize,hn(u,a,d+1,ut)),i+=3}});let o=Yi(i?Xi(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new pe(o.length?this.local.concat(o).sort(ft):this.local,s||this.children)}remove(e){return e.length==0||this==Ce?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,a=r[i]+n,l=r[i+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<l&&(e[u]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(o,a+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new pe(s,r):Ce}forChild(e,n){if(this==Ce)return this;if(n.isLeaf)return pe.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof Xe){let d=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;d<u&&(s||(s=[])).push(l.copy(d,u))}}if(s){let a=new pe(s.sort(ft),vt);return r?new it([a,r]):a}return r||Ce}eq(e){if(this==e)return!0;if(!(e instanceof pe)||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 Or(this.localsInner(e))}localsInner(e){if(this==Ce)return vt;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)}}pe.empty=new pe([],[]);pe.removeOverlap=Or;const Ce=pe.empty;class it{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return it.from(r)}forChild(e,n){if(n.isLeaf)return pe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ce&&(i instanceof it?r=r.concat(i.members):r.push(i))}return it.from(r)}eq(e){if(!(e instanceof it)||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?Or(r?n:n.sort(ft)):vt}static from(e){switch(e.length){case 0:return Ce;case 1:return e[0];default:return new it(e.every(n=>n instanceof pe)?e:e.reduce((n,r)=>n.concat(r instanceof pe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function _c(t,e,n,r,s,i,o){let a=t.slice();for(let d=0,u=i;d<n.maps.length;d++){let f=0;n.maps[d].forEach((m,h,k,b)=>{let y=b-k-(h-m);for(let S=0;S<a.length;S+=3){let N=a[S+1];if(N<0||m>N+u-f)continue;let j=a[S]+u-f;h>=j?a[S+1]=m<=j?-2:-1:m>=u&&y&&(a[S]+=y,a[S+1]+=y)}f+=y}),u=n.maps[d].map(u,-1)}let l=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(a[d+1]==-2){l=!0,a[d+1]=-1;continue}let u=n.map(t[d]+i),f=u-s;if(f<0||f>=r.content.size){l=!0;continue}let m=n.map(t[d+1]+i,-1),h=m-s,{index:k,offset:b}=r.content.findIndex(f),y=r.maybeChild(k);if(y&&b==f&&b+y.nodeSize==h){let S=a[d+2].mapInner(n,y,u+1,t[d]+i+1,o);S!=Ce?(a[d]=f,a[d+1]=h,a[d+2]=S):(a[d+1]=-2,l=!0)}else l=!0}if(l){let d=Hc(a,t,e,n,s,i,o),u=hn(d,r,0,o);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,m=0;f<u.children.length;f+=3){let h=u.children[f];for(;m<a.length&&a[m]<h;)m+=3;a.splice(m,0,u.children[f],u.children[f+1],u.children[f+2])}}return new pe(e.sort(ft),a)}function Yi(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 ze(s.from+e,s.to+e,s.type))}return n}function Hc(t,e,n,r,s,i,o){function a(l,d){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(r,s,d);f?n.push(f):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+d+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function Qi(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 Xi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function hn(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let d=Qi(t,a,l+n);if(d){i=!0;let u=hn(d,a,n+l+1,r);u!=Ce&&s.push(l,l+a.nodeSize,u)}});let o=Yi(i?Xi(t):t,-n).sort(ft);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new pe(o,s):Ce}function ft(t,e){return t.from-e.from||t.to-e.to}function Or(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),Ls(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),Ls(e,s,r.copy(i.from,r.to)));break}}}return e}function Ls(t,e,n){for(;e<t.length&&ft(n,t[e])>0;)e++;t.splice(e,0,n)}class le extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return le.valid(r)?new le(r):X.near(r)}content(){return K.empty}eq(e){return e instanceof le&&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 le(e.resolve(n.pos))}getBookmark(){return new Dr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Uc(e)||!qc(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&&le.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>0?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let l=e.doc.resolve(s);if(le.valid(l))return l}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!W.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let a=e.doc.resolve(s);if(le.valid(a))return a}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;X.jsonID("gapcursor",le);class Dr{constructor(e){this.pos=e}map(e){return new Dr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):X.near(n)}}function eo(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Uc(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function qc(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||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Kc(){return new vn({props:{decorations:Zc,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:Jc,handleKeyDown:Wc,handleDOMEvents:{beforeinput:Gc}}})}const Wc=nc({ArrowLeft:Zt("horiz",-1),ArrowRight:Zt("horiz",1),ArrowUp:Zt("vert",-1),ArrowDown:Zt("vert",1)});function Zt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=le.findGapCursorFrom(a,e,l);return d?(s&&s(r.tr.setSelection(new le(d))),!0):!1}}function Jc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!le.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&W.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new le(r))),!0)}function Gc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof le))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 Zc(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pe.create(t.doc,[ze.widget(t.selection.head,e,{key:"gapcursor"})])}const Yc=V.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Kc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=V.callOrReturn(V.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),jt={bold:{category:"mark",extension:Ga,priority:100},italic:{category:"mark",extension:el,priority:100},strike:{category:"mark",extension:rl,priority:100},underline:{category:"mark",extension:ca.Underline,priority:100},code:{category:"mark",extension:ol,priority:100},textColor:{category:"mark",extension:da.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:ua.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:fa.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:cl,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:fl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:pl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:ha.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Ml,priority:100},blockquote:{category:"node",extension:Dl,priority:100},horizontalRule:{category:"node",extension:Il,priority:100},hardBreak:{category:"node",extension:Ll,priority:100},undo:{category:"extension",extension:vs,priority:50},redo:{category:"extension",extension:vs,priority:50},textAlign:{category:"extension",extension:ma.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}},Qc=[Ul,ql,dl,ll.configure({HTMLAttributes:{}}),ml.configure({HTMLAttributes:{}}),pa.TaskItem.configure({nested:!0}),Jl,Yc];function Xc(t){const e=[],n=new Set,r=new Set;Qc.forEach(a=>{a&&(e.push(a),r.add(a.name))});const s=t.map(a=>Rt(a)),i=new Set;return s.forEach(a=>{const l=jt[a];l?.requiredExtensions&&l.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l||l.extension===null)return;const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),s.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l){console.warn(`Extension config not found for modifier: ${a}`);return}if(l.extension===null){n.add(a);return}const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),e.sort((a,l)=>{const d=Object.values(jt).find(h=>h?.extension?.name===a.name),u=Object.values(jt).find(h=>h?.extension?.name===l.name),f=d?.priority??100;return(u?.priority??100)-f})}const to={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","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","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","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","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},oe={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"}},Ge={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},se={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},ed={h1:`font-size: ${oe.fontSize["4xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h2:`font-size: ${oe.fontSize["2xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h3:`font-size: ${oe.fontSize.xl}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h4:`font-size: ${oe.fontSize.lg}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h5:`font-size: ${oe.fontSize.base}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h6:`font-size: ${oe.fontSize.sm}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,p:`min-height: ${oe.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,li:`display: list-item; margin: ${se.xs} 0;`,strong:`font-weight: ${oe.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Ge.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${oe.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${oe.fontFamily.mono};`,pre:`background: ${Ge.neutral.gray[800]}; border-radius: ${se.sm}; color: ${Ge.neutral.gray[100]}; font-family: ${oe.fontFamily.mono}; margin: ${se.lg} 0; padding: 0.75rem ${se.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ge.neutral.gray[300]}; margin: ${se.lg} 0; padding-left: ${se.md}; color: ${Ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ge.neutral.gray[200]}; margin: ${se.xl} 0;`,a:`color: ${Ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ge.palettes.warning[200]}; border-radius: ${se.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${se.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},td={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 nd(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(td)){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(ed)){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 rd=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=yr.useCurrentEditor();return c.jsx(Ua,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},sd=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=yr.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"]})]})},dr=x.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:a=!0,modifiers:l=to.full,variant:d="bordered",initialContent:u,content:f,onContentChange:m,onUpdate:h,onToolbarAction:k,isReadOnly:b=!1,isDisabled:y=!1,includeInlineStyles:S=!0,...N}=t,{zoom:j,setZoom:C}=za(),A=ts.lineHeight,M=n*A,L=s?void 0:r*A,P=x.useMemo(()=>Xc(l),[l]),{Component:$,label:H,shouldLabelBeOutside:D,getBaseProps:T,getLabelProps:R,getInputWrapperProps:B}=g.useInput({...N,variant:d,ref:e,isMultiline:!0}),U=H?c.jsx("label",{...R(),children:H}):null,re=x.useCallback(({editor:J})=>{const ge=J.getHTML(),ce=S?nd(ge):ge,xe=J.getJSON(),Le=J.getText(),ee=Le.length,Oe=Le.split(/\s+/).filter(Ae=>Ae.length>0).length,te={html:ce,json:xe,text:Le,characters:ee,words:Oe};if(m?.(te),h?.(te),"onChange"in N&&typeof N.onChange=="function"){const Ae={target:{value:ce},currentTarget:{value:ce}};N.onChange(Ae)}},[m,h,N,S]);return c.jsxs($,{...T(),children:[D?U:null,c.jsx("div",{...B(),className:g.cn(B().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:L?`${L+ts.toolbarHeight}px`:void 0,overflow:L?"auto":void 0},children:c.jsx(yr.EditorProvider,{editable:!b&&!y,slotBefore:a?c.jsx(rd,{modifiers:l,zoom:j,onZoomChange:C,onToolbarAction:k}):void 0,slotAfter:c.jsx(sd,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${j}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:P,content:f||u||t.defaultValue||"",onUpdate:re})})]})});dr.displayName="TipTapEditor";const no=x.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(dr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(dr,{...s,variant:r,ref:e}))});no.displayName="RichTextArea";function id(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 Fs=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],od={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},ro=({presetAmounts:t=Fs,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:o="en-US",showCustomAmount:a=!0,minCustomAmount:l=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:f=2,desktopColumns:m=3,isDisabled:h=!1,buttonVariant:k="bordered",buttonColor:b="default",inputVariant:y="bordered",size:S="md",className:N="",showCard:j=!0})=>{const C={...od,...u},A=Array.isArray(t)?t:Fs,M={2:"grid-cols-2",3:"grid-cols-3"},L={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},P=`${M[f]} ${L[m]}`,[$,H]=br(e,n,r),[D,T]=x.useState(""),[R,B]=x.useState(!1),[U,re]=x.useState(0),J=x.useCallback(ee=>{if(h)return;const Oe={amount:ee.amount,isCustom:!1,presetId:ee.id};H(Oe),T(""),B(!1),re(te=>te+1),s?.(Oe)},[h,H,s]),ge=x.useCallback(ee=>{if(h)return;if(T(ee!==void 0?String(ee):""),s){H(null);return}if(ee===void 0||isNaN(ee)){H(null);return}H({amount:ee,isCustom:!0})},[h,H,s]),ce=x.useCallback(()=>{if(h)return;const ee=D!==""?parseFloat(D):void 0;ee===void 0||isNaN(ee)||s?.({amount:ee,isCustom:!0})},[h,D,s]),xe=x.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Le=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[C.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:C.title}),A.length>0&&c.jsx("div",{className:g.cn("grid gap-3",P),"data-testid":"donation-amounts-presets",children:A.map(ee=>{const Oe=$!==null&&!$.isCustom&&$.presetId===ee.id;return c.jsx(G,{color:Oe?"primary":b,variant:Oe?"solid":k,className:"w-full",onPress:()=>J(ee),isDisabled:h,"data-testid":`donation-amounts-preset-${ee.id}`,children:ee.label||id(ee.amount,o,i)},ee.id)})}),a&&c.jsxs("div",{className:"flex gap-3 items-start",children:[c.jsx(g.NumberInput,{placeholder:C.customAmountPlaceholder,"aria-label":C.customAmountAriaLabel,onInput:s?()=>{H(null),B(!0)}:void 0,variant:y,radius:"full",size:S,minValue:l,maxValue:d,step:.01,formatOptions:xe,value:D!==""?parseFloat(D):void 0,onValueChange:ge,isDisabled:h,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${U}`:$?.isCustom===!1?$.presetId:"custom"),s&&c.jsx(G,{color:"primary",variant:"solid",radius:"full",size:S,className:"shrink-0",onPress:ce,isDisabled:h||!R,"data-testid":"donation-amounts-add-button",children:C.addDonationButton})]})]});return j?c.jsx(g.Card,{className:g.cn("w-full",N),"data-testid":"donation-amounts-card",children:c.jsx(g.CardBody,{children:Le})}):c.jsx("div",{className:g.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Le})};ro.displayName="DonationAmounts";const ad=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`},ld=t=>{switch(t){case"warning":return _.Clock;case"error":return _.AlertCircle;case"success":return _.CheckCircle;default:return _.Clock}},cd=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"}},so=x.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:a=!0,icon:l,position:d="fixed",autoStart:u=!0,formatTime:f=ad,className:m,...h},k)=>{const[b,y]=br(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=x.useRef(null),N=x.useRef(!1);x.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),x.useEffect(()=>{if(!u||b<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{y(M=>M<=1?(S.current&&(clearInterval(S.current),S.current=null),N.current||(N.current=!0,r?.()),0):M-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[u,b,y,r]),x.useEffect(()=>{b>0&&(N.current=!1)},[b]);const j=l||ld(s),C=cd(i),A={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:k,role:"banner","aria-live":"polite","aria-label":`${o} ${f(b)}`,"data-testid":"expire-cart-timer",className:g.cn("w-full text-white z-50",C,A[d],m),...h,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:[a&&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)})})]})})})});so.displayName="ExpireCartTimer";function dd(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 a=r[o]&&r[o].parent,l=a&&i(a);l&&(s[o]=[a].concat(l))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const io=Object.freeze({left:0,top:0,width:16,height:16}),pn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Ir=Object.freeze({...io,...pn}),ur=Object.freeze({...Ir,body:"",hidden:!1});function ud(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 Ps(t,e){const n=ud(t,e);for(const r in ur)r in pn?r in t&&!(r in n)&&(n[r]=pn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function fd(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(a){i=Ps(r[a]||s[a],i)}return o(e),n.forEach(o),Ps(t,i)}function oo(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=dd(t);for(const s in r){const i=r[s];i&&(e(s,fd(t,s,i)),n.push(s))}return n}const hd={provider:"",aliases:{},not_found:{},...io};function qn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function ao(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!qn(t,hd))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!qn(i,ur))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]||!qn(i,ur))return null}return e}const Rs=Object.create(null);function pd(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function Nt(t,e){const n=Rs[t]||(Rs[t]=Object.create(null));return n[e]||(n[e]=pd(t,e))}function lo(t,e){return ao(e)?oo(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function md(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const co=/^[a-z0-9]+(-[a-z0-9]+)*$/,Cn=(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 a=s.pop(),l=s.pop(),d={provider:s.length>0?s[0]:r,prefix:l,name:a};return e&&!tn(d)?null:d}const i=s[0],o=i.split("-");if(o.length>1){const a={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!tn(a)?null:a}if(n&&r===""){const a={provider:r,prefix:"",name:i};return e&&!tn(a,n)?null:a}return null},tn=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Ht=!1;function uo(t){return typeof t=="boolean"&&(Ht=t),Ht}function $s(t){const e=typeof t=="string"?Cn(t,!0,Ht):t;if(e){const n=Nt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function gd(t,e){const n=Cn(t,!0,Ht);if(!n)return!1;const r=Nt(n.provider,n.prefix);return e?md(r,n.name,e):(r.missing.add(n.name),!0)}function xd(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Ht&&!e&&!t.prefix){let s=!1;return ao(t)&&(t.prefix="",oo(t,(i,o)=>{gd(i,o)&&(s=!0)})),s}const n=t.prefix;if(!tn({prefix:n,name:"a"}))return!1;const r=Nt(e,n);return!!lo(r,t)}const fo=Object.freeze({width:null,height:null}),ho=Object.freeze({...fo,...pn}),yd=/(-?[0-9.]*[0-9]+[0-9.]*)/g,bd=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Vs(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(yd);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=bd.test(i);for(;;){if(o){const a=parseFloat(i);isNaN(a)?s.push(i):s.push(Math.ceil(a*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function vd(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 kd(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Sd(t,e,n){const r=vd(t);return kd(r.defs,e+r.content+n)}const Cd=t=>t==="unset"||t==="undefined"||t==="none";function wd(t,e){const n={...Ir,...t},r={...ho,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const y=[],S=b.hFlip,N=b.vFlip;let j=b.rotate;S?N?j+=2:(y.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),y.push("scale(-1 1)"),s.top=s.left=0):N&&(y.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),y.push("scale(1 -1)"),s.top=s.left=0);let C;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:C=s.height/2+s.top,y.unshift("rotate(90 "+C.toString()+" "+C.toString()+")");break;case 2:y.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:C=s.width/2+s.left,y.unshift("rotate(-90 "+C.toString()+" "+C.toString()+")");break}j%2===1&&(s.left!==s.top&&(C=s.left,s.left=s.top,s.top=C),s.width!==s.height&&(C=s.width,s.width=s.height,s.height=C)),y.length&&(i=Sd(i,'<g transform="'+y.join(" ")+'">',"</g>"))});const o=r.width,a=r.height,l=s.width,d=s.height;let u,f;o===null?(f=a===null?"1em":a==="auto"?d:a,u=Vs(f,l/d)):(u=o==="auto"?l:o,f=a===null?Vs(u,d/l):a==="auto"?d:a);const m={},h=(b,y)=>{Cd(y)||(m[b]=y.toString())};h("width",u),h("height",f);const k=[s.left,s.top,l,d];return m.viewBox=k.join(" "),{attributes:m,viewBox:k,body:i}}const Nd=/\sid="(\S+)"/g,Ad="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let jd=0;function Ed(t,e=Ad){const n=[];let r;for(;r=Nd.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+(jd++).toString(),a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+a+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const fr=Object.create(null);function Td(t,e){fr[t]=e}function hr(t){return fr[t]||fr[""]}function Lr(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 Fr=Object.create(null),Et=["https://api.simplesvg.com","https://api.unisvg.com"],nn=[];for(;Et.length>0;)Et.length===1||Math.random()>.5?nn.push(Et.shift()):nn.push(Et.pop());Fr[""]=Lr({resources:["https://api.iconify.design"].concat(nn)});function Md(t,e){const n=Lr(e);return n===null?!1:(Fr[t]=n,!0)}function Pr(t){return Fr[t]}const Od=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Bs=Od();function Dd(t,e){const n=Pr(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 Id(t){return t===404}const Ld=(t,e,n)=>{const r=[],s=Dd(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},a=0;return n.forEach((l,d)=>{a+=l.length+1,a>=s&&d>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},a=l.length),o.icons.push(l)}),r.push(o),r};function Fd(t){if(typeof t=="string"){const e=Pr(t);if(e)return e.path}return"/"}const Pd=(t,e,n)=>{if(!Bs){n("abort",424);return}let r=Fd(e.provider);switch(e.type){case"icons":{const i=e.prefix,a=e.icons.join(","),l=new URLSearchParams({icons:a});r+=i+".json?"+l.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;Bs(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(Id(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)})},Rd={prepare:Ld,send:Pd};function po(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function $d(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,a=o.pending.length;o.pending=o.pending.filter(l=>{if(l.prefix!==s)return!0;const d=l.name;if(t.icons[d])o.loaded.push({provider:r,prefix:s,name:d});else if(t.missing.has(d))o.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),o.pending.length!==a&&(n||po([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let Vd=0;function Bd(t,e,n){const r=Vd++,s=po.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 zd(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,a=s.name,l=n[i]||(n[i]=Object.create(null)),d=l[o]||(l[o]=Nt(i,o));let u;a in d.icons?u=e.loaded:o===""||d.missing.has(a)?u=e.missing:u=e.pending;const f={provider:i,prefix:o,name:a};u.push(f)}),e}function _d(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?Cn(s,e,n):s;i&&r.push(i)}),r}const Hd={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ud(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 M=t.resources.slice(0);for(o=[];M.length>1;){const L=Math.floor(Math.random()*M.length);o.push(M[L]),M=M.slice(0,L).concat(M.slice(L+1))}o=o.concat(M)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const a=Date.now();let l="pending",d=0,u,f=null,m=[],h=[];typeof r=="function"&&h.push(r);function k(){f&&(clearTimeout(f),f=null)}function b(){l==="pending"&&(l="aborted"),k(),m.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),m=[]}function y(M,L){L&&(h=[]),typeof M=="function"&&h.push(M)}function S(){return{startTime:a,payload:e,status:l,queriesSent:d,queriesPending:m.length,subscribe:y,abort:b}}function N(){l="failed",h.forEach(M=>{M(void 0,u)})}function j(){m.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),m=[]}function C(M,L,P){const $=L!=="success";switch(m=m.filter(H=>H!==M),l){case"pending":break;case"failed":if($||!t.dataAfterTimeout)return;break;default:return}if(L==="abort"){u=P,N();return}if($){u=P,m.length||(o.length?A():N());return}if(k(),j(),!t.random){const H=t.resources.indexOf(M.resource);H!==-1&&H!==t.index&&(t.index=H)}l="completed",h.forEach(H=>{H(P)})}function A(){if(l!=="pending")return;k();const M=o.shift();if(M===void 0){if(m.length){f=setTimeout(()=>{k(),l==="pending"&&(j(),N())},t.timeout);return}N();return}const L={status:"pending",resource:M,callback:(P,$)=>{C(L,P,$)}};m.push(L),d++,f=setTimeout(A,t.rotate),n(M,e,L.callback)}return setTimeout(A),S}function mo(t){const e={...Hd,...t};let n=[];function r(){n=n.filter(a=>a().status==="pending")}function s(a,l,d){const u=Ud(e,a,l,(f,m)=>{r(),d&&d(f,m)});return n.push(u),u}function i(a){return n.find(l=>a(l))||null}return{query:s,find:i,setIndex:a=>{e.index=a},getIndex:()=>e.index,cleanup:r}}function zs(){}const Kn=Object.create(null);function qd(t){if(!Kn[t]){const e=Pr(t);if(!e)return;const n=mo(e),r={config:e,redundancy:n};Kn[t]=r}return Kn[t]}function Kd(t,e,n){let r,s;if(typeof t=="string"){const i=hr(t);if(!i)return n(void 0,424),zs;s=i.send;const o=qd(t);o&&(r=o.redundancy)}else{const i=Lr(t);if(i){r=mo(i);const o=t.resources?t.resources[0]:"",a=hr(o);a&&(s=a.send)}}return!r||!s?(n(void 0,424),zs):r.query(e,s,n)().abort}function _s(){}function Wd(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,$d(t)}))}function Jd(t){const e=[],n=[];return t.forEach(r=>{(r.match(co)?e:n).push(r)}),{valid:e,invalid:n}}function Tt(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(!lo(t,n).length){r();return}}catch(s){console.error(s)}r(),Wd(t)}function Hs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Gd(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)){Hs(t.loadIcons(s,r,n),u=>{Tt(t,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);Hs(f,m=>{const h=m?{prefix:r,icons:{[u]:m}}:null;Tt(t,[u],h)})});return}const{valid:o,invalid:a}=Jd(s);if(a.length&&Tt(t,a,null),!o.length)return;const l=r.match(co)?hr(n):null;if(!l){Tt(t,o,null);return}l.prepare(n,r,o).forEach(u=>{Kd(n,u,f=>{Tt(t,u.icons,f)})})}))}const Zd=(t,e)=>{const n=_d(t,!0,uo()),r=zd(n);if(!r.pending.length){let l=!0;return e&&setTimeout(()=>{l&&e(r.loaded,r.missing,r.pending,_s)}),()=>{l=!1}}const s=Object.create(null),i=[];let o,a;return r.pending.forEach(l=>{const{provider:d,prefix:u}=l;if(u===a&&d===o)return;o=d,a=u,i.push(Nt(d,u));const f=s[d]||(s[d]=Object.create(null));f[u]||(f[u]=[])}),r.pending.forEach(l=>{const{provider:d,prefix:u,name:f}=l,m=Nt(d,u),h=m.pendingIcons||(m.pendingIcons=new Set);h.has(f)||(h.add(f),s[d][u].push(f))}),i.forEach(l=>{const d=s[l.provider][l.prefix];d.length&&Gd(l,d)}),e?Bd(e,r,i):_s};function Yd(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in fo?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Qd=/[\s,]+/;function Xd(t,e){e.split(Qd).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function eu(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 tu(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 nu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function ru(t){return"data:image/svg+xml,"+nu(t)}function su(t){return'url("'+ru(t)+'")'}let Lt;function iu(){try{Lt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Lt=null}}function ou(t){return Lt===void 0&&iu(),Lt?Lt.createHTML(t):t}const go={...ho,inline:!1},au={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},lu={display:"inline-block"},pr={backgroundColor:"currentColor"},xo={backgroundColor:"transparent"},Us={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},qs={WebkitMask:pr,mask:pr,background:xo};for(const t in qs){const e=qs[t];for(const n in Us)e[t+n]=Us[n]}const cu={...go,inline:!0};function Ks(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const du=(t,e,n)=>{const r=e.inline?cu:go,s=Yd(r,e),i=e.mode||"svg",o={},a=e.style||{},l={...i==="svg"?au:{}};if(n){const y=Cn(n,!1,!0);if(y){const S=["iconify"],N=["provider","prefix"];for(const j of N)y[j]&&S.push("iconify--"+y[j]);l.className=S.join(" ")}}for(let y in e){const S=e[y];if(S!==void 0)switch(y){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=S;break;case"className":l[y]=(l[y]?l[y]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[y]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&Xd(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[y]=eu(S):typeof S=="number"&&(s[y]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete l["aria-hidden"];break;default:r[y]===void 0&&(l[y]=S)}}const d=wd(t,s),u=d.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){l.style={...o,...a},Object.assign(l,u);let y=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:ou(Ed(d.body,S?()=>S+"ID"+y++:"iconifyReact"))},x.createElement("svg",l)}const{body:f,width:m,height:h}=t,k=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=tu(f,{...u,width:m+"",height:h+""});return l.style={...o,"--svg":su(b),width:Ks(u.width),height:Ks(u.height),...lu,...k?pr:xo,...a},x.createElement("span",l)};uo(!0);Td("",Rd);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"||!xd(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;Md(n,s)||console.error(r)}catch{console.error(r)}}}}function yo(t){const[e,n]=x.useState(!!t.ssr),[r,s]=x.useState({});function i(h){if(h){const k=t.icon;if(typeof k=="object")return{name:"",data:k};const b=$s(k);if(b)return{name:k,data:b}}return{name:""}}const[o,a]=x.useState(i(!!t.ssr));function l(){const h=r.callback;h&&(h(),s({}))}function d(h){if(JSON.stringify(o)!==JSON.stringify(h))return l(),a(h),!0}function u(){var h;const k=t.icon;if(typeof k=="object"){d({name:"",data:k});return}const b=$s(k);if(d({name:k,data:b}))if(b===void 0){const y=Zd([k],u);s({callback:y})}else b&&((h=t.onLoad)===null||h===void 0||h.call(t,k))}x.useEffect(()=>(n(!0),l),[]),x.useEffect(()=>{e&&u()},[t.icon,e]);const{name:f,data:m}=o;return m?du({...Ir,...m},t,f):t.children?t.children:t.fallback?t.fallback:x.createElement("span",{})}const ae=x.forwardRef((t,e)=>yo({...t,_ref:e}));x.forwardRef((t,e)=>yo({inline:!0,...t,_ref:e}));const Wn=({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(ae,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),uu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:a=!1,imageLoading:l="eager",showMoreButtonClassName:d,labels:u})=>{const[f,m]=x.useState(!1),[h,k]=x.useState(!1),b=x.useRef(null);return x.useEffect(()=>{const y=()=>{if(b.current){const S=b.current.scrollHeight>b.current.clientHeight;k(S)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[o]),c.jsxs(g.Card,{className:g.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(g.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[a&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(g.Image,{removeWrapper:!0,loading:l,alt:`Event image for ${e}`,className:"w-full h-full object-cover object-center",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(g.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(Wn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(Wn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(Wn,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{ref:b,className:g.cn("text-sm text-gray-700 leading-relaxed transition-all",!f&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!f&&h&&c.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(h||f)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(G,{onPress:()=>m(!f),variant:"light",className:g.cn("text-primary",d),startContent:c.jsx(ae,{icon:f?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:f?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function bo(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 fu(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 hu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Yt=t=>typeof t=="number"&&!isNaN(t),Rr=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:a,isDisabled:l=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:f=!0,showDescription:m=!0,showPeopleCount:h=!0,showPrice:k=!0,classNames:b={},"data-testid":y,selectedColor:S="default"})=>{const N={...hu,...o},[j,C]=x.useState(n),A=e!==void 0?e:j,M=ce=>{if(l)return;const xe=Math.max(0,A+ce);e===void 0&&C(xe),r?.(t.id,xe)},L=x.useMemo(()=>!Yt(t.totalTicketsSold)||!Yt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),P=x.useMemo(()=>L||!Yt(t.ticketsAllowed)?!1:A>=t.ticketsAllowed-(t.totalTicketsSold??0),[L,t.ticketsAllowed,t.totalTicketsSold,A]),$=bo(t.price,i,s),H=()=>a?.renderName?a.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:g.cn("text-base font-medium",b.name),children:t.name}),D=()=>k?a?.renderPrice?a.renderPrice(t.price,$,t):c.jsx("p",{"data-testid":"offer-card-price",className:g.cn("text-primary text-base mt-1",b.price),children:$}):null,T=()=>!m||!t.description?null:a?.renderDescription?a.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:g.cn("mb-4 text-sm text-gray-700 leading-relaxed",b.description),children:t.description}),R=()=>{if(!h||!Yt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ce=t.numberOfPeople===1?N.person:N.people;return a?.renderPeopleCount?a.renderPeopleCount(t.numberOfPeople,ce,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:g.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[c.jsx(ae,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ce]})},B=()=>{const ce=A===0||l,xe=P||l;return a?.renderQuantitySelector?a.renderQuantitySelector({quantity:A,onIncrement:()=>M(1),onDecrement:()=>M(-1),isDecrementDisabled:ce,isIncrementDisabled:xe,isDisabled:l}):c.jsxs("div",{className:g.cn("flex items-center gap-2",b.quantitySelector),children:[c.jsx(G,{"data-testid":"offer-card-decrement-button",onPress:()=>M(-1),isDisabled:ce,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(ae,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:g.cn("min-w-[2rem] text-center font-medium"),children:A}),c.jsx(G,{"data-testid":"offer-card-increment-button",onPress:()=>M(1),isDisabled:xe,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(ae,{icon:"gravity-ui:plus",width:16})})]})},U=()=>a?.renderSoldOut?a.renderSoldOut(N.soldOut):c.jsx(g.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:g.cn("gap-2 px-4 h-8",b.soldOut),startContent:c.jsx(ae,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:N.soldOut})}),re=()=>a?.renderMaxReachedAlert?a.renderMaxReachedAlert(N.maxReached):c.jsx(g.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:g.cn(" text-black! gap-2 px-4 h-10",b.maxReachedAlert),startContent:c.jsx(ae,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:N.maxReached})}),J=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:g.cn("h-full col-span-2",L?"opacity-50 pointer-events-none select-none":""),children:[H(),D(),c.jsxs("div",{className:g.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",L?"opacity-50 pointer-events-none select-none":""),children:[R(),T()]})]}),c.jsx("div",{className:"space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",children:L?U():B()})]}),ge=P&&!L&&c.jsx($e.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:re()});return f?c.jsxs(g.Card,{className:g.cn("w-full",b.base),"data-testid":y||`offer-card-${t.id}`,children:[c.jsx(g.CardBody,{className:g.cn("pt-1 pb-0",b.body),children:J}),c.jsx($e.AnimatePresence,{children:ge&&c.jsx(g.CardFooter,{className:g.cn("w-full mt-0 pt-0",b.footer),children:ge})})]}):c.jsxs("div",{className:g.cn("w-full",b.base),"data-testid":y||`offer-card-${t.id}`,children:[c.jsx("div",{className:g.cn("pt-1 pb-0",b.body),children:J}),c.jsx($e.AnimatePresence,{children:ge&&c.jsx("div",{className:g.cn("w-full mt-0 pt-0",b.footer),children:ge})})]})};Rr.displayName="OfferCard";const vo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const a=i();return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:a})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:g.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(ae,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:g.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:g.cn("text-lg",s.message),children:t})]});return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:o})};vo.displayName="OfferCardEmpty";const pu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ko=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...pu,...e},o=c.jsx(g.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:o})};ko.displayName="OfferCardError";const mu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},So=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=mu[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:g.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(g.Card,{"data-testid":`offer-card-skeleton-${i}`,className:g.cn("w-full",n.card),children:[c.jsx(g.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(g.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(g.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(g.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(g.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(g.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(g.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(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};So.displayName="OfferCardSkeleton";const Co={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},wo={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"}}},gu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},No=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:a,slots:l,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:m=!0,animated:h=!0,gap:k=2,classNames:b={}})=>{const[y,S]=x.useState(n),N=e!==void 0?e:y,j=x.useCallback((P,$)=>{const H={...N,[P]:Math.max(0,$)};e===void 0&&S(H),r?.(H),s?.(P,H[P])},[N,e,r,s]),C=[...t].sort((P,$)=>(P.position??0)-($.position??0)),A=gu[k],M=g.cn("grid mx-auto pt-2",A,b.base),L=P=>c.jsx(Rr,{offer:P,quantity:N[P.id]||0,onQuantityChange:j,currency:i,locale:o,labels:a,slots:l,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:m,classNames:b.card},P.id);return h?c.jsx($e.motion.div,{"data-testid":"offer-card-list",className:M,variants:Co,initial:"hidden",animate:"show",children:c.jsx($e.AnimatePresence,{children:C.map(P=>c.jsx($e.motion.div,{"data-testid":`offer-card-list-item-${P.id}`,className:b.cardWrapper,variants:wo,exit:{opacity:0,y:-20},transition:{duration:.3},children:L(P)},P.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:M,children:C.map(L)})};No.displayName="OfferCardList";var Kt=t=>t.type==="checkbox",ct=t=>t instanceof Date,Ne=t=>t==null;const Ao=t=>typeof t=="object";var he=t=>!Ne(t)&&!Array.isArray(t)&&Ao(t)&&!ct(t),jo=t=>he(t)&&t.target?Kt(t.target)?t.target.checked:t.target.value:t,xu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,Eo=(t,e)=>t.has(xu(e)),yu=t=>{const e=t.constructor&&t.constructor.prototype;return he(e)&&e.hasOwnProperty("isPrototypeOf")},$r=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if($r&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(he(t)&&yu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=de(t[s]));return r}var wn=t=>/^\w*$/.test(t),ie=t=>t===void 0,Vr=t=>Array.isArray(t)?t.filter(Boolean):[],Br=t=>Vr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),I=(t,e,n)=>{if(!e||!he(t))return n;const r=(wn(e)?[e]:Br(e)).reduce((s,i)=>Ne(s)?s:s[i],t);return ie(r)||r===t?ie(t[e])?n:t[e]:r},je=t=>typeof t=="boolean",we=t=>typeof t=="function",ne=(t,e,n)=>{let r=-1;const s=wn(e)?[e]:Br(e),i=s.length,o=i-1;for(;++r<i;){const a=s[r];let l=n;if(r!==o){const d=t[a];l=he(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;t[a]=l,t=t[a]}};const mn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Pe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},To=x.createContext(null);To.displayName="HookFormControlContext";const zr=()=>x.useContext(To);var Mo=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Pe.all&&(e._proxyFormState[o]=!r||Pe.all),n&&(n[o]=!0),t[o]}});return s};const _r=typeof window<"u"?x.useLayoutEffect:x.useEffect;function bu(t){const e=zr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,a]=x.useState(n._formState),l=x.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return _r(()=>n._subscribe({name:s,formState:l.current,exact:i,callback:d=>{!r&&a({...n._formState,...d})}}),[s,r,i]),x.useEffect(()=>{l.current.isValid&&n._setValid(!0)},[n]),x.useMemo(()=>Mo(o,n,l.current,!1),[o,n])}var Te=t=>typeof t=="string",mr=(t,e,n,r,s)=>Te(t)?(r&&e.watch.add(t),I(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),I(n,i))):(r&&(e.watchAll=!0),n),gr=t=>Ne(t)||!Ao(t);function Re(t,e,n=new WeakSet){if(gr(t)||gr(e))return Object.is(t,e);if(ct(t)&&ct(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 a=e[i];if(ct(o)&&ct(a)||he(o)&&he(a)||Array.isArray(o)&&Array.isArray(a)?!Re(o,a,n):!Object.is(o,a))return!1}}return!0}function vu(t){const e=zr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:a}=t||{},l=x.useRef(s),d=x.useRef(a),u=x.useRef(void 0),f=x.useRef(n),m=x.useRef(r);d.current=a;const[h,k]=x.useState(()=>{const C=n._getWatch(r,l.current);return d.current?d.current(C):C}),b=x.useCallback(C=>{const A=mr(r,n._names,C||n._formValues,!1,l.current);return d.current?d.current(A):A},[n._formValues,n._names,r]),y=x.useCallback(C=>{if(!i){const A=mr(r,n._names,C||n._formValues,!1,l.current);if(d.current){const M=d.current(A);Re(M,u.current)||(k(M),u.current=M)}else k(A)}},[n._formValues,n._names,i,r]);_r(()=>((f.current!==n||!Re(m.current,r))&&(f.current=n,m.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:C=>{y(C.values)}})),[n,o,r,y]),x.useEffect(()=>n._removeUnmounted());const S=f.current!==n,N=m.current,j=x.useMemo(()=>{if(i)return null;const C=!S&&!Re(N,r);return S||C?b():null},[i,S,r,N,b]);return j!==null?j:h}function ku(t){const e=zr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:a=!0}=t,l=Eo(s._names.array,n),d=x.useMemo(()=>I(s._formValues,n,I(s._defaultValues,n,o)),[s,n,o]),u=vu({control:s,name:n,defaultValue:d,exact:a}),f=bu({control:s,name:n,exact:a}),m=x.useRef(t),h=x.useRef(void 0),k=x.useRef(s.register(n,{...t.rules,value:u,...je(t.disabled)?{disabled:t.disabled}:{}}));m.current=t;const b=x.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!I(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!I(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!I(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!I(f.validatingFields,n)},error:{enumerable:!0,get:()=>I(f.errors,n)}}),[f,n]),y=x.useCallback(C=>k.current.onChange({target:{value:jo(C),name:n},type:mn.CHANGE}),[n]),S=x.useCallback(()=>k.current.onBlur({target:{value:I(s._formValues,n),name:n},type:mn.BLUR}),[n,s._formValues]),N=x.useCallback(C=>{const A=I(s._fields,n);A&&A._f&&C&&(A._f.ref={focus:()=>we(C.focus)&&C.focus(),select:()=>we(C.select)&&C.select(),setCustomValidity:M=>we(C.setCustomValidity)&&C.setCustomValidity(M),reportValidity:()=>we(C.reportValidity)&&C.reportValidity()})},[s._fields,n]),j=x.useMemo(()=>({name:n,value:u,...je(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:y,onBlur:S,ref:N}),[n,r,f.disabled,y,S,N,u]);return x.useEffect(()=>{const C=s._options.shouldUnregister||i,A=h.current;A&&A!==n&&!l&&s.unregister(A),s.register(n,{...m.current.rules,...je(m.current.disabled)?{disabled:m.current.disabled}:{}});const M=(L,P)=>{const $=I(s._fields,L);$&&$._f&&($._f.mount=P)};if(M(n,!0),C){const L=de(I(s._options.defaultValues,n,m.current.defaultValue));ne(s._defaultValues,n,L),ie(I(s._formValues,n))&&ne(s._formValues,n,L)}return!l&&s.register(n),h.current=n,()=>{(l?C&&!s._state.action:C)?s.unregister(n):M(n,!1)}},[n,s,l,i]),x.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),x.useMemo(()=>({field:j,formState:f,fieldState:b}),[j,f,b])}const Su=x.createContext(null);Su.displayName="HookFormContext";var Cu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Ft=t=>Array.isArray(t)?t:[t],Ws=()=>{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 Oo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&he(s)&&i){const o=Oo(s,i);he(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var Se=t=>he(t)&&!Object.keys(t).length,Hr=t=>t.type==="file",gn=t=>{if(!$r)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Do=t=>t.type==="select-multiple",Ur=t=>t.type==="radio",wu=t=>Ur(t)||Kt(t),Jn=t=>gn(t)&&t.isConnected;function Nu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=ie(t)?r++:t[e[r++]];return t}function Au(t){for(const e in t)if(t.hasOwnProperty(e)&&!ie(t[e]))return!1;return!0}function ue(t,e){const n=Array.isArray(e)?e:wn(e)?[e]:Br(e),r=n.length===1?t:Nu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(he(r)&&Se(r)||Array.isArray(r)&&Au(r))&&ue(t,n.slice(0,-1)),t}var ju=t=>{for(const e in t)if(we(t[e]))return!0;return!1};function Io(t){return Array.isArray(t)||he(t)&&!ju(t)}function xr(t,e={}){for(const n in t){const r=t[n];Io(r)?(e[n]=Array.isArray(r)?[]:{},xr(r,e[n])):ie(r)||(e[n]=!0)}return e}function kt(t,e,n){n||(n=xr(e));for(const r in t){const s=t[r];if(Io(s))ie(e)||gr(n[r])?n[r]=xr(s,Array.isArray(s)?[]:{}):kt(s,Ne(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Re(s,i)}}return n}const Js={value:!1,isValid:!1},Gs={value:!0,isValid:!0};var Lo=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&&!ie(t[0].attributes.value)?ie(t[0].value)||t[0].value===""?Gs:{value:t[0].value,isValid:!0}:Gs:Js}return Js},Fo=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>ie(t)?t:e?t===""?NaN:t&&+t:n&&Te(t)?new Date(t):r?r(t):t;const Zs={isValid:!1,value:null};var Po=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Zs):Zs;function Ys(t){const e=t.ref;return Hr(e)?e.files:Ur(e)?Po(t.refs).value:Do(e)?[...e.selectedOptions].map(({value:n})=>n):Kt(e)?Lo(t.refs).value:Fo(ie(e.value)?t.ref.value:e.value,t)}var Eu=(t,e,n,r)=>{const s={};for(const i of t){const o=I(e,i);o&&ne(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},xn=t=>t instanceof RegExp,Mt=t=>ie(t)?t:xn(t)?t.source:he(t)?xn(t.value)?t.value.source:t.value:t,Qs=t=>({isOnSubmit:!t||t===Pe.onSubmit,isOnBlur:t===Pe.onBlur,isOnChange:t===Pe.onChange,isOnAll:t===Pe.all,isOnTouch:t===Pe.onTouched});const Xs="AsyncFunction";var Tu=t=>!!t&&!!t.validate&&!!(we(t.validate)&&t.validate.constructor.name===Xs||he(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Xs)),Mu=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),ei=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Pt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=I(t,s);if(i){const{_f:o,...a}=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(Pt(a,e))break}else if(he(a)&&Pt(a,e))break}}};function ti(t,e,n){const r=I(t,n);if(r||wn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=I(e,i),a=I(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:n}}var Ou=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return Se(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Pe.all))},Du=(t,e,n)=>!t||!e||t===e||Ft(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),Iu=(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,Lu=(t,e)=>!Vr(I(t,e)).length&&ue(t,e),Fu=(t,e,n)=>{const r=Ft(I(t,n));return ne(r,"root",e[n]),ne(t,n,r),t};function ni(t,e,n="validate"){if(Te(t)||Array.isArray(t)&&t.every(Te)||je(t)&&!t)return{type:n,message:Te(t)?t:"",ref:e}}var xt=t=>he(t)&&!xn(t)?t:{value:t,message:""},ri=async(t,e,n,r,s,i)=>{const{ref:o,refs:a,required:l,maxLength:d,minLength:u,min:f,max:m,pattern:h,validate:k,name:b,valueAsNumber:y,mount:S}=t._f,N=I(n,b);if(!S||e.has(b))return{};const j=a?a[0]:o,C=T=>{s&&j.reportValidity&&(j.setCustomValidity(je(T)?"":T||""),j.reportValidity())},A={},M=Ur(o),L=Kt(o),P=M||L,$=(y||Hr(o))&&ie(o.value)&&ie(N)||gn(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length,H=Cu.bind(null,b,r,A),D=(T,R,B,U=Ue.maxLength,re=Ue.minLength)=>{const J=T?R:B;A[b]={type:T?U:re,message:J,ref:o,...H(T?U:re,J)}};if(i?!Array.isArray(N)||!N.length:l&&(!P&&($||Ne(N))||je(N)&&!N||L&&!Lo(a).isValid||M&&!Po(a).isValid)){const{value:T,message:R}=Te(l)?{value:!!l,message:l}:xt(l);if(T&&(A[b]={type:Ue.required,message:R,ref:j,...H(Ue.required,R)},!r))return C(R),A}if(!$&&(!Ne(f)||!Ne(m))){let T,R;const B=xt(m),U=xt(f);if(!Ne(N)&&!isNaN(N)){const re=o.valueAsNumber||N&&+N;Ne(B.value)||(T=re>B.value),Ne(U.value)||(R=re<U.value)}else{const re=o.valueAsDate||new Date(N),J=xe=>new Date(new Date().toDateString()+" "+xe),ge=o.type=="time",ce=o.type=="week";Te(B.value)&&N&&(T=ge?J(N)>J(B.value):ce?N>B.value:re>new Date(B.value)),Te(U.value)&&N&&(R=ge?J(N)<J(U.value):ce?N<U.value:re<new Date(U.value))}if((T||R)&&(D(!!T,B.message,U.message,Ue.max,Ue.min),!r))return C(A[b].message),A}if((d||u)&&!$&&(Te(N)||i&&Array.isArray(N))){const T=xt(d),R=xt(u),B=!Ne(T.value)&&N.length>+T.value,U=!Ne(R.value)&&N.length<+R.value;if((B||U)&&(D(B,T.message,R.message),!r))return C(A[b].message),A}if(h&&!$&&Te(N)){const{value:T,message:R}=xt(h);if(xn(T)&&!N.match(T)&&(A[b]={type:Ue.pattern,message:R,ref:o,...H(Ue.pattern,R)},!r))return C(R),A}if(k){if(we(k)){const T=await k(N,n),R=ni(T,j);if(R&&(A[b]={...R,...H(Ue.validate,R.message)},!r))return C(R.message),A}else if(he(k)){let T={};for(const R in k){if(!Se(T)&&!r)break;const B=ni(await k[R](N,n),j,R);B&&(T={...B,...H(R,B.message)},C(B.message),r&&(A[b]=T))}if(!Se(T)&&(A[b]={ref:j,...T},!r))return A}}return C(!0),A};const Pu={mode:Pe.onSubmit,reValidateMode:Pe.onChange,shouldFocusError:!0};function Ru(t={}){let e={...Pu,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:we(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=he(e.defaultValues)||he(e.values)?de(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:de(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let m={...f};const h={array:Ws(),state:Ws()},k=e.criteriaMode===Pe.all,b=p=>v=>{clearTimeout(d),d=setTimeout(p,v)},y=async p=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||m.isValid||p)){let v;e.resolver?(v=Se((await P()).errors),S()):v=await H(r,!0),v!==n.isValid&&h.state.next({isValid:v})}},S=(p,v)=>{!e.disabled&&(f.isValidating||f.validatingFields||m.isValidating||m.validatingFields)&&((p||Array.from(a.mount)).forEach(w=>{w&&(v?ne(n.validatingFields,w,v):ue(n.validatingFields,w))}),h.state.next({validatingFields:n.validatingFields,isValidating:!Se(n.validatingFields)}))},N=(p,v=[],w,F,O=!0,E=!0)=>{if(F&&w&&!e.disabled){if(o.action=!0,E&&Array.isArray(I(r,p))){const z=w(I(r,p),F.argA,F.argB);O&&ne(r,p,z)}if(E&&Array.isArray(I(n.errors,p))){const z=w(I(n.errors,p),F.argA,F.argB);O&&ne(n.errors,p,z),Lu(n.errors,p)}if((f.touchedFields||m.touchedFields)&&E&&Array.isArray(I(n.touchedFields,p))){const z=w(I(n.touchedFields,p),F.argA,F.argB);O&&ne(n.touchedFields,p,z)}(f.dirtyFields||m.dirtyFields)&&(n.dirtyFields=kt(s,i)),h.state.next({name:p,isDirty:T(p,v),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ne(i,p,v)},j=(p,v)=>{ne(n.errors,p,v),h.state.next({errors:n.errors})},C=p=>{n.errors=p,h.state.next({errors:n.errors,isValid:!1})},A=(p,v,w,F)=>{const O=I(r,p);if(O){const E=I(i,p,ie(w)?I(s,p):w);ie(E)||F&&F.defaultChecked||v?ne(i,p,v?E:Ys(O._f)):U(p,E),o.mount&&!o.action&&y()}},M=(p,v,w,F,O)=>{let E=!1,z=!1;const Z={name:p};if(!e.disabled){if(!w||F){(f.isDirty||m.isDirty)&&(z=n.isDirty,n.isDirty=Z.isDirty=T(),E=z!==Z.isDirty);const Y=Re(I(s,p),v);z=!!I(n.dirtyFields,p),Y?ue(n.dirtyFields,p):ne(n.dirtyFields,p,!0),Z.dirtyFields=n.dirtyFields,E=E||(f.dirtyFields||m.dirtyFields)&&z!==!Y}if(w){const Y=I(n.touchedFields,p);Y||(ne(n.touchedFields,p,w),Z.touchedFields=n.touchedFields,E=E||(f.touchedFields||m.touchedFields)&&Y!==w)}E&&O&&h.state.next(Z)}return E?Z:{}},L=(p,v,w,F)=>{const O=I(n.errors,p),E=(f.isValid||m.isValid)&&je(v)&&n.isValid!==v;if(e.delayError&&w?(l=b(()=>j(p,w)),l(e.delayError)):(clearTimeout(d),l=null,w?ne(n.errors,p,w):ue(n.errors,p)),(w?!Re(O,w):O)||!Se(F)||E){const z={...F,...E&&je(v)?{isValid:v}:{},errors:n.errors,name:p};n={...n,...z},h.state.next(z)}},P=async p=>(S(p,!0),await e.resolver(i,e.context,Eu(p||a.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),$=async p=>{const{errors:v}=await P(p);if(S(p),p)for(const w of p){const F=I(v,w);F?ne(n.errors,w,F):ue(n.errors,w)}else n.errors=v;return v},H=async(p,v,w={valid:!0})=>{for(const F in p){const O=p[F];if(O){const{_f:E,...z}=O;if(E){const Z=a.array.has(E.name),Y=O._f&&Tu(O._f);Y&&f.validatingFields&&S([E.name],!0);const ke=await ri(O,a.disabled,i,k,e.shouldUseNativeValidation&&!v,Z);if(Y&&f.validatingFields&&S([E.name]),ke[E.name]&&(w.valid=!1,v||t.shouldUseNativeValidation))break;!v&&(I(ke,E.name)?Z?Fu(n.errors,ke,E.name):ne(n.errors,E.name,ke[E.name]):ue(n.errors,E.name))}!Se(z)&&await H(z,v,w)}}return w.valid},D=()=>{for(const p of a.unMount){const v=I(r,p);v&&(v._f.refs?v._f.refs.every(w=>!Jn(w)):!Jn(v._f.ref))&&An(p)}a.unMount=new Set},T=(p,v)=>!e.disabled&&(p&&v&&ne(i,p,v),!Re(Le(),s)),R=(p,v,w)=>mr(p,a,{...o.mount?i:ie(v)?s:Te(p)?{[p]:v}:v},w,v),B=p=>Vr(I(o.mount?i:s,p,e.shouldUnregister?I(s,p,[]):[])),U=(p,v,w={})=>{const F=I(r,p);let O=v;if(F){const E=F._f;E&&(!E.disabled&&ne(i,p,Fo(v,E)),O=gn(E.ref)&&Ne(v)?"":v,Do(E.ref)?[...E.ref.options].forEach(z=>z.selected=O.includes(z.value)):E.refs?Kt(E.ref)?E.refs.forEach(z=>{(!z.defaultChecked||!z.disabled)&&(Array.isArray(O)?z.checked=!!O.find(Z=>Z===z.value):z.checked=O===z.value||!!O)}):E.refs.forEach(z=>z.checked=z.value===O):Hr(E.ref)?E.ref.value="":(E.ref.value=O,E.ref.type||h.state.next({name:p,values:de(i)})))}(w.shouldDirty||w.shouldTouch)&&M(p,O,w.shouldTouch,w.shouldDirty,!0),w.shouldValidate&&xe(p)},re=(p,v,w)=>{for(const F in v){if(!v.hasOwnProperty(F))return;const O=v[F],E=p+"."+F,z=I(r,E);(a.array.has(p)||he(O)||z&&!z._f)&&!ct(O)?re(E,O,w):U(E,O,w)}},J=(p,v,w={})=>{const F=I(r,p),O=a.array.has(p),E=de(v);ne(i,p,E),O?(h.array.next({name:p,values:de(i)}),(f.isDirty||f.dirtyFields||m.isDirty||m.dirtyFields)&&w.shouldDirty&&h.state.next({name:p,dirtyFields:kt(s,i),isDirty:T(p,E)})):F&&!F._f&&!Ne(E)?re(p,E,w):U(p,E,w),ei(p,a)?h.state.next({...n,name:p,values:de(i)}):h.state.next({name:o.mount?p:void 0,values:de(i)})},ge=async p=>{o.mount=!0;const v=p.target;let w=v.name,F=!0;const O=I(r,w),E=Y=>{F=Number.isNaN(Y)||ct(Y)&&isNaN(Y.getTime())||Re(Y,I(i,w,Y))},z=Qs(e.mode),Z=Qs(e.reValidateMode);if(O){let Y,ke;const nt=v.type?Ys(O._f):jo(p),Je=p.type===mn.BLUR||p.type===mn.FOCUS_OUT,oa=!Mu(O._f)&&!e.resolver&&!I(n.errors,w)&&!O._f.deps||Iu(Je,I(n.touchedFields,w),n.isSubmitted,Z,z),Tn=ei(w,a,Je);ne(i,w,nt),Je?(!v||!v.readOnly)&&(O._f.onBlur&&O._f.onBlur(p),l&&l(0)):O._f.onChange&&O._f.onChange(p);const Mn=M(w,nt,Je),aa=!Se(Mn)||Tn;if(!Je&&h.state.next({name:w,type:p.type,values:de(i)}),oa)return(f.isValid||m.isValid)&&(e.mode==="onBlur"?Je&&y():Je||y()),aa&&h.state.next({name:w,...Tn?{}:Mn});if(!Je&&Tn&&h.state.next({...n}),e.resolver){const{errors:Xr}=await P([w]);if(S([w]),E(nt),F){const la=ti(n.errors,r,w),es=ti(Xr,r,la.name||w);Y=es.error,w=es.name,ke=Se(Xr)}}else S([w],!0),Y=(await ri(O,a.disabled,i,k,e.shouldUseNativeValidation))[w],S([w]),E(nt),F&&(Y?ke=!1:(f.isValid||m.isValid)&&(ke=await H(r,!0)));F&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&xe(O._f.deps),L(w,ke,Y,Mn))}},ce=(p,v)=>{if(I(n.errors,v)&&p.focus)return p.focus(),1},xe=async(p,v={})=>{let w,F;const O=Ft(p);if(e.resolver){const E=await $(ie(p)?p:O);w=Se(E),F=p?!O.some(z=>I(E,z)):w}else p?(F=(await Promise.all(O.map(async E=>{const z=I(r,E);return await H(z&&z._f?{[E]:z}:z)}))).every(Boolean),!(!F&&!n.isValid)&&y()):F=w=await H(r);return h.state.next({...!Te(p)||(f.isValid||m.isValid)&&w!==n.isValid?{}:{name:p},...e.resolver||!p?{isValid:w}:{},errors:n.errors}),v.shouldFocus&&!F&&Pt(r,ce,p?O:a.mount),F},Le=(p,v)=>{let w={...o.mount?i:s};return v&&(w=Oo(v.dirtyFields?n.dirtyFields:n.touchedFields,w)),ie(p)?w:Te(p)?I(w,p):p.map(F=>I(w,F))},ee=(p,v)=>({invalid:!!I((v||n).errors,p),isDirty:!!I((v||n).dirtyFields,p),error:I((v||n).errors,p),isValidating:!!I(n.validatingFields,p),isTouched:!!I((v||n).touchedFields,p)}),Oe=p=>{p&&Ft(p).forEach(v=>ue(n.errors,v)),h.state.next({errors:p?n.errors:{}})},te=(p,v,w)=>{const F=(I(r,p,{_f:{}})._f||{}).ref,O=I(n.errors,p)||{},{ref:E,message:z,type:Z,...Y}=O;ne(n.errors,p,{...Y,...v,ref:F}),h.state.next({name:p,errors:n.errors,isValid:!1}),w&&w.shouldFocus&&F&&F.focus&&F.focus()},Ae=(p,v)=>we(p)?h.state.subscribe({next:w=>"values"in w&&p(R(void 0,v),w)}):R(p,v,!0),At=p=>h.state.subscribe({next:v=>{Du(p.name,v.name,p.exact)&&Ou(v,p.formState||f,ia,p.reRenderRoot)&&p.callback({values:{...i},...n,...v,defaultValues:s})}}).unsubscribe,Nn=p=>(o.mount=!0,m={...m,...p.formState},At({...p,formState:{...u,...p.formState}})),An=(p,v={})=>{for(const w of p?Ft(p):a.mount)a.mount.delete(w),a.array.delete(w),v.keepValue||(ue(r,w),ue(i,w)),!v.keepError&&ue(n.errors,w),!v.keepDirty&&ue(n.dirtyFields,w),!v.keepTouched&&ue(n.touchedFields,w),!v.keepIsValidating&&ue(n.validatingFields,w),!e.shouldUnregister&&!v.keepDefaultValue&&ue(s,w);h.state.next({values:de(i)}),h.state.next({...n,...v.keepDirty?{isDirty:T()}:{}}),!v.keepIsValid&&y()},Jr=({disabled:p,name:v})=>{if(je(p)&&o.mount||p||a.disabled.has(v)){const O=a.disabled.has(v)!==!!p;p?a.disabled.add(v):a.disabled.delete(v),O&&o.mount&&!o.action&&y()}},jn=(p,v={})=>{let w=I(r,p);const F=je(v.disabled)||je(e.disabled);return ne(r,p,{...w||{},_f:{...w&&w._f?w._f:{ref:{name:p}},name:p,mount:!0,...v}}),a.mount.add(p),w?Jr({disabled:je(v.disabled)?v.disabled:e.disabled,name:p}):A(p,!0,v.value),{...F?{disabled:v.disabled||e.disabled}:{},...e.progressive?{required:!!v.required,min:Mt(v.min),max:Mt(v.max),minLength:Mt(v.minLength),maxLength:Mt(v.maxLength),pattern:Mt(v.pattern)}:{},name:p,onChange:ge,onBlur:ge,ref:O=>{if(O){jn(p,v),w=I(r,p);const E=ie(O.value)&&O.querySelectorAll&&O.querySelectorAll("input,select,textarea")[0]||O,z=wu(E),Z=w._f.refs||[];if(z?Z.find(Y=>Y===E):E===w._f.ref)return;ne(r,p,{_f:{...w._f,...z?{refs:[...Z.filter(Jn),E,...Array.isArray(I(s,p))?[{}]:[]],ref:{type:E.type,name:p}}:{ref:E}}}),A(p,!1,void 0,E)}else w=I(r,p,{}),w._f&&(w._f.mount=!1),(e.shouldUnregister||v.shouldUnregister)&&!(Eo(a.array,p)&&o.action)&&a.unMount.add(p)}}},En=()=>e.shouldFocusError&&Pt(r,ce,a.mount),na=p=>{je(p)&&(h.state.next({disabled:p}),Pt(r,(v,w)=>{const F=I(r,w);F&&(v.disabled=F._f.disabled||p,Array.isArray(F._f.refs)&&F._f.refs.forEach(O=>{O.disabled=F._f.disabled||p}))},0,!1))},Gr=(p,v)=>async w=>{let F;w&&(w.preventDefault&&w.preventDefault(),w.persist&&w.persist());let O=de(i);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:E,values:z}=await P();S(),n.errors=E,O=de(z)}else await H(r);if(a.disabled.size)for(const E of a.disabled)ue(O,E);if(ue(n.errors,"root"),Se(n.errors)){h.state.next({errors:{}});try{await p(O,w)}catch(E){F=E}}else v&&await v({...n.errors},w),En(),setTimeout(En);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(n.errors)&&!F,submitCount:n.submitCount+1,errors:n.errors}),F)throw F},ra=(p,v={})=>{I(r,p)&&(ie(v.defaultValue)?J(p,de(I(s,p))):(J(p,v.defaultValue),ne(s,p,de(v.defaultValue))),v.keepTouched||ue(n.touchedFields,p),v.keepDirty||(ue(n.dirtyFields,p),n.isDirty=v.defaultValue?T(p,de(I(s,p))):T()),v.keepError||(ue(n.errors,p),f.isValid&&y()),h.state.next({...n}))},Zr=(p,v={})=>{const w=p?de(p):s,F=de(w),O=Se(p),E=O?s:F;if(v.keepDefaultValues||(s=w),!v.keepValues){if(v.keepDirtyValues){const z=new Set([...a.mount,...Object.keys(kt(s,i))]);for(const Z of Array.from(z)){const Y=I(n.dirtyFields,Z),ke=I(i,Z),nt=I(E,Z);Y&&!ie(ke)?ne(E,Z,ke):!Y&&!ie(nt)&&J(Z,nt)}}else{if($r&&ie(p))for(const z of a.mount){const Z=I(r,z);if(Z&&Z._f){const Y=Array.isArray(Z._f.refs)?Z._f.refs[0]:Z._f.ref;if(gn(Y)){const ke=Y.closest("form");if(ke){ke.reset();break}}}}if(v.keepFieldsRef)for(const z of a.mount)J(z,I(E,z));else r={}}i=e.shouldUnregister?v.keepDefaultValues?de(s):{}:de(E),h.array.next({values:{...E}}),h.state.next({values:{...E}})}a={mount:v.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!v.keepIsValid||!!v.keepDirtyValues||!e.shouldUnregister&&!Se(E),o.watch=!!e.shouldUnregister,o.keepIsValid=!!v.keepIsValid,o.action=!1,v.keepErrors||(n.errors={}),h.state.next({submitCount:v.keepSubmitCount?n.submitCount:0,isDirty:O?!1:v.keepDirty?n.isDirty:!!(v.keepDefaultValues&&!Re(p,s)),isSubmitted:v.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:O?{}:v.keepDirtyValues?v.keepDefaultValues&&i?kt(s,i):n.dirtyFields:v.keepDefaultValues&&p?kt(s,p):v.keepDirty?n.dirtyFields:{},touchedFields:v.keepTouched?n.touchedFields:{},errors:v.keepErrors?n.errors:{},isSubmitSuccessful:v.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Yr=(p,v)=>Zr(we(p)?p(i):p,{...e.resetOptions,...v}),sa=(p,v={})=>{const w=I(r,p),F=w&&w._f;if(F){const O=F.refs?F.refs[0]:F.ref;O.focus&&setTimeout(()=>{O.focus(),v.shouldSelect&&we(O.select)&&O.select()})}},ia=p=>{n={...n,...p}},Qr={control:{register:jn,unregister:An,getFieldState:ee,handleSubmit:Gr,setError:te,_subscribe:At,_runSchema:P,_updateIsValidating:S,_focusError:En,_getWatch:R,_getDirty:T,_setValid:y,_setFieldArray:N,_setDisabledField:Jr,_setErrors:C,_getFieldArray:B,_reset:Zr,_resetDefaultValues:()=>we(e.defaultValues)&&e.defaultValues().then(p=>{Yr(p,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:D,_disableForm:na,_subjects:h,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(p){o=p},get _defaultValues(){return s},get _names(){return a},set _names(p){a=p},get _formState(){return n},get _options(){return e},set _options(p){e={...e,...p}}},subscribe:Nn,trigger:xe,register:jn,handleSubmit:Gr,watch:Ae,setValue:J,getValues:Le,reset:Yr,resetField:ra,clearErrors:Oe,unregister:An,setError:te,setFocus:sa,getFieldState:ee};return{...Qr,formControl:Qr}}function $u(t={}){const e=x.useRef(void 0),n=x.useRef(void 0),[r,s]=x.useState({isDirty:!1,isValidating:!1,isLoading:we(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:we(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!we(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...a}=Ru(t);e.current={...a,formState:r}}const i=e.current.control;return i._options=t,_r(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),i._formState.isReady=!0,o},[i]),x.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),x.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),x.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),x.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),x.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),x.useEffect(()=>{var o;t.values&&!Re(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(a=>({...a}))):i._resetDefaultValues()},[i,t.values]),x.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=x.useMemo(()=>Mo(r,i),[i,r]),e.current}function Vu(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function Bu(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 zu(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 _u(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 Hu(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 qr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}qr();const Uu={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:"$"},Gn=()=>({id:qr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ro=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:a,onTaxDeductibleChange:l,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:m=!1,labels:h,classNames:k={},"data-testid":b,control:y,name:S,rules:N})=>{const j={...Uu,...h},C=y!==void 0&&S!==void 0,A=$u({defaultValues:{_internal:e||Gn()}}),M=ku({control:C?y:A.control,name:C?S:"_internal",rules:C?N:void 0}),[L,P]=x.useState(e||Gn()),$=C?M.field.value??Gn():t??L,H=C&&!!M.fieldState?.error,D=C&&(M.fieldState?.isTouched??!1),T=H||D,R=T&&(!$.amount||$.amount<=0),B=T&&!$.glAccount,[U,re]=x.useState($.glAccount?.name||""),J=x.useCallback(te=>{const Ae={...$,...te};C&&M.field.onChange(Ae),!C&&t===void 0&&P(Ae),i?.(Ae)},[$,t,i,C,M]),ge=x.useCallback(te=>{const Ae=te||0;J({amount:Ae}),o?.(Ae)},[J,o]),ce=x.useCallback(te=>{re(te),s?.(te)},[s]),xe=x.useCallback(te=>{if(te===null){J({glAccount:null}),a?.(null);return}const At=n.find(Nn=>String(Nn.id)===String(te))||null;J({glAccount:At}),a?.(At)},[n,J,a]),Le=x.useCallback(()=>{re(""),J({glAccount:null}),a?.(null)},[J,a]),ee=x.useCallback(te=>{J({isTaxDeductible:te}),l?.(te)},[J,l]),Oe=x.useCallback(()=>{d?.()},[d]);return c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:g.cn(k.base),children:c.jsxs(g.CardBody,{className:g.cn("flex flex-row flex-nowrap items-start gap-4",k.body),children:[c.jsx("div",{className:g.cn("shrink-0",k.amountContainer),children:c.jsx(g.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(g.Tooltip,{content:j.amountTooltip,children:c.jsx(ae,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:$.amount||void 0,onValueChange:ge,labelPlacement:"outside",placeholder:j.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:m,isInvalid:R,errorMessage:R?"Amount is required":void 0,minValue:0,step:.01,className:k.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:g.cn("grow",k.glAccountContainer),children:c.jsx(g.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(g.Tooltip,{content:j.glAccountTooltip,children:c.jsx(ae,{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:$.glAccount?.name??U,selectedKey:$.glAccount?.id??null,isDisabled:m,isInvalid:B,errorMessage:B?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:ce,onSelectionChange:xe,onClear:Le,className:k.glAccountInput,children:te=>c.jsx(g.AutocompleteItem,{textValue:te.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:te.name}),te.code&&c.jsx("span",{className:"text-xs text-default-400",children:te.code})]})},te.id)})}),c.jsx("div",{className:g.cn("shrink-0 pt-6 flex items-center",k.taxDeductibleContainer),children:c.jsx(g.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:$.isTaxDeductible,onValueChange:ee,isDisabled:m||!f,className:k.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:g.cn("shrink-0 pt-6",k.deleteContainer),children:c.jsx(G,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:m||!u,onPress:Oe,startContent:c.jsx(ae,{icon:"solar:trash-bin-trash-linear",width:16}),className:g.cn("text-danger",k.deleteButton),children:j.deleteButton})})]})})};Ro.displayName="RevenueDistributionCard";const $o=({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:g.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(ae,{icon:e,width:n,className:g.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:g.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:o})};$o.displayName="RevenueDistributionEmpty";const qu={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Vo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...qu,...e},o=c.jsx(g.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:o})};Vo.displayName="RevenueDistributionError";const Bo=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:g.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(g.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.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(g.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(g.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(g.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(g.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(g.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Bo.displayName="RevenueDistributionSkeleton";const Ku={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Wu=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:a=null,allowReselect:l=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const m=Array.isArray(t)?t:[],[h,k]=x.useState(a),[b,y]=x.useState(o),S={...Ku,...s};x.useEffect(()=>{k(a)},[a]);const N=C=>{if(C===h){l&&u?.(C);return}k(C),u?.(C)},j=C=>{y(C),d?.(C)};return c.jsxs("div",{className:g.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",f),"data-testid":"membership-select-cards",children:[c.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),c.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:S.title}),i&&c.jsx(_o,{title:S.renewalTitle,description:S.renewalDescription,value:b,onValueChange:j}),c.jsx("div",{className:g.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":g.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:m.map(C=>c.jsx(zo,{itemKey:C.id,name:C.name,type:C.type,price:C.price,locale:e,currency:n,isSelected:h===C.id,onSelect:N},C.id))})]})},zo=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:o=!1,onSelect:a,className:l=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return c.jsx(g.Card,{shadow:"none",isPressable:!!a,onPress:()=>a?.(t),className:g.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",l),"data-testid":"item-card","data-selected":o,children:c.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[c.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[c.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:e}),n&&c.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:c.jsx("p",{className:"text-center",children:n})})]}),c.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:d})]})})},_o=({title:t,value:e,description:n,onValueChange:r,className:s=""})=>{const i=x.useId();return c.jsxs("div",{className:g.cn("w-full flex flex-row items-center",t||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[c.jsxs("div",{className:"flex flex-col items-start",children:[t&&c.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:t}),n&&c.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),c.jsx(g.Switch,{id:i,isSelected:e,onValueChange:r,"data-testid":"toggle-switch"})]})},Ju={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},Gu=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Ho=t=>Object.values(t).reduce((e,n)=>e+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,o)=>i+o.selectedQuantity,0),0),0),Zu=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,o)=>i+o.max,0),0),0),Kr=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),si=(t,e,n)=>{const r={};let s=n?e??Zu(t):0;for(const{exhibition:i,dateGroup:o,ticket:a}of Kr(t)){r[i.id]??={},r[i.id][o.id]??={};const l=n?Math.min(a.max,s):0;r[i.id][o.id][a.id]={id:a.id,selectedQuantity:l,originalPrice:a.originalPrice,discountedPrice:a.price},s-=l}return r},ii=(t,e,n)=>`${t}::${e}::${n}`,Yu=(t,e,n)=>{const r=Ho(e);for(const{exhibition:s,dateGroup:i,ticket:o}of Kr(t)){const a=e[s.id]?.[i.id]?.[o.id]?.selectedQuantity??0,l=n===void 0?o.max:Math.min(o.max,n-(r-a));if(l>0&&a<l)return!1}return!0},Qu=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[o,a]=x.useState(()=>String(i)),[l,d]=x.useState(!1),u=l?o:String(i),f=()=>{s||i>=n||r?.(i+1)},m=()=>{s||i<=e||r?.(i-1)},h=C=>{if(s)return;a(C.target.value);const A=parseInt(C.target.value,10);isNaN(A)||r?.(Math.max(e,Math.min(n,A)))},k=C=>{const A=parseInt(C.target.value,10);if(d(!1),isNaN(A)){r?.(e);return}const M=Math.max(e,Math.min(n,A));M!==A?r?.(M):a(String(M))},b=i<=e,y=i>=n,S="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",j="bg-primary/40 cursor-not-allowed";return c.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[c.jsx("button",{type:"button",onClick:m,disabled:s||b,className:g.cn(S,s||b?j:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),c.jsx("input",{type:"number",value:u,onChange:h,onFocus:()=>d(!0),onBlur:k,disabled:s,min:e,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),c.jsx("button",{type:"button",onClick:f,disabled:s||y,className:g.cn(S,s||y?j:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Xu=({label:t,checked:e=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!e)};return c.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":e,"data-testid":"checkbox-button","data-checked":e,className:g.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[c.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),c.jsx("span",{className:g.cn("block w-3.5 h-3.5 rounded-sm relative",e?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:e&&c.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),c.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:t})]})},ef=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:o})=>{const a=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},l=i?.locale??"en-US",d=i?.currency??"USD",u=Gu(l,d);return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[c.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[c.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[c.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[t.name,typeof t.purchasedQuantity=="number"&&t.purchasedQuantity>1?c.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${t.purchasedQuantity}`}):null]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(t.originalPrice)}),c.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(t.price)})]})]}),t.membershipName?c.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:t.membershipName,children:c.jsx("p",{className:"max-w-full truncate text-center",children:t.membershipName})}):null,c.jsx("div",{className:"text-sm text-zinc-500",children:c.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[o.ticketsAllowedToRedeem," ",t.max]})})]}),c.jsx(Qu,{initialQuantity:e,minQuantity:0,maxQuantity:a(),onChange:n})]}),t.membershipAlert?c.jsx(g.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:c.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:t.membershipAlert})}):null]})},tf=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l})=>c.jsxs("div",{className:g.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[c.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:e.date}),e.tickets.map((d,u)=>c.jsxs("div",{children:[c.jsx(ef,{item:d,quantity:s(t,e.id,d.id),onChange:f=>r(t,e.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l}),u<e.tickets.length-1?c.jsx(g.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),nf=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a,initialExpanded:l=!1})=>{const[d,u]=x.useState(l),f=e.dates.reduce((h,k)=>h+k.tickets.reduce((b,y)=>b+r(e.id,k.id,y.id),0),0),m=e.dates.some(h=>h.tickets.length>0);return c.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[c.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${e.id}`,"data-testid":"upgrade-ticket-header-button",children:c.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[c.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:t}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[f," ",a.ticketsSelectedToRedeem]}),c.jsx("span",{className:g.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:c.jsx(ae,{icon:"mdi:chevron-down"})})]})]})}),c.jsx("div",{id:`upgrade-items-${e.id}`,className:g.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&c.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:m?e.dates.map((h,k)=>c.jsx(tf,{exhibitionId:e.id,dateGroup:h,isLast:k===e.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a},h.id)):c.jsx("div",{className:"px-5 py-10 text-center",children:c.jsx("p",{className:"m-0 text-zinc-500 italic",children:a.noUpgradeTicketsAvailable})})})})]})},rf=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:o})=>{const a=x.useMemo(()=>s??[],[s]),l={...Ju,...n},[d,u]=x.useState(()=>si(a,e,!0)),f=x.useRef(!1),m=x.useMemo(()=>{const N=Kr(a).map(({exhibition:j,dateGroup:C,ticket:A})=>[ii(j.id,C.id,A.id),A]);return new Map(N)},[a]),h=Yu(a,d,e),k=(N,j,C)=>d[N]?.[j]?.[C]?.selectedQuantity??0,b=()=>Ho(d),y=(N,j,C,A)=>{const M=k(N,j,C),L=b()-M;if(e!==void 0&&L+A>e)return;const P=m.get(ii(N,j,C));if(!P)return;const $={...d,[N]:{...d[N],[j]:{...d[N]?.[j],[C]:{id:C,selectedQuantity:A,originalPrice:P.originalPrice,discountedPrice:P.price}}}};u($),o?.($)},S=N=>{const j=si(a,e,N);u(j),o?.(j)};return x.useEffect(()=>{!f.current&&h&&(o?.(d),f.current=!0)},[h,d,o]),c.jsxs("div",{className:g.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[c.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[c.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:l.ticketSelectionTitle}),c.jsx(Xu,{label:l.selectAllButtonLabel,checked:h,onChange:S})]}),a.map(N=>c.jsx(nf,{title:N.exhibitionName,exhibition:N,onQuantityChange:y,getTicketQuantity:k,getTotalSelectedTickets:b,userMaxLimit:e,settings:r,labels:l,initialExpanded:t},N.id))]})},sf=350,of={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},Zn=(t,e)=>Object.entries(e).reduce((n,[r,s])=>n.replace(`{${r}}`,s),t),af=({dueAmount:t,received:e,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:o=!1,className:a,"data-testid":l="cash-tender-form"})=>{const d={...of,...i},u=vr(t.currency,s),f=e!==void 0,[m,h]=x.useState(n??null),k=f?e:m,b=x.useMemo(()=>{const D=typeof k=="number"&&Number.isFinite(k)?k:0,T=Qn(D,t.value,t.currency,s);return{received:D,change:T>0?T:0,isValid:D>=t.value&&D>0}},[k,t.value,t.currency,s]),y=x.useCallback(D=>{const T=D.currentTarget;requestAnimationFrame(()=>{T.isConnected&&T.select()})},[]),S=x.useCallback(D=>{if(o)return;const T=D.replace(/[^\d.,]/g,"").replace(",","."),R=T===""?null:Number.parseFloat(T),B=R===null||Number.isNaN(R)?null:R;f||h(B);const U=typeof B=="number"&&Number.isFinite(B)?B:0,re=Qn(U,t.value,t.currency,s);r?.({received:U,change:re>0?re:0,isValid:U>=t.value&&U>0})},[f,o,t.value,t.currency,s,r]),N=k==null?"":String(k),j=b.isValid&&b.change>0,C=!b.isValid&&b.received>0,A=ht(b.change,s,t.currency),M=ht(t.value,s,t.currency),[L,P]=x.useState(""),$=x.useRef(null);x.useEffect(()=>{$.current&&clearTimeout($.current);const D=j?Zn(d.changeMessageTemplate,{change:A}):"",T=j?sf:0;return $.current=setTimeout(()=>P(D),T),()=>{$.current&&clearTimeout($.current)}},[j,A,d.changeMessageTemplate]);const H=`${l}-received`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",a),"data-testid":l,children:[c.jsx(g.Input,{id:H,label:d.receivedLabel,labelPlacement:"outside",type:"text",inputMode:u===0?"numeric":"decimal",pattern:u===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:D=>S(D.target.value),onFocus:y,placeholder:d.receivedPlaceholder,isDisabled:o,isInvalid:C,errorMessage:C?Zn(d.insufficientMessageTemplate,{due:M}):void 0,variant:"bordered",radius:"lg","data-testid":`${l}-received-input`}),j&&c.jsx(g.Alert,{"data-testid":`${l}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:d.changeLabel,description:Zn(d.changeMessageTemplate,{change:A}),icon:c.jsx(ae,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),c.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:L})]})},lf={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},oi=()=>{const t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`},Uo=({dueAmount:t,value:e,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:o=!1,isDisabled:a=!1,className:l,"data-testid":d="check-tender-form"})=>{const u={...lf,...s},f=e!==void 0,[m,h]=x.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??oi()}),[k,b]=x.useState(!!n?.checkNumber),y=x.useMemo(()=>f?{checkNumber:e?.checkNumber??"",bankName:e?.bankName??"",date:e?.date??oi()}:m,[f,e,m]),S=x.useCallback(P=>{f||h(P);const $=P.checkNumber.trim(),H={amount:t.value,checkNumber:$,bankName:P.bankName.trim()||void 0,date:i?void 0:P.date,isValid:$.length>0&&t.value>0};r?.(H)},[f,t.value,i,r]),N=x.useCallback(P=>$=>{a||(P==="checkNumber"&&$.length>0&&b(!0),S({...y,[P]:$}))},[y,S,a]),j=x.useCallback(()=>{a||b(!0)},[a]),C=k&&y.checkNumber.trim()==="",A=`${d}-check-number`,M=`${d}-bank-name`,L=`${d}-date`;return c.jsxs("div",{className:g.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",l),"data-testid":d,children:[c.jsx(g.Input,{id:A,label:u.checkNumberLabel,labelPlacement:"outside",type:"text",value:y.checkNumber,onChange:P=>N("checkNumber")(P.target.value),onBlur:j,placeholder:u.checkNumberPlaceholder,isRequired:!0,isInvalid:C,errorMessage:C?u.checkNumberRequiredMessage:void 0,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-check-number-input`}),!o&&c.jsx(g.Input,{id:M,label:u.bankNameLabel,labelPlacement:"outside",type:"text",value:y.bankName,onChange:P=>N("bankName")(P.target.value),placeholder:u.bankNamePlaceholder,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-bank-name-input`}),!i&&c.jsx(g.Input,{id:L,label:u.dateLabel,labelPlacement:"outside",type:"date",value:y.date,onChange:P=>N("date")(P.target.value),isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-date-input`,className:"sm:col-span-2"})]})};Uo.displayName="CheckTenderForm";const cf={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},df=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],qo=({dueAmount:t,methodOptions:e=df,value:n,defaultValue:r,onChange:s,labels:i,showReference:o=!1,isDisabled:a=!1,className:l,"data-testid":d="other-tender-form"})=>{const u={...cf,...i},f=n!==void 0,[m,h]=x.useState({method:r?.method??"",reference:r?.reference??""}),k=x.useMemo(()=>f?{method:n?.method??"",reference:n?.reference??""}:m,[f,n,m]),b=x.useCallback(A=>e.find(M=>M.value===A)?.label??"",[e]),y=x.useCallback(A=>{f||h(A);const M=b(A.method),L={amount:t.value,method:A.method,description:M,reference:A.reference.trim()||void 0,isValid:A.method!==""};s?.(L)},[f,t.value,s,b]),S=x.useCallback(A=>{if(a)return;const M=typeof A=="string"?A:Array.from(A)[0]?.toString()??"";y({...k,method:M})},[k,y,a]),N=x.useCallback(A=>{a||y({...k,reference:A})},[k,y,a]),j=`${d}-method`,C=`${d}-reference`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",l),"data-testid":d,children:[c.jsx(wt,{id:j,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:k.method?[k.method]:[],onSelectionChange:S,isDisabled:a,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:e.map(A=>c.jsx(g.SelectItem,{"data-testid":`${d}-method-option-${A.value}`,children:A.label},A.value))}),o&&c.jsx(g.Input,{id:C,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:k.reference,onChange:A=>N(A.target.value),placeholder:u.referencePlaceholder,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};qo.displayName="OtherTenderForm";const uf={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ff={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},hf={pending:"warning",recorded:"success",failed:"danger"},pf=t=>t==="pending"||t==="recorded",mf=t=>`#${t+1}`,Ko=({total:t,tenders:e,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:o,"data-testid":a="split-payment-summary"})=>{const l={...uf,...s},{collected:d,remaining:u,isComplete:f}=x.useMemo(()=>{const h=e.reduce((b,y)=>pf(y.status)?b+y.amount:b,0),k=Math.max(t.value-h,0);return{collected:h,remaining:k,isComplete:h>=t.value&&t.value>0}},[e,t.value]),m=h=>h==="pending"?l.statusPending:h==="recorded"?l.statusRecorded:l.statusFailed;return c.jsxs("div",{className:g.cn("flex flex-col gap-4",o),"data-testid":a,children:[c.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${a}-remaining-banner`,children:[c.jsx("div",{className:"text-sm text-default-600",children:f?l.completeLabel:l.remainingLabel}),c.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${a}-remaining-amount`,children:ht(f?d:u,r,t.currency)})]}),!i&&e.length>0&&c.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${a}-collected-list`,children:[c.jsx("h3",{className:"text-base font-semibold",children:l.collectedHeading}),e.map((h,k)=>c.jsx(gf,{index:k,tender:h,locale:r,currency:t.currency,removable:!!n&&h.status!=="recorded",onRemove:n?()=>n(h.id):void 0,statusLabel:m(h.status),removeAriaLabel:l.removeAriaLabel,recordedTooltip:l.removeTooltipForRecorded,dataTestId:`${a}-row-${k}`},h.id))]})]})};Ko.displayName="SplitPaymentSummary";const gf=({index:t,tender:e,locale:n,currency:r,removable:s,onRemove:i,statusLabel:o,removeAriaLabel:a,recordedTooltip:l,dataTestId:d})=>{const u=i?c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":a,"data-testid":`${d}-remove`,className:g.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return c.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":d,children:[c.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:mf(t)}),c.jsx(ae,{icon:ff[e.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),c.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:e.label}),c.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:ht(e.amount,n,r)}),c.jsx(g.Chip,{size:"sm",radius:"full",variant:"flat",color:hf[e.status],startContent:e.status==="recorded"?c.jsx(ae,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):e.status==="failed"?c.jsx(ae,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:o}),u&&(s?u:c.jsx(g.Tooltip,{content:l,placement:"left",children:c.jsx("span",{tabIndex:0,"aria-label":l,children:u})}))]})},xf=`
18
+ `);return{dom:l,text:p,slice:e}}function Bi(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return a=new K(q.from(t.state.schema.text(e.replace(/\r\n?/g,`
19
+ `))),0,0),t.someProp("transformPasted",p=>{a=p(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)a=f;else{let p=s.marks(),{schema:h}=t.state,k=yn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(k.serializeNode(h.text(y,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=kc(n),Ar&&Sc(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||rn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!yc.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Cc(Ds(a,+u[1],+u[2]),u[4]);else if(a=K.maxOpen(bc(a.content,s),!0),a.openStart||a.openEnd){let f=0,p=0;for(let h=a.content.firstChild;f<a.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=a.content.lastChild;p<a.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);a=Ds(a,f,p)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const yc=/^(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 bc(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(a=>{if(!o)return;let l=s.findWrapping(a.type),d;if(!l)return o=null;if(d=o.length&&i.length&&_i(l,i,a,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Hi(o[o.length-1],i.length));let u=zi(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return q.from(o)}return t}function zi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function _i(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=_i(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(zi(n,t,s+1))))}}function Hi(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hi(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function lr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=lr(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Ds(t,e,n){return e<t.openStart&&(t=new K(lr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(lr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ui={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 Is=null;function qi(){return Is||(Is=document.implementation.createHTMLDocument("title"))}let Un=null;function vc(t){let e=window.trustedTypes;return e?(Un||(Un=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Un.createHTML(t)):t}function kc(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Ui[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=vc(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Sc(t){let e=t.querySelectorAll(We?"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 Cc(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 a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=q.from(l.create(r[a+1],s)),i++,o++}return new K(s,i,o)}const Ve={},Me={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wi(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qt&&We&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Nr&&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,Oi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||xc(t,n)?n.preventDefault():Qe(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(Wi(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||De&&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 Sn(t){return{left:t.clientX,top:t.clientY}}function wc(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Er(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,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Ct(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 Nc(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(Ct(t,new J(n)),!0):!1}function Ac(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 a=o>i.depth?i.nodeAfter:i.node(o);if(J.isSelectable(a)){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?(Ct(t,J.create(t.state.doc,s)),!0):!1}function jc(t,e,n,r,s){return Er(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ac(t,n):Nc(t,n))}function Ec(t,e,n,r){return Er(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Tc(t,e,n,r){return Er(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Mc(t,n,r)}function Mc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ct(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),a=s.before(i);if(o.inlineContent)Ct(t,Q.create(r,a+1,a+1+o.content.size));else if(J.isSelectable(o))Ct(t,J.create(r,a));else continue;return!0}}function Tr(t){return un(t)}const Ki=De?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Tr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&wc(n,t.input.lastClick)&&!n[Ki]&&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(Sn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Oc(t,o,n,!!r)):(i=="doubleClick"?Ec:Tc)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class Oc{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[Ki],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:d}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof J&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kn&&!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(()=>jr(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(Sn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):jc(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||mt&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!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)?(Ct(this.view,ee.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)}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),Tr(t),Qe(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Ve.contextmenu=t=>Tr(t);function Wi(t,e){return t.composing?!0:mt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Dc=qt?5e3:-1;Me.compositionstart=Me.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)||We&&Fi&&Ic(t)))t.markCursor=t.state.storedMarks||n.marks(),un(t,!0),t.markCursor=null;else if(un(t,!e.selection.empty),kn&&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 a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Ji(t,Dc)};function Ic(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"}Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Ji(t,20))};function Ji(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>un(t),e))}function Lc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Fc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Fc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function un(t,e=!1){if(!(qt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Lc(t),e||t.docView&&t.docView.dirty){let n=oc(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 Pc(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 zt=Ut&&Ii<15||Nr&&ic<604;Ve.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=zt?null:n.clipboardData,o=r.content(),{dom:a,text:l}=Vi(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Pc(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Rc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $c(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?cr(t,r.value,null,s,e):cr(t,r.textContent,r.innerHTML,s,e)},50)}function cr(t,e,n,r,s){let i=Bi(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||K.empty)))return!0;if(!i)return!1;let o=Rc(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gi(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," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!qt)return;let r=zt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&cr(t,Gi(r),r.getData("text/html"),s,n)?n.preventDefault():$c(t,n)};class Vc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Bc=De?"altKey":"ctrlKey";function Zi(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Bc]}Ve.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(Sn(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 a=(o||t.state.selection).content(),{dom:l,text:d,slice:u}=Vi(t,a);(!n.dataTransfer.files.length||!We||Li>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zt?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",zt||n.dataTransfer.setData("text/plain",d),t.dragging=new Vc(u,Zi(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{zc(t,e,t.dragging)}finally{t.dragging=null}};function zc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Sn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Bi(t,Gi(e.dataTransfer),zt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Zi(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||K.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?Si(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let d=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=l.doc;if(u?l.replaceRangeWith(d,d,i.content.firstChild):l.replaceRange(d,d,i),l.doc.eq(f))return;let p=l.doc.resolve(d);if(u&&J.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new J(p));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((k,y,b,S)=>h=S),l.setSelection(Ri(t,p,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Ve.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())&&jr(t)},20))};Ve.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)};Ve.beforeinput=(t,e)=>{if(We&&qt&&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,Oi(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 Me)Ve[t]=Me[t];function _t(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 fn{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 ze(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_t(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 ze(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class Mr{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 ze(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 Mr&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}destroy(){}}class ze{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ze(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 ze(e,e,new fn(n,r))}static inline(e,n,r,s){return new ze(e,n,new Xe(r,s))}static node(e,n,r,s){return new ze(e,n,new Mr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof fn}}const vt=[],ut={};class pe{constructor(e,n){this.local=e.length?e:vt,this.children=n.length?n:vt}static create(e,n){return n.length?hn(n,e,0,ut):Ce}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 a=this.local[o];a.from<=n&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==Ce||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}mapInner(e,n,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?_c(this.children,o||[],e,n,r,s,i):o?new pe(o.sort(ft),vt):Ce}add(e,n){return n.length?this==Ce?pe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let d=l+r,u;if(u=Qi(n,a,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,d+1):s.splice(i,0,l,l+a.nodeSize,hn(u,a,d+1,ut)),i+=3}});let o=Yi(i?Xi(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new pe(o.length?this.local.concat(o).sort(ft):this.local,s||this.children)}remove(e){return e.length==0||this==Ce?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,a=r[i]+n,l=r[i+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<l&&(e[u]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(o,a+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new pe(s,r):Ce}forChild(e,n){if(this==Ce)return this;if(n.isLeaf)return pe.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof Xe){let d=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;d<u&&(s||(s=[])).push(l.copy(d,u))}}if(s){let a=new pe(s.sort(ft),vt);return r?new it([a,r]):a}return r||Ce}eq(e){if(this==e)return!0;if(!(e instanceof pe)||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 Or(this.localsInner(e))}localsInner(e){if(this==Ce)return vt;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)}}pe.empty=new pe([],[]);pe.removeOverlap=Or;const Ce=pe.empty;class it{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return it.from(r)}forChild(e,n){if(n.isLeaf)return pe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ce&&(i instanceof it?r=r.concat(i.members):r.push(i))}return it.from(r)}eq(e){if(!(e instanceof it)||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?Or(r?n:n.sort(ft)):vt}static from(e){switch(e.length){case 0:return Ce;case 1:return e[0];default:return new it(e.every(n=>n instanceof pe)?e:e.reduce((n,r)=>n.concat(r instanceof pe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function _c(t,e,n,r,s,i,o){let a=t.slice();for(let d=0,u=i;d<n.maps.length;d++){let f=0;n.maps[d].forEach((p,h,k,y)=>{let b=y-k-(h-p);for(let S=0;S<a.length;S+=3){let N=a[S+1];if(N<0||p>N+u-f)continue;let j=a[S]+u-f;h>=j?a[S+1]=p<=j?-2:-1:p>=u&&b&&(a[S]+=b,a[S+1]+=b)}f+=b}),u=n.maps[d].map(u,-1)}let l=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(a[d+1]==-2){l=!0,a[d+1]=-1;continue}let u=n.map(t[d]+i),f=u-s;if(f<0||f>=r.content.size){l=!0;continue}let p=n.map(t[d+1]+i,-1),h=p-s,{index:k,offset:y}=r.content.findIndex(f),b=r.maybeChild(k);if(b&&y==f&&y+b.nodeSize==h){let S=a[d+2].mapInner(n,b,u+1,t[d]+i+1,o);S!=Ce?(a[d]=f,a[d+1]=h,a[d+2]=S):(a[d+1]=-2,l=!0)}else l=!0}if(l){let d=Hc(a,t,e,n,s,i,o),u=hn(d,r,0,o);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let h=u.children[f];for(;p<a.length&&a[p]<h;)p+=3;a.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new pe(e.sort(ft),a)}function Yi(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 ze(s.from+e,s.to+e,s.type))}return n}function Hc(t,e,n,r,s,i,o){function a(l,d){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(r,s,d);f?n.push(f):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+d+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function Qi(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 Xi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function hn(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let d=Qi(t,a,l+n);if(d){i=!0;let u=hn(d,a,n+l+1,r);u!=Ce&&s.push(l,l+a.nodeSize,u)}});let o=Yi(i?Xi(t):t,-n).sort(ft);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new pe(o,s):Ce}function ft(t,e){return t.from-e.from||t.to-e.to}function Or(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),Ls(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),Ls(e,s,r.copy(i.from,r.to)));break}}}return e}function Ls(t,e,n){for(;e<t.length&&ft(n,t[e])>0;)e++;t.splice(e,0,n)}class le extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return le.valid(r)?new le(r):ee.near(r)}content(){return K.empty}eq(e){return e instanceof le&&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 le(e.resolve(n.pos))}getBookmark(){return new Dr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Uc(e)||!qc(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&&le.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>0?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let l=e.doc.resolve(s);if(le.valid(l))return l}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 a=e.doc.resolve(s);if(le.valid(a))return a}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;ee.jsonID("gapcursor",le);class Dr{constructor(e){this.pos=e}map(e){return new Dr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):ee.near(n)}}function eo(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Uc(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function qc(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||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Kc(){return new vn({props:{decorations:Zc,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:Jc,handleKeyDown:Wc,handleDOMEvents:{beforeinput:Gc}}})}const Wc=nc({ArrowLeft:Zt("horiz",-1),ArrowRight:Zt("horiz",1),ArrowUp:Zt("vert",-1),ArrowDown:Zt("vert",1)});function Zt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=le.findGapCursorFrom(a,e,l);return d?(s&&s(r.tr.setSelection(new le(d))),!0):!1}}function Jc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!le.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 le(r))),!0)}function Gc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof le))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 Zc(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pe.create(t.doc,[ze.widget(t.selection.head,e,{key:"gapcursor"})])}const Yc=$.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Kc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=$.callOrReturn($.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),jt={bold:{category:"mark",extension:Ga,priority:100},italic:{category:"mark",extension:el,priority:100},strike:{category:"mark",extension:rl,priority:100},underline:{category:"mark",extension:ca.Underline,priority:100},code:{category:"mark",extension:ol,priority:100},textColor:{category:"mark",extension:da.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:ua.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:fa.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:cl,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:fl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:pl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:ha.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Ml,priority:100},blockquote:{category:"node",extension:Dl,priority:100},horizontalRule:{category:"node",extension:Il,priority:100},hardBreak:{category:"node",extension:Ll,priority:100},undo:{category:"extension",extension:vs,priority:50},redo:{category:"extension",extension:vs,priority:50},textAlign:{category:"extension",extension:ma.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}},Qc=[Ul,ql,dl,ll.configure({HTMLAttributes:{}}),ml.configure({HTMLAttributes:{}}),pa.TaskItem.configure({nested:!0}),Jl,Yc];function Xc(t){const e=[],n=new Set,r=new Set;Qc.forEach(a=>{a&&(e.push(a),r.add(a.name))});const s=t.map(a=>Rt(a)),i=new Set;return s.forEach(a=>{const l=jt[a];l?.requiredExtensions&&l.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l||l.extension===null)return;const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),s.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l){console.warn(`Extension config not found for modifier: ${a}`);return}if(l.extension===null){n.add(a);return}const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),e.sort((a,l)=>{const d=Object.values(jt).find(h=>h?.extension?.name===a.name),u=Object.values(jt).find(h=>h?.extension?.name===l.name),f=d?.priority??100;return(u?.priority??100)-f})}const to={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","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","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","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","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},oe={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"}},Ge={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},se={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},ed={h1:`font-size: ${oe.fontSize["4xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h2:`font-size: ${oe.fontSize["2xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h3:`font-size: ${oe.fontSize.xl}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h4:`font-size: ${oe.fontSize.lg}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h5:`font-size: ${oe.fontSize.base}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h6:`font-size: ${oe.fontSize.sm}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,p:`min-height: ${oe.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,li:`display: list-item; margin: ${se.xs} 0;`,strong:`font-weight: ${oe.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Ge.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${oe.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${oe.fontFamily.mono};`,pre:`background: ${Ge.neutral.gray[800]}; border-radius: ${se.sm}; color: ${Ge.neutral.gray[100]}; font-family: ${oe.fontFamily.mono}; margin: ${se.lg} 0; padding: 0.75rem ${se.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ge.neutral.gray[300]}; margin: ${se.lg} 0; padding-left: ${se.md}; color: ${Ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ge.neutral.gray[200]}; margin: ${se.xl} 0;`,a:`color: ${Ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ge.palettes.warning[200]}; border-radius: ${se.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${se.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},td={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 nd(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(td)){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(ed)){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 rd=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=yr.useCurrentEditor();return c.jsx(Ua,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},sd=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=yr.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"]})]})},dr=x.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:a=!0,modifiers:l=to.full,variant:d="bordered",initialContent:u,content:f,onContentChange:p,onUpdate:h,onToolbarAction:k,isReadOnly:y=!1,isDisabled:b=!1,includeInlineStyles:S=!0,...N}=t,{zoom:j,setZoom:C}=za(),A=ts.lineHeight,M=n*A,I=s?void 0:r*A,_=x.useMemo(()=>Xc(l),[l]),{Component:P,label:B,shouldLabelBeOutside:R,getBaseProps:E,getLabelProps:F,getInputWrapperProps:V}=g.useInput({...N,variant:d,ref:e,isMultiline:!0}),U=B?c.jsx("label",{...F(),children:B}):null,X=x.useCallback(({editor:W})=>{const ge=W.getHTML(),ce=S?nd(ge):ge,xe=W.getJSON(),Le=W.getText(),te=Le.length,Oe=Le.split(/\s+/).filter(Ae=>Ae.length>0).length,ne={html:ce,json:xe,text:Le,characters:te,words:Oe};if(p?.(ne),h?.(ne),"onChange"in N&&typeof N.onChange=="function"){const Ae={target:{value:ce},currentTarget:{value:ce}};N.onChange(Ae)}},[p,h,N,S]);return c.jsxs(P,{...E(),children:[R?U:null,c.jsx("div",{...V(),className:g.cn(V().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:I?`${I+ts.toolbarHeight}px`:void 0,overflow:I?"auto":void 0},children:c.jsx(yr.EditorProvider,{editable:!y&&!b,slotBefore:a?c.jsx(rd,{modifiers:l,zoom:j,onZoomChange:C,onToolbarAction:k}):void 0,slotAfter:c.jsx(sd,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${j}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:_,content:f||u||t.defaultValue||"",onUpdate:X})})]})});dr.displayName="TipTapEditor";const no=x.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(dr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(dr,{...s,variant:r,ref:e}))});no.displayName="RichTextArea";function id(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 Fs=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],od={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},ro=({presetAmounts:t=Fs,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:o="en-US",showCustomAmount:a=!0,minCustomAmount:l=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:f=2,desktopColumns:p=3,isDisabled:h=!1,buttonVariant:k="bordered",buttonColor:y="default",inputVariant:b="bordered",size:S="md",className:N="",showCard:j=!0})=>{const C={...od,...u},A=Array.isArray(t)?t:Fs,M={2:"grid-cols-2",3:"grid-cols-3"},I={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},_=`${M[f]} ${I[p]}`,[P,B]=br(e,n,r),[R,E]=x.useState(""),[F,V]=x.useState(!1),[U,X]=x.useState(0),W=x.useCallback(te=>{if(h)return;const Oe={amount:te.amount,isCustom:!1,presetId:te.id};B(Oe),E(""),V(!1),X(ne=>ne+1),s?.(Oe)},[h,B,s]),ge=x.useCallback(te=>{if(h)return;if(E(te!==void 0?String(te):""),s){B(null);return}if(te===void 0||isNaN(te)){B(null);return}B({amount:te,isCustom:!0})},[h,B,s]),ce=x.useCallback(()=>{if(h)return;const te=R!==""?parseFloat(R):void 0;te===void 0||isNaN(te)||s?.({amount:te,isCustom:!0})},[h,R,s]),xe=x.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Le=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[C.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:C.title}),A.length>0&&c.jsx("div",{className:g.cn("grid gap-3",_),"data-testid":"donation-amounts-presets",children:A.map(te=>{const Oe=P!==null&&!P.isCustom&&P.presetId===te.id;return c.jsx(G,{color:Oe?"primary":y,variant:Oe?"solid":k,className:"w-full",onPress:()=>W(te),isDisabled:h,"data-testid":`donation-amounts-preset-${te.id}`,children:te.label||id(te.amount,o,i)},te.id)})}),a&&c.jsxs("div",{className:"flex gap-3 items-start",children:[c.jsx(g.NumberInput,{placeholder:C.customAmountPlaceholder,"aria-label":C.customAmountAriaLabel,onInput:s?()=>{B(null),V(!0)}:void 0,variant:b,radius:"full",size:S,minValue:l,maxValue:d,step:.01,formatOptions:xe,value:R!==""?parseFloat(R):void 0,onValueChange:ge,isDisabled:h,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${U}`:P?.isCustom===!1?P.presetId:"custom"),s&&c.jsx(G,{color:"primary",variant:"solid",radius:"full",size:S,className:"shrink-0",onPress:ce,isDisabled:h||!F,"data-testid":"donation-amounts-add-button",children:C.addDonationButton})]})]});return j?c.jsx(g.Card,{className:g.cn("w-full",N),"data-testid":"donation-amounts-card",children:c.jsx(g.CardBody,{children:Le})}):c.jsx("div",{className:g.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Le})};ro.displayName="DonationAmounts";const ad=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`},ld=t=>{switch(t){case"warning":return H.Clock;case"error":return H.AlertCircle;case"success":return H.CheckCircle;default:return H.Clock}},cd=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"}},so=x.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:a=!0,icon:l,position:d="fixed",autoStart:u=!0,formatTime:f=ad,className:p,...h},k)=>{const[y,b]=br(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=x.useRef(null),N=x.useRef(!1);x.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),x.useEffect(()=>{if(!u||y<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{b(M=>M<=1?(S.current&&(clearInterval(S.current),S.current=null),N.current||(N.current=!0,r?.()),0):M-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[u,y,b,r]),x.useEffect(()=>{y>0&&(N.current=!1)},[y]);const j=l||ld(s),C=cd(i),A={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:k,role:"banner","aria-live":"polite","aria-label":`${o} ${f(y)}`,"data-testid":"expire-cart-timer",className:g.cn("w-full text-white z-50",C,A[d],p),...h,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:[a&&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(y)}`,"data-testid":"expire-cart-timer-value",children:f(y)})})]})})})});so.displayName="ExpireCartTimer";function dd(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 a=r[o]&&r[o].parent,l=a&&i(a);l&&(s[o]=[a].concat(l))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const io=Object.freeze({left:0,top:0,width:16,height:16}),pn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Ir=Object.freeze({...io,...pn}),ur=Object.freeze({...Ir,body:"",hidden:!1});function ud(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 Ps(t,e){const n=ud(t,e);for(const r in ur)r in pn?r in t&&!(r in n)&&(n[r]=pn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function fd(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(a){i=Ps(r[a]||s[a],i)}return o(e),n.forEach(o),Ps(t,i)}function oo(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=dd(t);for(const s in r){const i=r[s];i&&(e(s,fd(t,s,i)),n.push(s))}return n}const hd={provider:"",aliases:{},not_found:{},...io};function qn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function ao(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!qn(t,hd))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!qn(i,ur))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]||!qn(i,ur))return null}return e}const Rs=Object.create(null);function pd(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function Nt(t,e){const n=Rs[t]||(Rs[t]=Object.create(null));return n[e]||(n[e]=pd(t,e))}function lo(t,e){return ao(e)?oo(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function md(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const co=/^[a-z0-9]+(-[a-z0-9]+)*$/,Cn=(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 a=s.pop(),l=s.pop(),d={provider:s.length>0?s[0]:r,prefix:l,name:a};return e&&!tn(d)?null:d}const i=s[0],o=i.split("-");if(o.length>1){const a={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!tn(a)?null:a}if(n&&r===""){const a={provider:r,prefix:"",name:i};return e&&!tn(a,n)?null:a}return null},tn=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Ht=!1;function uo(t){return typeof t=="boolean"&&(Ht=t),Ht}function $s(t){const e=typeof t=="string"?Cn(t,!0,Ht):t;if(e){const n=Nt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function gd(t,e){const n=Cn(t,!0,Ht);if(!n)return!1;const r=Nt(n.provider,n.prefix);return e?md(r,n.name,e):(r.missing.add(n.name),!0)}function xd(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Ht&&!e&&!t.prefix){let s=!1;return ao(t)&&(t.prefix="",oo(t,(i,o)=>{gd(i,o)&&(s=!0)})),s}const n=t.prefix;if(!tn({prefix:n,name:"a"}))return!1;const r=Nt(e,n);return!!lo(r,t)}const fo=Object.freeze({width:null,height:null}),ho=Object.freeze({...fo,...pn}),yd=/(-?[0-9.]*[0-9]+[0-9.]*)/g,bd=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Vs(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(yd);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=bd.test(i);for(;;){if(o){const a=parseFloat(i);isNaN(a)?s.push(i):s.push(Math.ceil(a*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function vd(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 kd(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Sd(t,e,n){const r=vd(t);return kd(r.defs,e+r.content+n)}const Cd=t=>t==="unset"||t==="undefined"||t==="none";function wd(t,e){const n={...Ir,...t},r={...ho,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(y=>{const b=[],S=y.hFlip,N=y.vFlip;let j=y.rotate;S?N?j+=2:(b.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),b.push("scale(-1 1)"),s.top=s.left=0):N&&(b.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),b.push("scale(1 -1)"),s.top=s.left=0);let C;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:C=s.height/2+s.top,b.unshift("rotate(90 "+C.toString()+" "+C.toString()+")");break;case 2:b.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:C=s.width/2+s.left,b.unshift("rotate(-90 "+C.toString()+" "+C.toString()+")");break}j%2===1&&(s.left!==s.top&&(C=s.left,s.left=s.top,s.top=C),s.width!==s.height&&(C=s.width,s.width=s.height,s.height=C)),b.length&&(i=Sd(i,'<g transform="'+b.join(" ")+'">',"</g>"))});const o=r.width,a=r.height,l=s.width,d=s.height;let u,f;o===null?(f=a===null?"1em":a==="auto"?d:a,u=Vs(f,l/d)):(u=o==="auto"?l:o,f=a===null?Vs(u,d/l):a==="auto"?d:a);const p={},h=(y,b)=>{Cd(b)||(p[y]=b.toString())};h("width",u),h("height",f);const k=[s.left,s.top,l,d];return p.viewBox=k.join(" "),{attributes:p,viewBox:k,body:i}}const Nd=/\sid="(\S+)"/g,Ad="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let jd=0;function Ed(t,e=Ad){const n=[];let r;for(;r=Nd.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+(jd++).toString(),a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+a+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const fr=Object.create(null);function Td(t,e){fr[t]=e}function hr(t){return fr[t]||fr[""]}function Lr(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 Fr=Object.create(null),Et=["https://api.simplesvg.com","https://api.unisvg.com"],nn=[];for(;Et.length>0;)Et.length===1||Math.random()>.5?nn.push(Et.shift()):nn.push(Et.pop());Fr[""]=Lr({resources:["https://api.iconify.design"].concat(nn)});function Md(t,e){const n=Lr(e);return n===null?!1:(Fr[t]=n,!0)}function Pr(t){return Fr[t]}const Od=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Bs=Od();function Dd(t,e){const n=Pr(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 Id(t){return t===404}const Ld=(t,e,n)=>{const r=[],s=Dd(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},a=0;return n.forEach((l,d)=>{a+=l.length+1,a>=s&&d>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},a=l.length),o.icons.push(l)}),r.push(o),r};function Fd(t){if(typeof t=="string"){const e=Pr(t);if(e)return e.path}return"/"}const Pd=(t,e,n)=>{if(!Bs){n("abort",424);return}let r=Fd(e.provider);switch(e.type){case"icons":{const i=e.prefix,a=e.icons.join(","),l=new URLSearchParams({icons:a});r+=i+".json?"+l.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;Bs(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(Id(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)})},Rd={prepare:Ld,send:Pd};function po(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function $d(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,a=o.pending.length;o.pending=o.pending.filter(l=>{if(l.prefix!==s)return!0;const d=l.name;if(t.icons[d])o.loaded.push({provider:r,prefix:s,name:d});else if(t.missing.has(d))o.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),o.pending.length!==a&&(n||po([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let Vd=0;function Bd(t,e,n){const r=Vd++,s=po.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 zd(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,a=s.name,l=n[i]||(n[i]=Object.create(null)),d=l[o]||(l[o]=Nt(i,o));let u;a in d.icons?u=e.loaded:o===""||d.missing.has(a)?u=e.missing:u=e.pending;const f={provider:i,prefix:o,name:a};u.push(f)}),e}function _d(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?Cn(s,e,n):s;i&&r.push(i)}),r}const Hd={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ud(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 M=t.resources.slice(0);for(o=[];M.length>1;){const I=Math.floor(Math.random()*M.length);o.push(M[I]),M=M.slice(0,I).concat(M.slice(I+1))}o=o.concat(M)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const a=Date.now();let l="pending",d=0,u,f=null,p=[],h=[];typeof r=="function"&&h.push(r);function k(){f&&(clearTimeout(f),f=null)}function y(){l==="pending"&&(l="aborted"),k(),p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function b(M,I){I&&(h=[]),typeof M=="function"&&h.push(M)}function S(){return{startTime:a,payload:e,status:l,queriesSent:d,queriesPending:p.length,subscribe:b,abort:y}}function N(){l="failed",h.forEach(M=>{M(void 0,u)})}function j(){p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function C(M,I,_){const P=I!=="success";switch(p=p.filter(B=>B!==M),l){case"pending":break;case"failed":if(P||!t.dataAfterTimeout)return;break;default:return}if(I==="abort"){u=_,N();return}if(P){u=_,p.length||(o.length?A():N());return}if(k(),j(),!t.random){const B=t.resources.indexOf(M.resource);B!==-1&&B!==t.index&&(t.index=B)}l="completed",h.forEach(B=>{B(_)})}function A(){if(l!=="pending")return;k();const M=o.shift();if(M===void 0){if(p.length){f=setTimeout(()=>{k(),l==="pending"&&(j(),N())},t.timeout);return}N();return}const I={status:"pending",resource:M,callback:(_,P)=>{C(I,_,P)}};p.push(I),d++,f=setTimeout(A,t.rotate),n(M,e,I.callback)}return setTimeout(A),S}function mo(t){const e={...Hd,...t};let n=[];function r(){n=n.filter(a=>a().status==="pending")}function s(a,l,d){const u=Ud(e,a,l,(f,p)=>{r(),d&&d(f,p)});return n.push(u),u}function i(a){return n.find(l=>a(l))||null}return{query:s,find:i,setIndex:a=>{e.index=a},getIndex:()=>e.index,cleanup:r}}function zs(){}const Kn=Object.create(null);function qd(t){if(!Kn[t]){const e=Pr(t);if(!e)return;const n=mo(e),r={config:e,redundancy:n};Kn[t]=r}return Kn[t]}function Kd(t,e,n){let r,s;if(typeof t=="string"){const i=hr(t);if(!i)return n(void 0,424),zs;s=i.send;const o=qd(t);o&&(r=o.redundancy)}else{const i=Lr(t);if(i){r=mo(i);const o=t.resources?t.resources[0]:"",a=hr(o);a&&(s=a.send)}}return!r||!s?(n(void 0,424),zs):r.query(e,s,n)().abort}function _s(){}function Wd(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,$d(t)}))}function Jd(t){const e=[],n=[];return t.forEach(r=>{(r.match(co)?e:n).push(r)}),{valid:e,invalid:n}}function Tt(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(!lo(t,n).length){r();return}}catch(s){console.error(s)}r(),Wd(t)}function Hs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Gd(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)){Hs(t.loadIcons(s,r,n),u=>{Tt(t,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);Hs(f,p=>{const h=p?{prefix:r,icons:{[u]:p}}:null;Tt(t,[u],h)})});return}const{valid:o,invalid:a}=Jd(s);if(a.length&&Tt(t,a,null),!o.length)return;const l=r.match(co)?hr(n):null;if(!l){Tt(t,o,null);return}l.prepare(n,r,o).forEach(u=>{Kd(n,u,f=>{Tt(t,u.icons,f)})})}))}const Zd=(t,e)=>{const n=_d(t,!0,uo()),r=zd(n);if(!r.pending.length){let l=!0;return e&&setTimeout(()=>{l&&e(r.loaded,r.missing,r.pending,_s)}),()=>{l=!1}}const s=Object.create(null),i=[];let o,a;return r.pending.forEach(l=>{const{provider:d,prefix:u}=l;if(u===a&&d===o)return;o=d,a=u,i.push(Nt(d,u));const f=s[d]||(s[d]=Object.create(null));f[u]||(f[u]=[])}),r.pending.forEach(l=>{const{provider:d,prefix:u,name:f}=l,p=Nt(d,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(f)||(h.add(f),s[d][u].push(f))}),i.forEach(l=>{const d=s[l.provider][l.prefix];d.length&&Gd(l,d)}),e?Bd(e,r,i):_s};function Yd(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in fo?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Qd=/[\s,]+/;function Xd(t,e){e.split(Qd).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function eu(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 tu(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 nu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function ru(t){return"data:image/svg+xml,"+nu(t)}function su(t){return'url("'+ru(t)+'")'}let Lt;function iu(){try{Lt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Lt=null}}function ou(t){return Lt===void 0&&iu(),Lt?Lt.createHTML(t):t}const go={...ho,inline:!1},au={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},lu={display:"inline-block"},pr={backgroundColor:"currentColor"},xo={backgroundColor:"transparent"},Us={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},qs={WebkitMask:pr,mask:pr,background:xo};for(const t in qs){const e=qs[t];for(const n in Us)e[t+n]=Us[n]}const cu={...go,inline:!0};function Ks(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const du=(t,e,n)=>{const r=e.inline?cu:go,s=Yd(r,e),i=e.mode||"svg",o={},a=e.style||{},l={...i==="svg"?au:{}};if(n){const b=Cn(n,!1,!0);if(b){const S=["iconify"],N=["provider","prefix"];for(const j of N)b[j]&&S.push("iconify--"+b[j]);l.className=S.join(" ")}}for(let b in e){const S=e[b];if(S!==void 0)switch(b){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=S;break;case"className":l[b]=(l[b]?l[b]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[b]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&Xd(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[b]=eu(S):typeof S=="number"&&(s[b]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete l["aria-hidden"];break;default:r[b]===void 0&&(l[b]=S)}}const d=wd(t,s),u=d.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){l.style={...o,...a},Object.assign(l,u);let b=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:ou(Ed(d.body,S?()=>S+"ID"+b++:"iconifyReact"))},x.createElement("svg",l)}const{body:f,width:p,height:h}=t,k=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),y=tu(f,{...u,width:p+"",height:h+""});return l.style={...o,"--svg":su(y),width:Ks(u.width),height:Ks(u.height),...lu,...k?pr:xo,...a},x.createElement("span",l)};uo(!0);Td("",Rd);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"||!xd(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;Md(n,s)||console.error(r)}catch{console.error(r)}}}}function yo(t){const[e,n]=x.useState(!!t.ssr),[r,s]=x.useState({});function i(h){if(h){const k=t.icon;if(typeof k=="object")return{name:"",data:k};const y=$s(k);if(y)return{name:k,data:y}}return{name:""}}const[o,a]=x.useState(i(!!t.ssr));function l(){const h=r.callback;h&&(h(),s({}))}function d(h){if(JSON.stringify(o)!==JSON.stringify(h))return l(),a(h),!0}function u(){var h;const k=t.icon;if(typeof k=="object"){d({name:"",data:k});return}const y=$s(k);if(d({name:k,data:y}))if(y===void 0){const b=Zd([k],u);s({callback:b})}else y&&((h=t.onLoad)===null||h===void 0||h.call(t,k))}x.useEffect(()=>(n(!0),l),[]),x.useEffect(()=>{e&&u()},[t.icon,e]);const{name:f,data:p}=o;return p?du({...Ir,...p},t,f):t.children?t.children:t.fallback?t.fallback:x.createElement("span",{})}const ae=x.forwardRef((t,e)=>yo({...t,_ref:e}));x.forwardRef((t,e)=>yo({inline:!0,...t,_ref:e}));const Wn=({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(ae,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),uu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:a=!1,imageLoading:l="eager",showMoreButtonClassName:d,labels:u})=>{const[f,p]=x.useState(!1),[h,k]=x.useState(!1),y=x.useRef(null);return x.useEffect(()=>{const b=()=>{if(y.current){const S=y.current.scrollHeight>y.current.clientHeight;k(S)}};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[o]),c.jsxs(g.Card,{className:g.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(g.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[a&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(g.Image,{removeWrapper:!0,loading:l,alt:`Event image for ${e}`,className:"w-full h-full object-cover object-center",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(g.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(Wn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(Wn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(Wn,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{ref:y,className:g.cn("text-sm text-gray-700 leading-relaxed transition-all",!f&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!f&&h&&c.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(h||f)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(G,{onPress:()=>p(!f),variant:"light",className:g.cn("text-primary",d),startContent:c.jsx(ae,{icon:f?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:f?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function bo(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 fu(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 hu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Yt=t=>typeof t=="number"&&!isNaN(t),Rr=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:a,isDisabled:l=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:h=!0,showPrice:k=!0,classNames:y={},"data-testid":b,selectedColor:S="default"})=>{const N={...hu,...o},[j,C]=x.useState(n),A=e!==void 0?e:j,M=ce=>{if(l)return;const xe=Math.max(0,A+ce);e===void 0&&C(xe),r?.(t.id,xe)},I=x.useMemo(()=>!Yt(t.totalTicketsSold)||!Yt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),_=x.useMemo(()=>I||!Yt(t.ticketsAllowed)?!1:A>=t.ticketsAllowed-(t.totalTicketsSold??0),[I,t.ticketsAllowed,t.totalTicketsSold,A]),P=bo(t.price,i,s),B=()=>a?.renderName?a.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:g.cn("text-base font-medium",y.name),children:t.name}),R=()=>k?a?.renderPrice?a.renderPrice(t.price,P,t):c.jsx("p",{"data-testid":"offer-card-price",className:g.cn("text-primary text-base mt-1",y.price),children:P}):null,E=()=>!p||!t.description?null:a?.renderDescription?a.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:g.cn("mb-4 text-sm text-gray-700 leading-relaxed",y.description),children:t.description}),F=()=>{if(!h||!Yt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ce=t.numberOfPeople===1?N.person:N.people;return a?.renderPeopleCount?a.renderPeopleCount(t.numberOfPeople,ce,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:g.cn("text-sm text-gray-600 flex items-center mt-2",y.peopleCount),children:[c.jsx(ae,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ce]})},V=()=>{const ce=A===0||l,xe=_||l;return a?.renderQuantitySelector?a.renderQuantitySelector({quantity:A,onIncrement:()=>M(1),onDecrement:()=>M(-1),isDecrementDisabled:ce,isIncrementDisabled:xe,isDisabled:l}):c.jsxs("div",{className:g.cn("flex items-center gap-2",y.quantitySelector),children:[c.jsx(G,{"data-testid":"offer-card-decrement-button",onPress:()=>M(-1),isDisabled:ce,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(ae,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:g.cn("min-w-[2rem] text-center font-medium"),children:A}),c.jsx(G,{"data-testid":"offer-card-increment-button",onPress:()=>M(1),isDisabled:xe,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(ae,{icon:"gravity-ui:plus",width:16})})]})},U=()=>a?.renderSoldOut?a.renderSoldOut(N.soldOut):c.jsx(g.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:g.cn("gap-2 px-4 h-8",y.soldOut),startContent:c.jsx(ae,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:N.soldOut})}),X=()=>a?.renderMaxReachedAlert?a.renderMaxReachedAlert(N.maxReached):c.jsx(g.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:g.cn(" text-black! gap-2 px-4 h-10",y.maxReachedAlert),startContent:c.jsx(ae,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:N.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:g.cn("h-full col-span-2",I?"opacity-50 pointer-events-none select-none":""),children:[B(),R(),c.jsxs("div",{className:g.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",I?"opacity-50 pointer-events-none select-none":""),children:[F(),E()]})]}),c.jsx("div",{className:"space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",children:I?U():V()})]}),ge=_&&!I&&c.jsx($e.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:X()});return f?c.jsxs(g.Card,{className:g.cn("w-full",y.base),"data-testid":b||`offer-card-${t.id}`,children:[c.jsx(g.CardBody,{className:g.cn("pt-1 pb-0",y.body),children:W}),c.jsx($e.AnimatePresence,{children:ge&&c.jsx(g.CardFooter,{className:g.cn("w-full mt-0 pt-0",y.footer),children:ge})})]}):c.jsxs("div",{className:g.cn("w-full",y.base),"data-testid":b||`offer-card-${t.id}`,children:[c.jsx("div",{className:g.cn("pt-1 pb-0",y.body),children:W}),c.jsx($e.AnimatePresence,{children:ge&&c.jsx("div",{className:g.cn("w-full mt-0 pt-0",y.footer),children:ge})})]})};Rr.displayName="OfferCard";const vo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const a=i();return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:a})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:g.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(ae,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:g.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:g.cn("text-lg",s.message),children:t})]});return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:o})};vo.displayName="OfferCardEmpty";const pu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ko=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...pu,...e},o=c.jsx(g.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:o})};ko.displayName="OfferCardError";const mu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},So=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=mu[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:g.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(g.Card,{"data-testid":`offer-card-skeleton-${i}`,className:g.cn("w-full",n.card),children:[c.jsx(g.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(g.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(g.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(g.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(g.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(g.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(g.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(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};So.displayName="OfferCardSkeleton";const Co={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},wo={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"}}},gu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},No=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:a,slots:l,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:p=!0,animated:h=!0,gap:k=2,classNames:y={}})=>{const[b,S]=x.useState(n),N=e!==void 0?e:b,j=x.useCallback((_,P)=>{const B={...N,[_]:Math.max(0,P)};e===void 0&&S(B),r?.(B),s?.(_,B[_])},[N,e,r,s]),C=[...t].sort((_,P)=>(_.position??0)-(P.position??0)),A=gu[k],M=g.cn("grid mx-auto pt-2",A,y.base),I=_=>c.jsx(Rr,{offer:_,quantity:N[_.id]||0,onQuantityChange:j,currency:i,locale:o,labels:a,slots:l,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:p,classNames:y.card},_.id);return h?c.jsx($e.motion.div,{"data-testid":"offer-card-list",className:M,variants:Co,initial:"hidden",animate:"show",children:c.jsx($e.AnimatePresence,{children:C.map(_=>c.jsx($e.motion.div,{"data-testid":`offer-card-list-item-${_.id}`,className:y.cardWrapper,variants:wo,exit:{opacity:0,y:-20},transition:{duration:.3},children:I(_)},_.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:M,children:C.map(I)})};No.displayName="OfferCardList";var Kt=t=>t.type==="checkbox",ct=t=>t instanceof Date,Ne=t=>t==null;const Ao=t=>typeof t=="object";var he=t=>!Ne(t)&&!Array.isArray(t)&&Ao(t)&&!ct(t),jo=t=>he(t)&&t.target?Kt(t.target)?t.target.checked:t.target.value:t,xu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,Eo=(t,e)=>t.has(xu(e)),yu=t=>{const e=t.constructor&&t.constructor.prototype;return he(e)&&e.hasOwnProperty("isPrototypeOf")},$r=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if($r&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(he(t)&&yu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=de(t[s]));return r}var wn=t=>/^\w*$/.test(t),ie=t=>t===void 0,Vr=t=>Array.isArray(t)?t.filter(Boolean):[],Br=t=>Vr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),D=(t,e,n)=>{if(!e||!he(t))return n;const r=(wn(e)?[e]:Br(e)).reduce((s,i)=>Ne(s)?s:s[i],t);return ie(r)||r===t?ie(t[e])?n:t[e]:r},je=t=>typeof t=="boolean",we=t=>typeof t=="function",re=(t,e,n)=>{let r=-1;const s=wn(e)?[e]:Br(e),i=s.length,o=i-1;for(;++r<i;){const a=s[r];let l=n;if(r!==o){const d=t[a];l=he(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;t[a]=l,t=t[a]}};const mn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Pe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},To=x.createContext(null);To.displayName="HookFormControlContext";const zr=()=>x.useContext(To);var Mo=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Pe.all&&(e._proxyFormState[o]=!r||Pe.all),n&&(n[o]=!0),t[o]}});return s};const _r=typeof window<"u"?x.useLayoutEffect:x.useEffect;function bu(t){const e=zr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,a]=x.useState(n._formState),l=x.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return _r(()=>n._subscribe({name:s,formState:l.current,exact:i,callback:d=>{!r&&a({...n._formState,...d})}}),[s,r,i]),x.useEffect(()=>{l.current.isValid&&n._setValid(!0)},[n]),x.useMemo(()=>Mo(o,n,l.current,!1),[o,n])}var Te=t=>typeof t=="string",mr=(t,e,n,r,s)=>Te(t)?(r&&e.watch.add(t),D(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),D(n,i))):(r&&(e.watchAll=!0),n),gr=t=>Ne(t)||!Ao(t);function Re(t,e,n=new WeakSet){if(gr(t)||gr(e))return Object.is(t,e);if(ct(t)&&ct(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 a=e[i];if(ct(o)&&ct(a)||he(o)&&he(a)||Array.isArray(o)&&Array.isArray(a)?!Re(o,a,n):!Object.is(o,a))return!1}}return!0}function vu(t){const e=zr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:a}=t||{},l=x.useRef(s),d=x.useRef(a),u=x.useRef(void 0),f=x.useRef(n),p=x.useRef(r);d.current=a;const[h,k]=x.useState(()=>{const C=n._getWatch(r,l.current);return d.current?d.current(C):C}),y=x.useCallback(C=>{const A=mr(r,n._names,C||n._formValues,!1,l.current);return d.current?d.current(A):A},[n._formValues,n._names,r]),b=x.useCallback(C=>{if(!i){const A=mr(r,n._names,C||n._formValues,!1,l.current);if(d.current){const M=d.current(A);Re(M,u.current)||(k(M),u.current=M)}else k(A)}},[n._formValues,n._names,i,r]);_r(()=>((f.current!==n||!Re(p.current,r))&&(f.current=n,p.current=r,b()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:C=>{b(C.values)}})),[n,o,r,b]),x.useEffect(()=>n._removeUnmounted());const S=f.current!==n,N=p.current,j=x.useMemo(()=>{if(i)return null;const C=!S&&!Re(N,r);return S||C?y():null},[i,S,r,N,y]);return j!==null?j:h}function ku(t){const e=zr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:a=!0}=t,l=Eo(s._names.array,n),d=x.useMemo(()=>D(s._formValues,n,D(s._defaultValues,n,o)),[s,n,o]),u=vu({control:s,name:n,defaultValue:d,exact:a}),f=bu({control:s,name:n,exact:a}),p=x.useRef(t),h=x.useRef(void 0),k=x.useRef(s.register(n,{...t.rules,value:u,...je(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const y=x.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!D(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!D(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!D(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!D(f.validatingFields,n)},error:{enumerable:!0,get:()=>D(f.errors,n)}}),[f,n]),b=x.useCallback(C=>k.current.onChange({target:{value:jo(C),name:n},type:mn.CHANGE}),[n]),S=x.useCallback(()=>k.current.onBlur({target:{value:D(s._formValues,n),name:n},type:mn.BLUR}),[n,s._formValues]),N=x.useCallback(C=>{const A=D(s._fields,n);A&&A._f&&C&&(A._f.ref={focus:()=>we(C.focus)&&C.focus(),select:()=>we(C.select)&&C.select(),setCustomValidity:M=>we(C.setCustomValidity)&&C.setCustomValidity(M),reportValidity:()=>we(C.reportValidity)&&C.reportValidity()})},[s._fields,n]),j=x.useMemo(()=>({name:n,value:u,...je(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:b,onBlur:S,ref:N}),[n,r,f.disabled,b,S,N,u]);return x.useEffect(()=>{const C=s._options.shouldUnregister||i,A=h.current;A&&A!==n&&!l&&s.unregister(A),s.register(n,{...p.current.rules,...je(p.current.disabled)?{disabled:p.current.disabled}:{}});const M=(I,_)=>{const P=D(s._fields,I);P&&P._f&&(P._f.mount=_)};if(M(n,!0),C){const I=de(D(s._options.defaultValues,n,p.current.defaultValue));re(s._defaultValues,n,I),ie(D(s._formValues,n))&&re(s._formValues,n,I)}return!l&&s.register(n),h.current=n,()=>{(l?C&&!s._state.action:C)?s.unregister(n):M(n,!1)}},[n,s,l,i]),x.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),x.useMemo(()=>({field:j,formState:f,fieldState:y}),[j,f,y])}const Su=x.createContext(null);Su.displayName="HookFormContext";var Cu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Ft=t=>Array.isArray(t)?t:[t],Ws=()=>{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 Oo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&he(s)&&i){const o=Oo(s,i);he(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var Se=t=>he(t)&&!Object.keys(t).length,Hr=t=>t.type==="file",gn=t=>{if(!$r)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Do=t=>t.type==="select-multiple",Ur=t=>t.type==="radio",wu=t=>Ur(t)||Kt(t),Jn=t=>gn(t)&&t.isConnected;function Nu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=ie(t)?r++:t[e[r++]];return t}function Au(t){for(const e in t)if(t.hasOwnProperty(e)&&!ie(t[e]))return!1;return!0}function ue(t,e){const n=Array.isArray(e)?e:wn(e)?[e]:Br(e),r=n.length===1?t:Nu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(he(r)&&Se(r)||Array.isArray(r)&&Au(r))&&ue(t,n.slice(0,-1)),t}var ju=t=>{for(const e in t)if(we(t[e]))return!0;return!1};function Io(t){return Array.isArray(t)||he(t)&&!ju(t)}function xr(t,e={}){for(const n in t){const r=t[n];Io(r)?(e[n]=Array.isArray(r)?[]:{},xr(r,e[n])):ie(r)||(e[n]=!0)}return e}function kt(t,e,n){n||(n=xr(e));for(const r in t){const s=t[r];if(Io(s))ie(e)||gr(n[r])?n[r]=xr(s,Array.isArray(s)?[]:{}):kt(s,Ne(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Re(s,i)}}return n}const Js={value:!1,isValid:!1},Gs={value:!0,isValid:!0};var Lo=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&&!ie(t[0].attributes.value)?ie(t[0].value)||t[0].value===""?Gs:{value:t[0].value,isValid:!0}:Gs:Js}return Js},Fo=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>ie(t)?t:e?t===""?NaN:t&&+t:n&&Te(t)?new Date(t):r?r(t):t;const Zs={isValid:!1,value:null};var Po=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Zs):Zs;function Ys(t){const e=t.ref;return Hr(e)?e.files:Ur(e)?Po(t.refs).value:Do(e)?[...e.selectedOptions].map(({value:n})=>n):Kt(e)?Lo(t.refs).value:Fo(ie(e.value)?t.ref.value:e.value,t)}var Eu=(t,e,n,r)=>{const s={};for(const i of t){const o=D(e,i);o&&re(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},xn=t=>t instanceof RegExp,Mt=t=>ie(t)?t:xn(t)?t.source:he(t)?xn(t.value)?t.value.source:t.value:t,Qs=t=>({isOnSubmit:!t||t===Pe.onSubmit,isOnBlur:t===Pe.onBlur,isOnChange:t===Pe.onChange,isOnAll:t===Pe.all,isOnTouch:t===Pe.onTouched});const Xs="AsyncFunction";var Tu=t=>!!t&&!!t.validate&&!!(we(t.validate)&&t.validate.constructor.name===Xs||he(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Xs)),Mu=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),ei=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Pt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=D(t,s);if(i){const{_f:o,...a}=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(Pt(a,e))break}else if(he(a)&&Pt(a,e))break}}};function ti(t,e,n){const r=D(t,n);if(r||wn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=D(e,i),a=D(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:n}}var Ou=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return Se(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Pe.all))},Du=(t,e,n)=>!t||!e||t===e||Ft(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),Iu=(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,Lu=(t,e)=>!Vr(D(t,e)).length&&ue(t,e),Fu=(t,e,n)=>{const r=Ft(D(t,n));return re(r,"root",e[n]),re(t,n,r),t};function ni(t,e,n="validate"){if(Te(t)||Array.isArray(t)&&t.every(Te)||je(t)&&!t)return{type:n,message:Te(t)?t:"",ref:e}}var xt=t=>he(t)&&!xn(t)?t:{value:t,message:""},ri=async(t,e,n,r,s,i)=>{const{ref:o,refs:a,required:l,maxLength:d,minLength:u,min:f,max:p,pattern:h,validate:k,name:y,valueAsNumber:b,mount:S}=t._f,N=D(n,y);if(!S||e.has(y))return{};const j=a?a[0]:o,C=E=>{s&&j.reportValidity&&(j.setCustomValidity(je(E)?"":E||""),j.reportValidity())},A={},M=Ur(o),I=Kt(o),_=M||I,P=(b||Hr(o))&&ie(o.value)&&ie(N)||gn(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length,B=Cu.bind(null,y,r,A),R=(E,F,V,U=Ue.maxLength,X=Ue.minLength)=>{const W=E?F:V;A[y]={type:E?U:X,message:W,ref:o,...B(E?U:X,W)}};if(i?!Array.isArray(N)||!N.length:l&&(!_&&(P||Ne(N))||je(N)&&!N||I&&!Lo(a).isValid||M&&!Po(a).isValid)){const{value:E,message:F}=Te(l)?{value:!!l,message:l}:xt(l);if(E&&(A[y]={type:Ue.required,message:F,ref:j,...B(Ue.required,F)},!r))return C(F),A}if(!P&&(!Ne(f)||!Ne(p))){let E,F;const V=xt(p),U=xt(f);if(!Ne(N)&&!isNaN(N)){const X=o.valueAsNumber||N&&+N;Ne(V.value)||(E=X>V.value),Ne(U.value)||(F=X<U.value)}else{const X=o.valueAsDate||new Date(N),W=xe=>new Date(new Date().toDateString()+" "+xe),ge=o.type=="time",ce=o.type=="week";Te(V.value)&&N&&(E=ge?W(N)>W(V.value):ce?N>V.value:X>new Date(V.value)),Te(U.value)&&N&&(F=ge?W(N)<W(U.value):ce?N<U.value:X<new Date(U.value))}if((E||F)&&(R(!!E,V.message,U.message,Ue.max,Ue.min),!r))return C(A[y].message),A}if((d||u)&&!P&&(Te(N)||i&&Array.isArray(N))){const E=xt(d),F=xt(u),V=!Ne(E.value)&&N.length>+E.value,U=!Ne(F.value)&&N.length<+F.value;if((V||U)&&(R(V,E.message,F.message),!r))return C(A[y].message),A}if(h&&!P&&Te(N)){const{value:E,message:F}=xt(h);if(xn(E)&&!N.match(E)&&(A[y]={type:Ue.pattern,message:F,ref:o,...B(Ue.pattern,F)},!r))return C(F),A}if(k){if(we(k)){const E=await k(N,n),F=ni(E,j);if(F&&(A[y]={...F,...B(Ue.validate,F.message)},!r))return C(F.message),A}else if(he(k)){let E={};for(const F in k){if(!Se(E)&&!r)break;const V=ni(await k[F](N,n),j,F);V&&(E={...V,...B(F,V.message)},C(V.message),r&&(A[y]=E))}if(!Se(E)&&(A[y]={ref:j,...E},!r))return A}}return C(!0),A};const Pu={mode:Pe.onSubmit,reValidateMode:Pe.onChange,shouldFocusError:!0};function Ru(t={}){let e={...Pu,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:we(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=he(e.defaultValues)||he(e.values)?de(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:de(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let p={...f};const h={array:Ws(),state:Ws()},k=e.criteriaMode===Pe.all,y=m=>v=>{clearTimeout(d),d=setTimeout(m,v)},b=async m=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||m)){let v;e.resolver?(v=Se((await _()).errors),S()):v=await B(r,!0),v!==n.isValid&&h.state.next({isValid:v})}},S=(m,v)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((m||Array.from(a.mount)).forEach(w=>{w&&(v?re(n.validatingFields,w,v):ue(n.validatingFields,w))}),h.state.next({validatingFields:n.validatingFields,isValidating:!Se(n.validatingFields)}))},N=(m,v=[],w,L,O=!0,T=!0)=>{if(L&&w&&!e.disabled){if(o.action=!0,T&&Array.isArray(D(r,m))){const z=w(D(r,m),L.argA,L.argB);O&&re(r,m,z)}if(T&&Array.isArray(D(n.errors,m))){const z=w(D(n.errors,m),L.argA,L.argB);O&&re(n.errors,m,z),Lu(n.errors,m)}if((f.touchedFields||p.touchedFields)&&T&&Array.isArray(D(n.touchedFields,m))){const z=w(D(n.touchedFields,m),L.argA,L.argB);O&&re(n.touchedFields,m,z)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=kt(s,i)),h.state.next({name:m,isDirty:E(m,v),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else re(i,m,v)},j=(m,v)=>{re(n.errors,m,v),h.state.next({errors:n.errors})},C=m=>{n.errors=m,h.state.next({errors:n.errors,isValid:!1})},A=(m,v,w,L)=>{const O=D(r,m);if(O){const T=D(i,m,ie(w)?D(s,m):w);ie(T)||L&&L.defaultChecked||v?re(i,m,v?T:Ys(O._f)):U(m,T),o.mount&&!o.action&&b()}},M=(m,v,w,L,O)=>{let T=!1,z=!1;const Z={name:m};if(!e.disabled){if(!w||L){(f.isDirty||p.isDirty)&&(z=n.isDirty,n.isDirty=Z.isDirty=E(),T=z!==Z.isDirty);const Y=Re(D(s,m),v);z=!!D(n.dirtyFields,m),Y?ue(n.dirtyFields,m):re(n.dirtyFields,m,!0),Z.dirtyFields=n.dirtyFields,T=T||(f.dirtyFields||p.dirtyFields)&&z!==!Y}if(w){const Y=D(n.touchedFields,m);Y||(re(n.touchedFields,m,w),Z.touchedFields=n.touchedFields,T=T||(f.touchedFields||p.touchedFields)&&Y!==w)}T&&O&&h.state.next(Z)}return T?Z:{}},I=(m,v,w,L)=>{const O=D(n.errors,m),T=(f.isValid||p.isValid)&&je(v)&&n.isValid!==v;if(e.delayError&&w?(l=y(()=>j(m,w)),l(e.delayError)):(clearTimeout(d),l=null,w?re(n.errors,m,w):ue(n.errors,m)),(w?!Re(O,w):O)||!Se(L)||T){const z={...L,...T&&je(v)?{isValid:v}:{},errors:n.errors,name:m};n={...n,...z},h.state.next(z)}},_=async m=>(S(m,!0),await e.resolver(i,e.context,Eu(m||a.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),P=async m=>{const{errors:v}=await _(m);if(S(m),m)for(const w of m){const L=D(v,w);L?re(n.errors,w,L):ue(n.errors,w)}else n.errors=v;return v},B=async(m,v,w={valid:!0})=>{for(const L in m){const O=m[L];if(O){const{_f:T,...z}=O;if(T){const Z=a.array.has(T.name),Y=O._f&&Tu(O._f);Y&&f.validatingFields&&S([T.name],!0);const ke=await ri(O,a.disabled,i,k,e.shouldUseNativeValidation&&!v,Z);if(Y&&f.validatingFields&&S([T.name]),ke[T.name]&&(w.valid=!1,v||t.shouldUseNativeValidation))break;!v&&(D(ke,T.name)?Z?Fu(n.errors,ke,T.name):re(n.errors,T.name,ke[T.name]):ue(n.errors,T.name))}!Se(z)&&await B(z,v,w)}}return w.valid},R=()=>{for(const m of a.unMount){const v=D(r,m);v&&(v._f.refs?v._f.refs.every(w=>!Jn(w)):!Jn(v._f.ref))&&An(m)}a.unMount=new Set},E=(m,v)=>!e.disabled&&(m&&v&&re(i,m,v),!Re(Le(),s)),F=(m,v,w)=>mr(m,a,{...o.mount?i:ie(v)?s:Te(m)?{[m]:v}:v},w,v),V=m=>Vr(D(o.mount?i:s,m,e.shouldUnregister?D(s,m,[]):[])),U=(m,v,w={})=>{const L=D(r,m);let O=v;if(L){const T=L._f;T&&(!T.disabled&&re(i,m,Fo(v,T)),O=gn(T.ref)&&Ne(v)?"":v,Do(T.ref)?[...T.ref.options].forEach(z=>z.selected=O.includes(z.value)):T.refs?Kt(T.ref)?T.refs.forEach(z=>{(!z.defaultChecked||!z.disabled)&&(Array.isArray(O)?z.checked=!!O.find(Z=>Z===z.value):z.checked=O===z.value||!!O)}):T.refs.forEach(z=>z.checked=z.value===O):Hr(T.ref)?T.ref.value="":(T.ref.value=O,T.ref.type||h.state.next({name:m,values:de(i)})))}(w.shouldDirty||w.shouldTouch)&&M(m,O,w.shouldTouch,w.shouldDirty,!0),w.shouldValidate&&xe(m)},X=(m,v,w)=>{for(const L in v){if(!v.hasOwnProperty(L))return;const O=v[L],T=m+"."+L,z=D(r,T);(a.array.has(m)||he(O)||z&&!z._f)&&!ct(O)?X(T,O,w):U(T,O,w)}},W=(m,v,w={})=>{const L=D(r,m),O=a.array.has(m),T=de(v);re(i,m,T),O?(h.array.next({name:m,values:de(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&w.shouldDirty&&h.state.next({name:m,dirtyFields:kt(s,i),isDirty:E(m,T)})):L&&!L._f&&!Ne(T)?X(m,T,w):U(m,T,w),ei(m,a)?h.state.next({...n,name:m,values:de(i)}):h.state.next({name:o.mount?m:void 0,values:de(i)})},ge=async m=>{o.mount=!0;const v=m.target;let w=v.name,L=!0;const O=D(r,w),T=Y=>{L=Number.isNaN(Y)||ct(Y)&&isNaN(Y.getTime())||Re(Y,D(i,w,Y))},z=Qs(e.mode),Z=Qs(e.reValidateMode);if(O){let Y,ke;const nt=v.type?Ys(O._f):jo(m),Je=m.type===mn.BLUR||m.type===mn.FOCUS_OUT,oa=!Mu(O._f)&&!e.resolver&&!D(n.errors,w)&&!O._f.deps||Iu(Je,D(n.touchedFields,w),n.isSubmitted,Z,z),Tn=ei(w,a,Je);re(i,w,nt),Je?(!v||!v.readOnly)&&(O._f.onBlur&&O._f.onBlur(m),l&&l(0)):O._f.onChange&&O._f.onChange(m);const Mn=M(w,nt,Je),aa=!Se(Mn)||Tn;if(!Je&&h.state.next({name:w,type:m.type,values:de(i)}),oa)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Je&&b():Je||b()),aa&&h.state.next({name:w,...Tn?{}:Mn});if(!Je&&Tn&&h.state.next({...n}),e.resolver){const{errors:Xr}=await _([w]);if(S([w]),T(nt),L){const la=ti(n.errors,r,w),es=ti(Xr,r,la.name||w);Y=es.error,w=es.name,ke=Se(Xr)}}else S([w],!0),Y=(await ri(O,a.disabled,i,k,e.shouldUseNativeValidation))[w],S([w]),T(nt),L&&(Y?ke=!1:(f.isValid||p.isValid)&&(ke=await B(r,!0)));L&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&xe(O._f.deps),I(w,ke,Y,Mn))}},ce=(m,v)=>{if(D(n.errors,v)&&m.focus)return m.focus(),1},xe=async(m,v={})=>{let w,L;const O=Ft(m);if(e.resolver){const T=await P(ie(m)?m:O);w=Se(T),L=m?!O.some(z=>D(T,z)):w}else m?(L=(await Promise.all(O.map(async T=>{const z=D(r,T);return await B(z&&z._f?{[T]:z}:z)}))).every(Boolean),!(!L&&!n.isValid)&&b()):L=w=await B(r);return h.state.next({...!Te(m)||(f.isValid||p.isValid)&&w!==n.isValid?{}:{name:m},...e.resolver||!m?{isValid:w}:{},errors:n.errors}),v.shouldFocus&&!L&&Pt(r,ce,m?O:a.mount),L},Le=(m,v)=>{let w={...o.mount?i:s};return v&&(w=Oo(v.dirtyFields?n.dirtyFields:n.touchedFields,w)),ie(m)?w:Te(m)?D(w,m):m.map(L=>D(w,L))},te=(m,v)=>({invalid:!!D((v||n).errors,m),isDirty:!!D((v||n).dirtyFields,m),error:D((v||n).errors,m),isValidating:!!D(n.validatingFields,m),isTouched:!!D((v||n).touchedFields,m)}),Oe=m=>{m&&Ft(m).forEach(v=>ue(n.errors,v)),h.state.next({errors:m?n.errors:{}})},ne=(m,v,w)=>{const L=(D(r,m,{_f:{}})._f||{}).ref,O=D(n.errors,m)||{},{ref:T,message:z,type:Z,...Y}=O;re(n.errors,m,{...Y,...v,ref:L}),h.state.next({name:m,errors:n.errors,isValid:!1}),w&&w.shouldFocus&&L&&L.focus&&L.focus()},Ae=(m,v)=>we(m)?h.state.subscribe({next:w=>"values"in w&&m(F(void 0,v),w)}):F(m,v,!0),At=m=>h.state.subscribe({next:v=>{Du(m.name,v.name,m.exact)&&Ou(v,m.formState||f,ia,m.reRenderRoot)&&m.callback({values:{...i},...n,...v,defaultValues:s})}}).unsubscribe,Nn=m=>(o.mount=!0,p={...p,...m.formState},At({...m,formState:{...u,...m.formState}})),An=(m,v={})=>{for(const w of m?Ft(m):a.mount)a.mount.delete(w),a.array.delete(w),v.keepValue||(ue(r,w),ue(i,w)),!v.keepError&&ue(n.errors,w),!v.keepDirty&&ue(n.dirtyFields,w),!v.keepTouched&&ue(n.touchedFields,w),!v.keepIsValidating&&ue(n.validatingFields,w),!e.shouldUnregister&&!v.keepDefaultValue&&ue(s,w);h.state.next({values:de(i)}),h.state.next({...n,...v.keepDirty?{isDirty:E()}:{}}),!v.keepIsValid&&b()},Jr=({disabled:m,name:v})=>{if(je(m)&&o.mount||m||a.disabled.has(v)){const O=a.disabled.has(v)!==!!m;m?a.disabled.add(v):a.disabled.delete(v),O&&o.mount&&!o.action&&b()}},jn=(m,v={})=>{let w=D(r,m);const L=je(v.disabled)||je(e.disabled);return re(r,m,{...w||{},_f:{...w&&w._f?w._f:{ref:{name:m}},name:m,mount:!0,...v}}),a.mount.add(m),w?Jr({disabled:je(v.disabled)?v.disabled:e.disabled,name:m}):A(m,!0,v.value),{...L?{disabled:v.disabled||e.disabled}:{},...e.progressive?{required:!!v.required,min:Mt(v.min),max:Mt(v.max),minLength:Mt(v.minLength),maxLength:Mt(v.maxLength),pattern:Mt(v.pattern)}:{},name:m,onChange:ge,onBlur:ge,ref:O=>{if(O){jn(m,v),w=D(r,m);const T=ie(O.value)&&O.querySelectorAll&&O.querySelectorAll("input,select,textarea")[0]||O,z=wu(T),Z=w._f.refs||[];if(z?Z.find(Y=>Y===T):T===w._f.ref)return;re(r,m,{_f:{...w._f,...z?{refs:[...Z.filter(Jn),T,...Array.isArray(D(s,m))?[{}]:[]],ref:{type:T.type,name:m}}:{ref:T}}}),A(m,!1,void 0,T)}else w=D(r,m,{}),w._f&&(w._f.mount=!1),(e.shouldUnregister||v.shouldUnregister)&&!(Eo(a.array,m)&&o.action)&&a.unMount.add(m)}}},En=()=>e.shouldFocusError&&Pt(r,ce,a.mount),na=m=>{je(m)&&(h.state.next({disabled:m}),Pt(r,(v,w)=>{const L=D(r,w);L&&(v.disabled=L._f.disabled||m,Array.isArray(L._f.refs)&&L._f.refs.forEach(O=>{O.disabled=L._f.disabled||m}))},0,!1))},Gr=(m,v)=>async w=>{let L;w&&(w.preventDefault&&w.preventDefault(),w.persist&&w.persist());let O=de(i);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:T,values:z}=await _();S(),n.errors=T,O=de(z)}else await B(r);if(a.disabled.size)for(const T of a.disabled)ue(O,T);if(ue(n.errors,"root"),Se(n.errors)){h.state.next({errors:{}});try{await m(O,w)}catch(T){L=T}}else v&&await v({...n.errors},w),En(),setTimeout(En);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(n.errors)&&!L,submitCount:n.submitCount+1,errors:n.errors}),L)throw L},ra=(m,v={})=>{D(r,m)&&(ie(v.defaultValue)?W(m,de(D(s,m))):(W(m,v.defaultValue),re(s,m,de(v.defaultValue))),v.keepTouched||ue(n.touchedFields,m),v.keepDirty||(ue(n.dirtyFields,m),n.isDirty=v.defaultValue?E(m,de(D(s,m))):E()),v.keepError||(ue(n.errors,m),f.isValid&&b()),h.state.next({...n}))},Zr=(m,v={})=>{const w=m?de(m):s,L=de(w),O=Se(m),T=O?s:L;if(v.keepDefaultValues||(s=w),!v.keepValues){if(v.keepDirtyValues){const z=new Set([...a.mount,...Object.keys(kt(s,i))]);for(const Z of Array.from(z)){const Y=D(n.dirtyFields,Z),ke=D(i,Z),nt=D(T,Z);Y&&!ie(ke)?re(T,Z,ke):!Y&&!ie(nt)&&W(Z,nt)}}else{if($r&&ie(m))for(const z of a.mount){const Z=D(r,z);if(Z&&Z._f){const Y=Array.isArray(Z._f.refs)?Z._f.refs[0]:Z._f.ref;if(gn(Y)){const ke=Y.closest("form");if(ke){ke.reset();break}}}}if(v.keepFieldsRef)for(const z of a.mount)W(z,D(T,z));else r={}}i=e.shouldUnregister?v.keepDefaultValues?de(s):{}:de(T),h.array.next({values:{...T}}),h.state.next({values:{...T}})}a={mount:v.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!v.keepIsValid||!!v.keepDirtyValues||!e.shouldUnregister&&!Se(T),o.watch=!!e.shouldUnregister,o.keepIsValid=!!v.keepIsValid,o.action=!1,v.keepErrors||(n.errors={}),h.state.next({submitCount:v.keepSubmitCount?n.submitCount:0,isDirty:O?!1:v.keepDirty?n.isDirty:!!(v.keepDefaultValues&&!Re(m,s)),isSubmitted:v.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:O?{}:v.keepDirtyValues?v.keepDefaultValues&&i?kt(s,i):n.dirtyFields:v.keepDefaultValues&&m?kt(s,m):v.keepDirty?n.dirtyFields:{},touchedFields:v.keepTouched?n.touchedFields:{},errors:v.keepErrors?n.errors:{},isSubmitSuccessful:v.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Yr=(m,v)=>Zr(we(m)?m(i):m,{...e.resetOptions,...v}),sa=(m,v={})=>{const w=D(r,m),L=w&&w._f;if(L){const O=L.refs?L.refs[0]:L.ref;O.focus&&setTimeout(()=>{O.focus(),v.shouldSelect&&we(O.select)&&O.select()})}},ia=m=>{n={...n,...m}},Qr={control:{register:jn,unregister:An,getFieldState:te,handleSubmit:Gr,setError:ne,_subscribe:At,_runSchema:_,_updateIsValidating:S,_focusError:En,_getWatch:F,_getDirty:E,_setValid:b,_setFieldArray:N,_setDisabledField:Jr,_setErrors:C,_getFieldArray:V,_reset:Zr,_resetDefaultValues:()=>we(e.defaultValues)&&e.defaultValues().then(m=>{Yr(m,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:R,_disableForm:na,_subjects:h,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(m){o=m},get _defaultValues(){return s},get _names(){return a},set _names(m){a=m},get _formState(){return n},get _options(){return e},set _options(m){e={...e,...m}}},subscribe:Nn,trigger:xe,register:jn,handleSubmit:Gr,watch:Ae,setValue:W,getValues:Le,reset:Yr,resetField:ra,clearErrors:Oe,unregister:An,setError:ne,setFocus:sa,getFieldState:te};return{...Qr,formControl:Qr}}function $u(t={}){const e=x.useRef(void 0),n=x.useRef(void 0),[r,s]=x.useState({isDirty:!1,isValidating:!1,isLoading:we(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:we(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!we(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...a}=Ru(t);e.current={...a,formState:r}}const i=e.current.control;return i._options=t,_r(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),i._formState.isReady=!0,o},[i]),x.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),x.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),x.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),x.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),x.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),x.useEffect(()=>{var o;t.values&&!Re(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(a=>({...a}))):i._resetDefaultValues()},[i,t.values]),x.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=x.useMemo(()=>Mo(r,i),[i,r]),e.current}function Vu(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function Bu(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 zu(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 _u(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 Hu(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 qr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}qr();const Uu={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:"$"},Gn=()=>({id:qr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ro=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:a,onTaxDeductibleChange:l,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:h,classNames:k={},"data-testid":y,control:b,name:S,rules:N})=>{const j={...Uu,...h},C=b!==void 0&&S!==void 0,A=$u({defaultValues:{_internal:e||Gn()}}),M=ku({control:C?b:A.control,name:C?S:"_internal",rules:C?N:void 0}),[I,_]=x.useState(e||Gn()),P=C?M.field.value??Gn():t??I,B=C&&!!M.fieldState?.error,R=C&&(M.fieldState?.isTouched??!1),E=B||R,F=E&&(!P.amount||P.amount<=0),V=E&&!P.glAccount,[U,X]=x.useState(P.glAccount?.name||""),W=x.useCallback(ne=>{const Ae={...P,...ne};C&&M.field.onChange(Ae),!C&&t===void 0&&_(Ae),i?.(Ae)},[P,t,i,C,M]),ge=x.useCallback(ne=>{const Ae=ne||0;W({amount:Ae}),o?.(Ae)},[W,o]),ce=x.useCallback(ne=>{X(ne),s?.(ne)},[s]),xe=x.useCallback(ne=>{if(ne===null){W({glAccount:null}),a?.(null);return}const At=n.find(Nn=>String(Nn.id)===String(ne))||null;W({glAccount:At}),a?.(At)},[n,W,a]),Le=x.useCallback(()=>{X(""),W({glAccount:null}),a?.(null)},[W,a]),te=x.useCallback(ne=>{W({isTaxDeductible:ne}),l?.(ne)},[W,l]),Oe=x.useCallback(()=>{d?.()},[d]);return c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":y||"revenue-distribution-card",className:g.cn(k.base),children:c.jsxs(g.CardBody,{className:g.cn("flex flex-row flex-nowrap items-start gap-4",k.body),children:[c.jsx("div",{className:g.cn("shrink-0",k.amountContainer),children:c.jsx(g.NumberInput,{"data-testid":`${y||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(g.Tooltip,{content:j.amountTooltip,children:c.jsx(ae,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:P.amount||void 0,onValueChange:ge,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:k.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:g.cn("grow",k.glAccountContainer),children:c.jsx(g.Autocomplete,{"data-testid":`${y||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.glAccount,c.jsx(g.Tooltip,{content:j.glAccountTooltip,children:c.jsx(ae,{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:P.glAccount?.name??U,selectedKey:P.glAccount?.id??null,isDisabled:p,isInvalid:V,errorMessage:V?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:ce,onSelectionChange:xe,onClear:Le,className:k.glAccountInput,children:ne=>c.jsx(g.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:g.cn("shrink-0 pt-6 flex items-center",k.taxDeductibleContainer),children:c.jsx(g.Checkbox,{radius:"full","data-testid":`${y||"revenue-distribution-card"}-tax-deductible`,isSelected:P.isTaxDeductible,onValueChange:te,isDisabled:p||!f,className:k.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:g.cn("shrink-0 pt-6",k.deleteContainer),children:c.jsx(G,{"data-testid":`${y||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:Oe,startContent:c.jsx(ae,{icon:"solar:trash-bin-trash-linear",width:16}),className:g.cn("text-danger",k.deleteButton),children:j.deleteButton})})]})})};Ro.displayName="RevenueDistributionCard";const $o=({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:g.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(ae,{icon:e,width:n,className:g.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:g.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:o})};$o.displayName="RevenueDistributionEmpty";const qu={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Vo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...qu,...e},o=c.jsx(g.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:o})};Vo.displayName="RevenueDistributionError";const Bo=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:g.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(g.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.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(g.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(g.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(g.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(g.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(g.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Bo.displayName="RevenueDistributionSkeleton";const Ku={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Wu=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:a=null,allowReselect:l=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const p=Array.isArray(t)?t:[],[h,k]=x.useState(a),[y,b]=x.useState(o),S={...Ku,...s};x.useEffect(()=>{k(a)},[a]);const N=C=>{if(C===h){l&&u?.(C);return}k(C),u?.(C)},j=C=>{b(C),d?.(C)};return c.jsxs("div",{className:g.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",f),"data-testid":"membership-select-cards",children:[c.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),c.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:S.title}),i&&c.jsx(_o,{title:S.renewalTitle,description:S.renewalDescription,value:y,onValueChange:j}),c.jsx("div",{className:g.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":g.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(C=>c.jsx(zo,{itemKey:C.id,name:C.name,type:C.type,price:C.price,locale:e,currency:n,isSelected:h===C.id,onSelect:N},C.id))})]})},zo=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:o=!1,onSelect:a,className:l=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return c.jsx(g.Card,{shadow:"none",isPressable:!!a,onPress:()=>a?.(t),className:g.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",l),"data-testid":"item-card","data-selected":o,children:c.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[c.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[c.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:e}),n&&c.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:c.jsx("p",{className:"text-center",children:n})})]}),c.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:d})]})})},_o=({title:t,value:e,description:n,onValueChange:r,className:s=""})=>{const i=x.useId();return c.jsxs("div",{className:g.cn("w-full flex flex-row items-center",t||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[c.jsxs("div",{className:"flex flex-col items-start",children:[t&&c.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:t}),n&&c.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),c.jsx(g.Switch,{id:i,isSelected:e,onValueChange:r,"data-testid":"toggle-switch"})]})},Ju={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},Gu=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Ho=t=>Object.values(t).reduce((e,n)=>e+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,o)=>i+o.selectedQuantity,0),0),0),Zu=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,o)=>i+o.max,0),0),0),Kr=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),si=(t,e,n)=>{const r={};let s=n?e??Zu(t):0;for(const{exhibition:i,dateGroup:o,ticket:a}of Kr(t)){r[i.id]??={},r[i.id][o.id]??={};const l=n?Math.min(a.max,s):0;r[i.id][o.id][a.id]={id:a.id,selectedQuantity:l,originalPrice:a.originalPrice,discountedPrice:a.price},s-=l}return r},ii=(t,e,n)=>`${t}::${e}::${n}`,Yu=(t,e,n)=>{const r=Ho(e);for(const{exhibition:s,dateGroup:i,ticket:o}of Kr(t)){const a=e[s.id]?.[i.id]?.[o.id]?.selectedQuantity??0,l=n===void 0?o.max:Math.min(o.max,n-(r-a));if(l>0&&a<l)return!1}return!0},Qu=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[o,a]=x.useState(()=>String(i)),[l,d]=x.useState(!1),u=l?o:String(i),f=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=e||r?.(i-1)},h=C=>{if(s)return;a(C.target.value);const A=parseInt(C.target.value,10);isNaN(A)||r?.(Math.max(e,Math.min(n,A)))},k=C=>{const A=parseInt(C.target.value,10);if(d(!1),isNaN(A)){r?.(e);return}const M=Math.max(e,Math.min(n,A));M!==A?r?.(M):a(String(M))},y=i<=e,b=i>=n,S="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",j="bg-primary/40 cursor-not-allowed";return c.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[c.jsx("button",{type:"button",onClick:p,disabled:s||y,className:g.cn(S,s||y?j:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),c.jsx("input",{type:"number",value:u,onChange:h,onFocus:()=>d(!0),onBlur:k,disabled:s,min:e,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),c.jsx("button",{type:"button",onClick:f,disabled:s||b,className:g.cn(S,s||b?j:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Xu=({label:t,checked:e=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!e)};return c.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":e,"data-testid":"checkbox-button","data-checked":e,className:g.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[c.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),c.jsx("span",{className:g.cn("block w-3.5 h-3.5 rounded-sm relative",e?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:e&&c.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),c.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:t})]})},ef=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:o})=>{const a=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},l=i?.locale??"en-US",d=i?.currency??"USD",u=Gu(l,d);return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[c.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[c.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[c.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[t.name,typeof t.purchasedQuantity=="number"&&t.purchasedQuantity>1?c.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${t.purchasedQuantity}`}):null]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(t.originalPrice)}),c.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(t.price)})]})]}),t.membershipName?c.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:t.membershipName,children:c.jsx("p",{className:"max-w-full truncate text-center",children:t.membershipName})}):null,c.jsx("div",{className:"text-sm text-zinc-500",children:c.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[o.ticketsAllowedToRedeem," ",t.max]})})]}),c.jsx(Qu,{initialQuantity:e,minQuantity:0,maxQuantity:a(),onChange:n})]}),t.membershipAlert?c.jsx(g.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:c.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:t.membershipAlert})}):null]})},tf=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l})=>c.jsxs("div",{className:g.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[c.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:e.date}),e.tickets.map((d,u)=>c.jsxs("div",{children:[c.jsx(ef,{item:d,quantity:s(t,e.id,d.id),onChange:f=>r(t,e.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l}),u<e.tickets.length-1?c.jsx(g.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),nf=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a,initialExpanded:l=!1})=>{const[d,u]=x.useState(l),f=e.dates.reduce((h,k)=>h+k.tickets.reduce((y,b)=>y+r(e.id,k.id,b.id),0),0),p=e.dates.some(h=>h.tickets.length>0);return c.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[c.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${e.id}`,"data-testid":"upgrade-ticket-header-button",children:c.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[c.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:t}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[f," ",a.ticketsSelectedToRedeem]}),c.jsx("span",{className:g.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:c.jsx(ae,{icon:"mdi:chevron-down"})})]})]})}),c.jsx("div",{id:`upgrade-items-${e.id}`,className:g.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&c.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?e.dates.map((h,k)=>c.jsx(tf,{exhibitionId:e.id,dateGroup:h,isLast:k===e.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a},h.id)):c.jsx("div",{className:"px-5 py-10 text-center",children:c.jsx("p",{className:"m-0 text-zinc-500 italic",children:a.noUpgradeTicketsAvailable})})})})]})},rf=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:o})=>{const a=x.useMemo(()=>s??[],[s]),l={...Ju,...n},[d,u]=x.useState(()=>si(a,e,!0)),f=x.useRef(!1),p=x.useMemo(()=>{const N=Kr(a).map(({exhibition:j,dateGroup:C,ticket:A})=>[ii(j.id,C.id,A.id),A]);return new Map(N)},[a]),h=Yu(a,d,e),k=(N,j,C)=>d[N]?.[j]?.[C]?.selectedQuantity??0,y=()=>Ho(d),b=(N,j,C,A)=>{const M=k(N,j,C),I=y()-M;if(e!==void 0&&I+A>e)return;const _=p.get(ii(N,j,C));if(!_)return;const P={...d,[N]:{...d[N],[j]:{...d[N]?.[j],[C]:{id:C,selectedQuantity:A,originalPrice:_.originalPrice,discountedPrice:_.price}}}};u(P),o?.(P)},S=N=>{const j=si(a,e,N);u(j),o?.(j)};return x.useEffect(()=>{!f.current&&h&&(o?.(d),f.current=!0)},[h,d,o]),c.jsxs("div",{className:g.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[c.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[c.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:l.ticketSelectionTitle}),c.jsx(Xu,{label:l.selectAllButtonLabel,checked:h,onChange:S})]}),a.map(N=>c.jsx(nf,{title:N.exhibitionName,exhibition:N,onQuantityChange:b,getTicketQuantity:k,getTotalSelectedTickets:y,userMaxLimit:e,settings:r,labels:l,initialExpanded:t},N.id))]})},sf=350,of={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},Zn=(t,e)=>Object.entries(e).reduce((n,[r,s])=>n.replace(`{${r}}`,s),t),af=({dueAmount:t,received:e,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:o=!1,autoFocus:a=!1,className:l,"data-testid":d="cash-tender-form"})=>{const u={...of,...i},f=vr(t.currency,s),p=e!==void 0,[h,k]=x.useState(n??null),y=p?e:h,b=x.useMemo(()=>{const E=typeof y=="number"&&Number.isFinite(y)?y:0,F=Qn(E,t.value,t.currency,s);return{received:E,change:F>0?F:0,isValid:E>=t.value&&E>0}},[y,t.value,t.currency,s]),S=x.useCallback(E=>{const F=E.currentTarget;requestAnimationFrame(()=>{F.isConnected&&F.select()})},[]),N=x.useCallback(E=>{if(o)return;const F=E.replace(/[^\d.,]/g,"").replace(",","."),V=F===""?null:Number.parseFloat(F),U=V===null||Number.isNaN(V)?null:V;p||k(U);const X=typeof U=="number"&&Number.isFinite(U)?U:0,W=Qn(X,t.value,t.currency,s);r?.({received:X,change:W>0?W:0,isValid:X>=t.value&&X>0})},[p,o,t.value,t.currency,s,r]),j=y==null?"":String(y),C=b.isValid&&b.change>0,A=!b.isValid&&b.received>0,M=ht(b.change,s,t.currency),I=ht(t.value,s,t.currency),[_,P]=x.useState(""),B=x.useRef(null);x.useEffect(()=>{B.current&&clearTimeout(B.current);const E=C?Zn(u.changeMessageTemplate,{change:M}):"",F=C?sf:0;return B.current=setTimeout(()=>P(E),F),()=>{B.current&&clearTimeout(B.current)}},[C,M,u.changeMessageTemplate]);const R=`${d}-received`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",l),"data-testid":d,children:[c.jsx(g.Input,{id:R,label:u.receivedLabel,labelPlacement:"outside",type:"text",inputMode:f===0?"numeric":"decimal",pattern:f===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:j,onChange:E=>N(E.target.value),onFocus:S,placeholder:u.receivedPlaceholder,isDisabled:o,isInvalid:A,errorMessage:A?Zn(u.insufficientMessageTemplate,{due:I}):void 0,variant:"bordered",radius:"lg",autoFocus:a,"data-testid":`${d}-received-input`}),C&&c.jsx(g.Alert,{"data-testid":`${d}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:u.changeLabel,description:Zn(u.changeMessageTemplate,{change:M}),icon:c.jsx(ae,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),c.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:_})]})},lf={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},oi=()=>{const t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`},Uo=({dueAmount:t,value:e,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:o=!1,isDisabled:a=!1,autoFocus:l=!1,className:d,"data-testid":u="check-tender-form"})=>{const f={...lf,...s},p=e!==void 0,[h,k]=x.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??oi()}),[y,b]=x.useState(!!n?.checkNumber),S=x.useMemo(()=>p?{checkNumber:e?.checkNumber??"",bankName:e?.bankName??"",date:e?.date??oi()}:h,[p,e,h]),N=x.useCallback(P=>{p||k(P);const B=P.checkNumber.trim(),R={amount:t.value,checkNumber:B,bankName:P.bankName.trim()||void 0,date:i?void 0:P.date,isValid:B.length>0&&t.value>0};r?.(R)},[p,t.value,i,r]),j=x.useCallback(P=>B=>{a||(P==="checkNumber"&&B.length>0&&b(!0),N({...S,[P]:B}))},[S,N,a]),C=x.useCallback(()=>{a||b(!0)},[a]),A=y&&S.checkNumber.trim()==="",M=`${u}-check-number`,I=`${u}-bank-name`,_=`${u}-date`;return c.jsxs("div",{className:g.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",d),"data-testid":u,children:[c.jsx(g.Input,{id:M,label:f.checkNumberLabel,labelPlacement:"outside",type:"text",value:S.checkNumber,onChange:P=>j("checkNumber")(P.target.value),onBlur:C,placeholder:f.checkNumberPlaceholder,isRequired:!0,isInvalid:A,errorMessage:A?f.checkNumberRequiredMessage:void 0,isDisabled:a,variant:"bordered",radius:"lg",autoFocus:l,"data-testid":`${u}-check-number-input`}),!o&&c.jsx(g.Input,{id:I,label:f.bankNameLabel,labelPlacement:"outside",type:"text",value:S.bankName,onChange:P=>j("bankName")(P.target.value),placeholder:f.bankNamePlaceholder,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${u}-bank-name-input`}),!i&&c.jsx(g.Input,{id:_,label:f.dateLabel,labelPlacement:"outside",type:"date",value:S.date,onChange:P=>j("date")(P.target.value),isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${u}-date-input`,className:"sm:col-span-2"})]})};Uo.displayName="CheckTenderForm";const cf={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},df=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],qo=({dueAmount:t,methodOptions:e=df,value:n,defaultValue:r,onChange:s,labels:i,showReference:o=!1,isDisabled:a=!1,className:l,"data-testid":d="other-tender-form"})=>{const u={...cf,...i},f=n!==void 0,[p,h]=x.useState({method:r?.method??"",reference:r?.reference??""}),k=x.useMemo(()=>f?{method:n?.method??"",reference:n?.reference??""}:p,[f,n,p]),y=x.useCallback(A=>e.find(M=>M.value===A)?.label??"",[e]),b=x.useCallback(A=>{f||h(A);const M=y(A.method),I={amount:t.value,method:A.method,description:M,reference:A.reference.trim()||void 0,isValid:A.method!==""};s?.(I)},[f,t.value,s,y]),S=x.useCallback(A=>{if(a)return;const M=typeof A=="string"?A:Array.from(A)[0]?.toString()??"";b({...k,method:M})},[k,b,a]),N=x.useCallback(A=>{a||b({...k,reference:A})},[k,b,a]),j=`${d}-method`,C=`${d}-reference`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",l),"data-testid":d,children:[c.jsx(wt,{id:j,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:k.method?[k.method]:[],onSelectionChange:S,isDisabled:a,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:e.map(A=>c.jsx(g.SelectItem,{"data-testid":`${d}-method-option-${A.value}`,children:A.label},A.value))}),o&&c.jsx(g.Input,{id:C,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:k.reference,onChange:A=>N(A.target.value),placeholder:u.referencePlaceholder,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};qo.displayName="OtherTenderForm";const uf={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ff={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},hf={pending:"warning",recorded:"success",failed:"danger"},pf=t=>t==="pending"||t==="recorded",mf=t=>`#${t+1}`,Ko=({total:t,tenders:e,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:o,"data-testid":a="split-payment-summary"})=>{const l={...uf,...s},{collected:d,remaining:u,isComplete:f}=x.useMemo(()=>{const h=e.reduce((y,b)=>pf(b.status)?y+b.amount:y,0),k=Math.max(t.value-h,0);return{collected:h,remaining:k,isComplete:h>=t.value&&t.value>0}},[e,t.value]),p=h=>h==="pending"?l.statusPending:h==="recorded"?l.statusRecorded:l.statusFailed;return c.jsxs("div",{className:g.cn("flex flex-col gap-4",o),"data-testid":a,children:[c.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${a}-remaining-banner`,children:[c.jsx("div",{className:"text-sm text-default-600",children:f?l.completeLabel:l.remainingLabel}),c.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${a}-remaining-amount`,children:ht(f?d:u,r,t.currency)})]}),!i&&e.length>0&&c.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${a}-collected-list`,children:[c.jsx("h3",{className:"text-base font-semibold",children:l.collectedHeading}),e.map((h,k)=>c.jsx(gf,{index:k,tender:h,locale:r,currency:t.currency,removable:!!n&&h.status!=="recorded",onRemove:n?()=>n(h.id):void 0,statusLabel:p(h.status),removeAriaLabel:l.removeAriaLabel,recordedTooltip:l.removeTooltipForRecorded,dataTestId:`${a}-row-${k}`},h.id))]})]})};Ko.displayName="SplitPaymentSummary";const gf=({index:t,tender:e,locale:n,currency:r,removable:s,onRemove:i,statusLabel:o,removeAriaLabel:a,recordedTooltip:l,dataTestId:d})=>{const u=i?c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":a,"data-testid":`${d}-remove`,className:g.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return c.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":d,children:[c.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:mf(t)}),c.jsx(ae,{icon:ff[e.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),c.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:e.label}),c.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:ht(e.amount,n,r)}),c.jsx(g.Chip,{size:"sm",radius:"full",variant:"flat",color:hf[e.status],startContent:e.status==="recorded"?c.jsx(ae,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):e.status==="failed"?c.jsx(ae,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:o}),u&&(s?u:c.jsx(g.Tooltip,{content:l,placement:"left",children:c.jsx("span",{tabIndex:0,"aria-label":l,children:u})}))]})},xf=`
20
20
  @keyframes pp-modal-in {
21
21
  from { opacity: 0; transform: scale(0.96); }
22
22
  to { opacity: 1; transform: scale(1); }
@@ -41,5 +41,5 @@
41
41
  from { opacity: 0; transform: translateY(-6px); }
42
42
  to { opacity: 1; transform: translateY(0); }
43
43
  }
44
- `,Wo=x.forwardRef(({children:t,relativeOverlayRoot:e=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>c.jsxs(c.Fragment,{children:[c.jsx("style",{children:xf}),c.jsx("div",{ref:i,"data-testid":s,style:r,className:g.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",e&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:t})]}));Wo.displayName="ModalShell";const Jo=({title:t,onClose:e,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>c.jsxs("header",{className:g.cn("flex items-center justify-between",s),"data-testid":i,children:[c.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),c.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:e,"aria-label":n,"data-testid":`${i}-close`,children:c.jsx(ae,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});Jo.displayName="ModalShellHeader";const Go=({children:t,columns:e=2,className:n,"data-testid":r="modal-shell-footer"})=>c.jsx("footer",{className:g.cn("mt-2 gap-3",e===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:t});Go.displayName="ModalShellFooter";const yf={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},bf={1:"grid-cols-1",2:"grid-cols-2"},Yn=t=>typeof t=="string"?c.jsx(ae,{icon:t,width:28,height:28,"aria-hidden":"true"}):t,Zo=({options:t,selectedKey:e,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:o=2,className:a,"data-testid":l="tile-select"})=>{const d=t.find(u=>u.key===e);return c.jsxs("div",{className:g.cn("flex flex-col gap-3",a),"data-testid":l,children:[r&&c.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${l}-heading`,children:r}),c.jsx("div",{className:"md:hidden",children:c.jsx(wt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${l}-heading`:void 0,selectedKeys:e?[e]:[],onSelectionChange:u=>{const m=Array.from(u)[0];typeof m=="string"&&n(m)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${l}-mobile-select`,startContent:d?c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(d.icon)}):void 0,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(u=>c.jsx(g.SelectItem,{isDisabled:u.isDisabled,startContent:c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(u.icon)}),"data-testid":u["data-testid"]??`${l}-${u.key}-mobile`,children:u.label},u.key))})}),c.jsx("div",{role:"group","aria-labelledby":r?`${l}-heading`:void 0,"aria-label":r?void 0:s,className:g.cn("hidden md:grid gap-3",bf[o],yf[i]),children:t.map(u=>{const f=e===u.key;return c.jsxs(G,{variant:"bordered",radius:"lg","aria-pressed":f,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${l}-${u.key}`,className:g.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[88px] px-4 py-5","border bg-transparent transition-colors",f?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[c.jsx("span",{"aria-hidden":"true",children:Yn(u.icon)}),c.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};Zo.displayName="TileSelect";const vf={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Yo=({total:t,label:e,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const o=vf[r];return c.jsxs("div",{"data-testid":i,className:g.cn("rounded-2xl px-6 py-5 text-center",o.wrapper,s),children:[c.jsx("div",{className:"text-sm text-default-600",children:e}),c.jsx("div",{className:g.cn("mt-1 text-4xl font-bold tracking-tight",o.amount),"data-testid":`${i}-amount`,children:ht(t.value,n,t.currency)})]})};Yo.displayName="PaymentTotalBanner";const kf={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Qo=({title:t,subtitle:e,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>c.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:g.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",kf[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[c.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),e&&c.jsx("div",{className:"mt-1 text-sm text-default-600",children:e})]})]});Qo.displayName="LoadingOverlay";const Wr=({cashChange:t,label:e="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:o="left",className:a,"data-testid":l="payment-cash-change-banner"})=>{if(!t||t.value<=0)return null;const d=o==="center";return c.jsxs("div",{role:"status","aria-live":"polite","data-testid":l,className:g.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",a),children:[c.jsx(ae,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),c.jsxs("div",{className:g.cn("flex flex-col",d?"items-center":"flex-1"),children:[c.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:e}),c.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${l}-amount`,children:ht(t.value,r,t.currency)}),n&&c.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${l}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Wr.displayName="PaymentCashChangeBanner";const Xo=({title:t,subtitle:e,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:o="en-US",closeLabel:a="Close",onClose:l,className:d,"data-testid":u="payment-success-view"})=>{const f=!!(s&&s.value>0);return c.jsxs("div",{"data-testid":u,className:g.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[c.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:c.jsx(ae,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:t}),c.jsx("p",{className:"text-default-700",children:e}),n&&r&&c.jsxs("p",{className:"text-default-700",children:[n,c.jsx("br",{}),c.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&c.jsx(Wr,{cashChange:s,label:i,locale:o,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),l&&c.jsx(G,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:l,"data-testid":`${u}-close`,className:"mt-4 w-full",children:a})]})};Xo.displayName="PaymentSuccessView";const ea=({heading:t,amountLabel:e,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:l,className:d,"data-testid":u="payment-sub-amount-input"})=>{const f=`${u}-input`,m=x.useCallback(h=>{const k=h.currentTarget;requestAnimationFrame(()=>{k.isConnected&&k.select()})},[]);return c.jsxs("div",{className:g.cn("flex flex-col gap-3 border-t border-default-100 pt-5",d),"data-testid":u,children:[c.jsx("h3",{className:"text-lg font-semibold","data-testid":`${u}-heading`,children:t}),c.jsx(g.Input,{id:f,label:e,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:h=>s?.(h.target.value),onFocus:m,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:a?l:void 0,variant:"bordered",radius:"lg","aria-invalid":a||void 0,"data-testid":`${u}-field`})]})};ea.displayName="PaymentSubAmountInput";const ta=({isOpen:t,title:e,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:o,onDismiss:a,"data-testid":l="confirm-dialog"})=>c.jsx(g.Modal,{isOpen:t,onOpenChange:d=>{d||a()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":l,"aria-labelledby":`${l}-title`,"aria-describedby":`${l}-body`,children:c.jsxs(g.ModalContent,{children:[c.jsx(g.ModalHeader,{id:`${l}-title`,className:"text-lg font-semibold",children:e}),c.jsx(g.ModalBody,{id:`${l}-body`,className:"text-sm text-default-700",children:n}),c.jsxs(g.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[c.jsx(G,{variant:"bordered",radius:"full",onPress:a,"data-testid":`${l}-dismiss`,className:"h-11",children:i}),c.jsx(G,{color:s,variant:"solid",radius:"full",onPress:o,"data-testid":`${l}-confirm`,className:"h-11",children:r})]})]})});ta.displayName="ConfirmDialog";exports.Button=G;exports.CashTenderForm=af;exports.CheckTenderForm=Uo;exports.ConfirmDialog=ta;exports.ConfirmationPageTemplate=Sa;exports.DonationAmounts=ro;exports.EventDetails=uu;exports.EventDetailsTemplate=Na;exports.ExpireCartTimer=so;exports.Footer=Aa;exports.HeroUIProvider=ga;exports.ItemCard=zo;exports.LoadingOverlay=Qo;exports.MembershipSelectCards=Wu;exports.ModalShell=Wo;exports.ModalShellFooter=Go;exports.ModalShellHeader=Jo;exports.Multiselect=ja;exports.Navbar=ka;exports.OfferCard=Rr;exports.OfferCardEmpty=vo;exports.OfferCardError=ko;exports.OfferCardList=No;exports.OfferCardSkeleton=So;exports.OtherTenderForm=qo;exports.PaymentCashChangeBanner=Wr;exports.PaymentSubAmountInput=ea;exports.PaymentSuccessView=Xo;exports.PaymentTotalBanner=Yo;exports.RICH_TEXT_PRESETS=to;exports.RevenueDistributionCard=Ro;exports.RevenueDistributionEmpty=$o;exports.RevenueDistributionError=Vo;exports.RevenueDistributionSkeleton=Bo;exports.RichTextArea=no;exports.Select=wt;exports.SplitPaymentSummary=Ko;exports.Stepper=ai;exports.TicketSelection=rf;exports.TileSelect=Zo;exports.Toggle=_o;exports.calculateAllocationDifference=Hu;exports.computeChange=Qn;exports.currencyFractionDigits=vr;exports.formatMoney=ht;exports.formatOfferCurrency=bo;exports.formatRevenueAmount=Vu;exports.formatRevenueCurrency=Bu;exports.generateDistributionId=qr;exports.getCurrencySymbol=zu;exports.offerCardVariants=wo;exports.offerListVariants=Co;exports.parseOfferCurrency=fu;exports.parseRevenueCurrency=_u;exports.roundToCurrency=li;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
44
+ `,Wo=x.forwardRef(({children:t,relativeOverlayRoot:e=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>c.jsxs(c.Fragment,{children:[c.jsx("style",{children:xf}),c.jsx("div",{ref:i,"data-testid":s,style:r,className:g.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",e&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:t})]}));Wo.displayName="ModalShell";const Jo=({title:t,onClose:e,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>c.jsxs("header",{className:g.cn("flex items-center justify-between",s),"data-testid":i,children:[c.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),c.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:e,"aria-label":n,"data-testid":`${i}-close`,children:c.jsx(ae,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});Jo.displayName="ModalShellHeader";const Go=({children:t,columns:e=2,className:n,"data-testid":r="modal-shell-footer"})=>c.jsx("footer",{className:g.cn("mt-2 gap-3",e===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:t});Go.displayName="ModalShellFooter";const yf={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},bf={1:"grid-cols-1",2:"grid-cols-2"},Yn=t=>typeof t=="string"?c.jsx(ae,{icon:t,width:20,height:20,"aria-hidden":"true"}):t,Zo=({options:t,selectedKey:e,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:o=2,className:a,"data-testid":l="tile-select"})=>{const d=t.find(u=>u.key===e);return c.jsxs("div",{className:g.cn("flex flex-col gap-3",a),"data-testid":l,children:[r&&c.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${l}-heading`,children:r}),c.jsx("div",{className:"md:hidden",children:c.jsx(wt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${l}-heading`:void 0,selectedKeys:e?[e]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${l}-mobile-select`,startContent:d?c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(d.icon)}):void 0,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(u=>c.jsx(g.SelectItem,{isDisabled:u.isDisabled,startContent:c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(u.icon)}),"data-testid":u["data-testid"]??`${l}-${u.key}-mobile`,children:u.label},u.key))})}),c.jsx("div",{role:"group","aria-labelledby":r?`${l}-heading`:void 0,"aria-label":r?void 0:s,className:g.cn("hidden md:grid gap-3",bf[o],yf[i]),children:t.map(u=>{const f=e===u.key;return c.jsxs(G,{variant:"bordered",radius:"lg","aria-pressed":f,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${l}-${u.key}`,className:g.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",f?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[c.jsx("span",{"aria-hidden":"true",children:Yn(u.icon)}),c.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};Zo.displayName="TileSelect";const vf={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Yo=({total:t,label:e,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const o=vf[r];return c.jsxs("div",{"data-testid":i,className:g.cn("rounded-2xl px-6 py-5 text-center",o.wrapper,s),children:[c.jsx("div",{className:"text-sm text-default-600",children:e}),c.jsx("div",{className:g.cn("mt-1 text-4xl font-bold tracking-tight",o.amount),"data-testid":`${i}-amount`,children:ht(t.value,n,t.currency)})]})};Yo.displayName="PaymentTotalBanner";const kf={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Qo=({title:t,subtitle:e,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>c.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:g.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",kf[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[c.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),e&&c.jsx("div",{className:"mt-1 text-sm text-default-600",children:e})]})]});Qo.displayName="LoadingOverlay";const Wr=({cashChange:t,label:e="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:o="left",className:a,"data-testid":l="payment-cash-change-banner"})=>{if(!t||t.value<=0)return null;const d=o==="center";return c.jsxs("div",{role:"status","aria-live":"polite","data-testid":l,className:g.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",a),children:[c.jsx(ae,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),c.jsxs("div",{className:g.cn("flex flex-col",d?"items-center":"flex-1"),children:[c.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:e}),c.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${l}-amount`,children:ht(t.value,r,t.currency)}),n&&c.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${l}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Wr.displayName="PaymentCashChangeBanner";const Xo=({title:t,subtitle:e,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:o="en-US",closeLabel:a="Close",onClose:l,className:d,"data-testid":u="payment-success-view"})=>{const f=!!(s&&s.value>0);return c.jsxs("div",{"data-testid":u,className:g.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[c.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:c.jsx(ae,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:t}),c.jsx("p",{className:"text-default-700",children:e}),n&&r&&c.jsxs("p",{className:"text-default-700",children:[n,c.jsx("br",{}),c.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&c.jsx(Wr,{cashChange:s,label:i,locale:o,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),l&&c.jsx(G,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:l,"data-testid":`${u}-close`,className:"mt-4 w-full",children:a})]})};Xo.displayName="PaymentSuccessView";const ea=({heading:t,amountLabel:e,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:l,autoFocus:d,className:u,"data-testid":f="payment-sub-amount-input"})=>{const p=`${f}-input`,h=x.useCallback(k=>{const y=k.currentTarget;requestAnimationFrame(()=>{y.isConnected&&y.select()})},[]);return c.jsxs("div",{className:g.cn("flex flex-col gap-3 border-t border-default-100 pt-5",u),"data-testid":f,children:[c.jsx("h3",{className:"text-lg font-semibold","data-testid":`${f}-heading`,children:t}),c.jsx(g.Input,{id:p,label:e,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:k=>s?.(k.target.value),onFocus:h,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:a?l:void 0,variant:"bordered",radius:"lg","aria-invalid":a||void 0,autoFocus:d,"data-testid":`${f}-field`})]})};ea.displayName="PaymentSubAmountInput";const ta=({isOpen:t,title:e,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:o,onDismiss:a,"data-testid":l="confirm-dialog"})=>c.jsx(g.Modal,{isOpen:t,onOpenChange:d=>{d||a()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":l,"aria-labelledby":`${l}-title`,"aria-describedby":`${l}-body`,children:c.jsxs(g.ModalContent,{children:[c.jsx(g.ModalHeader,{id:`${l}-title`,className:"text-lg font-semibold",children:e}),c.jsx(g.ModalBody,{id:`${l}-body`,className:"text-sm text-default-700",children:n}),c.jsxs(g.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[c.jsx(G,{variant:"bordered",radius:"full",onPress:a,"data-testid":`${l}-dismiss`,className:"h-11",children:i}),c.jsx(G,{color:s,variant:"solid",radius:"full",onPress:o,"data-testid":`${l}-confirm`,className:"h-11",children:r})]})]})});ta.displayName="ConfirmDialog";exports.Button=G;exports.CashTenderForm=af;exports.CheckTenderForm=Uo;exports.ConfirmDialog=ta;exports.ConfirmationPageTemplate=Sa;exports.DonationAmounts=ro;exports.EventDetails=uu;exports.EventDetailsTemplate=Na;exports.ExpireCartTimer=so;exports.Footer=Aa;exports.HeroUIProvider=ga;exports.ItemCard=zo;exports.LoadingOverlay=Qo;exports.MembershipSelectCards=Wu;exports.ModalShell=Wo;exports.ModalShellFooter=Go;exports.ModalShellHeader=Jo;exports.Multiselect=ja;exports.Navbar=ka;exports.OfferCard=Rr;exports.OfferCardEmpty=vo;exports.OfferCardError=ko;exports.OfferCardList=No;exports.OfferCardSkeleton=So;exports.OtherTenderForm=qo;exports.PaymentCashChangeBanner=Wr;exports.PaymentSubAmountInput=ea;exports.PaymentSuccessView=Xo;exports.PaymentTotalBanner=Yo;exports.RICH_TEXT_PRESETS=to;exports.RevenueDistributionCard=Ro;exports.RevenueDistributionEmpty=$o;exports.RevenueDistributionError=Vo;exports.RevenueDistributionSkeleton=Bo;exports.RichTextArea=no;exports.Select=wt;exports.SplitPaymentSummary=Ko;exports.Stepper=ai;exports.TicketSelection=rf;exports.TileSelect=Zo;exports.Toggle=_o;exports.calculateAllocationDifference=Hu;exports.computeChange=Qn;exports.currencyFractionDigits=vr;exports.formatMoney=ht;exports.formatOfferCurrency=bo;exports.formatRevenueAmount=Vu;exports.formatRevenueCurrency=Bu;exports.generateDistributionId=qr;exports.getCurrencySymbol=zu;exports.offerCardVariants=wo;exports.offerListVariants=Co;exports.parseOfferCurrency=fu;exports.parseRevenueCurrency=_u;exports.roundToCurrency=li;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
45
45
  (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:underline}.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)}})();