@veevarts/design-system 1.12.5 → 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 +36 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4946 -3779
- package/dist/patterns/CashTenderForm/CashTenderForm.d.ts +4 -0
- package/dist/patterns/CashTenderForm/__test__/CashTenderForm.test.d.ts +4 -0
- package/dist/patterns/CashTenderForm/index.d.ts +9 -0
- package/dist/patterns/CashTenderForm/types.d.ts +85 -0
- package/dist/patterns/CheckTenderForm/CheckTenderForm.d.ts +4 -0
- package/dist/patterns/CheckTenderForm/__test__/CheckTenderForm.test.d.ts +4 -0
- package/dist/patterns/CheckTenderForm/index.d.ts +9 -0
- package/dist/patterns/CheckTenderForm/types.d.ts +52 -0
- package/dist/patterns/ConfirmDialog/ConfirmDialog.d.ts +21 -0
- package/dist/patterns/ConfirmDialog/index.d.ts +2 -0
- package/dist/patterns/LoadingOverlay/LoadingOverlay.d.ts +18 -0
- package/dist/patterns/LoadingOverlay/index.d.ts +2 -0
- package/dist/patterns/ModalShell/ModalShell.d.ts +40 -0
- package/dist/patterns/ModalShell/index.d.ts +2 -0
- package/dist/patterns/OtherTenderForm/OtherTenderForm.d.ts +4 -0
- package/dist/patterns/OtherTenderForm/__test__/OtherTenderForm.test.d.ts +4 -0
- package/dist/patterns/OtherTenderForm/index.d.ts +8 -0
- package/dist/patterns/OtherTenderForm/types.d.ts +53 -0
- package/dist/patterns/PaymentCashChangeBanner/PaymentCashChangeBanner.d.ts +35 -0
- package/dist/patterns/PaymentCashChangeBanner/index.d.ts +2 -0
- package/dist/patterns/PaymentSubAmountInput/PaymentSubAmountInput.d.ts +44 -0
- package/dist/patterns/PaymentSubAmountInput/index.d.ts +2 -0
- package/dist/patterns/PaymentSuccessView/PaymentSuccessView.d.ts +30 -0
- package/dist/patterns/PaymentSuccessView/index.d.ts +2 -0
- package/dist/patterns/PaymentTotalBanner/PaymentTotalBanner.d.ts +15 -0
- package/dist/patterns/PaymentTotalBanner/index.d.ts +2 -0
- package/dist/patterns/SplitPaymentSummary/SplitPaymentSummary.d.ts +4 -0
- package/dist/patterns/SplitPaymentSummary/__test__/SplitPaymentSummary.test.d.ts +4 -0
- package/dist/patterns/SplitPaymentSummary/index.d.ts +9 -0
- package/dist/patterns/SplitPaymentSummary/types.d.ts +61 -0
- package/dist/patterns/TileSelect/TileSelect.d.ts +39 -0
- package/dist/patterns/TileSelect/index.d.ts +2 -0
- package/dist/patterns/index.d.ts +24 -0
- package/dist/tailwind/index.d.ts +13 -0
- package/dist/tailwind/index.js +13 -0
- package/dist/tokens/colors.d.ts +13 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/money.d.ts +55 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("@heroui/react"),x=require("react"),B=require("lucide-react"),$e=require("framer-motion"),pr=require("@tiptap/react"),R=require("@tiptap/core"),Ho=require("@tiptap/extension-underline"),Uo=require("@tiptap/extension-color"),qo=require("@tiptap/extension-highlight"),Ko=require("@tiptap/extension-link"),Wo=require("@tiptap/extension-task-list"),Jo=require("@tiptap/extension-task-item"),Go=require("@tiptap/extension-text-align");function Zo({children:t}){return c.jsx(g.HeroUIProvider,{children:t})}const se=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}));se.displayName="Button";function Qo(t){const e=t?.closest('[role="dialog"]');return e?.parentElement??e??void 0}const tn=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(Qo(r.current))},[]),c.jsx("span",{ref:r,className:"contents",children:c.jsx(g.Select,{ref:n,...e,popoverProps:o})})});tn.displayName="Select";const Xo={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function Yo({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(tn,{"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(B.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(tn,{"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(B.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 el({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(se,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,size:"md",children:[c.jsx(B.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(se,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:e,size:"md",children:[c.jsx(B.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function tl({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...Xo,...u};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",d),children:[c.jsx("div",{className:"flex items-center min-w-10",children:t&&c.jsx("a",{href:"/",className:"block",children:c.jsx("img",{"data-testid":"navbar-logo",src:t,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||e.length>0)&&c.jsx(Yo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(el,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function nl(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 jn;const rl=typeof document<"u"?(jn=x.useInsertionEffect)!==null&&jn!==void 0?jn:x.useLayoutEffect:()=>{};function mr(t,e,n){let[r,s]=x.useState(t||e),i=x.useRef(r),o=x.useRef(t!==void 0),l=t!==void 0;x.useEffect(()=>{let f=o.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?t:r;rl(()=>{i.current=a});let[,u]=x.useReducer(()=>({}),{}),d=x.useCallback((f,...m)=>{let h=typeof f=="function"?f(i.current):f;Object.is(i.current,h)||(i.current=h,s(h),u(),n?.(h,...m))},[n]);return[a,d]}function sl(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 ei=x.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,isDisabled:u=!1,...d},f)=>{const[m,h]=mr(i,n,s),C=x.useMemo(()=>{let b,k;const v=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(t){case"primary":b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",k="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",k="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",k="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",k="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",k="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break}return v.unshift(k),v.unshift(b),v},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:g.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...d,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:g.cn("flex flex-row flex-nowrap gap-x-3",C,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((b,k)=>{const v=m===k?"active":m<k?"inactive":"complete";return c.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${k}`,children:c.jsxs("button",{"aria-current":v==="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":u},l),onClick:()=>!u&&h(k),disabled:u,"data-testid":`stepper-step-btn-${k}`,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:v,className:"relative",children:c.jsx($e.m.div,{animate:v,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":v==="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:v==="complete"?c.jsx(sl,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${k}`}):c.jsx("span",{})})})})})}),k<e-1&&!o&&c.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":k},children:c.jsx("div",{className: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":k<m})})})]},k)},k)})})]})});ei.displayName="Stepper";function il(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 ol(){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 ll=t=>{const e=x.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(al,{...t},e)},al=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=x.useState([]),[l,a]=x.useState([]),[u,d]=x.useState(null),[f,m]=x.useState(null),h=x.useMemo(()=>new Set(e),[e]),C=x.useMemo(()=>new Set(t),[t]),b=x.useMemo(()=>t.filter(F=>!h.has(F)),[t,h]),k=F=>{if(F.length===0)return;const j=Array.from(new Set([...e,...F]));n(j)},v=F=>{if(F.length===0)return;const j=new Set(F);n(e.filter(P=>!j.has(P)))},A=()=>{i.length!==0&&(k(i),o([]))},N=()=>{l.length!==0&&(v(l),a([]))},w=()=>{b.length!==0&&(k(b),o([]))},E=()=>{e.length!==0&&(n([]),a([]))},O=(F,j,P)=>{const $=Math.min(j,P),W=Math.max(j,P);return F.slice($,W+1)},L=(F,j,P)=>{if(P&&u!==null){o(O(b,u,j)),a([]),d(j);return}const $=i.includes(F);o($?i.filter(W=>W!==F):[...i,F]),a([]),d(j)},_=(F,j,P)=>{if(P&&f!==null){a(O(e,f,j)),o([]),m(j);return}const $=l.includes(F);a($?l.filter(W=>W!==F):[...l,F]),o([]),m(j)},z=(F,j,P)=>{const $=P==="available"?i.includes(j)?i:[j]:l.includes(j)?l:[j];F.dataTransfer.setData("text/plain",JSON.stringify({source:P,items:$})),F.dataTransfer.effectAllowed="move"},H=(F,j)=>{F.preventDefault();const P=F.dataTransfer.getData("text/plain");if(P)try{const $=JSON.parse(P),W=($.items||[]).filter(oe=>C.has(oe));if(W.length===0||$.source===j)return;j==="selected"?(k(W),o([])):(v(W),a([]))}catch{return}};return c.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),c.jsx(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:F=>F.preventDefault(),onDrop:F=>H(F,"available"),children:b.map((F,j)=>{const P=i.includes(F);return c.jsx("button",{type:"button",onClick:$=>{L(F,j,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>z($,F,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${P?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:F},F)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:A,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:N,isDisabled:l.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:w,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:E,"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:F=>F.preventDefault(),onDrop:F=>H(F,"selected"),children:e.map((F,j)=>{const P=l.includes(F);return c.jsx("button",{type:"button",onClick:$=>{_(F,j,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>z($,F,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${P?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:F},F)})})})]})]})};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:l}){const a=i?`${e} (${i})`:e;return c.jsx(g.Tooltip,{content:a,placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:c.jsx(t,{size:o})})})}const 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"}},cl={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function ul({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const o=()=>r(l=>l+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=Ke.heading;a&&a.execute({editor:t,config:{type:"heading",level:l}})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(B.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(B.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:cl[o]},o))})]})}const In={bulletList:{label:"Bullet List",icon:B.List},orderedList:{label:"Numbered List",icon:B.ListOrdered},taskList:{label:"Task List",icon:B.ListTodo}};function dl({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const l=()=>r(a=>a+1);return t.on("selectionUpdate",l),t.on("transaction",l),()=>{t.off("selectionUpdate",l),t.off("transaction",l)}},[t]);const s=e.find(l=>t.isActive(l)),i=s?In[s].icon:B.List,o=l=>{const u=Ke[l];u&&u.execute({editor:t})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:c.jsx(i,{size:16})})}),c.jsx(g.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=In[l].icon;return c.jsx(g.DropdownItem,{startContent:c.jsx(a,{size:16}),children:In[l].label},l)})})]})}function fl({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
|
|
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
|
-
${
|
|
10
|
-
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(g.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(B.ZoomIn,{size:16})})})]})}function bl({editor:t,isDisabled:e=!1}){const[n,r]=x.useState(!1),[s,i]=x.useState(""),[o,l]=x.useState(""),[a,u]=x.useState(!1),d=t.isActive("link"),f=h=>{if(h){const{from:C,to:b}=t.state.selection,k=t.isActive("link");let v="";if(k){const N=t.schema.marks.link,w=t.state.doc.resolve(C),E=R.getMarkRange(w,N);E&&(v=t.state.doc.textBetween(E.from,E.to,""))}else v=t.state.doc.textBetween(C,b,"");const A=t.getAttributes("link").href||"";i(v),l(A),u(k)}r(h)},m=()=>{if(o.trim()){const{from:h,to:C}=t.state.selection,b=t.schema.marks.link,k=t.state.doc.resolve(h),v=R.getMarkRange(k,b),A=v?.from??h,N=v?.to??C,w=t.state.doc.textBetween(A,N,"");s.trim()&&s!==w?t.chain().focus().setTextSelection({from:A,to:N}).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(se,{size:"sm",radius:"sm",variant:d?"solid":"bordered",color:d?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:c.jsx(B.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=>l(h.target.value),onKeyDown:h=>h.key==="Enter"&&m(),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(se,{size:"sm",color:"primary",onPress:m,isDisabled:!o.trim(),children:a?"Update":"Apply"})]})})]})}function kl({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 ti(t,e){const n=x.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const a=Ke[l];if(a)try{const u=a.canExecute?.(t)??!0,d=a.isActive?.(t)??!1;i[l]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=x.useState(n);return x.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const u=Ke[a];if(u)try{const d=u.canExecute?.(t)??!0,f=u.isActive?.(t)??!1;o[a]={isActive:f,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function ni(t,e){const n=x.useCallback((o,l)=>{if(!t)return;const a=Ke[o];if(a)try{a.execute({editor:t,config:l}),e?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[t,e]),r=x.useCallback(o=>{n(o)},[n]),s=x.useCallback((o,l)=>{if(!t)return!1;const a=Ke[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=x.useCallback((o,l)=>{if(!t)return!1;const a=Ke[o];try{return a?.isActive?.(t,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function vl(t=xe.default){const[e,n]=x.useState(t),r=x.useCallback((l=xe.step)=>{n(a=>Math.min(xe.max,a+l))},[]),s=x.useCallback((l=xe.step)=>{n(a=>Math.max(xe.min,a-l))},[]),i=x.useCallback(()=>{n(xe.default)},[]),o=x.useCallback(l=>{const a=Math.max(xe.min,Math.min(xe.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=xe.min,isMaxZoom:e>=xe.max,isDefaultZoom:e===xe.default}}const Sl=["bold","italic","strike","underline","code"];function Cl({editor:t,modifiers:e,onToolbarAction:n}){const r=ti(t,e),{toggleModifier:s}=ni(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>Sl.includes(o));return i.length===0?null:c.jsx(kl,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=yt(o);return c.jsx(st,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function wl({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=ti(t,e),{toggleModifier:a,executeCommand:u}=ni(t,o);if(!t)return null;const d=e.map(L=>Rt(L)),f=d.some(L=>["bold","italic","strike","underline","code"].includes(L)),m=d.some(L=>["textColor","highlight"].includes(L)),h=d.includes("heading"),C=d.includes("textAlign"),b=d.some(L=>["bulletList","orderedList","taskList"].includes(L)),k=d.includes("blockquote"),v=d.includes("codeBlock"),A=d.includes("link"),N=d.includes("horizontalRule"),w=d.some(L=>["undo","redo"].includes(L)),E=n!==void 0&&r!==void 0,O=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${O} ${i||""}`,children:c.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&c.jsxs(c.Fragment,{children:[c.jsx(Cl,{editor:t,modifiers:e,onToolbarAction:o}),(m||h||C||b||k||v||A||N||w||E)&&c.jsx(rt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(Zr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(Zr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(h||C||b||k||v||A||N||w||E)&&c.jsx(rt,{})]}),h&&c.jsxs(c.Fragment,{children:[c.jsx(ul,{editor:t}),(C||b||k||v||A||N||w||E)&&c.jsx(rt,{})]}),C&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(L=>{const _=gl[L],z=t.isActive({textAlign:L});return c.jsx(st,{icon:_,label:`Align ${L}`,isActive:z,onClick:()=>u("textAlign",{type:"textAlign",alignment:L})},L)})}),(b||k||v||A||N||w||E)&&c.jsx(rt,{})]}),b&&c.jsxs(c.Fragment,{children:[c.jsx(dl,{editor:t,types:d.filter(L=>["bulletList","orderedList","taskList"].includes(L))}),(k||v||A||N||w||E)&&c.jsx(rt,{})]}),(k||v||A||N)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[k&&c.jsx(st,{icon:yt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),v&&c.jsx(st,{icon:yt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),A&&c.jsx(bl,{editor:t,isDisabled:l.link?.isDisabled}),N&&c.jsx(st,{icon:yt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(w||E)&&c.jsx(rt,{})]}),w&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(st,{icon:yt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(st,{icon:yt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),E&&c.jsx(rt,{})]}),E&&c.jsx(xl,{zoom:n,onZoomChange:L=>{r?.(L),o?.({type:"zoom",modifier:`${L}%`})}})]})})}const Al=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Nl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,El=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Tl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ml=R.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[R.markInputRule({find:Al,type:this.type}),R.markInputRule({find:El,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Nl,type:this.type}),R.markPasteRule({find:Tl,type:this.type})]}}),jl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Il=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ol=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ll=R.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[R.markInputRule({find:jl,type:this.type}),R.markInputRule({find:Ol,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Il,type:this.type}),R.markPasteRule({find:Dl,type:this.type})]}}),Rl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Fl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Pl=R.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[R.markInputRule({find:Rl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Fl,type:this.type})]}}),$l=/(^|[^`])`([^`]+)`(?!`)/,Vl=/(^|[^`])`([^`]+)`(?!`)/g,zl=R.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[R.markInputRule({find:$l,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Vl,type:this.type})]}}),Bl=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}`)})},_l=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Bl(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Hl=R.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,R.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>R.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Ul=R.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ql="listItem",Qr="textStyle",Xr=/^\s*([-+*])\s$/,Kl=R.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ql,this.editor.getAttributes(Qr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=R.wrappingInputRule({find:Xr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Xr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Qr),editor:this.editor})),[t]}}),Wl="listItem",Yr="textStyle",es=/^(\d+)\.\s$/,Jl=R.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",R.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Wl,this.editor.getAttributes(Yr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=R.wrappingInputRule({find:es,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:es,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Yr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Gl=R.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function ri(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=ri(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function si(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=si(o.content,l.content,n-1,r-1);if(u)return u}n-=a,r-=a}}class U{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new U(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new U(r,s)}cutByIndex(e,n){return e==n?U.empty:e==0&&n==this.content.length?this:new U(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 U(s,i)}addToStart(e){return new U([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new U(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 ri(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return si(this,e,n,r)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?qt(n+1,i):qt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return U.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new U(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return U.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 U(n||e,r)}static from(e){if(!e)return U.empty;if(e instanceof U)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new U([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}U.empty=new U([],0);const Dn={index:0,offset:0};function qt(t,e){return Dn.index=t,Dn.offset=e,Dn}function Gn(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(!Gn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Gn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class De{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&&Gn(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 De.none;if(e instanceof De)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}De.none=[];class Zl extends Error{}class q{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=oi(this.content,e+this.openStart,n);return r&&new q(r,this.openStart,this.openEnd)}removeBetween(e,n){return new q(ii(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 q.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 q(U.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 q(e,r,s)}}q.empty=new q(U.empty,0,0);function ii(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(ii(i.content,e-s-1,n-s-1)))}function oi(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=oi(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function Ql(t){return t.tag!=null}function Xl(t){return t.style!=null}class nn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Ql(s))this.tags.push(s);else if(Xl(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 ns(this,n,!1);return r.addAll(e,De.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ns(this,n,!0);return r.addAll(e,De.none,n.from,n.to),q.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(ta(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=rs(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=rs(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nn(e,nn.schemaRules(e)))}}const li={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},Yl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ai={ol:!0,ul:!0},Ft=1,Zn=2,Mt=4;function ts(t,e,n){return e!=null?(e?Ft:0)|(e==="full"?Zn:0):t&&t.whitespace=="pre"?Ft|Zn:n&~Mt}class Kt{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=De.none,this.match=i||(o&Mt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(U.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ft)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=U.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(U.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&&!li.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ns{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=ts(null,n.preserveWhitespace,0)|(r?Mt:0);s?i=new Kt(s.type,s.attrs,De.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Kt(null,null,De.none,!0,null,o):i=new Kt(e.schema.topNodeType,null,De.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&Zn?"full":this.localPreserveWS||(s.options&Ft)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let
|
|
12
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(u=>!a.clearMark(u)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=a,!u.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=De.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):ss(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=ts(e,i,o.options);o.options&Mt&&o.content.length==0&&(l|=Mt);let a=De.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):ss(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Kt(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ft)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ea(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ai.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ta(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function rs(t){let e={};for(let n in t)e[n]=t[n];return e}function ss(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:d}=l.edge(a);if(u==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class yn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ln(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],d=this.serializeMark(u,o.isInline,n);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Zt(Ln(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Zt(Ln(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Zt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=is(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return is(e.marks)}}function is(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ln(t){return t.document||window.document}const os=new WeakMap;function na(t){let e=os.get(t);return e===void 0&&os.set(t,e=ra(t)),e}function ra(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Zt(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=na(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let m=f.indexOf(" ");m>0?a.setAttributeNS(f.slice(0,m),f.slice(m+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:C}=Zt(t,m,n,r);if(a.appendChild(h),C){if(l)throw new RangeError("Multiple content holes");l=C}}}return{dom:a,contentDOM:l}}const ci=65535,ui=Math.pow(2,16);function sa(t,e){return t+e*ui}function ls(t){return t&ci}function ia(t){return(t-(t&ci))/ui}const di=1,fi=2,Qt=4,hi=8;class Qn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&hi)>0}get deletedBefore(){return(this.delInfo&(di|Qt))>0}get deletedAfter(){return(this.delInfo&(fi|Qt))>0}get deletedAcross(){return(this.delInfo&Qt)>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=ls(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+ia(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let u=this.ranges[l+i],d=this.ranges[l+o],f=a+u;if(e<=f){let m=u?e==a?-1:e==f?1:n:n,h=a+s+(m<0?0:d);if(r)return h;let C=e==(n<0?a:f)?null:sa(l/3,e-a),b=e==a?fi:e==f?di:Qt;return(n<0?e!=a:e!=f)&&(b|=hi),new Qn(h,b,C)}s+=d-u}return r?e+s:new Qn(e+s,0,null)}touches(e,n){let r=0,s=ls(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let u=this.ranges[l+i],d=a+u;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,a,a+d),i+=d-u}}invert(){return new 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 rn{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 rn(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 rn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Qn(e,s,null)}}const Rn=Object.create(null);class be{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=Rn[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 Rn)throw new RangeError("Duplicate use of step JSON ID "+e);return Rn[e]=n,n.prototype.jsonID=e,n}}class de{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,n,r,s){try{return de.ok(e.replace(n,r,s))}catch(i){if(i instanceof Zl)return de.fail(i.message);throw i}}}function gr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(gr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return U.fromArray(r)}class ot extends be{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 q(gr(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return de.fromReplace(e,this.from,this.to,i)}invert(){return new lt(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))}}be.jsonID("addMark",ot);class lt extends be{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 q(gr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return de.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 lt(n.pos,r.pos,this.mark)}merge(e){return e instanceof lt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lt(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 lt(n.from,n.to,e.markFromJSON(n.mark))}}be.jsonID("removeMark",lt);class at extends be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new q(U.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 at(this.pos,n.marks[s]);return new at(this.pos,this.mark)}}return new Pt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new at(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 at(n.pos,e.markFromJSON(n.mark))}}be.jsonID("addNodeMark",at);class Pt extends be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new q(U.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new at(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Pt(n.pos,e.markFromJSON(n.mark))}}be.jsonID("removeNodeMark",Pt);class qe extends be{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Xn(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.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?q.empty:new q(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?q.empty:new q(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,q.fromJSON(e,n.slice),!!n.structure)}}be.jsonID("replace",qe);class vt extends be{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Xn(e,this.from,this.gapFrom)||Xn(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?de.fromReplace(e,this.from,this.to,r):de.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 vt(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 vt(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 vt(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(e,n.slice),n.insert,!!n.structure)}}be.jsonID("replaceAround",vt);function Xn(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 pi(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(i==1)d=u.canReplace(a,a,s);else{let f=u.contentMatchAt(a).findWrapping(s.firstChild.type);d=f&&u.canReplaceWith(a,a,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class jt extends be{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 de.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 de.fromReplace(e,this.pos,this.pos+1,new q(U.from(s),0,n.isLeaf?0:1))}getMap(){return Ee.empty}invert(e){return new jt(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 jt(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 jt(n.pos,n.attr,n.value)}}be.jsonID("attr",jt);class sn extends be{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 de.ok(r)}getMap(){return Ee.empty}invert(e){return new sn(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 sn(n.attr,n.value)}}be.jsonID("docAttr",sn);let $t=class extends Error{};$t=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";const Fn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new oa(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=q.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(u.pos),l?q.empty:n),l==0&&us(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),u=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),us(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):xt(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?xt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):xt(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 xt(e,e,0,0,1)||new _e(e)}static atEnd(e){return xt(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=Fn[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 Fn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class oa{constructor(e,n){this.$from=e,this.$to=n}}let as=!1;function cs(t){!as&&!t.parent.inlineContent&&(as=!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){cs(e),cs(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=q.empty){if(super.replace(e,n),n==q.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 xn(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 xn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class K 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 K(i)}content(){return new q(U.from(this.node),0,0)}eq(e){return e instanceof K&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new K(e.resolve(n.anchor))}static create(e,n){return new K(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}K.prototype.visible=!1;X.jsonID("node",K);class yr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xn(r,r):new yr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&K.isSelectable(r)?new K(n):X.near(n)}}class _e extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=q.empty){if(n==q.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 la}}X.jsonID("all",_e);const la={map(){return this},resolve(t){return new _e(t)}};function xt(t,e,n,r,s,i=!1){if(e.inlineContent)return Q.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&K.isSelectable(l))return K.create(t,n-(s<0?l.nodeSize:0))}else{let a=xt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function us(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof vt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,u,d)=>{o==null&&(o=d)}),t.setSelection(X.near(t.doc.resolve(o),n))}function ds(t,e){return!e||!t?t:t.bind(e)}class Wt{constructor(e,n,r){this.name=e,this.init=ds(n.init,r),this.apply=ds(n.apply,r)}}new Wt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Wt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Wt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Wt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function mi(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=mi(s,e,{})),n[r]=s}return n}class bn{constructor(e){this.spec=e,this.props={},e.props&&mi(e.props,this,this.props),this.key=e.key?e.key.key:gi("plugin")}getState(e){return e[this.key]}}const Pn=Object.create(null);function gi(t){return t in Pn?t+"$"+ ++Pn[t]:(Pn[t]=0,t+"$")}class xr{constructor(e="key"){this.key=gi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const aa=/^```([a-z]+)?[\s\n]$/,ca=/^~~~([a-z]+)?[\s\n]$/,ua=R.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",R.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
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(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
|
+
`);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 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:
|
|
15
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},
|
|
16
|
-
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&a&&o){const f=a.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var on=200,pe=function(){};pe.prototype.append=function(e){return e.length?(e=pe.from(e),!this.length&&e||e.length<on&&this.leafAppend(e)||this.length<on&&e.leafPrepend(this)||this.appendInner(e)):this};pe.prototype.prepend=function(e){return e.length?pe.from(e).append(this):this};pe.prototype.appendInner=function(e){return new ma(this,e)};pe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};pe.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)};pe.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};pe.from=function(e){return e instanceof pe?e:e&&e.length?new yi(e):pe.empty};var yi=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=on)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=on)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})(pe);pe.empty=new yi([]);var ma=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(pe);const ga=500;class Re{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){s||(s=this.remapping(r,m+1),i=s.maps.length),i--,d.push(f);return}if(s){d.push(new ze(f.map));let h=f.step.map(s.slice(i)),C;h&&o.maybeStep(h).doc&&(C=o.mapping.maps[o.mapping.maps.length-1],u.push(new ze(C,void 0,void 0,u.length+d.length))),i--,C&&s.appendMap(C,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new Re(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new ze(e.mapping.maps[d],f,n),h;(h=a&&a.merge(m))&&(m=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(m),n&&(o++,n=void 0),s||(a=m)}let u=o-r.depth;return u>xa&&(l=ya(l,u),o-=u),new Re(l.append(i),o)}remapping(e,n){let r=new rn;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 Re(this.items.append(e.map(n=>new ze(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},s);let a=n;this.items.forEach(m=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let C=i.maps[h];if(m.step){let b=e.steps[h].invert(e.docs[h]),k=m.selection&&m.selection.map(i.slice(a+1,h));k&&l++,r.push(new ze(C,b,k))}else r.push(new ze(C))},s);let u=[];for(let m=n;m<o;m++)u.push(new ze(i.maps[m]));let d=this.items.slice(0,s).append(u).append(r),f=new Re(d,l);return f.emptyItemCount()>ga&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let f=new ze(u.invert(),a,d),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 Re(pe.from(s.reverse()),i)}}Re.empty=new Re(pe.empty,0);function ya(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class ze{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 ze(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 xa=20;function ba(t,e,n,r){let s=n.getMeta(ut),i;if(s)return s.historyState;n.getMeta(Sa)&&(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(ut))return o.getMeta(ut).redo?new Ze(t.done.addTransform(n,void 0,r,Xt(e)),t.undone,fs(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,Xt(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ka(n,t.prevRanges)),u=o?$n(t.prevRanges,n.mapping):fs(n.mapping.maps);return new Ze(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Xt(e)),Re.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),$n(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),$n(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ka(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 fs(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 $n(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 va(t,e,n){let r=Xt(e),s=ut.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Ze(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ut,{redo:n,historyState:a})}let Vn=!1,hs=null;function Xt(t){let e=t.plugins;if(hs!=e){Vn=!1,hs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Vn=!0;break}}return Vn}const ut=new xr("history"),Sa=new xr("closeHistory");function Ca(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new bn({key:ut,state:{init(){return new Ze(Re.empty,Re.empty,null,0,-1)},apply(e,n,r){return ba(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?bi:r=="historyRedo"?ki:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function xi(t,e){return(n,r)=>{let s=ut.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=va(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const bi=xi(!1,!0),ki=xi(!0,!0),ps=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>bi(t,e),redo:()=>({state:t,dispatch:e})=>ki(t,e)}},addProseMirrorPlugins(){return[Ca(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),wa=R.Node.create({name:"doc",topNode:!0,content:"block+"}),Aa=R.Node.create({name:"text",group:"inline"});function Na(t={}){return new bn({view(e){return new Ea(e,t)}})}class Ea{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let C=h.getBoundingClientRect(),b=f?C.bottom:C.top;f&&m&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*l;r={left:C.left,right:C.right,top:b-k,bottom:b+k}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=a.getBoundingClientRect(),m=f.width/a.offsetWidth,h=f.height/a.offsetHeight;u=f.left-a.scrollLeft*m,d=f.top-a.scrollTop*h}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=pi(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Ta=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Na(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:'"'},Ma=typeof navigator<"u"&&/Mac/.test(navigator.platform),ja=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 Ia(t){var e=Ma&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ja&&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 Oa=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Da=typeof navigator<"u"&&/Win/.test(navigator.platform);function La(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Oa?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Ra(t){let e=Object.create(null);for(let n in t)e[La(n)]=t[n];return e}function Bn(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Fa(t){let e=Ra(t);return function(n,r){let s=Ia(r),i,o=e[Bn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Bn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Da&&r.ctrlKey&&r.altKey)&&(i=et[r.keyCode])&&i!=s){let l=e[Bn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ht=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},vi=function(t,e,n,r){return n&&(ms(t,e,n,r,-1)||ms(t,e,n,r,1))},Pa=/^(img|br|input|textarea|hr)$/i;function ms(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:an(t))){let o=t.parentNode;if(!o||o.nodeType!=1||br(t)||Pa.test(t.nodeName)||t.contentEditable=="false")return!1;e=ht(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?an(t):0}else return!1}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $a(t,e,n){for(let r=e==0,s=e==an(t);r||s;){if(t==n)return!0;let i=ht(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==an(t)}}function br(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 Si=function(t){return t.focusNode&&vi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ci(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,gs=typeof document<"u"?document:null,tt=He&&He.userAgent||"",Yn=/Edge\/(\d+)/.exec(tt),wi=/MSIE \d/.exec(tt),er=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),_t=!!(wi||er||Yn),Ai=wi?document.documentMode:er?+er[1]:Yn?+Yn[1]:0,kn=!_t&&/gecko\/(\d+)/i.test(tt);kn&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];const tr=!_t&&/Chrome\/(\d+)/.exec(tt),We=!!tr,Ni=tr?+tr[1]:0,pt=!_t&&!!He&&/Apple Computer/.test(He.vendor),kr=pt&&(/Mobile\/\w+/.test(tt)||!!He&&He.maxTouchPoints>2),Oe=kr||(He?/Mac/.test(He.platform):!1),Ei=He?/Win/.test(He.platform):!1,Ht=/Android \d/.test(tt),vr=!!gs&&"webkitFontSmoothing"in gs.documentElement.style,Va=vr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function za(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(Si(n)){for(a=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&K.isSelectable(f)&&s.parent&&!(f.isInline&&$a(n.focusNode,n.focusOffset,s.dom))){let m=s.posBefore;u=new K(o==m?l: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 C=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(C.startContainer,C.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(C.endContainer,C.endOffset,-1))}if(f<0)return null;[a,o]=m==t.state.selection.anchor?[m,f]:[f,m],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;u=Mi(t,d,l,f)}return u}function Ti(t){return t.editable?t.hasFocus():Ua(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Sr(t,e=!1){let n=t.state.selection;if(Ha(t,n),!!Ti(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&We){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&vi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)_a(t);else{let{anchor:r,head:s}=n,i,o;ys&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=xs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=xs(t,n.to))),t.docView.setSelection(r,s,t,e),ys&&(i&&bs(i),o&&bs(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ba(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ys=pt||We&&Ni<63;function xs(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(pt&&s&&s.contentEditable=="false")return _n(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return _n(s);if(i)return _n(i)}}function _n(t){return t.contentEditable="true",pt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function bs(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ba(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(()=>{(!Ti(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _a(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ht(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_t&&Ai<=11&&(n.disabled=!0,n.disabled=!1)}function Ha(t,e){if(e instanceof K){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ks(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ks(t)}function ks(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Mi(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Ua(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 nr(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 Qe(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function vs(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 Qe(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=nr(t.state,e);return s&&s instanceof K?Qe(t,s):!1}else if(!(Oe&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?K.isSelectable(i)?Qe(t,new K(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):vr?Qe(t,new Q(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof K&&r.node.isInline)return Qe(t,new Q(e>0?r.$to:r.$from));{let s=nr(t.state,e);return s?Qe(t,s):!1}}}function cn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function It(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mt(t,e){return e<0?qa(t):Ka(t)}function qa(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<cn(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(It(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ji(n))break;{let l=n.previousSibling;for(;l&&It(l,-1);)s=n.parentNode,i=ht(l),l=l.previousSibling;if(l)n=l,r=cn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?rr(t,n,r):s&&rr(t,s,i)}function Ka(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=cn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(It(l,1))i=n,o=++r;else break}else{if(ji(n))break;{let l=n.nextSibling;for(;l&&It(l,1);)i=l.parentNode,o=ht(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=cn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&rr(t,i,o)}function ji(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Wa(t,e){for(;t&&e==t.childNodes.length&&!br(t);)e=ht(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 Ja(t,e){for(;t&&!e&&!br(t);)e=ht(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 rr(t,e,n){if(e.nodeType!=3){let i,o;(o=Wa(e,n))?(e=o,n=0):(i=Ja(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Si(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&&Sr(t)},50)}function Ss(t,e){let n=t.state.doc.resolve(e);if(!(We||Ei)&&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 Cs(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Oe&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=nr(t.state,e);if(o&&o instanceof K)return Qe(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof _e?X.near(o,e):X.findFrom(o,e);return l?Qe(t,l):!1}return!1}function ws(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 As(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ga(t){if(!pt||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;As(t,r,"true"),setTimeout(()=>As(t,r,"false"),20)}return!1}function Za(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Qa(t,e){let n=e.keyCode,r=Za(e);if(n==8||Oe&&n==72&&r=="c")return ws(t,-1)||mt(t,-1);if(n==46&&!e.shiftKey||Oe&&n==68&&r=="c")return ws(t,1)||mt(t,1);if(n==13||n==27)return!0;if(n==37||Oe&&n==66&&r=="c"){let s=n==37?Ss(t,t.state.selection.from)=="ltr"?-1:1:-1;return vs(t,s,r)||mt(t,s)}else if(n==39||Oe&&n==70&&r=="c"){let s=n==39?Ss(t,t.state.selection.from)=="ltr"?1:-1:1;return vs(t,s,r)||mt(t,s)}else{if(n==38||Oe&&n==80&&r=="c")return Cs(t,-1,r)||mt(t,-1);if(n==40||Oe&&n==78&&r=="c")return Ga(t)||Cs(t,1,r)||mt(t,1);if(r==(Oe?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ii(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),l=Pi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Fi[u.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let C=l.createElement(d[h]);for(;a.firstChild;)C.appendChild(a.firstChild);a.appendChild(C),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let 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:
|
|
19
|
-
`))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,s,r,t));if(f)l=f;else{let m=s.marks(),{schema:h}=t.state,C=yn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let k=o.appendChild(document.createElement("p"));b&&k.appendChild(C.serializeNode(h.text(b,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=tc(n),vr&&nc(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||nn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!Xa.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=rc(Ns(l,+d[1],+d[2]),d[4]);else if(l=q.maxOpen(Ya(l.content,s),!0),l.openStart||l.openEnd){let f=0,m=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;m<l.openEnd&&!h.type.spec.isolating;m++,h=h.lastChild);l=Ns(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Xa=/^(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 Ya(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&i.length&&Li(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ri(o[o.length-1],i.length));let d=Di(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return U.from(o)}return t}function Di(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,U.from(t));return t}function Li(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Li(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(U.from(Di(n,t,s+1))))}}function Ri(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ri(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(U.empty,!0);return t.copy(n.append(r))}function sr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=sr(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(U.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Ns(t,e,n){return e<t.openStart&&(t=new q(sr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new q(sr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Fi={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 Es=null;function Pi(){return Es||(Es=document.implementation.createHTMLDocument("title"))}let Hn=null;function ec(t){let e=window.trustedTypes;return e?(Hn||(Hn=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Hn.createHTML(t)):t}function tc(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Pi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Fi[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=ec(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function nc(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 rc(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=U.from(a.create(r[l+1],s)),i++,o++}return new q(s,i,o)}const Ve={},je={};function Xe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}je.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Vi(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ht&&We&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),kr&&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,Ci(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Qa(t,n)?n.preventDefault():Xe(t,"key")};je.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};je.keypress=(t,e)=>{let n=e;if(Vi(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Oe&&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 vn(t){return{left:t.clientX,top:t.clientY}}function sc(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Cr(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function St(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 ic(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&K.isSelectable(r)?(St(t,new K(n)),!0):!1}function oc(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof K&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(K.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(St(t,K.create(t.state.doc,s)),!0):!1}function lc(t,e,n,r,s){return Cr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?oc(t,n):ic(t,n))}function ac(t,e,n,r){return Cr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function cc(t,e,n,r){return Cr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||uc(t,n,r)}function uc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(St(t,Q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)St(t,Q.create(r,l+1,l+1+o.content.size));else if(K.isSelectable(o))St(t,K.create(r,l));else continue;return!0}}function wr(t){return un(t)}const $i=Oe?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&sc(n,t.input.lastClick)&&!n[$i]&&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(vn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new dc(t,o,n,!!r)):(i=="doubleClick"?ac:cc)(t,o.pos,o.inside,n)?n.preventDefault():Xe(t,"pointer"))};class dc{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[$i],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof K&&u.from<=o&&u.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)),Xe(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(()=>Sr(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(vn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Xe(this.view,"pointer"):lc(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||pt&&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)?(St(this.view,X.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Xe(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(),wr(t),Xe(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Xe(t,"pointer")};Ve.contextmenu=t=>wr(t);function Vi(t,e){return t.composing?!0:pt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const fc=Ht?5e3:-1;je.compositionstart=je.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&&Ei&&hc(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 l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}zi(t,fc)};function hc(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"}je.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++,zi(t,20))};function zi(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>un(t),e))}function pc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=mc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function mc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function un(t,e=!1){if(!(Ht&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),pc(t),e||t.docView&&t.docView.dirty){let n=za(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 gc(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Vt=_t&&Ai<15||kr&&Va<604;Ve.copy=je.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Vt?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Ii(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):gc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function xc(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?ir(t,r.value,null,s,e):ir(t,r.textContent,r.innerHTML,s,e)},50)}function ir(t,e,n,r,s){let i=Oi(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||q.empty)))return!0;if(!i)return!1;let o=yc(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Bi(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," "):""}je.paste=(t,e)=>{let n=e;if(t.composing&&!Ht)return;let r=Vt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ir(t,Bi(r),r.getData("text/html"),s,n)?n.preventDefault():xc(t,n)};class bc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const kc=Oe?"altKey":"ctrlKey";function _i(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[kc]}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(vn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof K?s.to-1:s.to))){if(r&&r.mightDrag)o=K.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=K.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:u,slice:d}=Ii(t,l);(!n.dataTransfer.files.length||!We||Ni>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vt||n.dataTransfer.setData("text/plain",u),t.dragging=new bc(d,_i(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};je.dragover=je.dragenter=(t,e)=>e.preventDefault();je.drop=(t,e)=>{try{vc(t,e,t.dragging)}finally{t.dragging=null}};function vc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(vn(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=Oi(t,Bi(e.dataTransfer),Vt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&_i(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||q.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?pi(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let u=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(d?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(f))return;let m=a.doc.resolve(u);if(d&&K.isSelectable(i.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new K(m));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((C,b,k,v)=>h=v),a.setSelection(Mi(t,m,a.doc.resolve(h)))}t.focus(),t.dispatch(a.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())&&Sr(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&&Ht&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Ci(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 je)Ve[t]=je[t];function zt(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 dn{constructor(e,n){this.toDOM=e,this.spec=n||dt,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 Be(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&zt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ye{constructor(e,n){this.attrs=e,this.spec=n||dt}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 Be(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ye&&zt(this.attrs,e.attrs)&&zt(this.spec,e.spec)}static is(e){return e.type instanceof Ye}destroy(){}}class Ar{constructor(e,n){this.attrs=e,this.spec=n||dt}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 Be(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 Ar&&zt(this.attrs,e.attrs)&&zt(this.spec,e.spec)}destroy(){}}class Be{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Be(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 Be(e,e,new dn(n,r))}static inline(e,n,r,s){return new Be(e,n,new Ye(r,s))}static node(e,n,r,s){return new Be(e,n,new Ar(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ye}get widget(){return this.type instanceof dn}}const bt=[],dt={};class he{constructor(e,n){this.local=e.length?e:bt,this.children=n.length?n:bt}static create(e,n){return n.length?fn(n,e,0,dt):Se}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==Se||e.maps.length==0?this:this.mapInner(e,n,0,0,r||dt)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Sc(this.children,o||[],e,n,r,s,i):o?new he(o.sort(ft),bt):Se}add(e,n){return n.length?this==Se?he.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let u=a+r,d;if(d=Ui(n,l,u)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,u+1):s.splice(i,0,a,a+l.nodeSize,fn(d,l,u+1,dt)),i+=3}});let o=Hi(i?qi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new he(o.length?this.local.concat(o).sort(ft):this.local,s||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<a&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(o,l+1);u!=Se?r[i+2]=u:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new he(s,r):Se}forChild(e,n){if(this==Se)return this;if(n.isLeaf)return he.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof Ye){let u=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;u<d&&(s||(s=[])).push(a.copy(u,d))}}if(s){let l=new he(s.sort(ft),bt);return r?new it([l,r]):l}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof he)||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 Nr(this.localsInner(e))}localsInner(e){if(this==Se)return bt;if(e.inlineContent||!this.local.some(Ye.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ye||n.push(this.local[r]);return n}forEachSet(e){e(this)}}he.empty=new he([],[]);he.removeOverlap=Nr;const Se=he.empty;class it{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,dt));return it.from(r)}forChild(e,n){if(n.isLeaf)return he.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Se&&(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?Nr(r?n:n.sort(ft)):bt}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new it(e.every(n=>n instanceof he)?e:e.reduce((n,r)=>n.concat(r instanceof he?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Sc(t,e,n,r,s,i,o){let l=t.slice();for(let u=0,d=i;u<n.maps.length;u++){let f=0;n.maps[u].forEach((m,h,C,b)=>{let k=b-C-(h-m);for(let v=0;v<l.length;v+=3){let A=l[v+1];if(A<0||m>A+d-f)continue;let N=l[v]+d-f;h>=N?l[v+1]=m<=N?-2:-1:m>=d&&k&&(l[v]+=k,l[v+1]+=k)}f+=k}),d=n.maps[u].map(d,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let d=n.map(t[u]+i),f=d-s;if(f<0||f>=r.content.size){a=!0;continue}let m=n.map(t[u+1]+i,-1),h=m-s,{index:C,offset:b}=r.content.findIndex(f),k=r.maybeChild(C);if(k&&b==f&&b+k.nodeSize==h){let v=l[u+2].mapInner(n,k,d+1,t[u]+i+1,o);v!=Se?(l[u]=f,l[u+1]=h,l[u+2]=v):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Cc(l,t,e,n,s,i,o),d=fn(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,m=0;f<d.children.length;f+=3){let h=d.children[f];for(;m<l.length&&l[m]<h;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new he(e.sort(ft),l)}function Hi(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 Be(s.from+e,s.to+e,s.type))}return n}function Cc(t,e,n,r,s,i,o){function l(a,u){for(let d=0;d<a.local.length;d++){let f=a.local[d].map(r,s,u);f?n.push(f):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+u+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ui(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 qi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function fn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Ui(t,l,a+n);if(u){i=!0;let d=fn(u,l,n+a+1,r);d!=Se&&s.push(a,a+l.nodeSize,d)}});let o=Hi(i?qi(t):t,-n).sort(ft);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new he(o,s):Se}function ft(t,e){return t.from-e.from||t.to-e.to}function Nr(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),Ts(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),Ts(e,s,r.copy(i.from,r.to)));break}}}return e}function Ts(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 q.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 Er(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!wc(e)||!Ac(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 l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(le.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!K.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(le.valid(l))return l}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;X.jsonID("gapcursor",le);class Er{constructor(e){this.pos=e}map(e){return new Er(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):X.near(n)}}function Ki(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function wc(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||Ki(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Ac(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||Ki(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Nc(){return new bn({props:{decorations:jc,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:Tc,handleKeyDown:Ec,handleDOMEvents:{beforeinput:Mc}}})}const Ec=Fa({ArrowLeft:Jt("horiz",-1),ArrowRight:Jt("horiz",1),ArrowUp:Jt("vert",-1),ArrowDown:Jt("vert",1)});function Jt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=le.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new le(u))),!0):!1}}function Tc(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&&K.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new le(r))),!0)}function Mc(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=U.empty;for(let o=r.length-1;o>=0;o--)s=U.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new q(s,0,0));return i.setSelection(Q.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function jc(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",he.create(t.doc,[Be.widget(t.selection.head,e,{key:"gapcursor"})])}const Ic=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Nc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=R.callOrReturn(R.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),At={bold:{category:"mark",extension:Ml,priority:100},italic:{category:"mark",extension:Ll,priority:100},strike:{category:"mark",extension:Pl,priority:100},underline:{category:"mark",extension:Ho.Underline,priority:100},code:{category:"mark",extension:zl,priority:100},textColor:{category:"mark",extension:Uo.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:qo.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Ko.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Hl,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Kl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Jl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Wo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ua,priority:100},blockquote:{category:"node",extension:fa,priority:100},horizontalRule:{category:"node",extension:ha,priority:100},hardBreak:{category:"node",extension:pa,priority:100},undo:{category:"extension",extension:ps,priority:50},redo:{category:"extension",extension:ps,priority:50},textAlign:{category:"extension",extension:Go.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}},Oc=[wa,Aa,Ul,_l.configure({HTMLAttributes:{}}),Gl.configure({HTMLAttributes:{}}),Jo.TaskItem.configure({nested:!0}),Ta,Ic];function Dc(t){const e=[],n=new Set,r=new Set;Oc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Rt(l)),i=new Set;return s.forEach(l=>{const a=At[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a||a.extension===null)return;const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),s.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a){console.warn(`Extension config not found for modifier: ${l}`);return}if(a.extension===null){n.add(l);return}const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),e.sort((l,a)=>{const u=Object.values(At).find(h=>h?.extension?.name===l.name),d=Object.values(At).find(h=>h?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Wi={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"]},ie={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"}}},ne={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Lc={h1:`font-size: ${ie.fontSize["4xl"]}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h2:`font-size: ${ie.fontSize["2xl"]}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h3:`font-size: ${ie.fontSize.xl}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h4:`font-size: ${ie.fontSize.lg}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h5:`font-size: ${ie.fontSize.base}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h6:`font-size: ${ie.fontSize.sm}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,p:`min-height: ${ie.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ne.xl}; margin: ${ne.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ne.xl}; margin: ${ne.md} 0;`,li:`display: list-item; margin: ${ne.xs} 0;`,strong:`font-weight: ${ie.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: ${ie.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ie.fontFamily.mono};`,pre:`background: ${Ge.neutral.gray[800]}; border-radius: ${ne.sm}; color: ${Ge.neutral.gray[100]}; font-family: ${ie.fontFamily.mono}; margin: ${ne.lg} 0; padding: 0.75rem ${ne.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ge.neutral.gray[300]}; margin: ${ne.lg} 0; padding-left: ${ne.md}; color: ${Ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ge.neutral.gray[200]}; margin: ${ne.xl} 0;`,a:`color: ${Ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ge.palettes.warning[200]}; border-radius: ${ne.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ne.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Rc={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 Fc(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Rc)){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(Lc)){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 Pc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=pr.useCurrentEditor();return c.jsx(wl,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},$c=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=pr.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"]})]})},or=x.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Wi.full,variant:u="bordered",initialContent:d,content:f,onContentChange:m,onUpdate:h,onToolbarAction:C,isReadOnly:b=!1,isDisabled:k=!1,includeInlineStyles:v=!0,...A}=t,{zoom:N,setZoom:w}=vl(),E=Gr.lineHeight,O=n*E,L=s?void 0:r*E,_=x.useMemo(()=>Dc(a),[a]),{Component:z,label:H,shouldLabelBeOutside:F,getBaseProps:j,getLabelProps:P,getInputWrapperProps:$}=g.useInput({...A,variant:u,ref:e,isMultiline:!0}),W=H?c.jsx("label",{...P(),children:H}):null,oe=x.useCallback(({editor:J})=>{const me=J.getHTML(),ae=v?Fc(me):me,ge=J.getJSON(),Le=J.getText(),Y=Le.length,Ie=Le.split(/\s+/).filter(Ae=>Ae.length>0).length,ee={html:ae,json:ge,text:Le,characters:Y,words:Ie};if(m?.(ee),h?.(ee),"onChange"in A&&typeof A.onChange=="function"){const Ae={target:{value:ae},currentTarget:{value:ae}};A.onChange(Ae)}},[m,h,A,v]);return c.jsxs(z,{...j(),children:[F?W:null,c.jsx("div",{...$(),className:g.cn($().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:L?`${L+Gr.toolbarHeight}px`:void 0,overflow:L?"auto":void 0},children:c.jsx(pr.EditorProvider,{editable:!b&&!k,slotBefore:l?c.jsx(Pc,{modifiers:a,zoom:N,onZoomChange:w,onToolbarAction:C}):void 0,slotAfter:c.jsx($c,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${O}px`,fontSize:`${N}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:_,content:f||d||t.defaultValue||"",onUpdate:oe})})]})});or.displayName="TipTapEditor";const Ji=x.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(or,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(or,{...s,variant:r,ref:e}))});Ji.displayName="RichTextArea";function Vc(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 Ms=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],zc={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Gi=({presetAmounts:t=Ms,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:o="en-US",showCustomAmount:l=!0,minCustomAmount:a=.5,maxCustomAmount:u=1e6,labels:d,mobileColumns:f=2,desktopColumns:m=3,isDisabled:h=!1,buttonVariant:C="bordered",buttonColor:b="default",inputVariant:k="bordered",size:v="md",className:A="",showCard:N=!0})=>{const w={...zc,...d},E=Array.isArray(t)?t:Ms,O={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"},_=`${O[f]} ${L[m]}`,[z,H]=mr(e,n,r),[F,j]=x.useState(""),[P,$]=x.useState(!1),[W,oe]=x.useState(0),J=x.useCallback(Y=>{if(h)return;const Ie={amount:Y.amount,isCustom:!1,presetId:Y.id};H(Ie),j(""),$(!1),oe(ee=>ee+1),s?.(Ie)},[h,H,s]),me=x.useCallback(Y=>{if(h)return;if(j(Y!==void 0?String(Y):""),s){H(null);return}if(Y===void 0||isNaN(Y)){H(null);return}H({amount:Y,isCustom:!0})},[h,H,s]),ae=x.useCallback(()=>{if(h)return;const Y=F!==""?parseFloat(F):void 0;Y===void 0||isNaN(Y)||s?.({amount:Y,isCustom:!0})},[h,F,s]),ge=x.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Le=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[w.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:w.title}),E.length>0&&c.jsx("div",{className:g.cn("grid gap-3",_),"data-testid":"donation-amounts-presets",children:E.map(Y=>{const Ie=z!==null&&!z.isCustom&&z.presetId===Y.id;return c.jsx(se,{color:Ie?"primary":b,variant:Ie?"solid":C,className:"w-full",onPress:()=>J(Y),isDisabled:h,"data-testid":`donation-amounts-preset-${Y.id}`,children:Y.label||Vc(Y.amount,o,i)},Y.id)})}),l&&c.jsxs("div",{className:"flex gap-3 items-start",children:[c.jsx(g.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,onInput:s?()=>{H(null),$(!0)}:void 0,variant:k,radius:"full",size:v,minValue:a,maxValue:u,step:.01,formatOptions:ge,value:F!==""?parseFloat(F):void 0,onValueChange:me,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-${W}`:z?.isCustom===!1?z.presetId:"custom"),s&&c.jsx(se,{color:"primary",variant:"solid",radius:"full",size:v,className:"shrink-0",onPress:ae,isDisabled:h||!P,"data-testid":"donation-amounts-add-button",children:w.addDonationButton})]})]});return N?c.jsx(g.Card,{className:g.cn("w-full",A),"data-testid":"donation-amounts-card",children:c.jsx(g.CardBody,{children:Le})}):c.jsx("div",{className:g.cn("w-full",A),"data-testid":"donation-amounts-plain",children:Le})};Gi.displayName="DonationAmounts";const Bc=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`},_c=t=>{switch(t){case"warning":return B.Clock;case"error":return B.AlertCircle;case"success":return B.CheckCircle;default:return B.Clock}},Hc=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"}},Zi=x.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:a,position:u="fixed",autoStart:d=!0,formatTime:f=Bc,className:m,...h},C)=>{const[b,k]=mr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),v=x.useRef(null),A=x.useRef(!1);x.useEffect(()=>()=>{v.current&&clearInterval(v.current)},[]),x.useEffect(()=>{if(!d||b<=0){v.current&&(clearInterval(v.current),v.current=null);return}return v.current=setInterval(()=>{k(O=>O<=1?(v.current&&(clearInterval(v.current),v.current=null),A.current||(A.current=!0,r?.()),0):O-1)},1e3),()=>{v.current&&(clearInterval(v.current),v.current=null)}},[d,b,k,r]),x.useEffect(()=>{b>0&&(A.current=!1)},[b]);const N=a||_c(s),w=Hc(i),E={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:C,role:"banner","aria-live":"polite","aria-label":`${o} ${f(b)}`,"data-testid":"expire-cart-timer",className:g.cn("w-full text-white z-50",w,E[u],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:[l&&c.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:c.jsx(N,{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)})})]})})})});Zi.displayName="ExpireCartTimer";function Uc(t,e){const n=t.icons,r=t.aliases||Object.create(null),s=Object.create(null);function i(o){if(n[o])return s[o]=[];if(!(o in s)){s[o]=null;const l=r[o]&&r[o].parent,a=l&&i(l);a&&(s[o]=[l].concat(a))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Qi=Object.freeze({left:0,top:0,width:16,height:16}),hn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Tr=Object.freeze({...Qi,...hn}),lr=Object.freeze({...Tr,body:"",hidden:!1});function qc(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 js(t,e){const n=qc(t,e);for(const r in lr)r in hn?r in t&&!(r in n)&&(n[r]=hn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Kc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=js(r[l]||s[l],i)}return o(e),n.forEach(o),js(t,i)}function Xi(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=Uc(t);for(const s in r){const i=r[s];i&&(e(s,Kc(t,s,i)),n.push(s))}return n}const Wc={provider:"",aliases:{},not_found:{},...Qi};function Un(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Yi(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Un(t,Wc))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Un(i,lr))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]||!Un(i,lr))return null}return e}const Is=Object.create(null);function Jc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function Ct(t,e){const n=Is[t]||(Is[t]=Object.create(null));return n[e]||(n[e]=Jc(t,e))}function eo(t,e){return Yi(e)?Xi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Gc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const to=/^[a-z0-9]+(-[a-z0-9]+)*$/,Sn=(t,e,n,r="")=>{const s=t.split(":");if(t.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),a=s.pop(),u={provider:s.length>0?s[0]:r,prefix:a,name:l};return e&&!Yt(u)?null:u}const i=s[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!Yt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Yt(l,n)?null:l}return null},Yt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Bt=!1;function no(t){return typeof t=="boolean"&&(Bt=t),Bt}function Os(t){const e=typeof t=="string"?Sn(t,!0,Bt):t;if(e){const n=Ct(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Zc(t,e){const n=Sn(t,!0,Bt);if(!n)return!1;const r=Ct(n.provider,n.prefix);return e?Gc(r,n.name,e):(r.missing.add(n.name),!0)}function Qc(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Bt&&!e&&!t.prefix){let s=!1;return Yi(t)&&(t.prefix="",Xi(t,(i,o)=>{Zc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Yt({prefix:n,name:"a"}))return!1;const r=Ct(e,n);return!!eo(r,t)}const ro=Object.freeze({width:null,height:null}),so=Object.freeze({...ro,...hn}),Xc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Yc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ds(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(Xc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Yc.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function eu(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 tu(t,e){return t?"<defs>"+t+"</defs>"+e:e}function nu(t,e,n){const r=eu(t);return tu(r.defs,e+r.content+n)}const ru=t=>t==="unset"||t==="undefined"||t==="none";function su(t,e){const n={...Tr,...t},r={...so,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const k=[],v=b.hFlip,A=b.vFlip;let N=b.rotate;v?A?N+=2:(k.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),k.push("scale(-1 1)"),s.top=s.left=0):A&&(k.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),k.push("scale(1 -1)"),s.top=s.left=0);let w;switch(N<0&&(N-=Math.floor(N/4)*4),N=N%4,N){case 1:w=s.height/2+s.top,k.unshift("rotate(90 "+w.toString()+" "+w.toString()+")");break;case 2:k.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:w=s.width/2+s.left,k.unshift("rotate(-90 "+w.toString()+" "+w.toString()+")");break}N%2===1&&(s.left!==s.top&&(w=s.left,s.left=s.top,s.top=w),s.width!==s.height&&(w=s.width,s.width=s.height,s.height=w)),k.length&&(i=nu(i,'<g transform="'+k.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,a=s.width,u=s.height;let d,f;o===null?(f=l===null?"1em":l==="auto"?u:l,d=Ds(f,a/u)):(d=o==="auto"?a:o,f=l===null?Ds(d,u/a):l==="auto"?u:l);const m={},h=(b,k)=>{ru(k)||(m[b]=k.toString())};h("width",d),h("height",f);const C=[s.left,s.top,a,u];return m.viewBox=C.join(" "),{attributes:m,viewBox:C,body:i}}const iu=/\sid="(\S+)"/g,ou="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let lu=0;function au(t,e=ou){const n=[];let r;for(;r=iu.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+(lu++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const ar=Object.create(null);function cu(t,e){ar[t]=e}function cr(t){return ar[t]||ar[""]}function Mr(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 jr=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],en=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?en.push(Nt.shift()):en.push(Nt.pop());jr[""]=Mr({resources:["https://api.iconify.design"].concat(en)});function uu(t,e){const n=Mr(e);return n===null?!1:(jr[t]=n,!0)}function Ir(t){return jr[t]}const du=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ls=du();function fu(t,e){const n=Ir(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 hu(t){return t===404}const pu=(t,e,n)=>{const r=[],s=fu(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,u)=>{l+=a.length+1,l>=s&&u>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},l=a.length),o.icons.push(a)}),r.push(o),r};function mu(t){if(typeof t=="string"){const e=Ir(t);if(e)return e.path}return"/"}const gu=(t,e,n)=>{if(!Ls){n("abort",424);return}let r=mu(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});r+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;Ls(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(hu(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)})},yu={prepare:pu,send:gu};function io(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function xu(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(a=>{if(a.prefix!==s)return!0;const u=a.name;if(t.icons[u])o.loaded.push({provider:r,prefix:s,name:u});else if(t.missing.has(u))o.missing.push({provider:r,prefix:s,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||io([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let bu=0;function ku(t,e,n){const r=bu++,s=io.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 vu(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return t.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,o=s.prefix,l=s.name,a=n[i]||(n[i]=Object.create(null)),u=a[o]||(a[o]=Ct(i,o));let d;l in u.icons?d=e.loaded:o===""||u.missing.has(l)?d=e.missing:d=e.pending;const f={provider:i,prefix:o,name:l};d.push(f)}),e}function Su(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?Sn(s,e,n):s;i&&r.push(i)}),r}const Cu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wu(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 O=t.resources.slice(0);for(o=[];O.length>1;){const L=Math.floor(Math.random()*O.length);o.push(O[L]),O=O.slice(0,L).concat(O.slice(L+1))}o=o.concat(O)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",u=0,d,f=null,m=[],h=[];typeof r=="function"&&h.push(r);function C(){f&&(clearTimeout(f),f=null)}function b(){a==="pending"&&(a="aborted"),C(),m.forEach(O=>{O.status==="pending"&&(O.status="aborted")}),m=[]}function k(O,L){L&&(h=[]),typeof O=="function"&&h.push(O)}function v(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:m.length,subscribe:k,abort:b}}function A(){a="failed",h.forEach(O=>{O(void 0,d)})}function N(){m.forEach(O=>{O.status==="pending"&&(O.status="aborted")}),m=[]}function w(O,L,_){const z=L!=="success";switch(m=m.filter(H=>H!==O),a){case"pending":break;case"failed":if(z||!t.dataAfterTimeout)return;break;default:return}if(L==="abort"){d=_,A();return}if(z){d=_,m.length||(o.length?E():A());return}if(C(),N(),!t.random){const H=t.resources.indexOf(O.resource);H!==-1&&H!==t.index&&(t.index=H)}a="completed",h.forEach(H=>{H(_)})}function E(){if(a!=="pending")return;C();const O=o.shift();if(O===void 0){if(m.length){f=setTimeout(()=>{C(),a==="pending"&&(N(),A())},t.timeout);return}A();return}const L={status:"pending",resource:O,callback:(_,z)=>{w(L,_,z)}};m.push(L),u++,f=setTimeout(E,t.rotate),n(O,e,L.callback)}return setTimeout(E),v}function oo(t){const e={...Cu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=wu(e,l,a,(f,m)=>{r(),u&&u(f,m)});return n.push(d),d}function i(l){return n.find(a=>l(a))||null}return{query:s,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:r}}function Rs(){}const qn=Object.create(null);function Au(t){if(!qn[t]){const e=Ir(t);if(!e)return;const n=oo(e),r={config:e,redundancy:n};qn[t]=r}return qn[t]}function Nu(t,e,n){let r,s;if(typeof t=="string"){const i=cr(t);if(!i)return n(void 0,424),Rs;s=i.send;const o=Au(t);o&&(r=o.redundancy)}else{const i=Mr(t);if(i){r=oo(i);const o=t.resources?t.resources[0]:"",l=cr(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),Rs):r.query(e,s,n)().abort}function Fs(){}function Eu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,xu(t)}))}function Tu(t){const e=[],n=[];return t.forEach(r=>{(r.match(to)?e:n).push(r)}),{valid:e,invalid:n}}function Et(t,e,n){function r(){const s=t.pendingIcons;e.forEach(i=>{s&&s.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!eo(t,n).length){r();return}}catch(s){console.error(s)}r(),Eu(t)}function Ps(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Mu(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)){Ps(t.loadIcons(s,r,n),d=>{Et(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Ps(f,m=>{const h=m?{prefix:r,icons:{[d]:m}}:null;Et(t,[d],h)})});return}const{valid:o,invalid:l}=Tu(s);if(l.length&&Et(t,l,null),!o.length)return;const a=r.match(to)?cr(n):null;if(!a){Et(t,o,null);return}a.prepare(n,r,o).forEach(d=>{Nu(n,d,f=>{Et(t,d.icons,f)})})}))}const ju=(t,e)=>{const n=Su(t,!0,no()),r=vu(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Fs)}),()=>{a=!1}}const s=Object.create(null),i=[];let o,l;return r.pending.forEach(a=>{const{provider:u,prefix:d}=a;if(d===l&&u===o)return;o=u,l=d,i.push(Ct(u,d));const f=s[u]||(s[u]=Object.create(null));f[d]||(f[d]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:d,name:f}=a,m=Ct(u,d),h=m.pendingIcons||(m.pendingIcons=new Set);h.has(f)||(h.add(f),s[u][d].push(f))}),i.forEach(a=>{const u=s[a.provider][a.prefix];u.length&&Mu(a,u)}),e?ku(e,r,i):Fs};function Iu(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in ro?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Ou=/[\s,]+/;function Du(t,e){e.split(Ou).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Lu(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 Ru(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 Fu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Pu(t){return"data:image/svg+xml,"+Fu(t)}function $u(t){return'url("'+Pu(t)+'")'}let Ot;function Vu(){try{Ot=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Ot=null}}function zu(t){return Ot===void 0&&Vu(),Ot?Ot.createHTML(t):t}const lo={...so,inline:!1},Bu={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},_u={display:"inline-block"},ur={backgroundColor:"currentColor"},ao={backgroundColor:"transparent"},$s={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Vs={WebkitMask:ur,mask:ur,background:ao};for(const t in Vs){const e=Vs[t];for(const n in $s)e[t+n]=$s[n]}const Hu={...lo,inline:!0};function zs(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Uu=(t,e,n)=>{const r=e.inline?Hu:lo,s=Iu(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Bu:{}};if(n){const k=Sn(n,!1,!0);if(k){const v=["iconify"],A=["provider","prefix"];for(const N of A)k[N]&&v.push("iconify--"+k[N]);a.className=v.join(" ")}}for(let k in e){const v=e[k];if(v!==void 0)switch(k){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=v;break;case"className":a[k]=(a[k]?a[k]+" ":"")+v;break;case"inline":case"hFlip":case"vFlip":s[k]=v===!0||v==="true"||v===1;break;case"flip":typeof v=="string"&&Du(s,v);break;case"color":o.color=v;break;case"rotate":typeof v=="string"?s[k]=Lu(v):typeof v=="number"&&(s[k]=v);break;case"ariaHidden":case"aria-hidden":v!==!0&&v!=="true"&&delete a["aria-hidden"];break;default:r[k]===void 0&&(a[k]=v)}}const u=su(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let k=0,v=e.id;return typeof v=="string"&&(v=v.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:zu(au(u.body,v?()=>v+"ID"+k++:"iconifyReact"))},x.createElement("svg",a)}const{body:f,width:m,height:h}=t,C=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=Ru(f,{...d,width:m+"",height:h+""});return a.style={...o,"--svg":$u(b),width:zs(d.width),height:zs(d.height),..._u,...C?ur:ao,...l},x.createElement("span",a)};no(!0);cu("",yu);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"||!Qc(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;uu(n,s)||console.error(r)}catch{console.error(r)}}}}function co(t){const[e,n]=x.useState(!!t.ssr),[r,s]=x.useState({});function i(h){if(h){const C=t.icon;if(typeof C=="object")return{name:"",data:C};const b=Os(C);if(b)return{name:C,data:b}}return{name:""}}const[o,l]=x.useState(i(!!t.ssr));function a(){const h=r.callback;h&&(h(),s({}))}function u(h){if(JSON.stringify(o)!==JSON.stringify(h))return a(),l(h),!0}function d(){var h;const C=t.icon;if(typeof C=="object"){u({name:"",data:C});return}const b=Os(C);if(u({name:C,data:b}))if(b===void 0){const k=ju([C],d);s({callback:k})}else b&&((h=t.onLoad)===null||h===void 0||h.call(t,C))}x.useEffect(()=>(n(!0),a),[]),x.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:m}=o;return m?Uu({...Tr,...m},t,f):t.children?t.children:t.fallback?t.fallback:x.createElement("span",{})}const Te=x.forwardRef((t,e)=>co({...t,_ref:e}));x.forwardRef((t,e)=>co({inline:!0,...t,_ref:e}));const Kn=({icon:t,children:e,testId:n})=>c.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[c.jsx(Te,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),qu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,imageLoading:a="eager",showMoreButtonClassName:u,labels:d})=>{const[f,m]=x.useState(!1),[h,C]=x.useState(!1),b=x.useRef(null);return x.useEffect(()=>{const k=()=>{if(b.current){const v=b.current.scrollHeight>b.current.clientHeight;C(v)}};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[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:[l&&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:a,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:d.eventInformation}),c.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&c.jsx(Kn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(Kn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(Kn,{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(se,{onPress:()=>m(!f),variant:"light",className:g.cn("text-primary",u),startContent:c.jsx(Te,{icon:f?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:f?d.showLess||"Hide":d.showMore||"Show"})})]})]})]})};function uo(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 Ku(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 Wu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Gt=t=>typeof t=="number"&&!isNaN(t),Or=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:l,isDisabled:a=!1,buttonVariant:u="bordered",buttonColor:d="default",showCard:f=!0,showDescription:m=!0,showPeopleCount:h=!0,showPrice:C=!0,classNames:b={},"data-testid":k,selectedColor:v="default"})=>{const A={...Wu,...o},[N,w]=x.useState(n),E=e!==void 0?e:N,O=ae=>{if(a)return;const ge=Math.max(0,E+ae);e===void 0&&w(ge),r?.(t.id,ge)},L=x.useMemo(()=>!Gt(t.totalTicketsSold)||!Gt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),_=x.useMemo(()=>L||!Gt(t.ticketsAllowed)?!1:E>=t.ticketsAllowed-(t.totalTicketsSold??0),[L,t.ticketsAllowed,t.totalTicketsSold,E]),z=uo(t.price,i,s),H=()=>l?.renderName?l.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:g.cn("text-base font-medium",b.name),children:t.name}),F=()=>C?l?.renderPrice?l.renderPrice(t.price,z,t):c.jsx("p",{"data-testid":"offer-card-price",className:g.cn("text-primary text-base mt-1",b.price),children:z}):null,j=()=>!m||!t.description?null:l?.renderDescription?l.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}),P=()=>{if(!h||!Gt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ae=t.numberOfPeople===1?A.person:A.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,ae,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(Te,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ae]})},$=()=>{const ae=E===0||a,ge=_||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:E,onIncrement:()=>O(1),onDecrement:()=>O(-1),isDecrementDisabled:ae,isIncrementDisabled:ge,isDisabled:a}):c.jsxs("div",{className:g.cn("flex items-center gap-2",b.quantitySelector),children:[c.jsx(se,{"data-testid":"offer-card-decrement-button",onPress:()=>O(-1),isDisabled:ae,variant:u,color:E>0?v:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Te,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:g.cn("min-w-[2rem] text-center font-medium"),children:E}),c.jsx(se,{"data-testid":"offer-card-increment-button",onPress:()=>O(1),isDisabled:ge,variant:u,color:E>0?v:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Te,{icon:"gravity-ui:plus",width:16})})]})},W=()=>l?.renderSoldOut?l.renderSoldOut(A.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(Te,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:A.soldOut})}),oe=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(A.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(Te,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:A.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(),F(),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:[P(),j()]})]}),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?W():$()})]}),me=_&&!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:oe()});return f?c.jsxs(g.Card,{className:g.cn("w-full",b.base),"data-testid":k||`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:me&&c.jsx(g.CardFooter,{className:g.cn("w-full mt-0 pt-0",b.footer),children:me})})]}):c.jsxs("div",{className:g.cn("w-full",b.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx("div",{className:g.cn("pt-1 pb-0",b.body),children:J}),c.jsx($e.AnimatePresence,{children:me&&c.jsx("div",{className:g.cn("w-full mt-0 pt-0",b.footer),children:me})})]})};Or.displayName="OfferCard";const fo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?c.jsx(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:l})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:l})}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(Te,{"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})};fo.displayName="OfferCardEmpty";const Ju={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ho=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Ju,...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})};ho.displayName="OfferCardError";const Gu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},po=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Gu[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))})};po.displayName="OfferCardSkeleton";const mo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},go={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},Zu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},yo=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:l,slots:a,isDisabled:u=!1,buttonVariant:d="bordered",buttonColor:f="default",showCard:m=!0,animated:h=!0,gap:C=2,classNames:b={}})=>{const[k,v]=x.useState(n),A=e!==void 0?e:k,N=x.useCallback((_,z)=>{const H={...A,[_]:Math.max(0,z)};e===void 0&&v(H),r?.(H),s?.(_,H[_])},[A,e,r,s]),w=[...t].sort((_,z)=>(_.position??0)-(z.position??0)),E=Zu[C],O=g.cn("grid mx-auto pt-2",E,b.base),L=_=>c.jsx(Or,{offer:_,quantity:A[_.id]||0,onQuantityChange:N,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:m,classNames:b.card},_.id);return h?c.jsx($e.motion.div,{"data-testid":"offer-card-list",className:O,variants:mo,initial:"hidden",animate:"show",children:c.jsx($e.AnimatePresence,{children:w.map(_=>c.jsx($e.motion.div,{"data-testid":`offer-card-list-item-${_.id}`,className:b.cardWrapper,variants:go,exit:{opacity:0,y:-20},transition:{duration:.3},children:L(_)},_.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:O,children:w.map(L)})};yo.displayName="OfferCardList";var Ut=t=>t.type==="checkbox",ct=t=>t instanceof Date,we=t=>t==null;const xo=t=>typeof t=="object";var fe=t=>!we(t)&&!Array.isArray(t)&&xo(t)&&!ct(t),bo=t=>fe(t)&&t.target?Ut(t.target)?t.target.checked:t.target.value:t,Qu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,ko=(t,e)=>t.has(Qu(e)),Xu=t=>{const e=t.constructor&&t.constructor.prototype;return fe(e)&&e.hasOwnProperty("isPrototypeOf")},Dr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ce(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Dr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(fe(t)&&Xu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=ce(t[s]));return r}var Cn=t=>/^\w*$/.test(t),re=t=>t===void 0,Lr=t=>Array.isArray(t)?t.filter(Boolean):[],Rr=t=>Lr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),I=(t,e,n)=>{if(!e||!fe(t))return n;const r=(Cn(e)?[e]:Rr(e)).reduce((s,i)=>we(s)?s:s[i],t);return re(r)||r===t?re(t[e])?n:t[e]:r},Ne=t=>typeof t=="boolean",Ce=t=>typeof t=="function",te=(t,e,n)=>{let r=-1;const s=Cn(e)?[e]:Rr(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let a=n;if(r!==o){const u=t[l];a=fe(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const pn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Fe={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"},vo=x.createContext(null);vo.displayName="HookFormControlContext";const Fr=()=>x.useContext(vo);var So=(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]!==Fe.all&&(e._proxyFormState[o]=!r||Fe.all),n&&(n[o]=!0),t[o]}});return s};const Pr=typeof window<"u"?x.useLayoutEffect:x.useEffect;function Yu(t){const e=Fr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=x.useState(n._formState),a=x.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Pr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),x.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),x.useMemo(()=>So(o,n,a.current,!1),[o,n])}var Me=t=>typeof t=="string",dr=(t,e,n,r,s)=>Me(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),fr=t=>we(t)||!xo(t);function Pe(t,e,n=new WeakSet){if(fr(t)||fr(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 l=e[i];if(ct(o)&&ct(l)||fe(o)&&fe(l)||Array.isArray(o)&&Array.isArray(l)?!Pe(o,l,n):!Object.is(o,l))return!1}}return!0}function ed(t){const e=Fr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=x.useRef(s),u=x.useRef(l),d=x.useRef(void 0),f=x.useRef(n),m=x.useRef(r);u.current=l;const[h,C]=x.useState(()=>{const w=n._getWatch(r,a.current);return u.current?u.current(w):w}),b=x.useCallback(w=>{const E=dr(r,n._names,w||n._formValues,!1,a.current);return u.current?u.current(E):E},[n._formValues,n._names,r]),k=x.useCallback(w=>{if(!i){const E=dr(r,n._names,w||n._formValues,!1,a.current);if(u.current){const O=u.current(E);Pe(O,d.current)||(C(O),d.current=O)}else C(E)}},[n._formValues,n._names,i,r]);Pr(()=>((f.current!==n||!Pe(m.current,r))&&(f.current=n,m.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:w=>{k(w.values)}})),[n,o,r,k]),x.useEffect(()=>n._removeUnmounted());const v=f.current!==n,A=m.current,N=x.useMemo(()=>{if(i)return null;const w=!v&&!Pe(A,r);return v||w?b():null},[i,v,r,A,b]);return N!==null?N:h}function td(t){const e=Fr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=ko(s._names.array,n),u=x.useMemo(()=>I(s._formValues,n,I(s._defaultValues,n,o)),[s,n,o]),d=ed({control:s,name:n,defaultValue:u,exact:l}),f=Yu({control:s,name:n,exact:l}),m=x.useRef(t),h=x.useRef(void 0),C=x.useRef(s.register(n,{...t.rules,value:d,...Ne(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]),k=x.useCallback(w=>C.current.onChange({target:{value:bo(w),name:n},type:pn.CHANGE}),[n]),v=x.useCallback(()=>C.current.onBlur({target:{value:I(s._formValues,n),name:n},type:pn.BLUR}),[n,s._formValues]),A=x.useCallback(w=>{const E=I(s._fields,n);E&&E._f&&w&&(E._f.ref={focus:()=>Ce(w.focus)&&w.focus(),select:()=>Ce(w.select)&&w.select(),setCustomValidity:O=>Ce(w.setCustomValidity)&&w.setCustomValidity(O),reportValidity:()=>Ce(w.reportValidity)&&w.reportValidity()})},[s._fields,n]),N=x.useMemo(()=>({name:n,value:d,...Ne(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:k,onBlur:v,ref:A}),[n,r,f.disabled,k,v,A,d]);return x.useEffect(()=>{const w=s._options.shouldUnregister||i,E=h.current;E&&E!==n&&!a&&s.unregister(E),s.register(n,{...m.current.rules,...Ne(m.current.disabled)?{disabled:m.current.disabled}:{}});const O=(L,_)=>{const z=I(s._fields,L);z&&z._f&&(z._f.mount=_)};if(O(n,!0),w){const L=ce(I(s._options.defaultValues,n,m.current.defaultValue));te(s._defaultValues,n,L),re(I(s._formValues,n))&&te(s._formValues,n,L)}return!a&&s.register(n),h.current=n,()=>{(a?w&&!s._state.action:w)?s.unregister(n):O(n,!1)}},[n,s,a,i]),x.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),x.useMemo(()=>({field:N,formState:f,fieldState:b}),[N,f,b])}const nd=x.createContext(null);nd.displayName="HookFormContext";var rd=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Dt=t=>Array.isArray(t)?t:[t],Bs=()=>{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 Co(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&fe(s)&&i){const o=Co(s,i);fe(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ve=t=>fe(t)&&!Object.keys(t).length,$r=t=>t.type==="file",mn=t=>{if(!Dr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},wo=t=>t.type==="select-multiple",Vr=t=>t.type==="radio",sd=t=>Vr(t)||Ut(t),Wn=t=>mn(t)&&t.isConnected;function id(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=re(t)?r++:t[e[r++]];return t}function od(t){for(const e in t)if(t.hasOwnProperty(e)&&!re(t[e]))return!1;return!0}function ue(t,e){const n=Array.isArray(e)?e:Cn(e)?[e]:Rr(e),r=n.length===1?t:id(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(fe(r)&&ve(r)||Array.isArray(r)&&od(r))&&ue(t,n.slice(0,-1)),t}var ld=t=>{for(const e in t)if(Ce(t[e]))return!0;return!1};function Ao(t){return Array.isArray(t)||fe(t)&&!ld(t)}function hr(t,e={}){for(const n in t){const r=t[n];Ao(r)?(e[n]=Array.isArray(r)?[]:{},hr(r,e[n])):re(r)||(e[n]=!0)}return e}function kt(t,e,n){n||(n=hr(e));for(const r in t){const s=t[r];if(Ao(s))re(e)||fr(n[r])?n[r]=hr(s,Array.isArray(s)?[]:{}):kt(s,we(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Pe(s,i)}}return n}const _s={value:!1,isValid:!1},Hs={value:!0,isValid:!0};var No=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!re(t[0].attributes.value)?re(t[0].value)||t[0].value===""?Hs:{value:t[0].value,isValid:!0}:Hs:_s}return _s},Eo=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>re(t)?t:e?t===""?NaN:t&&+t:n&&Me(t)?new Date(t):r?r(t):t;const Us={isValid:!1,value:null};var To=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Us):Us;function qs(t){const e=t.ref;return $r(e)?e.files:Vr(e)?To(t.refs).value:wo(e)?[...e.selectedOptions].map(({value:n})=>n):Ut(e)?No(t.refs).value:Eo(re(e.value)?t.ref.value:e.value,t)}var ad=(t,e,n,r)=>{const s={};for(const i of t){const o=I(e,i);o&&te(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},gn=t=>t instanceof RegExp,Tt=t=>re(t)?t:gn(t)?t.source:fe(t)?gn(t.value)?t.value.source:t.value:t,Ks=t=>({isOnSubmit:!t||t===Fe.onSubmit,isOnBlur:t===Fe.onBlur,isOnChange:t===Fe.onChange,isOnAll:t===Fe.all,isOnTouch:t===Fe.onTouched});const Ws="AsyncFunction";var cd=t=>!!t&&!!t.validate&&!!(Ce(t.validate)&&t.validate.constructor.name===Ws||fe(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Ws)),ud=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Js=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Lt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=I(t,s);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(Lt(l,e))break}else if(fe(l)&&Lt(l,e))break}}};function Gs(t,e,n){const r=I(t,n);if(r||Cn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=I(e,i),l=I(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var dd=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ve(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Fe.all))},fd=(t,e,n)=>!t||!e||t===e||Dt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),hd=(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,pd=(t,e)=>!Lr(I(t,e)).length&&ue(t,e),md=(t,e,n)=>{const r=Dt(I(t,n));return te(r,"root",e[n]),te(t,n,r),t};function Zs(t,e,n="validate"){if(Me(t)||Array.isArray(t)&&t.every(Me)||Ne(t)&&!t)return{type:n,message:Me(t)?t:"",ref:e}}var gt=t=>fe(t)&&!gn(t)?t:{value:t,message:""},Qs=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:a,maxLength:u,minLength:d,min:f,max:m,pattern:h,validate:C,name:b,valueAsNumber:k,mount:v}=t._f,A=I(n,b);if(!v||e.has(b))return{};const N=l?l[0]:o,w=j=>{s&&N.reportValidity&&(N.setCustomValidity(Ne(j)?"":j||""),N.reportValidity())},E={},O=Vr(o),L=Ut(o),_=O||L,z=(k||$r(o))&&re(o.value)&&re(A)||mn(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,H=rd.bind(null,b,r,E),F=(j,P,$,W=Ue.maxLength,oe=Ue.minLength)=>{const J=j?P:$;E[b]={type:j?W:oe,message:J,ref:o,...H(j?W:oe,J)}};if(i?!Array.isArray(A)||!A.length:a&&(!_&&(z||we(A))||Ne(A)&&!A||L&&!No(l).isValid||O&&!To(l).isValid)){const{value:j,message:P}=Me(a)?{value:!!a,message:a}:gt(a);if(j&&(E[b]={type:Ue.required,message:P,ref:N,...H(Ue.required,P)},!r))return w(P),E}if(!z&&(!we(f)||!we(m))){let j,P;const $=gt(m),W=gt(f);if(!we(A)&&!isNaN(A)){const oe=o.valueAsNumber||A&&+A;we($.value)||(j=oe>$.value),we(W.value)||(P=oe<W.value)}else{const oe=o.valueAsDate||new Date(A),J=ge=>new Date(new Date().toDateString()+" "+ge),me=o.type=="time",ae=o.type=="week";Me($.value)&&A&&(j=me?J(A)>J($.value):ae?A>$.value:oe>new Date($.value)),Me(W.value)&&A&&(P=me?J(A)<J(W.value):ae?A<W.value:oe<new Date(W.value))}if((j||P)&&(F(!!j,$.message,W.message,Ue.max,Ue.min),!r))return w(E[b].message),E}if((u||d)&&!z&&(Me(A)||i&&Array.isArray(A))){const j=gt(u),P=gt(d),$=!we(j.value)&&A.length>+j.value,W=!we(P.value)&&A.length<+P.value;if(($||W)&&(F($,j.message,P.message),!r))return w(E[b].message),E}if(h&&!z&&Me(A)){const{value:j,message:P}=gt(h);if(gn(j)&&!A.match(j)&&(E[b]={type:Ue.pattern,message:P,ref:o,...H(Ue.pattern,P)},!r))return w(P),E}if(C){if(Ce(C)){const j=await C(A,n),P=Zs(j,N);if(P&&(E[b]={...P,...H(Ue.validate,P.message)},!r))return w(P.message),E}else if(fe(C)){let j={};for(const P in C){if(!ve(j)&&!r)break;const $=Zs(await C[P](A,n),N,P);$&&(j={...$,...H(P,$.message)},w($.message),r&&(E[b]=j))}if(!ve(j)&&(E[b]={ref:N,...j},!r))return E}}return w(!0),E};const gd={mode:Fe.onSubmit,reValidateMode:Fe.onChange,shouldFocusError:!0};function yd(t={}){let e={...gd,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ce(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=fe(e.defaultValues)||fe(e.values)?ce(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:ce(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},a,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let m={...f};const h={array:Bs(),state:Bs()},C=e.criteriaMode===Fe.all,b=p=>y=>{clearTimeout(u),u=setTimeout(p,y)},k=async p=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||m.isValid||p)){let y;e.resolver?(y=ve((await _()).errors),v()):y=await H(r,!0),y!==n.isValid&&h.state.next({isValid:y})}},v=(p,y)=>{!e.disabled&&(f.isValidating||f.validatingFields||m.isValidating||m.validatingFields)&&((p||Array.from(l.mount)).forEach(S=>{S&&(y?te(n.validatingFields,S,y):ue(n.validatingFields,S))}),h.state.next({validatingFields:n.validatingFields,isValidating:!ve(n.validatingFields)}))},A=(p,y=[],S,D,M=!0,T=!0)=>{if(D&&S&&!e.disabled){if(o.action=!0,T&&Array.isArray(I(r,p))){const V=S(I(r,p),D.argA,D.argB);M&&te(r,p,V)}if(T&&Array.isArray(I(n.errors,p))){const V=S(I(n.errors,p),D.argA,D.argB);M&&te(n.errors,p,V),pd(n.errors,p)}if((f.touchedFields||m.touchedFields)&&T&&Array.isArray(I(n.touchedFields,p))){const V=S(I(n.touchedFields,p),D.argA,D.argB);M&&te(n.touchedFields,p,V)}(f.dirtyFields||m.dirtyFields)&&(n.dirtyFields=kt(s,i)),h.state.next({name:p,isDirty:j(p,y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else te(i,p,y)},N=(p,y)=>{te(n.errors,p,y),h.state.next({errors:n.errors})},w=p=>{n.errors=p,h.state.next({errors:n.errors,isValid:!1})},E=(p,y,S,D)=>{const M=I(r,p);if(M){const T=I(i,p,re(S)?I(s,p):S);re(T)||D&&D.defaultChecked||y?te(i,p,y?T:qs(M._f)):W(p,T),o.mount&&!o.action&&k()}},O=(p,y,S,D,M)=>{let T=!1,V=!1;const G={name:p};if(!e.disabled){if(!S||D){(f.isDirty||m.isDirty)&&(V=n.isDirty,n.isDirty=G.isDirty=j(),T=V!==G.isDirty);const Z=Pe(I(s,p),y);V=!!I(n.dirtyFields,p),Z?ue(n.dirtyFields,p):te(n.dirtyFields,p,!0),G.dirtyFields=n.dirtyFields,T=T||(f.dirtyFields||m.dirtyFields)&&V!==!Z}if(S){const Z=I(n.touchedFields,p);Z||(te(n.touchedFields,p,S),G.touchedFields=n.touchedFields,T=T||(f.touchedFields||m.touchedFields)&&Z!==S)}T&&M&&h.state.next(G)}return T?G:{}},L=(p,y,S,D)=>{const M=I(n.errors,p),T=(f.isValid||m.isValid)&&Ne(y)&&n.isValid!==y;if(e.delayError&&S?(a=b(()=>N(p,S)),a(e.delayError)):(clearTimeout(u),a=null,S?te(n.errors,p,S):ue(n.errors,p)),(S?!Pe(M,S):M)||!ve(D)||T){const V={...D,...T&&Ne(y)?{isValid:y}:{},errors:n.errors,name:p};n={...n,...V},h.state.next(V)}},_=async p=>(v(p,!0),await e.resolver(i,e.context,ad(p||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),z=async p=>{const{errors:y}=await _(p);if(v(p),p)for(const S of p){const D=I(y,S);D?te(n.errors,S,D):ue(n.errors,S)}else n.errors=y;return y},H=async(p,y,S={valid:!0})=>{for(const D in p){const M=p[D];if(M){const{_f:T,...V}=M;if(T){const G=l.array.has(T.name),Z=M._f&&cd(M._f);Z&&f.validatingFields&&v([T.name],!0);const ke=await Qs(M,l.disabled,i,C,e.shouldUseNativeValidation&&!y,G);if(Z&&f.validatingFields&&v([T.name]),ke[T.name]&&(S.valid=!1,y||t.shouldUseNativeValidation))break;!y&&(I(ke,T.name)?G?md(n.errors,ke,T.name):te(n.errors,T.name,ke[T.name]):ue(n.errors,T.name))}!ve(V)&&await H(V,y,S)}}return S.valid},F=()=>{for(const p of l.unMount){const y=I(r,p);y&&(y._f.refs?y._f.refs.every(S=>!Wn(S)):!Wn(y._f.ref))&&An(p)}l.unMount=new Set},j=(p,y)=>!e.disabled&&(p&&y&&te(i,p,y),!Pe(Le(),s)),P=(p,y,S)=>dr(p,l,{...o.mount?i:re(y)?s:Me(p)?{[p]:y}:y},S,y),$=p=>Lr(I(o.mount?i:s,p,e.shouldUnregister?I(s,p,[]):[])),W=(p,y,S={})=>{const D=I(r,p);let M=y;if(D){const T=D._f;T&&(!T.disabled&&te(i,p,Eo(y,T)),M=mn(T.ref)&&we(y)?"":y,wo(T.ref)?[...T.ref.options].forEach(V=>V.selected=M.includes(V.value)):T.refs?Ut(T.ref)?T.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(M)?V.checked=!!M.find(G=>G===V.value):V.checked=M===V.value||!!M)}):T.refs.forEach(V=>V.checked=V.value===M):$r(T.ref)?T.ref.value="":(T.ref.value=M,T.ref.type||h.state.next({name:p,values:ce(i)})))}(S.shouldDirty||S.shouldTouch)&&O(p,M,S.shouldTouch,S.shouldDirty,!0),S.shouldValidate&&ge(p)},oe=(p,y,S)=>{for(const D in y){if(!y.hasOwnProperty(D))return;const M=y[D],T=p+"."+D,V=I(r,T);(l.array.has(p)||fe(M)||V&&!V._f)&&!ct(M)?oe(T,M,S):W(T,M,S)}},J=(p,y,S={})=>{const D=I(r,p),M=l.array.has(p),T=ce(y);te(i,p,T),M?(h.array.next({name:p,values:ce(i)}),(f.isDirty||f.dirtyFields||m.isDirty||m.dirtyFields)&&S.shouldDirty&&h.state.next({name:p,dirtyFields:kt(s,i),isDirty:j(p,T)})):D&&!D._f&&!we(T)?oe(p,T,S):W(p,T,S),Js(p,l)?h.state.next({...n,name:p,values:ce(i)}):h.state.next({name:o.mount?p:void 0,values:ce(i)})},me=async p=>{o.mount=!0;const y=p.target;let S=y.name,D=!0;const M=I(r,S),T=Z=>{D=Number.isNaN(Z)||ct(Z)&&isNaN(Z.getTime())||Pe(Z,I(i,S,Z))},V=Ks(e.mode),G=Ks(e.reValidateMode);if(M){let Z,ke;const nt=y.type?qs(M._f):bo(p),Je=p.type===pn.BLUR||p.type===pn.FOCUS_OUT,zo=!ud(M._f)&&!e.resolver&&!I(n.errors,S)&&!M._f.deps||hd(Je,I(n.touchedFields,S),n.isSubmitted,G,V),Tn=Js(S,l,Je);te(i,S,nt),Je?(!y||!y.readOnly)&&(M._f.onBlur&&M._f.onBlur(p),a&&a(0)):M._f.onChange&&M._f.onChange(p);const Mn=O(S,nt,Je),Bo=!ve(Mn)||Tn;if(!Je&&h.state.next({name:S,type:p.type,values:ce(i)}),zo)return(f.isValid||m.isValid)&&(e.mode==="onBlur"?Je&&k():Je||k()),Bo&&h.state.next({name:S,...Tn?{}:Mn});if(!Je&&Tn&&h.state.next({...n}),e.resolver){const{errors:Wr}=await _([S]);if(v([S]),T(nt),D){const _o=Gs(n.errors,r,S),Jr=Gs(Wr,r,_o.name||S);Z=Jr.error,S=Jr.name,ke=ve(Wr)}}else v([S],!0),Z=(await Qs(M,l.disabled,i,C,e.shouldUseNativeValidation))[S],v([S]),T(nt),D&&(Z?ke=!1:(f.isValid||m.isValid)&&(ke=await H(r,!0)));D&&(M._f.deps&&(!Array.isArray(M._f.deps)||M._f.deps.length>0)&&ge(M._f.deps),L(S,ke,Z,Mn))}},ae=(p,y)=>{if(I(n.errors,y)&&p.focus)return p.focus(),1},ge=async(p,y={})=>{let S,D;const M=Dt(p);if(e.resolver){const T=await z(re(p)?p:M);S=ve(T),D=p?!M.some(V=>I(T,V)):S}else p?(D=(await Promise.all(M.map(async T=>{const V=I(r,T);return await H(V&&V._f?{[T]:V}:V)}))).every(Boolean),!(!D&&!n.isValid)&&k()):D=S=await H(r);return h.state.next({...!Me(p)||(f.isValid||m.isValid)&&S!==n.isValid?{}:{name:p},...e.resolver||!p?{isValid:S}:{},errors:n.errors}),y.shouldFocus&&!D&&Lt(r,ae,p?M:l.mount),D},Le=(p,y)=>{let S={...o.mount?i:s};return y&&(S=Co(y.dirtyFields?n.dirtyFields:n.touchedFields,S)),re(p)?S:Me(p)?I(S,p):p.map(D=>I(S,D))},Y=(p,y)=>({invalid:!!I((y||n).errors,p),isDirty:!!I((y||n).dirtyFields,p),error:I((y||n).errors,p),isValidating:!!I(n.validatingFields,p),isTouched:!!I((y||n).touchedFields,p)}),Ie=p=>{p&&Dt(p).forEach(y=>ue(n.errors,y)),h.state.next({errors:p?n.errors:{}})},ee=(p,y,S)=>{const D=(I(r,p,{_f:{}})._f||{}).ref,M=I(n.errors,p)||{},{ref:T,message:V,type:G,...Z}=M;te(n.errors,p,{...Z,...y,ref:D}),h.state.next({name:p,errors:n.errors,isValid:!1}),S&&S.shouldFocus&&D&&D.focus&&D.focus()},Ae=(p,y)=>Ce(p)?h.state.subscribe({next:S=>"values"in S&&p(P(void 0,y),S)}):P(p,y,!0),wt=p=>h.state.subscribe({next:y=>{fd(p.name,y.name,p.exact)&&dd(y,p.formState||f,Vo,p.reRenderRoot)&&p.callback({values:{...i},...n,...y,defaultValues:s})}}).unsubscribe,wn=p=>(o.mount=!0,m={...m,...p.formState},wt({...p,formState:{...d,...p.formState}})),An=(p,y={})=>{for(const S of p?Dt(p):l.mount)l.mount.delete(S),l.array.delete(S),y.keepValue||(ue(r,S),ue(i,S)),!y.keepError&&ue(n.errors,S),!y.keepDirty&&ue(n.dirtyFields,S),!y.keepTouched&&ue(n.touchedFields,S),!y.keepIsValidating&&ue(n.validatingFields,S),!e.shouldUnregister&&!y.keepDefaultValue&&ue(s,S);h.state.next({values:ce(i)}),h.state.next({...n,...y.keepDirty?{isDirty:j()}:{}}),!y.keepIsValid&&k()},_r=({disabled:p,name:y})=>{if(Ne(p)&&o.mount||p||l.disabled.has(y)){const M=l.disabled.has(y)!==!!p;p?l.disabled.add(y):l.disabled.delete(y),M&&o.mount&&!o.action&&k()}},Nn=(p,y={})=>{let S=I(r,p);const D=Ne(y.disabled)||Ne(e.disabled);return te(r,p,{...S||{},_f:{...S&&S._f?S._f:{ref:{name:p}},name:p,mount:!0,...y}}),l.mount.add(p),S?_r({disabled:Ne(y.disabled)?y.disabled:e.disabled,name:p}):E(p,!0,y.value),{...D?{disabled:y.disabled||e.disabled}:{},...e.progressive?{required:!!y.required,min:Tt(y.min),max:Tt(y.max),minLength:Tt(y.minLength),maxLength:Tt(y.maxLength),pattern:Tt(y.pattern)}:{},name:p,onChange:me,onBlur:me,ref:M=>{if(M){Nn(p,y),S=I(r,p);const T=re(M.value)&&M.querySelectorAll&&M.querySelectorAll("input,select,textarea")[0]||M,V=sd(T),G=S._f.refs||[];if(V?G.find(Z=>Z===T):T===S._f.ref)return;te(r,p,{_f:{...S._f,...V?{refs:[...G.filter(Wn),T,...Array.isArray(I(s,p))?[{}]:[]],ref:{type:T.type,name:p}}:{ref:T}}}),E(p,!1,void 0,T)}else S=I(r,p,{}),S._f&&(S._f.mount=!1),(e.shouldUnregister||y.shouldUnregister)&&!(ko(l.array,p)&&o.action)&&l.unMount.add(p)}}},En=()=>e.shouldFocusError&&Lt(r,ae,l.mount),Fo=p=>{Ne(p)&&(h.state.next({disabled:p}),Lt(r,(y,S)=>{const D=I(r,S);D&&(y.disabled=D._f.disabled||p,Array.isArray(D._f.refs)&&D._f.refs.forEach(M=>{M.disabled=D._f.disabled||p}))},0,!1))},Hr=(p,y)=>async S=>{let D;S&&(S.preventDefault&&S.preventDefault(),S.persist&&S.persist());let M=ce(i);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:T,values:V}=await _();v(),n.errors=T,M=ce(V)}else await H(r);if(l.disabled.size)for(const T of l.disabled)ue(M,T);if(ue(n.errors,"root"),ve(n.errors)){h.state.next({errors:{}});try{await p(M,S)}catch(T){D=T}}else y&&await y({...n.errors},S),En(),setTimeout(En);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ve(n.errors)&&!D,submitCount:n.submitCount+1,errors:n.errors}),D)throw D},Po=(p,y={})=>{I(r,p)&&(re(y.defaultValue)?J(p,ce(I(s,p))):(J(p,y.defaultValue),te(s,p,ce(y.defaultValue))),y.keepTouched||ue(n.touchedFields,p),y.keepDirty||(ue(n.dirtyFields,p),n.isDirty=y.defaultValue?j(p,ce(I(s,p))):j()),y.keepError||(ue(n.errors,p),f.isValid&&k()),h.state.next({...n}))},Ur=(p,y={})=>{const S=p?ce(p):s,D=ce(S),M=ve(p),T=M?s:D;if(y.keepDefaultValues||(s=S),!y.keepValues){if(y.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(kt(s,i))]);for(const G of Array.from(V)){const Z=I(n.dirtyFields,G),ke=I(i,G),nt=I(T,G);Z&&!re(ke)?te(T,G,ke):!Z&&!re(nt)&&J(G,nt)}}else{if(Dr&&re(p))for(const V of l.mount){const G=I(r,V);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(mn(Z)){const ke=Z.closest("form");if(ke){ke.reset();break}}}}if(y.keepFieldsRef)for(const V of l.mount)J(V,I(T,V));else r={}}i=e.shouldUnregister?y.keepDefaultValues?ce(s):{}:ce(T),h.array.next({values:{...T}}),h.state.next({values:{...T}})}l={mount:y.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!y.keepIsValid||!!y.keepDirtyValues||!e.shouldUnregister&&!ve(T),o.watch=!!e.shouldUnregister,o.keepIsValid=!!y.keepIsValid,o.action=!1,y.keepErrors||(n.errors={}),h.state.next({submitCount:y.keepSubmitCount?n.submitCount:0,isDirty:M?!1:y.keepDirty?n.isDirty:!!(y.keepDefaultValues&&!Pe(p,s)),isSubmitted:y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:M?{}:y.keepDirtyValues?y.keepDefaultValues&&i?kt(s,i):n.dirtyFields:y.keepDefaultValues&&p?kt(s,p):y.keepDirty?n.dirtyFields:{},touchedFields:y.keepTouched?n.touchedFields:{},errors:y.keepErrors?n.errors:{},isSubmitSuccessful:y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},qr=(p,y)=>Ur(Ce(p)?p(i):p,{...e.resetOptions,...y}),$o=(p,y={})=>{const S=I(r,p),D=S&&S._f;if(D){const M=D.refs?D.refs[0]:D.ref;M.focus&&setTimeout(()=>{M.focus(),y.shouldSelect&&Ce(M.select)&&M.select()})}},Vo=p=>{n={...n,...p}},Kr={control:{register:Nn,unregister:An,getFieldState:Y,handleSubmit:Hr,setError:ee,_subscribe:wt,_runSchema:_,_updateIsValidating:v,_focusError:En,_getWatch:P,_getDirty:j,_setValid:k,_setFieldArray:A,_setDisabledField:_r,_setErrors:w,_getFieldArray:$,_reset:Ur,_resetDefaultValues:()=>Ce(e.defaultValues)&&e.defaultValues().then(p=>{qr(p,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:F,_disableForm:Fo,_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 l},set _names(p){l=p},get _formState(){return n},get _options(){return e},set _options(p){e={...e,...p}}},subscribe:wn,trigger:ge,register:Nn,handleSubmit:Hr,watch:Ae,setValue:J,getValues:Le,reset:qr,resetField:Po,clearErrors:Ie,unregister:An,setError:ee,setFocus:$o,getFieldState:Y};return{...Kr,formControl:Kr}}function xd(t={}){const e=x.useRef(void 0),n=x.useRef(void 0),[r,s]=x.useState({isDirty:!1,isValidating:!1,isLoading:Ce(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:Ce(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!Ce(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=yd(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,Pr(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),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&&!Pe(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=t.values,s(l=>({...l}))):i._resetDefaultValues()},[i,t.values]),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(()=>So(r,i),[i,r]),e.current}function bd(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function kd(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 vd(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 Sd(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 Cd(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 zr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}zr();const wd={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Jn=()=>({id:zr(),amount:0,glAccount:null,isTaxDeductible:!1}),Mo=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:a,onDelete:u,canDelete:d=!0,canEditTaxDeductible:f=!0,isDisabled:m=!1,labels:h,classNames:C={},"data-testid":b,control:k,name:v,rules:A})=>{const N={...wd,...h},w=k!==void 0&&v!==void 0,E=xd({defaultValues:{_internal:e||Jn()}}),O=td({control:w?k:E.control,name:w?v:"_internal",rules:w?A:void 0}),[L,_]=x.useState(e||Jn()),z=w?O.field.value??Jn():t??L,H=w&&!!O.fieldState?.error,F=w&&(O.fieldState?.isTouched??!1),j=H||F,P=j&&(!z.amount||z.amount<=0),$=j&&!z.glAccount,[W,oe]=x.useState(z.glAccount?.name||""),J=x.useCallback(ee=>{const Ae={...z,...ee};w&&O.field.onChange(Ae),!w&&t===void 0&&_(Ae),i?.(Ae)},[z,t,i,w,O]),me=x.useCallback(ee=>{const Ae=ee||0;J({amount:Ae}),o?.(Ae)},[J,o]),ae=x.useCallback(ee=>{oe(ee),s?.(ee)},[s]),ge=x.useCallback(ee=>{if(ee===null){J({glAccount:null}),l?.(null);return}const wt=n.find(wn=>String(wn.id)===String(ee))||null;J({glAccount:wt}),l?.(wt)},[n,J,l]),Le=x.useCallback(()=>{oe(""),J({glAccount:null}),l?.(null)},[J,l]),Y=x.useCallback(ee=>{J({isTaxDeductible:ee}),a?.(ee)},[J,a]),Ie=x.useCallback(()=>{u?.()},[u]);return c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:g.cn(C.base),children:c.jsxs(g.CardBody,{className:g.cn("flex flex-row flex-nowrap items-start gap-4",C.body),children:[c.jsx("div",{className:g.cn("shrink-0",C.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:[N.amount,c.jsx(g.Tooltip,{content:N.amountTooltip,children:c.jsx(Te,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:z.amount||void 0,onValueChange:me,labelPlacement:"outside",placeholder:N.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:m,isInvalid:P,errorMessage:P?"Amount is required":void 0,minValue:0,step:.01,className:C.amountInput,startContent:c.jsx("div",{className:"pointer-events-none flex items-center",children:c.jsx("span",{className:"text-default-400 text-small",children:N.currencySymbol})})})}),c.jsx("div",{className:g.cn("grow",C.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:[N.glAccount,c.jsx(g.Tooltip,{content:N.glAccountTooltip,children:c.jsx(Te,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:z.glAccount?.name??W,selectedKey:z.glAccount?.id??null,isDisabled:m,isInvalid:$,errorMessage:$?"GL Account is required":void 0,listboxProps:{emptyContent:r?N.searching:N.noGlAccountsFound},placeholder:N.glAccountPlaceholder,onInputChange:ae,onSelectionChange:ge,onClear:Le,className:C.glAccountInput,children:ee=>c.jsx(g.AutocompleteItem,{textValue:ee.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:ee.name}),ee.code&&c.jsx("span",{className:"text-xs text-default-400",children:ee.code})]})},ee.id)})}),c.jsx("div",{className:g.cn("shrink-0 pt-6 flex items-center",C.taxDeductibleContainer),children:c.jsx(g.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:z.isTaxDeductible,onValueChange:Y,isDisabled:m||!f,className:C.taxDeductibleCheckbox,children:N.taxDeductible})}),c.jsx("div",{className:g.cn("shrink-0 pt-6",C.deleteContainer),children:c.jsx(se,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:m||!d,onPress:Ie,startContent:c.jsx(Te,{icon:"solar:trash-bin-trash-linear",width:16}),className:g.cn("text-danger",C.deleteButton),children:N.deleteButton})})]})})};Mo.displayName="RevenueDistributionCard";const jo=({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(Te,{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})};jo.displayName="RevenueDistributionEmpty";const Ad={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Io=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Ad,...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})};Io.displayName="RevenueDistributionError";const Oo=({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))})};Oo.displayName="RevenueDistributionSkeleton";const Nd={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Ed=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:l=null,allowReselect:a=!0,onRenewalChange:u,onCardSelect:d,className:f=""})=>{const m=Array.isArray(t)?t:[],[h,C]=x.useState(l),[b,k]=x.useState(o),v={...Nd,...s};x.useEffect(()=>{C(l)},[l]);const A=w=>{if(w===h){a&&d?.(w);return}C(w),d?.(w)},N=w=>{k(w),u?.(w)};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:v.title}),i&&c.jsx(Lo,{title:v.renewalTitle,description:v.renewalDescription,value:b,onValueChange:N}),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(w=>c.jsx(Do,{itemKey:w.id,name:w.name,type:w.type,price:w.price,locale:e,currency:n,isSelected:h===w.id,onSelect:A},w.id))})]})},Do=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:o=!1,onSelect:l,className:a=""})=>{const u=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return c.jsx(g.Card,{shadow:"none",isPressable:!!l,onPress:()=>l?.(t),className:g.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",a),"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:u})]})})},Lo=({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"})]})},Td={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"},Md=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Ro=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),jd=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,o)=>i+o.max,0),0),0),Br=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),Xs=(t,e,n)=>{const r={};let s=n?e??jd(t):0;for(const{exhibition:i,dateGroup:o,ticket:l}of Br(t)){r[i.id]??={},r[i.id][o.id]??={};const a=n?Math.min(l.max,s):0;r[i.id][o.id][l.id]={id:l.id,selectedQuantity:a,originalPrice:l.originalPrice,discountedPrice:l.price},s-=a}return r},Ys=(t,e,n)=>`${t}::${e}::${n}`,Id=(t,e,n)=>{const r=Ro(e);for(const{exhibition:s,dateGroup:i,ticket:o}of Br(t)){const l=e[s.id]?.[i.id]?.[o.id]?.selectedQuantity??0,a=n===void 0?o.max:Math.min(o.max,n-(r-l));if(a>0&&l<a)return!1}return!0},Od=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[o,l]=x.useState(()=>String(i)),[a,u]=x.useState(!1),d=a?o:String(i),f=()=>{s||i>=n||r?.(i+1)},m=()=>{s||i<=e||r?.(i-1)},h=w=>{if(s)return;l(w.target.value);const E=parseInt(w.target.value,10);isNaN(E)||r?.(Math.max(e,Math.min(n,E)))},C=w=>{const E=parseInt(w.target.value,10);if(u(!1),isNaN(E)){r?.(e);return}const O=Math.max(e,Math.min(n,E));O!==E?r?.(O):l(String(O))},b=i<=e,k=i>=n,v="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",A="bg-primary hover:bg-primary/80",N="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(v,s||b?N:A),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),c.jsx("input",{type:"number",value:d,onChange:h,onFocus:()=>u(!0),onBlur:C,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||k,className:g.cn(v,s||k?N:A),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Dd=({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})]})},Ld=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:o})=>{const l=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},a=i?.locale??"en-US",u=i?.currency??"USD",d=Md(a,u);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:d.format(t.originalPrice)}),c.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:d.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(Od,{initialQuantity:e,minQuantity:0,maxQuantity:l(),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]})},Rd=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:a})=>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((u,d)=>c.jsxs("div",{children:[c.jsx(Ld,{item:u,quantity:s(t,e.id,u.id),onChange:f=>r(t,e.id,u.id,f),getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:a}),d<e.tickets.length-1?c.jsx(g.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),Fd=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:l,initialExpanded:a=!1})=>{const[u,d]=x.useState(a),f=e.dates.reduce((h,C)=>h+C.tickets.reduce((b,k)=>b+r(e.id,C.id,k.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:()=>d(!u),"aria-expanded":u,"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," ",l.ticketsSelectedToRedeem]}),c.jsx("span",{className:g.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:c.jsx(Te,{icon:"mdi:chevron-down"})})]})]})}),c.jsx("div",{id:`upgrade-items-${e.id}`,className:g.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&c.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:m?e.dates.map((h,C)=>c.jsx(Rd,{exhibitionId:e.id,dateGroup:h,isLast:C===e.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:l},h.id)):c.jsx("div",{className:"px-5 py-10 text-center",children:c.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},Pd=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:o})=>{const l=x.useMemo(()=>s??[],[s]),a={...Td,...n},[u,d]=x.useState(()=>Xs(l,e,!0)),f=x.useRef(!1),m=x.useMemo(()=>{const A=Br(l).map(({exhibition:N,dateGroup:w,ticket:E})=>[Ys(N.id,w.id,E.id),E]);return new Map(A)},[l]),h=Id(l,u,e),C=(A,N,w)=>u[A]?.[N]?.[w]?.selectedQuantity??0,b=()=>Ro(u),k=(A,N,w,E)=>{const O=C(A,N,w),L=b()-O;if(e!==void 0&&L+E>e)return;const _=m.get(Ys(A,N,w));if(!_)return;const z={...u,[A]:{...u[A],[N]:{...u[A]?.[N],[w]:{id:w,selectedQuantity:E,originalPrice:_.originalPrice,discountedPrice:_.price}}}};d(z),o?.(z)},v=A=>{const N=Xs(l,e,A);d(N),o?.(N)};return x.useEffect(()=>{!f.current&&h&&(o?.(u),f.current=!0)},[h,u,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:a.ticketSelectionTitle}),c.jsx(Dd,{label:a.selectAllButtonLabel,checked:h,onChange:v})]}),l.map(A=>c.jsx(Fd,{title:A.exhibitionName,exhibition:A,onQuantityChange:k,getTicketQuantity:C,getTotalSelectedTickets:b,userMaxLimit:e,settings:r,labels:a,initialExpanded:t},A.id))]})};exports.Button=se;exports.ConfirmationPageTemplate=nl;exports.DonationAmounts=Gi;exports.EventDetails=qu;exports.EventDetailsTemplate=il;exports.ExpireCartTimer=Zi;exports.Footer=ol;exports.HeroUIProvider=Zo;exports.ItemCard=Do;exports.MembershipSelectCards=Ed;exports.Multiselect=ll;exports.Navbar=tl;exports.OfferCard=Or;exports.OfferCardEmpty=fo;exports.OfferCardError=ho;exports.OfferCardList=yo;exports.OfferCardSkeleton=po;exports.RICH_TEXT_PRESETS=Wi;exports.RevenueDistributionCard=Mo;exports.RevenueDistributionEmpty=jo;exports.RevenueDistributionError=Io;exports.RevenueDistributionSkeleton=Oo;exports.RichTextArea=Ji;exports.Select=tn;exports.Stepper=ei;exports.TicketSelection=Pd;exports.Toggle=Lo;exports.calculateAllocationDifference=Cd;exports.formatOfferCurrency=uo;exports.formatRevenueAmount=bd;exports.formatRevenueCurrency=kd;exports.generateDistributionId=zr;exports.getCurrencySymbol=vd;exports.offerCardVariants=go;exports.offerListVariants=mo;exports.parseOfferCurrency=Ku;exports.parseRevenueCurrency=Sd;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
|
|
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
|
+
@keyframes pp-modal-in {
|
|
21
|
+
from { opacity: 0; transform: scale(0.96); }
|
|
22
|
+
to { opacity: 1; transform: scale(1); }
|
|
23
|
+
}
|
|
24
|
+
@keyframes pp-fade-in {
|
|
25
|
+
from { opacity: 0; }
|
|
26
|
+
to { opacity: 1; }
|
|
27
|
+
}
|
|
28
|
+
@keyframes pp-fade-out {
|
|
29
|
+
from { opacity: 1; }
|
|
30
|
+
to { opacity: 0; }
|
|
31
|
+
}
|
|
32
|
+
@keyframes pp-scale-in {
|
|
33
|
+
from { opacity: 0; transform: scale(0.92); }
|
|
34
|
+
to { opacity: 1; transform: scale(1); }
|
|
35
|
+
}
|
|
36
|
+
@keyframes pp-slide-down {
|
|
37
|
+
from { opacity: 0; transform: translateY(-8px); }
|
|
38
|
+
to { opacity: 1; transform: translateY(0); }
|
|
39
|
+
}
|
|
40
|
+
@keyframes pp-row-in {
|
|
41
|
+
from { opacity: 0; transform: translateY(-6px); }
|
|
42
|
+
to { opacity: 1; transform: translateY(0); }
|
|
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: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]})});
|
|
20
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)}})();
|