@veevarts/design-system 1.13.0-beta.1 → 1.13.0-beta.2
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 +5 -14
- package/dist/index.js +4796 -10235
- package/dist/patterns/ConfirmationModal/ConfirmationModal.d.ts +5 -1
- package/dist/patterns/InstallmentFundAssignment/InstallmentFundAssignment.d.ts +1 -1
- package/dist/patterns/InstallmentFundAssignment/types.d.ts +2 -2
- package/dist/patterns/InstallmentFundAssignment/utils.d.ts +12 -0
- package/dist/patterns/InstallmentSchedule/types.d.ts +7 -0
- package/dist/patterns/InstallmentSchedule/utils.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("@heroui/react"),y=require("react"),J=require("lucide-react"),Pe=require("framer-motion"),Jr=require("@tiptap/react"),V=require("@tiptap/core"),Eo=require("@tiptap/extension-underline"),To=require("@tiptap/extension-color"),Do=require("@tiptap/extension-highlight"),Io=require("@tiptap/extension-link"),$o=require("@tiptap/extension-task-list"),Oo=require("@tiptap/extension-task-item"),Lo=require("@tiptap/extension-text-align");function Fo({children:e}){return l.jsx(f.HeroUIProvider,{children:e})}const K=y.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},s)=>l.jsx(f.Button,{ref:s,color:e,radius:t,"data-testid":n,...r}));K.displayName="Button";function Po(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const yt=y.forwardRef(({popoverProps:e,...t},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...e,disableDialogFocus:e?.disableDialogFocus??(s?!0:void 0),portalContainer:e?.portalContainer??s};return y.useEffect(()=>{i(Po(r.current))},[]),l.jsx("span",{ref:r,className:"contents",children:l.jsx(f.Select,{ref:n,...t,popoverProps:a})})});yt.displayName="Select";const Ro={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function zo({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const s=e.find(i=>i.code===t);return l.jsx("div",{className:"flex items-center",children:l.jsxs("div",{className:"relative flex items-center",children:[l.jsx(yt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:l.jsx(J.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>l.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),l.jsx(yt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:l.jsx(J.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>l.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Bo({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?l.jsxs(K,{"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:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.logout})]}):l.jsxs(K,{"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:t,size:"md",children:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.login})]})}function _o({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:o,hasAuth:c,labels:d={},className:u}){const h={...Ro,...d};return l.jsxs("nav",{"data-testid":"navbar",className:f.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),children:[l.jsx("div",{className:"flex items-center min-w-10",children:e&&l.jsx("a",{href:"/",className:"block",children:l.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),l.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(o||t.length>0)&&l.jsx(zo,{languages:t,selectedLanguage:n,onLanguageChange:r,label:h.selectLanguage}),c&&l.jsx(Bo,{isLoggedIn:s,onLogin:i,onLogout:a,labels:h})]})]})}function Vo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.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 Zn;const Ho=typeof document<"u"?(Zn=y.useInsertionEffect)!==null&&Zn!==void 0?Zn:y.useLayoutEffect:()=>{};function Yr(e,t,n){let[r,s]=y.useState(e||t),i=y.useRef(r),a=y.useRef(e!==void 0),o=e!==void 0;y.useEffect(()=>{let h=a.current;h!==o&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${h?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),a.current=o},[o]);let c=o?e:r;Ho(()=>{i.current=c});let[,d]=y.useReducer(()=>({}),{}),u=y.useCallback((h,...p)=>{let m=typeof h=="function"?h(i.current):h;Object.is(i.current,m)||(i.current=m,s(m),d(),n?.(m,...p))},[n]);return[c,u]}function Uo(e){return l.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:l.jsx(Pe.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 Yi=y.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:o,className:c,isDisabled:d=!1,...u},h)=>{const[p,m]=Yr(i,n,s),v=y.useMemo(()=>{let b,x;const w=["[--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(e){case"primary":b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return w.unshift(x),w.unshift(b),w},[e]);return l.jsxs("nav",{ref:h,"aria-label":"Progress",className:f.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...u,children:[r&&l.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),l.jsx("ol",{className:f.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((b,x)=>{const w=p===x?"active":p<x?"inactive":"complete";return l.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${x}`,children:l.jsxs("button",{"aria-current":w==="active"?"step":void 0,className:f.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},o),onClick:()=>!d&&m(x),disabled:d,"data-testid":`stepper-step-btn-${x}`,children:[l.jsx("div",{className:"h-full relative flex items-center",children:l.jsx(Pe.LazyMotion,{features:Pe.domAnimation,children:l.jsx(Pe.m.div,{animate:w,className:"relative",children:l.jsx(Pe.m.div,{animate:w,className:f.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":w==="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:l.jsx("div",{className:"flex items-center justify-center",children:w==="complete"?l.jsx(Uo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):l.jsx("span",{})})})})})}),x<t-1&&!a&&l.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":x},children:l.jsx("div",{className:f.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":x<p})})})]},x)},x)})})]})});Yi.displayName="Stepper";function qo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.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 rt(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function Gr(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function Gi(e,t,n="en-US"){const r=Gr(t,n),s=Math.pow(10,r);return Math.round(e*s)/s}function Cr(e,t,n,r){return Gi(e-t,n,r)}function Wo(){return l.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 Ko=e=>{const t=y.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return l.jsx(Jo,{...e},t)},Jo=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[o,c]=y.useState([]),[d,u]=y.useState(null),[h,p]=y.useState(null),m=y.useMemo(()=>new Set(t),[t]),v=y.useMemo(()=>new Set(e),[e]),b=y.useMemo(()=>e.filter(E=>!m.has(E)),[e,m]),x=E=>{if(E.length===0)return;const C=Array.from(new Set([...t,...E]));n(C)},w=E=>{if(E.length===0)return;const C=new Set(E);n(t.filter(I=>!C.has(I)))},S=()=>{i.length!==0&&(x(i),a([]))},M=()=>{o.length!==0&&(w(o),c([]))},N=()=>{b.length!==0&&(x(b),a([]))},j=()=>{t.length!==0&&(n([]),c([]))},T=(E,C,I)=>{const F=Math.min(C,I),H=Math.max(C,I);return E.slice(F,H+1)},$=(E,C,I)=>{if(I&&d!==null){a(T(b,d,C)),c([]),u(C);return}const F=i.includes(E);a(F?i.filter(H=>H!==E):[...i,E]),c([]),u(C)},W=(E,C,I)=>{if(I&&h!==null){c(T(t,h,C)),a([]),p(C);return}const F=o.includes(E);c(F?o.filter(H=>H!==E):[...o,E]),a([]),p(C)},D=(E,C,I)=>{const F=I==="available"?i.includes(C)?i:[C]:o.includes(C)?o:[C];E.dataTransfer.setData("text/plain",JSON.stringify({source:I,items:F})),E.dataTransfer.effectAllowed="move"},R=(E,C)=>{E.preventDefault();const I=E.dataTransfer.getData("text/plain");if(I)try{const F=JSON.parse(I),H=(F.items||[]).filter(Q=>v.has(Q));if(H.length===0||F.source===C)return;C==="selected"?(x(H),a([])):(w(H),c([]))}catch{return}};return l.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"available"),children:b.map((E,C)=>{const I=i.includes(E);return l.jsx("button",{type:"button",onClick:F=>{$(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]}),l.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[l.jsx(K,{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:S,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),l.jsx(K,{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:M,isDisabled:o.length===0,"aria-label":"Move selected to left",children:"‹"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:N,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:j,"data-testid":"move-all-to-available",isDisabled:t.length===0,"aria-label":"Move all to left",children:"«"})]}),l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"selected"),children:t.map((E,C)=>{const I=o.includes(E);return l.jsx("button",{type:"button",onClick:F=>{W(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]})]})};function Yt(e){return typeof e=="string"?e:e.type}function ot({className:e}){return l.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:l.jsx(f.Divider,{orientation:"vertical"})})}function ct({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:o}){const c=i?`${t} (${i})`:t;return l.jsx(f.Tooltip,{content:c,placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":t,className:o,children:l.jsx(e,{size:a})})})}const Je={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,s=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:s}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Yo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Go({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(o=>o+1);return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e]);const s=t.find(a=>e.isActive("heading",{level:a})),i=a=>{const o=Number(a),c=Je.heading;c&&c.execute({editor:e,config:{type:"heading",level:o}})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:l.jsx(J.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),l.jsx(f.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:t.map(a=>l.jsx(f.DropdownItem,{startContent:e.isActive("heading",{level:a})?l.jsx(J.Check,{size:16}):l.jsx("div",{className:"w-4"}),children:Yo[a]},a))})]})}const Xn={bulletList:{label:"Bullet List",icon:J.List},orderedList:{label:"Numbered List",icon:J.ListOrdered},taskList:{label:"Task List",icon:J.ListTodo}};function Qo({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const o=()=>r(c=>c+1);return e.on("selectionUpdate",o),e.on("transaction",o),()=>{e.off("selectionUpdate",o),e.off("transaction",o)}},[e]);const s=t.find(o=>e.isActive(o)),i=s?Xn[s].icon:J.List,a=o=>{const d=Je[o];d&&d.execute({editor:e})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:l.jsx(i,{size:16})})}),l.jsx(f.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:t.map(o=>{const c=Xn[o].icon;return l.jsx(f.DropdownItem,{startContent:l.jsx(c,{size:16}),children:Xn[o].label},o)})})]})}function Zo({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return l.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(s=>{const i=t===s;return l.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),d=require("@heroui/react"),g=require("react"),Y=require("lucide-react"),ve=require("framer-motion"),tn=require("@tiptap/react"),kn=require("@tiptap/core"),ra=require("@tiptap/extension-bold"),aa=require("@tiptap/extension-italic"),ia=require("@tiptap/extension-strike"),la=require("@tiptap/extension-underline"),oa=require("@tiptap/extension-code"),ca=require("@tiptap/extension-color"),da=require("@tiptap/extension-highlight"),ua=require("@tiptap/extension-link"),fa=require("@tiptap/extension-text-style"),ma=require("@tiptap/extension-heading"),ha=require("@tiptap/extension-paragraph"),xa=require("@tiptap/extension-bullet-list"),pa=require("@tiptap/extension-ordered-list"),ga=require("@tiptap/extension-task-list"),ba=require("@tiptap/extension-task-item"),ya=require("@tiptap/extension-list-item"),va=require("@tiptap/extension-code-block"),ja=require("@tiptap/extension-blockquote"),wa=require("@tiptap/extension-horizontal-rule"),Na=require("@tiptap/extension-hard-break"),An=require("@tiptap/extension-history"),Ca=require("@tiptap/extension-text-align"),Sa=require("@tiptap/extension-document"),ka=require("@tiptap/extension-text"),Aa=require("@tiptap/extension-dropcursor"),$a=require("@tiptap/extension-gapcursor");function Da({children:e}){return s.jsx(d.HeroUIProvider,{children:e})}const q=g.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},a)=>s.jsx(d.Button,{ref:a,color:e,radius:t,"data-testid":n,...r}));q.displayName="Button";function Ea(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const Te=g.forwardRef(({popoverProps:e,...t},n)=>{const r=g.useRef(null),[a,i]=g.useState(void 0),l={...e,disableDialogFocus:e?.disableDialogFocus??(a?!0:void 0),portalContainer:e?.portalContainer??a};return g.useEffect(()=>{i(Ea(r.current))},[]),s.jsx("span",{ref:r,className:"contents",children:s.jsx(d.Select,{ref:n,...t,popoverProps:l})})});Te.displayName="Select";const Ia={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function Ma({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const a=e.find(i=>i.code===t);return s.jsx("div",{className:"flex items-center",children:s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(Te,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const l=Array.from(i)[0]||t;n?.(l)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:s.jsx(Y.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>s.jsx("span",{children:a?.label||r}),size:"md",radius:"full",children:e.map(i=>s.jsx(d.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),s.jsx(Te,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const l=Array.from(i)[0]||t;n?.(l)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:s.jsx(Y.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>s.jsx("span",{children:a?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>s.jsx(d.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Fa({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?s.jsxs(q,{"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:[s.jsx(Y.User,{className:"inline w-5 h-5"}),s.jsx("span",{className:"hidden md:inline",children:r.logout})]}):s.jsxs(q,{"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:t,size:"md",children:[s.jsx(Y.User,{className:"inline w-5 h-5"}),s.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Ta({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:a,onLogin:i,onLogout:l,hasLanguages:o,hasAuth:c,labels:u={},className:f}){const x={...Ia,...u};return s.jsxs("nav",{"data-testid":"navbar",className:d.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",f),children:[s.jsx("div",{className:"flex items-center min-w-10",children:e&&s.jsx("a",{href:"/",className:"block",children:s.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),s.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(o||t.length>0)&&s.jsx(Ma,{languages:t,selectedLanguage:n,onLanguageChange:r,label:x.selectLanguage}),c&&s.jsx(Fa,{isLoggedIn:a,onLogin:i,onLogout:l,labels:x})]})]})}function La(e){return s.jsx("div",{className:"min-h-screen flex flex-col",children:s.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:s.jsx(d.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 $t;const _a=typeof document<"u"?($t=g.useInsertionEffect)!==null&&$t!==void 0?$t:g.useLayoutEffect:()=>{};function nn(e,t,n){let[r,a]=g.useState(e||t),i=g.useRef(r),l=g.useRef(e!==void 0),o=e!==void 0;g.useEffect(()=>{let x=l.current;x!==o&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${x?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),l.current=o},[o]);let c=o?e:r;_a(()=>{i.current=c});let[,u]=g.useReducer(()=>({}),{}),f=g.useCallback((x,...y)=>{let h=typeof x=="function"?x(i.current):x;Object.is(i.current,h)||(i.current=h,a(h),u(),n?.(h,...y))},[n]);return[c,f]}function Pa(e){return s.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:s.jsx(ve.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 hs=g.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:a,currentStep:i,hideProgressBars:l=!1,stepClassName:o,className:c,isDisabled:u=!1,...f},x)=>{const[y,h]=nn(i,n,a),C=g.useMemo(()=>{let v,p;const b=["[--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(e){case"primary":v="[--step-color:var(--heroui-primary)]",p="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":v="[--step-color:var(--heroui-secondary)]",p="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":v="[--step-color:var(--heroui-success)]",p="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":v="[--step-color:var(--heroui-warning)]",p="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":v="[--step-color:var(--heroui-danger)]",p="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":v="[--step-color:var(--heroui-default)]",p="[--step-fg-color:var(--heroui-default-foreground)]";break;default:v="[--step-color:var(--heroui-primary)]",p="[--step-fg-color:var(--heroui-primary-foreground)]";break}return b.unshift(p),b.unshift(v),b},[e]);return s.jsxs("nav",{ref:x,"aria-label":"Progress",className:d.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...f,children:[r&&s.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),s.jsx("ol",{className:d.cn("flex flex-row flex-nowrap gap-x-3",C,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((v,p)=>{const b=y===p?"active":y<p?"inactive":"complete";return s.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${p}`,children:s.jsxs("button",{"aria-current":b==="active"?"step":void 0,className:d.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},o),onClick:()=>!u&&h(p),disabled:u,"data-testid":`stepper-step-btn-${p}`,children:[s.jsx("div",{className:"h-full relative flex items-center",children:s.jsx(ve.LazyMotion,{features:ve.domAnimation,children:s.jsx(ve.m.div,{animate:b,className:"relative",children:s.jsx(ve.m.div,{animate:b,className:d.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":b==="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:s.jsx("div",{className:"flex items-center justify-center",children:b==="complete"?s.jsx(Pa,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${p}`}):s.jsx("span",{})})})})})}),p<t-1&&!l&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":p},children:s.jsx("div",{className:d.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":p<y})})})]},p)},p)})})]})});hs.displayName="Stepper";function Oa(e){return s.jsx("div",{className:"min-h-screen flex flex-col",children:s.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:s.jsx(d.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 $e(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function sn(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function xs(e,t,n="en-US"){const r=sn(t,n),a=Math.pow(10,r);return Math.round(e*a)/a}function Ht(e,t,n,r){return xs(e-t,n,r)}function za(){return s.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 Ra=e=>{const t=g.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return s.jsx(Ba,{...e},t)},Ba=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:a})=>{const[i,l]=g.useState([]),[o,c]=g.useState([]),[u,f]=g.useState(null),[x,y]=g.useState(null),h=g.useMemo(()=>new Set(t),[t]),C=g.useMemo(()=>new Set(e),[e]),v=g.useMemo(()=>e.filter(D=>!h.has(D)),[e,h]),p=D=>{if(D.length===0)return;const S=Array.from(new Set([...t,...D]));n(S)},b=D=>{if(D.length===0)return;const S=new Set(D);n(t.filter(E=>!S.has(E)))},N=()=>{i.length!==0&&(p(i),l([]))},$=()=>{o.length!==0&&(b(o),c([]))},w=()=>{v.length!==0&&(p(v),l([]))},k=()=>{t.length!==0&&(n([]),c([]))},M=(D,S,E)=>{const L=Math.min(S,E),R=Math.max(S,E);return D.slice(L,R+1)},F=(D,S,E)=>{if(E&&u!==null){l(M(v,u,S)),c([]),f(S);return}const L=i.includes(D);l(L?i.filter(R=>R!==D):[...i,D]),c([]),f(S)},W=(D,S,E)=>{if(E&&x!==null){c(M(t,x,S)),l([]),y(S);return}const L=o.includes(D);c(L?o.filter(R=>R!==D):[...o,D]),l([]),y(S)},I=(D,S,E)=>{const L=E==="available"?i.includes(S)?i:[S]:o.includes(S)?o:[S];D.dataTransfer.setData("text/plain",JSON.stringify({source:E,items:L})),D.dataTransfer.effectAllowed="move"},P=(D,S)=>{D.preventDefault();const E=D.dataTransfer.getData("text/plain");if(E)try{const L=JSON.parse(E),R=(L.items||[]).filter(G=>C.has(G));if(R.length===0||L.source===S)return;S==="selected"?(p(R),l([])):(b(R),c([]))}catch{return}};return s.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[s.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[s.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),s.jsx(d.Card,{className:"w-full border border-gray-200 shadow-none",children:s.jsx(d.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:D=>D.preventDefault(),onDrop:D=>P(D,"available"),children:v.map((D,S)=>{const E=i.includes(D);return s.jsx("button",{type:"button",onClick:L=>{F(D,S,L.shiftKey)},onMouseDown:L=>{L.shiftKey&&L.preventDefault()},draggable:!0,onDragStart:L=>I(L,D,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${E?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:D},D)})})})]}),s.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[s.jsx(q,{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:"›"}),s.jsx(q,{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:$,isDisabled:o.length===0,"aria-label":"Move selected to left",children:"‹"}),s.jsx(q,{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:v.length===0,"aria-label":"Move all to right",children:"»"}),s.jsx(q,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:k,"data-testid":"move-all-to-available",isDisabled:t.length===0,"aria-label":"Move all to left",children:"«"})]}),s.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[s.jsx("h2",{className:"text-sm font-medium text-gray-700",children:a}),s.jsx(d.Card,{className:"w-full border border-gray-200 shadow-none",children:s.jsx(d.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:D=>D.preventDefault(),onDrop:D=>P(D,"selected"),children:t.map((D,S)=>{const E=o.includes(D);return s.jsx("button",{type:"button",onClick:L=>{W(D,S,L.shiftKey)},onMouseDown:L=>{L.shiftKey&&L.preventDefault()},draggable:!0,onDragStart:L=>I(L,D,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${E?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:D},D)})})})]})]})};function tt(e){return typeof e=="string"?e:e.type}function Ie({className:e}){return s.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:s.jsx(d.Divider,{orientation:"vertical"})})}function Me({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:a,shortcut:i,iconSize:l=16,className:o}){const c=i?`${t} (${i})`:t;return s.jsx(d.Tooltip,{content:c,placement:"top",offset:10,children:s.jsx(q,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:a,"aria-label":t,className:o,children:s.jsx(e,{size:l})})})}const Ce={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,a=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:a}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Va={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Ua({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=g.useState(0);g.useEffect(()=>{const l=()=>r(o=>o+1);return e.on("selectionUpdate",l),e.on("transaction",l),()=>{e.off("selectionUpdate",l),e.off("transaction",l)}},[e]);const a=t.find(l=>e.isActive("heading",{level:l})),i=l=>{const o=Number(l),c=Ce.heading;c&&c.execute({editor:e,config:{type:"heading",level:o}})};return s.jsxs(d.Dropdown,{placement:"top-start",offset:10,children:[s.jsx(d.DropdownTrigger,{children:s.jsx(q,{size:"sm",radius:"sm",variant:a?"solid":"bordered",color:a?"primary":"default",isDisabled:n,startContent:s.jsx(Y.Heading,{size:16}),"aria-label":"Select heading level",children:a?`H${a}`:"H"})}),s.jsx(d.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:a?new Set([String(a)]):new Set,onAction:i,children:t.map(l=>s.jsx(d.DropdownItem,{startContent:e.isActive("heading",{level:l})?s.jsx(Y.Check,{size:16}):s.jsx("div",{className:"w-4"}),children:Va[l]},l))})]})}const Dt={bulletList:{label:"Bullet List",icon:Y.List},orderedList:{label:"Numbered List",icon:Y.ListOrdered},taskList:{label:"Task List",icon:Y.ListTodo}};function Ha({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=g.useState(0);g.useEffect(()=>{const o=()=>r(c=>c+1);return e.on("selectionUpdate",o),e.on("transaction",o),()=>{e.off("selectionUpdate",o),e.off("transaction",o)}},[e]);const a=t.find(o=>e.isActive(o)),i=a?Dt[a].icon:Y.List,l=o=>{const u=Ce[o];u&&u.execute({editor:e})};return s.jsxs(d.Dropdown,{placement:"top-start",offset:10,children:[s.jsx(d.DropdownTrigger,{children:s.jsx(q,{size:"sm",radius:"sm",variant:a?"solid":"bordered",color:a?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:s.jsx(i,{size:16})})}),s.jsx(d.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:a?new Set([a]):new Set,onAction:l,children:t.map(o=>{const c=Dt[o].icon;return s.jsx(d.DropdownItem,{startContent:s.jsx(c,{size:16}),children:Dt[o].label},o)})})]})}function qa({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(a=>{const i=t===a;return s.jsx("button",{type:"button",onClick:()=>n(a),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:
|
|
7
|
+
`,style:{backgroundColor:a},"aria-label":`Select color ${a}`,title:a},a)})})}const Wa=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],Ya=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Et(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const ue={min:50,max:200,step:10,default:100},$n={lineHeight:24,toolbarHeight:60},Ga={bold:Y.Bold,italic:Y.Italic,strike:Y.Strikethrough,underline:Y.Underline,code:Y.Code,textColor:Y.Palette,highlight:Y.Highlighter,link:Y.Link2,paragraph:Y.FileText,heading:Y.Heading,bulletList:Y.List,orderedList:Y.ListOrdered,taskList:Y.ListTodo,codeBlock:Y.CodeSquare,blockquote:Y.Quote,horizontalRule:Y.Minus,clearMarks:Y.Eraser,clearNodes:Y.Eraser,undo:Y.Undo2,redo:Y.Redo2,hardBreak:Y.CornerDownLeft,textAlign:Y.AlignLeft},Qa={left:Y.AlignLeft,center:Y.AlignCenter,right:Y.AlignRight,justify:Y.AlignJustify};function Pe(e){return Ga[e]}function Ka({value:e,onChange:t,onApply:n,placeholder:r="#000000"}){const[a,i]=g.useState(""),l=u=>{const f=u.target.value;t(f),a&&i("")},o=()=>{if(!e){i("Please enter a color");return}if(!Et(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(e)},c=u=>{u.key==="Enter"&&(u.preventDefault(),o())};return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(d.Input,{type:"text",value:e,onChange:l,onKeyDown:c,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!a,errorMessage:a,startContent:s.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:Et(e)?e:"transparent"}})}),s.jsx(q,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!e||!Et(e),children:s.jsx(Y.Check,{size:16})})]}),s.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Dn({editor:e,type:t,allowCustomColor:n=!0,label:r,isDisabled:a=!1}){const[i,l]=g.useState(!1),[o,c]=g.useState(""),u=t==="textColor"?Wa:Ya,f=v=>{const p=Ce[t];p&&p.execute({editor:e,config:{type:t,color:v}}),l(!1),c("")},x=v=>{f(v)},y=()=>{const v=Ce[t];v&&v.execute({editor:e,config:{type:t,color:""}}),l(!1)},h=t==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),C=t==="textColor"?Y.Palette:Y.Highlighter;return s.jsxs(d.Popover,{isOpen:i,onOpenChange:l,placement:"top",offset:10,showArrow:!0,children:[s.jsx(d.PopoverTrigger,{children:s.jsx(q,{size:"sm",radius:"sm",variant:h?"solid":"bordered",color:h?"primary":"default",isIconOnly:!0,isDisabled:a,"aria-label":r,children:s.jsx(C,{size:16})})}),s.jsx(d.PopoverContent,{className:"w-64",children:s.jsxs("div",{className:"px-2 py-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-semibold",children:r}),s.jsx(q,{size:"sm",variant:"light",isIconOnly:!0,onPress:y,"aria-label":"Clear color",children:s.jsx(Y.X,{size:16})})]}),s.jsx(qa,{colors:u,onColorSelect:f}),n&&s.jsxs(s.Fragment,{children:[s.jsx(d.Divider,{}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),s.jsx(Ka,{value:o,onChange:c,onApply:x})]})]})]})})]})}function Za({zoom:e,onZoomChange:t,min:n=ue.min,max:r=ue.max,step:a=ue.step}){const i=()=>{const x=Math.max(n,e-a);t(x)},l=()=>{const x=Math.min(r,e+a);t(x)},o=()=>{t(ue.default)},c=e<=n,u=e>=r,f=e===ue.default;return s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(d.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:s.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:i,"aria-label":"Zoom out",children:s.jsx(Y.ZoomOut,{size:16})})}),s.jsx(d.Tooltip,{content:f?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:s.jsxs("button",{type:"button",onClick:o,disabled:f,className:`
|
|
8
8
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
9
|
-
${
|
|
10
|
-
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),l.jsx(f.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:l.jsx(J.ZoomIn,{size:16})})})]})}function ic({editor:e,isDisabled:t=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,o]=y.useState(""),[c,d]=y.useState(!1),u=e.isActive("link"),h=m=>{if(m){const{from:v,to:b}=e.state.selection,x=e.isActive("link");let w="";if(x){const M=e.schema.marks.link,N=e.state.doc.resolve(v),j=V.getMarkRange(N,M);j&&(w=e.state.doc.textBetween(j.from,j.to,""))}else w=e.state.doc.textBetween(v,b,"");const S=e.getAttributes("link").href||"";i(w),o(S),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=e.state.selection,b=e.schema.marks.link,x=e.state.doc.resolve(m),w=V.getMarkRange(x,b),S=w?.from??m,M=w?.to??v,N=e.state.doc.textBetween(S,M,"");s.trim()&&s!==N?e.chain().focus().setTextSelection({from:S,to:M}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return l.jsxs(f.Popover,{isOpen:n,onOpenChange:h,placement:"bottom",children:[l.jsx(f.PopoverTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:l.jsx(J.Link,{size:16})})}),l.jsx(f.PopoverContent,{children:l.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:a,onChange:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(K,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function ac({children:e,id:t,label:n,className:r,useButtonGroup:s=!0}){return s?l.jsx(f.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):l.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Qi(e,t){const n=y.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(o=>Yt(o)))).forEach(o=>{const c=Je[o];if(c)try{const d=c.canExecute?.(e)??!0,u=c.isActive?.(e)??!1;i[o]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${o}`,d),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!e)return;const i=()=>{const a={};Array.from(new Set(t.map(c=>Yt(c)))).forEach(c=>{const d=Je[c];if(d)try{const u=d.canExecute?.(e)??!0,h=d.isActive?.(e)??!1;a[c]={isActive:h,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${c}`,u),a[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(a)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Zi(e,t){const n=y.useCallback((a,o)=>{if(!e)return;const c=Je[a];if(c)try{c.execute({editor:e,config:o}),t?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[e,t]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.canExecute?.(e,o)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[e]),i=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.isActive?.(e,o)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function lc(e=ke.default){const[t,n]=y.useState(e),r=y.useCallback((o=ke.step)=>{n(c=>Math.min(ke.max,c+o))},[]),s=y.useCallback((o=ke.step)=>{n(c=>Math.max(ke.min,c-o))},[]),i=y.useCallback(()=>{n(ke.default)},[]),a=y.useCallback(o=>{const c=Math.max(ke.min,Math.min(ke.max,o));n(c)},[]);return{zoom:t,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:t<=ke.min,isMaxZoom:t>=ke.max,isDefaultZoom:t===ke.default}}const oc=["bold","italic","strike","underline","code"];function cc({editor:e,modifiers:t,onToolbarAction:n}){const r=Qi(e,t),{toggleModifier:s}=Zi(e,n);if(!e)return null;const i=t.map(a=>Yt(a)).filter(a=>oc.includes(a));return i.length===0?null:l.jsx(ac,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const o=r[a],c=St(a);return l.jsx(ct,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>s(a)},a)})})}function dc({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const o=Qi(e,t),{toggleModifier:c,executeCommand:d}=Zi(e,a);if(!e)return null;const u=t.map($=>Yt($)),h=u.some($=>["bold","italic","strike","underline","code"].includes($)),p=u.some($=>["textColor","highlight"].includes($)),m=u.includes("heading"),v=u.includes("textAlign"),b=u.some($=>["bulletList","orderedList","taskList"].includes($)),x=u.includes("blockquote"),w=u.includes("codeBlock"),S=u.includes("link"),M=u.includes("horizontalRule"),N=u.some($=>["undo","redo"].includes($)),j=n!==void 0&&r!==void 0,T=s?"sticky top-0 z-10":"";return l.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${T} ${i||""}`,children:l.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[h&&l.jsxs(l.Fragment,{children:[l.jsx(cc,{editor:e,modifiers:t,onToolbarAction:a}),(p||m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&l.jsx(Ds,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),u.includes("highlight")&&l.jsx(Ds,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),m&&l.jsxs(l.Fragment,{children:[l.jsx(Go,{editor:e}),(v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map($=>{const W=nc[$],D=e.isActive({textAlign:$});return l.jsx(ct,{icon:W,label:`Align ${$}`,isActive:D,onClick:()=>d("textAlign",{type:"textAlign",alignment:$})},$)})}),(b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(Qo,{editor:e,types:u.filter($=>["bulletList","orderedList","taskList"].includes($))}),(x||w||S||M||N||j)&&l.jsx(ot,{})]}),(x||w||S||M)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(ct,{icon:St("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>c("blockquote")}),w&&l.jsx(ct,{icon:St("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),S&&l.jsx(ic,{editor:e,isDisabled:o.link?.isDisabled}),M&&l.jsx(ct,{icon:St("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(N||j)&&l.jsx(ot,{})]}),N&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&l.jsx(ct,{icon:St("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&l.jsx(ct,{icon:St("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&l.jsx(ot,{})]}),j&&l.jsx(sc,{zoom:n,onZoomChange:$=>{r?.($),a?.({type:"zoom",modifier:`${$}%`})}})]})})}const uc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pc=V.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[V.markInputRule({find:uc,type:this.type}),V.markInputRule({find:hc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:fc,type:this.type}),V.markPasteRule({find:mc,type:this.type})]}}),gc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,yc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,bc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vc=V.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[V.markInputRule({find:gc,type:this.type}),V.markInputRule({find:yc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:xc,type:this.type}),V.markPasteRule({find:bc,type:this.type})]}}),wc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,kc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Nc=V.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[V.markInputRule({find:wc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:kc,type:this.type})]}}),Sc=/(^|[^`])`([^`]+)`(?!`)/,Cc=/(^|[^`])`([^`]+)`(?!`)/g,jc=V.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[V.markInputRule({find:Sc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:Cc,type:this.type})]}}),Ac=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,s;const i=n.getAttribute("style"),a=(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",`${a};${i}`)})},Mc=V.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Ac(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.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))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Ec=V.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,V.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>V.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Tc=V.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dc="listItem",Is="textStyle",$s=/^\s*([-+*])\s$/,Ic=V.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dc,this.editor.getAttributes(Is)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=V.wrappingInputRule({find:$s,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:$s,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Is),editor:this.editor})),[e]}}),$c="listItem",Os="textStyle",Ls=/^(\d+)\.\s$/,Oc=V.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",V.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($c,this.editor.getAttributes(Os)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=V.wrappingInputRule({find:Ls,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:Ls,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Os)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Lc=V.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",V.mergeAttributes(this.options.HTMLAttributes,e),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 Xi(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=Xi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function ea(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=e.child(--s),o=t.child(--i),c=a.nodeSize;if(a==o){n-=c,r-=c;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let d=0,u=Math.min(a.text.length,o.text.length);for(;d<u&&a.text[a.text.length-d-1]==o.text[o.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let d=ea(a.content,o.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class Z{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,i){for(let a=0,o=0;o<n;a++){let c=this.content[a],d=o+c.nodeSize;if(d>t&&r(c,s+o,i||null,a)!==!1&&c.content.size){let u=o+1;c.nodesBetween(Math.max(0,t-u),Math.min(c.content.size,n-u),r,s+u)}o=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let i="",a=!0;return this.nodesBetween(t,n,(o,c)=>{let d=o.isText?o.text.slice(Math.max(t,c)-c,n-c):o.isLeaf?s?typeof s=="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&d||o.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.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<t.content.length;i++)s.push(t.content[i]);return new Z(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let i=0,a=0;a<n;i++){let o=this.content[i],c=a+o.nodeSize;c>t&&((a<t||c>n)&&(o.isText?o=o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),s+=o.nodeSize),a=c}return new Z(r,s)}cutByIndex(t,n){return t==n?Z.empty:t==0&&n==this.content.length?this:new Z(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new Z(s,i)}addToStart(t){return new Z([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Z(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.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(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return Xi(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return ea(this,t,n,r)}findIndex(t){if(t==0)return dn(0,t);if(t==this.size)return dn(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=t)return i==t?dn(n+1,i):dn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Z.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Z(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Z.empty;let n,r=0;for(let s=0;s<t.length;s++){let i=t[s];r+=i.nodeSize,s&&i.isText&&t[s-1].sameMarkup(i)?(n||(n=t.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new Z(n||t,r)}static from(t){if(!t)return Z.empty;if(t instanceof Z)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Z([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Z.empty=new Z([],0);const tr={index:0,offset:0};function dn(e,t){return tr.index=e,tr.offset=t,tr}function jr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!jr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!jr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Fe{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let i=t[s];if(this.eq(i))return t;if(this.type.excludes(i.type))n||(n=t.slice(0,s));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&jr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.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(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Fe.none;if(t instanceof Fe)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Fe.none=[];class Fc extends Error{}class X{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=na(this.content,t+this.openStart,n);return r&&new X(r,this.openStart,this.openEnd)}removeBetween(t,n){return new X(ta(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return X.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 X(Z.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new X(t,r,s)}}X.empty=new X(Z.empty,0,0);function ta(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:a,offset:o}=e.findIndex(n);if(s==t||i.isText){if(o!=n&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(ta(i.content,t-s-1,n-s-1)))}function na(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s);if(i==t||a.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let o=na(a.content,t-i-1,n,a);return o&&e.replaceChild(s,a.copy(o))}function Pc(e){return e.tag!=null}function Rc(e){return e.style!=null}class Nn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Pc(s))this.tags.push(s);else if(Rc(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=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let r=new Ps(this,n,!1);return r.addAll(t,Fe.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Ps(this,n,!0);return r.addAll(t,Fe.none,n.from,n.to),X.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(_c(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(t,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],o=a.style;if(!(o.indexOf(t)!=0||a.context&&!r.matchesContext(a.context)||o.length>t.length&&(o.charCodeAt(t.length)!=61||o.slice(t.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(t){let n=[];function r(s){let i=s.priority==null?50:s.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<i)break}n.splice(a,0,s)}for(let s in t.marks){let i=t.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in t.nodes){let i=t.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Nn(t,Nn.schemaRules(t)))}}const ra={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},zc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sa={ol:!0,ul:!0},Gt=1,Ar=2,Ht=4;function Fs(e,t,n){return t!=null?(t?Gt:0)|(t==="full"?Ar:0):e&&e.whitespace=="pre"?Gt|Ar:n&~Ht}class un{constructor(t,n,r,s,i,a){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Fe.none,this.match=i||(a&Ht?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Z.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Gt)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=Z.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ra.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ps{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Fs(null,n.preserveWhitespace,0)|(r?Ht:0);s?i=new un(s.type,s.attrs,Fe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new un(null,null,Fe.none,!0,null,a):i=new un(t.schema.topNodeType,null,Fe.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,i=s.options&Ar?"full":this.localPreserveWS||(s.options&Gt)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
-
`);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(a.text(o[c]),n,!/\S/.test(o[c]));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 o=s.content[s.content.length-1],c=t.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let s=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let a=t.nodeName.toLowerCase(),o;sa.hasOwnProperty(a)&&this.parser.normalizeLists&&Bc(t);let c=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,r));e:if(c?c.ignore:zc.hasOwnProperty(a))this.findInside(t),this.ignoreFallback(t,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(t=c.skip);let d,u=this.needsBlock;if(ra.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let h=c&&c.skip?n:this.readStyles(t,n);h&&this.addAll(t,h),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(t,n);d&&this.addElementByRule(t,c,d,c.consuming===!1?o:void 0)}this.localPreserveWS=s}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
12
|
-
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=r.getPropertyValue(i);if(a)for(let o=void 0;;){let c=this.parser.matchStyle(i,a,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(t,n,r,s){let i,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}i&&this.sync(o)&&this.open--}addAll(t,n,r,s){let i=r||0;for(let a=r?t.childNodes[r]:t.firstChild,o=s==null?null:t.childNodes[s];a!=o;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a,n);this.findAtPoint(t,i)}findPlace(t,n,r){let s,i;for(let a=this.open,o=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(t);if(d&&(!s||s.length>d.length+o)&&(s=d,i=c,!d.length))break;if(c.solid){if(r)break;o+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)n=this.enterInner(s[a],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let a=Fe.none;for(let o of s.concat(t.marks))(i.type?i.type.allowsMarkType(o.type):zs(o.type,t.type))&&(a=o.addToSet(a));return i.content.push(t.mark(a)),!0}return!1}enter(t,n,r,s){let i=this.findPlace(t.create(n),r,!1);return i&&(i=this.enterInner(t,n,r,!0,s)),i}enterInner(t,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(t);let o=Fs(t,i,a.options);a.options&Ht&&a.content.length==0&&(o|=Ht);let c=Fe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):zs(d.type,t))?(c=d.addToSet(c),!1):!0),this.nodes.push(new un(t,n,c,s,null,o)),this.open++,r}closeExtra(t=!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(t));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(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Gt)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.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),a=(o,c)=>{for(;o>=0;o--){let d=n[o];if(d==""){if(o==n.length-1||o==0)continue;for(;c>=i;c--)if(a(o-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.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 Bc(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&sa.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function _c(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Rs(e){let t={};for(let n in e)t[n]=e[n];return t}function zs(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],a=o=>{i.push(o);for(let c=0;c<o.edgeCount;c++){let{type:d,next:u}=o.edge(c);if(d==t||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Vn{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=nr(n).createDocumentFragment());let s=r,i=[];return t.forEach(a=>{if(i.length||a.marks.length){let o=0,c=0;for(;o<i.length&&c<a.marks.length;){let d=a.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[o][0])||d.type.spec.spanning===!1)break;o++,c++}for(;o<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let d=a.marks[c++],u=this.serializeMark(d,a.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:s}=xn(nr(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let i=this.serializeMark(t.marks[s],t.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&xn(nr(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return xn(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Vn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Bs(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Bs(t.marks)}}function Bs(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function nr(e){return e.document||window.document}const _s=new WeakMap;function Vc(e){let t=_s.get(e);return t===void 0&&_s.set(e,t=Hc(e)),t}function Hc(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.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(e),t}function xn(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Vc(r))&&i.indexOf(t)>-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 a=s.indexOf(" ");a>0&&(n=s.slice(0,a),s=s.slice(a+1));let o,c=n?e.createElementNS(n,s):e.createElement(s),d=t[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;h<t.length;h++){let p=t[h];if(p===0){if(h<t.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:v}=xn(e,p,n,r);if(c.appendChild(m),v){if(o)throw new RangeError("Multiple content holes");o=v}}}return{dom:c,contentDOM:o}}const ia=65535,aa=Math.pow(2,16);function Uc(e,t){return e+t*aa}function Vs(e){return e&ia}function qc(e){return(e-(e&ia))/aa}const la=1,oa=2,yn=4,ca=8;class Mr{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ca)>0}get deletedBefore(){return(this.delInfo&(la|yn))>0}get deletedAfter(){return(this.delInfo&(oa|yn))>0}get deletedAcross(){return(this.delInfo&yn)>0}}class Ie{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Ie.empty)return Ie.empty}recover(t){let n=0,r=Vs(t);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+qc(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>t)break;let d=this.ranges[o+i],u=this.ranges[o+a],h=c+d;if(t<=h){let p=d?t==c?-1:t==h?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=t==(n<0?c:h)?null:Uc(o/3,t-c),b=t==c?oa:t==h?la:yn;return(n<0?t!=c:t!=h)&&(b|=ca),new Mr(m,b,v)}s+=u-d}return r?t+s:new Mr(t+s,0,null)}touches(t,n){let r=0,s=Vs(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[o+i],u=c+d;if(t<=u&&o==s*3)return!0;r+=this.ranges[o+a]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],o=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];t(o,o+d,c,c+u),i+=u-d}}invert(){return new Ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ie.empty:new Ie(t<0?[0,-t,0]:[0,0,t])}}Ie.empty=new Ie([]);class Sn{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Sn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new Sn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],o=a.mapResult(t,n);if(o.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,t=this._maps[c].recover(o.recover);continue}}s|=o.delInfo,t=o.pos}return r?t:new Mr(t,s,null)}}const rr=Object.create(null);class Ne{getMap(){return Ie.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=rr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in rr)throw new RangeError("Duplicate use of step JSON ID "+t);return rr[t]=n,n.prototype.jsonID=t,n}}class xe{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new xe(t,null)}static fail(t){return new xe(null,t)}static fromReplace(t,n,r,s){try{return xe.ok(t.replace(n,r,s))}catch(i){if(i instanceof Fc)return xe.fail(i.message);throw i}}}function Qr(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(Qr(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return Z.fromArray(r)}class ut extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new X(Qr(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,i)}invert(){return new ft(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ut(n.pos,r.pos,this.mark)}merge(t){return t instanceof ut&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ut(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ut(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("addMark",ut);class ft extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new X(Qr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,r)}invert(){return new ut(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ft(n.pos,r.pos,this.mark)}merge(t){return t instanceof ft&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ft(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ft(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("removeMark",ft);class ht extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.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 ht(this.pos,n.marks[s]);return new ht(this.pos,this.mark)}}return new Qt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ht(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ht(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",ht);class Qt extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ht(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Qt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qt(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",Qt);class Ke extends Ne{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&Er(t,this.from,this.to)?xe.fail("Structure replace would overwrite content"):xe.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ie([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ke(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ke(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ke)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?X.empty:new X(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ke(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?X.empty:new X(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ke(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(n.from,n.to,X.fromJSON(t,n.slice),!!n.structure)}}Ne.jsonID("replace",Ke);class Mt extends Ne{constructor(t,n,r,s,i,a,o=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(t){if(this.structure&&(Er(t,this.from,this.gapFrom)||Er(t,this.gapTo,this.to)))return xe.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xe.fromReplace(t,this.from,this.to,r):xe.fail("Content does not fit in gap")}getMap(){return new Ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Mt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Mt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,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 Mt(n.from,n.to,n.gapFrom,n.gapTo,X.fromJSON(t,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",Mt);function Er(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function da(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;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 a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(o>0?1:0),d=r.node(a),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let h=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}class Ut extends Ne{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.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 xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(s),0,n.isLeaf?0:1))}getMap(){return Ie.empty}invert(t){return new Ut(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Ut(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ut(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Ut);class Cn extends Ne{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return xe.ok(r)}getMap(){return Ie.empty}invert(t){return new Cn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Cn(n.attr,n.value)}}Ne.jsonID("docAttr",Cn);let Zt=class extends Error{};Zt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Zt.prototype=Object.create(Error.prototype);Zt.prototype.constructor=Zt;Zt.prototype.name="TransformError";const sr=Object.create(null);class ae{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new Wc(t.min(n),t.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 t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=X.empty){let r=n.content.lastChild,s=null;for(let o=0;o<n.openEnd;o++)s=r,r=r.lastChild;let i=t.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:d}=a[o],u=t.mapping.slice(i);t.replaceRange(u.map(c.pos),u.map(d.pos),o?X.empty:n),o==0&&qs(t,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:o}=s[i],c=t.mapping.slice(r),d=c.map(a.pos),u=c.map(o.pos);i?t.deleteRange(d,u):(t.replaceRangeWith(d,u,n),qs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new ie(t):Ct(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let i=t.depth-1;i>=0;i--){let a=n<0?Ct(t.node(0),t.node(i),t.before(i+1),t.index(i),n,r):Ct(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,n,r);if(a)return a}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Ue(t.node(0))}static atStart(t){return Ct(t,t,0,0,1)||new Ue(t)}static atEnd(t){return Ct(t,t,t.content.size,t.childCount,-1)||new Ue(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=sr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in sr)throw new RangeError("Duplicate use of selection JSON ID "+t);return sr[t]=n,n.prototype.jsonID=t,n}getBookmark(){return ie.between(this.$anchor,this.$head).getBookmark()}}ae.prototype.visible=!0;class Wc{constructor(t,n){this.$from=t,this.$to=n}}let Hs=!1;function Us(e){!Hs&&!e.parent.inlineContent&&(Hs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ie extends ae{constructor(t,n=t){Us(t),Us(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return ae.near(r);let s=t.resolve(n.map(this.anchor));return new ie(s.parent.inlineContent?s:r,r)}replace(t,n=X.empty){if(super.replace(t,n),n==X.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof ie&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ie(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ae.findFrom(n,r,!0)||ae.findFrom(n,-r,!0);if(i)n=i.$head;else return ae.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(ae.findFrom(t,-r,!0)||ae.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new ie(t,n)}}ae.jsonID("text",ie);class Hn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Hn(t.map(this.anchor),t.map(this.head))}resolve(t){return ie.between(t.resolve(this.anchor),t.resolve(this.head))}}class ee extends ae{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?ae.near(i):new ee(i)}content(){return new X(Z.from(this.node),0,0)}eq(t){return t instanceof ee&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ee(t.resolve(n.anchor))}static create(t,n){return new ee(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}ee.prototype.visible=!1;ae.jsonID("node",ee);class Zr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Hn(r,r):new Zr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&ee.isSelectable(r)?new ee(n):ae.near(n)}}class Ue extends ae{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=X.empty){if(n==X.empty){t.delete(0,t.doc.content.size);let r=ae.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Ue(t)}map(t){return new Ue(t)}eq(t){return t instanceof Ue}getBookmark(){return Kc}}ae.jsonID("all",Ue);const Kc={map(){return this},resolve(e){return new Ue(e)}};function Ct(e,t,n,r,s,i=!1){if(t.inlineContent)return ie.create(e,n);for(let a=r-(s>0?0:1);s>0?a<t.childCount:a>=0;a+=s){let o=t.child(a);if(o.isAtom){if(!i&&ee.isSelectable(o))return ee.create(e,n-(s<0?o.nodeSize:0))}else{let c=Ct(e,o,n+s,s<0?o.childCount:0,s,i);if(c)return c}n+=o.nodeSize*s}return null}function qs(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof Ke||s instanceof Mt))return;let i=e.mapping.maps[r],a;i.forEach((o,c,d,u)=>{a==null&&(a=u)}),e.setSelection(ae.near(e.doc.resolve(a),n))}function Ws(e,t){return!t||!e?e:e.bind(t)}class fn{constructor(t,n,r){this.name=t,this.init=Ws(n.init,r),this.apply=Ws(n.apply,r)}}new fn("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new fn("selection",{init(e,t){return e.selection||ae.atStart(t.doc)},apply(e){return e.selection}}),new fn("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new fn("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function ua(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=ua(s,t,{})),n[r]=s}return n}class Un{constructor(t){this.spec=t,this.props={},t.props&&ua(t.props,this,this.props),this.key=t.key?t.key.key:fa("plugin")}getState(t){return t[this.key]}}const ir=Object.create(null);function fa(e){return e in ir?e+"$"+ ++ir[e]:(ir[e]=0,e+"$")}class Xr{constructor(t="key"){this.key=fa(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Jc=/^```([a-z]+)?[\s\n]$/,Yc=/^~~~([a-z]+)?[\s\n]$/,Gc=V.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",V.mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
|
|
13
|
-
|
|
14
|
-
`);return!i||!a?!1:e.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const o=s.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:d})=>(d.setSelection(ae.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[V.textblockTypeInputRule({find:Jc,type:this.type,getAttributes:e=>({language:e[1]})}),V.textblockTypeInputRule({find:Yc,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Un({key:new Xr("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:a,schema:o}=e.state,c=o.text(n.replace(/\r\n?/g,`
|
|
15
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(ie.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),e.dispatch(a),!0}}})]}}),Qc=/^\s*>\s$/,Zc=V.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[V.wrappingInputRule({find:Qc,type:this.type})]}}),Xc=V.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",V.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!V.canInsertNode(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$from:r,$to:s}=n,i=e();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):V.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:o})=>{var c;if(o){const{$to:d}=a.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?a.setSelection(ie.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(ee.create(a.doc,d.pos)):a.setSelection(ie.create(a.doc,d.pos));else{const h=(c=d.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();h&&(a.insert(u,h),a.setSelection(ie.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[V.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ed=V.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",V.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
16
|
-
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const h=c.filter(p=>o.includes(p.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jn=200,ve=function(){};ve.prototype.append=function(t){return t.length?(t=ve.from(t),!this.length&&t||t.length<jn&&this.leafAppend(t)||this.length<jn&&t.leafPrepend(this)||this.appendInner(t)):this};ve.prototype.prepend=function(t){return t.length?ve.from(t).append(this):this};ve.prototype.appendInner=function(t){return new td(this,t)};ve.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?ve.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};ve.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};ve.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};ve.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(t(i,a))},n,r),s};ve.from=function(t){return t instanceof ve?t:t&&t.length?new ha(t):ve.empty};var ha=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new t(this.values.slice(s,i))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,i,a,o){for(var c=i;c<a;c++)if(s(this.values[c],o+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,i,a,o){for(var c=i-1;c>=a;c--)if(s(this.values[c],o+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=jn)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=jn)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(ve);ve.empty=new ha([]);var td=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,i,a){var o=this.left.length;if(s<o&&this.left.forEachInner(r,s,Math.min(i,o),a)===!1||i>o&&this.right.forEachInner(r,Math.max(s-o,0),Math.min(this.length,i)-o,a+o)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,i,a){var o=this.left.length;if(s>o&&this.right.forEachInvertedInner(r,s-o,Math.max(i,o)-o,a+o)===!1||i<o&&this.left.forEachInvertedInner(r,Math.min(s,o),i,a)===!1)return!1},t.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))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(ve);const nd=500;class Re{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,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 a=t.tr,o,c,d=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new Ve(h.map));let m=h.step.map(s.slice(i)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],d.push(new Ve(v,void 0,void 0,d.length+u.length))),i--,v&&s.appendMap(v,i)}else a.maybeStep(h.step);if(h.selection)return o=s?h.selection.map(s.slice(i)):h.selection,c=new Re(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:o}}addTransform(t,n,r,s){let i=[],a=this.eventCount,o=this.items,c=!s&&o.length?o.get(o.length-1):null;for(let u=0;u<t.steps.length;u++){let h=t.steps[u].invert(t.docs[u]),p=new Ve(t.mapping.maps[u],h,n),m;(m=c&&c.merge(p))&&(p=m,u?i.pop():o=o.slice(0,o.length-1)),i.push(p),n&&(a++,n=void 0),s||(c=p)}let d=a-r.depth;return d>sd&&(o=rd(o,d),a-=d),new Re(o.append(i),a)}remapping(t,n){let r=new Sn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Re(this.items.append(t.map(n=>new Ve(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=t.mapping,a=t.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},s);let c=n;this.items.forEach(p=>{let m=i.getMirror(--c);if(m==null)return;a=Math.min(a,m);let v=i.maps[m];if(p.step){let b=t.steps[m].invert(t.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&o++,r.push(new Ve(v,b,x))}else r.push(new Ve(v))},s);let d=[];for(let p=n;p<a;p++)d.push(new Ve(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),h=new Re(u,o);return h.emptyItemCount()>nd&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],i=0;return this.items.forEach((a,o)=>{if(o>=t)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(n.slice(r)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=a.selection&&a.selection.map(n.slice(r));u&&i++;let h=new Ve(d.invert(),c,u),p,m=s.length-1;(p=s.length&&s[m].merge(h))?s[m]=p:s.push(h)}}else a.map&&r--},this.items.length,0),new Re(ve.from(s.reverse()),i)}}Re.empty=new Re(ve.empty,0);function rd(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Ve{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Ve(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(t,n,r,s,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const sd=20;function id(e,t,n,r){let s=n.getMeta(pt),i;if(s)return s.historyState;n.getMeta(od)&&(e=new Ze(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(pt))return a.getMeta(pt).redo?new Ze(e.done.addTransform(n,void 0,r,bn(t)),e.undone,Ks(n.mapping.maps),e.prevTime,e.prevComposition):new Ze(e.done,e.undone.addTransform(n,void 0,r,bn(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=e.prevTime==0||!a&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ad(n,e.prevRanges)),d=a?ar(e.prevRanges,n.mapping):Ks(n.mapping.maps);return new Ze(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,bn(t)),Re.empty,d,n.time,o??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(e.done.rebased(n,i),e.undone.rebased(n,i),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ze(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ad(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&s>=t[i]&&(n=!0)}),n}function Ks(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,i,a)=>t.push(i,a));return t}function ar(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}function ld(e,t,n){let r=bn(t),s=pt.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),o=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),c=new Ze(n?o:i.remaining,n?i.remaining:o,null,0,-1);return i.transform.setSelection(a).setMeta(pt,{redo:n,historyState:c})}let lr=!1,Js=null;function bn(e){let t=e.plugins;if(Js!=t){lr=!1,Js=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){lr=!0;break}}return lr}const pt=new Xr("history"),od=new Xr("closeHistory");function cd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Un({key:pt,state:{init(){return new Ze(Re.empty,Re.empty,null,0,-1)},apply(t,n,r){return id(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?pa:r=="historyRedo"?ga:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function ma(e,t){return(n,r)=>{let s=pt.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let i=ld(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const pa=ma(!1,!0),ga=ma(!0,!0),Ys=V.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>pa(e,t),redo:()=>({state:e,dispatch:t})=>ga(e,t)}},addProseMirrorPlugins(){return[cd(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()}}}),dd=V.Node.create({name:"doc",topNode:!0,content:"block+"}),ud=V.Node.create({name:"text",group:"inline"});function fd(e={}){return new Un({view(t){return new hd(t,e)}})}class hd{constructor(t,n){var r;this.editorView=t,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=a=>{this[s](a)};return t.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,o=i.height/s.offsetHeight;if(n){let h=t.nodeBefore,p=t.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let v=m.getBoundingClientRect(),b=h?v.bottom:v.top;h&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*o;r={left:v.left,right:v.right,top:b-x,bottom:b+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.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(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;d=h.left-c.scrollLeft*p,u=h.top-c.scrollTop*m}this.element.style.left=(r.left-d)/a+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.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,t):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=da(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const md=V.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[fd(this.options)]}});var st={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:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pd=typeof navigator<"u"&&/Mac/.test(navigator.platform),gd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)st[48+we]=st[96+we]=String(we);for(var we=1;we<=24;we++)st[we+111]="F"+we;for(var we=65;we<=90;we++)st[we]=String.fromCharCode(we+32),An[we]=String.fromCharCode(we);for(var or in st)An.hasOwnProperty(or)||(An[or]=st[or]);function xd(e){var t=pd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||gd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?An:st)[e.keyCode]||e.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 yd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),bd=typeof navigator<"u"&&/Win/.test(navigator.platform);function vd(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let o=0;o<t.length-1;o++){let c=t[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))yd?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function wd(e){let t=Object.create(null);for(let n in e)t[vd(n)]=e[n];return t}function cr(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function kd(e){let t=wd(e);return function(n,r){let s=xd(r),i,a=t[cr(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let o=t[cr(s,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(bd&&r.ctrlKey&&r.altKey)&&(i=st[r.keyCode])&&i!=s){let o=t[cr(i,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}const bt=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},xa=function(e,t,n,r){return n&&(Gs(e,t,n,r,-1)||Gs(e,t,n,r,1))},Nd=/^(img|br|input|textarea|hr)$/i;function Gs(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:Mn(e))){let a=e.parentNode;if(!a||a.nodeType!=1||es(e)||Nd.test(e.nodeName)||e.contentEditable=="false")return!1;t=bt(e)+(s<0?0:1),e=a}else if(e.nodeType==1){let a=e.childNodes[t+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=s;else return!1;else e=a,t=s<0?Mn(e):0}else return!1}}function Mn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Sd(e,t,n){for(let r=t==0,s=t==Mn(e);r||s;){if(e==n)return!0;let i=bt(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,s=s&&i==Mn(e)}}function es(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ya=function(e){return e.focusNode&&xa(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ba(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const qe=typeof navigator<"u"?navigator:null,Qs=typeof document<"u"?document:null,it=qe&&qe.userAgent||"",Tr=/Edge\/(\d+)/.exec(it),va=/MSIE \d/.exec(it),Dr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),rn=!!(va||Dr||Tr),wa=va?document.documentMode:Dr?+Dr[1]:Tr?+Tr[1]:0,qn=!rn&&/gecko\/(\d+)/i.test(it);qn&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const Ir=!rn&&/Chrome\/(\d+)/.exec(it),Ye=!!Ir,ka=Ir?+Ir[1]:0,vt=!rn&&!!qe&&/Apple Computer/.test(qe.vendor),ts=vt&&(/Mobile\/\w+/.test(it)||!!qe&&qe.maxTouchPoints>2),Le=ts||(qe?/Mac/.test(qe.platform):!1),Na=qe?/Win/.test(qe.platform):!1,sn=/Android \d/.test(it),ns=!!Qs&&"webkitFontSmoothing"in Qs.documentElement.style,Cd=ns?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),c,d;if(ya(n)){for(c=a;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&ee.isSelectable(h)&&s.parent&&!(h.isInline&&Sd(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new ee(a==p?o:r.resolve(p))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=a,p=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);h=Math.min(h,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;[c,a]=p==e.state.selection.anchor?[p,h]:[h,p],o=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let h=t=="pointer"||e.state.selection.head<o.pos&&!i?1:-1;d=Ca(e,u,o,h)}return d}function Sa(e){return e.editable?e.hasFocus():Td(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rs(e,t=!1){let n=e.state.selection;if(Ed(e,n),!!Sa(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ye){let r=e.domSelectionRange(),s=e.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&xa(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Md(e);else{let{anchor:r,head:s}=n,i,a;Zs&&!(n instanceof ie)&&(n.$from.parent.inlineContent||(i=Xs(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Xs(e,n.to))),e.docView.setSelection(r,s,e,t),Zs&&(i&&ei(i),a&&ei(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ad(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Zs=vt||Ye&&ka<63;function Xs(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(vt&&s&&s.contentEditable=="false")return dr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return dr(s);if(i)return dr(i)}}function dr(e){return e.contentEditable="true",vt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ei(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ad(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Sa(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Md(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,bt(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&rn&&wa<=11&&(n.disabled=!0,n.disabled=!1)}function Ed(e,t){if(t instanceof ee){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ti(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ti(e)}function ti(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ca(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||ie.between(t,n,r)}function Td(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function $r(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&ae.findFrom(i,t)}function Xe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ni(e,t,n){let r=e.state.selection;if(r instanceof ie)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(s.pos+i.nodeSize*(t<0?-1:1));return Xe(e,new ie(r.$anchor,a))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=$r(e.state,t);return s&&s instanceof ee?Xe(e,s):!1}else if(!(Le&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?ee.isSelectable(i)?Xe(e,new ee(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):ns?Xe(e,new ie(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ee&&r.node.isInline)return Xe(e,new ie(t>0?r.$to:r.$from));{let s=$r(e.state,t);return s?Xe(e,s):!1}}}function En(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function qt(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function kt(e,t){return t<0?Dd(e):Id(e)}function Dd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,a=!1;for(qn&&n.nodeType==1&&r<En(n)&&qt(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(qt(o,-1))s=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(ja(n))break;{let o=n.previousSibling;for(;o&&qt(o,-1);)s=n.parentNode,i=bt(o),o=o.previousSibling;if(o)n=o,r=En(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}a?Or(e,n,r):s&&Or(e,s,i)}function Id(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=En(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let o=n.childNodes[r];if(qt(o,1))i=n,a=++r;else break}else{if(ja(n))break;{let o=n.nextSibling;for(;o&&qt(o,1);)i=o.parentNode,a=bt(o)+1,o=o.nextSibling;if(o)n=o,r=0,s=En(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Or(e,i,a)}function ja(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function $d(e,t){for(;e&&t==e.childNodes.length&&!es(e);)t=bt(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function Od(e,t){for(;e&&!t&&!es(e);)t=bt(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Or(e,t,n){if(t.nodeType!=3){let i,a;(a=$d(t,n))?(t=a,n=0):(i=Od(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(ya(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&rs(e)},50)}function ri(e,t){let n=e.state.doc.resolve(t);if(!(Ye||Na)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function si(e,t,n){let r=e.state.selection;if(r instanceof ie&&!r.empty||n.indexOf("s")>-1||Le&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let a=$r(e.state,t);if(a&&a instanceof ee)return Xe(e,a)}if(!s.parent.inlineContent){let a=t<0?s:i,o=r instanceof Ue?ae.near(a,t):ae.findFrom(a,t);return o?Xe(e,o):!1}return!1}function ii(e,t){if(!(e.state.selection instanceof ie))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=e.state.tr;return t<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),e.dispatch(a),!0}return!1}function ai(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ld(e){if(!vt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ai(e,r,"true"),setTimeout(()=>ai(e,r,"false"),20)}return!1}function Fd(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Pd(e,t){let n=t.keyCode,r=Fd(t);if(n==8||Le&&n==72&&r=="c")return ii(e,-1)||kt(e,-1);if(n==46&&!t.shiftKey||Le&&n==68&&r=="c")return ii(e,1)||kt(e,1);if(n==13||n==27)return!0;if(n==37||Le&&n==66&&r=="c"){let s=n==37?ri(e,e.state.selection.from)=="ltr"?-1:1:-1;return ni(e,s,r)||kt(e,s)}else if(n==39||Le&&n==70&&r=="c"){let s=n==39?ri(e,e.state.selection.from)=="ltr"?1:-1:1;return ni(e,s,r)||kt(e,s)}else{if(n==38||Le&&n==80&&r=="c")return si(e,-1,r)||kt(e,-1);if(n==40||Le&&n==78&&r=="c")return Ld(e)||si(e,1,r)||kt(e,1);if(r==(Le?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Aa(e,t){e.someProp("transformCopied",m=>{t=m(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=e.someProp("clipboardSerializer")||Vn.fromSchema(e.state.schema),o=$a(),c=o.createElement("div");c.appendChild(a.serializeFragment(r,{document:o}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=Ia[d.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let v=o.createElement(u[m]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),h++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",m=>m(t,e))||t.content.textBetween(0,t.content.size,`
|
|
17
|
-
|
|
18
|
-
`);return{dom:c,text:p,slice:t}}function Ma(e,t,n,r,s){let i=s.parent.type.spec.code,a,o;if(!n&&!t)return null;let c=!!t&&(r||i||!n);if(c){if(e.someProp("transformPastedText",p=>{t=p(t,i||r,e)}),i)return o=new X(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
19
|
-
`))),0,0),e.someProp("transformPasted",p=>{o=p(o,e,!0)}),o;let h=e.someProp("clipboardTextParser",p=>p(t,s,r,e));if(h)o=h;else{let p=s.marks(),{schema:m}=e.state,v=Vn.fromSchema(m);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else e.someProp("transformPastedHTML",h=>{n=h(n,e)}),a=_d(n),ns&&Vd(a);let d=a&&a.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let p=a.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;a=p}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||Nn.fromSchema(e.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Rd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Hd(li(o,+u[1],+u[2]),u[4]);else if(o=X.maxOpen(zd(o.content,s),!0),o.openStart||o.openEnd){let h=0,p=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;p<o.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);o=li(o,h,p)}return e.someProp("transformPasted",h=>{o=h(o,e,c)}),o}const Rd=/^(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 zd(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(o=>{if(!a)return;let c=s.findWrapping(o.type),d;if(!c)return a=null;if(d=a.length&&i.length&&Ta(c,i,o,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Da(a[a.length-1],i.length));let u=Ea(o,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return Z.from(a)}return e}function Ea(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function Ta(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=Ta(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(Z.from(Ea(n,e,s+1))))}}function Da(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Da(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function Lr(e,t,n,r,s,i){let a=t<0?e.firstChild:e.lastChild,o=a.content;return e.childCount>1&&(i=0),s<r-1&&(o=Lr(o,t,n,r,s+1,i)),s>=n&&(o=t<0?a.contentMatchAt(0).fillBefore(o,i<=s).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(o))}function li(e,t,n){return t<e.openStart&&(e=new X(Lr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new X(Lr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ia={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 oi=null;function $a(){return oi||(oi=document.implementation.createHTMLDocument("title"))}let ur=null;function Bd(e){let t=window.trustedTypes;return t?(ur||(ur=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ur.createHTML(e)):e}function _d(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$a().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),s;if((s=r&&Ia[r[1].toLowerCase()])&&(e=s.map(i=>"<"+i+">").join("")+e+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Bd(e),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Vd(e){let t=e.querySelectorAll(Ye?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Hd(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:i,openEnd:a}=e;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;s=Z.from(c.create(r[o+1],s)),i++,a++}return new X(s,i,a)}const _e={},Oe={};function et(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}Oe.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!La(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(sn&&Ye&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ts&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ba(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Pd(e,n)?n.preventDefault():et(e,"key")};Oe.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Oe.keypress=(e,t)=>{let n=t;if(La(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Le&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof ie)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",a=>a(e,r.$from.pos,r.$to.pos,s,i))&&e.dispatch(i()),n.preventDefault()}};function Wn(e){return{left:e.clientX,top:e.clientY}}function Ud(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ss(e,t,n,r,s){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(e.someProp(t,o=>a>i.depth?o(e,n,i.nodeAfter,i.before(a),s,!0):o(e,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Et(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function qd(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&ee.isSelectable(r)?(Et(e,new ee(n)),!0):!1}function Wd(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof ee&&(r=n.node);let i=e.state.doc.resolve(t);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a);if(ee.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(a);break}}return s!=null?(Et(e,ee.create(e.state.doc,s)),!0):!1}function Kd(e,t,n,r,s){return ss(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(s?Wd(e,n):qd(e,n))}function Jd(e,t,n,r){return ss(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function Yd(e,t,n,r){return ss(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||Gd(e,n,r)}function Gd(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Et(e,ie.create(r,0,r.content.size)),!0):!1;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),o=s.before(i);if(a.inlineContent)Et(e,ie.create(r,o+1,o+1+a.content.size));else if(ee.isSelectable(a))Et(e,ee.create(r,o));else continue;return!0}}function is(e){return Tn(e)}const Oa=Le?"metaKey":"ctrlKey";_e.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=is(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&Ud(n,e.input.lastClick)&&!n[Oa]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=e.posAtCoords(Wn(n));a&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Qd(e,a,n,!!r)):(i=="doubleClick"?Jd:Yd)(e,a.pos,a.inside,n)?n.preventDefault():et(e,"pointer"))};class Qd{constructor(t,n,r,s){this.view=t,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Oa],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),a=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const o=s?null:r.target,c=o?t.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof ee&&d.from<=a&&d.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qn&&!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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),et(t,"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(()=>rs(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Wn(t))),this.updateAllowDefault(t),this.allowDefault||!n?et(this.view,"pointer"):Kd(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||vt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ye&&!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)?(Et(this.view,ae.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):et(this.view,"pointer")}move(t){this.updateAllowDefault(t),et(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}_e.touchstart=e=>{e.input.lastTouch=Date.now(),is(e),et(e,"pointer")};_e.touchmove=e=>{e.input.lastTouch=Date.now(),et(e,"pointer")};_e.contextmenu=e=>is(e);function La(e,t){return e.composing?!0:vt&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Zd=sn?5e3:-1;Oe.compositionstart=Oe.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ie&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ye&&Na&&Xd(e)))e.markCursor=e.state.storedMarks||n.marks(),Tn(e,!0),e.markCursor=null;else if(Tn(e,!t.selection.empty),qn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let o=e.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}e.input.composing=!0}Fa(e,Zd)};function Xd(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Oe.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Fa(e,20))};function Fa(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tn(e),t))}function eu(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=tu());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function tu(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Tn(e,t=!1){if(!(sn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),eu(e),t||e.docView&&e.docView.dirty){let n=jd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function nu(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Xt=rn&&wa<15||ts&&Cd<604;_e.copy=Oe.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let i=Xt?null:n.clipboardData,a=r.content(),{dom:o,text:c}=Aa(e,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",c)):nu(e,o),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ru(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function su(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fr(e,r.value,null,s,t):Fr(e,r.textContent,r.innerHTML,s,t)},50)}function Fr(e,t,n,r,s){let i=Ma(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,i||X.empty)))return!0;if(!i)return!1;let a=ru(i),o=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pa(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Oe.paste=(e,t)=>{let n=t;if(e.composing&&!sn)return;let r=Xt?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fr(e,Pa(r),r.getData("text/html"),s,n)?n.preventDefault():su(e,n)};class iu{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const au=Le?"altKey":"ctrlKey";function Ra(e,t){let n=e.someProp("dragCopies",r=>!r(t));return n??!t[au]}_e.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(Wn(n)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ee?s.to-1:s.to))){if(r&&r.mightDrag)a=ee.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=e.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=e.docView&&(a=ee.create(e.state.doc,h.posBefore))}}let o=(a||e.state.selection).content(),{dom:c,text:d,slice:u}=Aa(e,o);(!n.dataTransfer.files.length||!Ye||ka>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xt?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Xt||n.dataTransfer.setData("text/plain",d),e.dragging=new iu(u,Ra(e,n),a)};_e.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Oe.dragover=Oe.dragenter=(e,t)=>t.preventDefault();Oe.drop=(e,t)=>{try{lu(e,t,e.dragging)}finally{e.dragging=null}};function lu(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Wn(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",m=>{i=m(i,e,!1)}):i=Ma(e,Pa(t.dataTransfer),Xt?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Ra(e,t));if(e.someProp("handleDrop",m=>m(e,t,i||X.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let o=i?da(e.state.doc,s.pos,i):s.pos;o==null&&(o=s.pos);let c=e.state.tr;if(a){let{node:m}=n;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(o),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&ee.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new ee(p));else{let m=c.mapping.map(o);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,w)=>m=w),c.setSelection(Ca(e,p,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}_e.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rs(e)},20))};_e.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};_e.beforeinput=(e,t)=>{if(Ye&&sn&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,ba(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in Oe)_e[e]=Oe[e];function en(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Dn{constructor(t,n){this.toDOM=t,this.spec=n||gt,this.side=this.spec.side||0}map(t,n,r,s){let{pos:i,deleted:a}=t.mapResult(n.from+s,this.side<0?-1:1);return a?null:new He(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Dn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&en(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class nt{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new He(i,a,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof nt&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}static is(t){return t.type instanceof nt}destroy(){}}class as{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.mapResult(n.from+s,1);if(i.deleted)return null;let a=t.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new He(i.pos-r,a.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),i;return s==n.from&&!(i=t.child(r)).isText&&s+i.nodeSize==n.to}eq(t){return this==t||t instanceof as&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}destroy(){}}class He{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new He(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new He(t,t,new Dn(n,r))}static inline(t,n,r,s){return new He(t,n,new nt(r,s))}static node(t,n,r,s){return new He(t,n,new as(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Dn}}const jt=[],gt={};class be{constructor(t,n){this.local=t.length?t:jt,this.children=n.length?n:jt}static create(t,n){return n.length?In(n,t,0,gt):Ae}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=t&&(!i||i(o.spec))&&r.push(o.copy(o.from+s,o.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>t){let o=this.children[a]+1;this.children[a+2].findInner(t-o,n-o,r,s+o,i)}}map(t,n,r){return this==Ae||t.maps.length==0?this:this.mapInner(t,n,0,0,r||gt)}mapInner(t,n,r,s,i){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(t,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?ou(this.children,a||[],t,n,r,s,i):a?new be(a.sort(xt),jt):Ae}add(t,n){return n.length?this==Ae?be.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((o,c)=>{let d=c+r,u;if(u=Ba(n,o,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(o,u,d+1):s.splice(i,0,c,c+o.nodeSize,In(u,o,d+1,gt)),i+=3}});let a=za(i?_a(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||a.splice(o--,1);return new be(a.length?this.local.concat(a).sort(xt):this.local,s||this.children)}remove(t){return t.length==0||this==Ae?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let a,o=r[i]+n,c=r[i+1]+n;for(let u=0,h;u<t.length;u++)(h=t[u])&&h.from>o&&h.to<c&&(t[u]=null,(a||(a=[])).push(h));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,o+1);d!=Ae?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<t.length;i++)if(a=t[i])for(let o=0;o<s.length;o++)s[o].eq(a,n)&&(s==this.local&&(s=this.local.slice()),s.splice(o--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):Ae}forChild(t,n){if(this==Ae)return this;if(n.isLeaf)return be.empty;let r,s;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}let i=t+1,a=i+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<a&&c.to>i&&c.type instanceof nt){let d=Math.max(i,c.from)-i,u=Math.min(a,c.to)-i;d<u&&(s||(s=[])).push(c.copy(d,u))}}if(s){let o=new be(s.sort(xt),jt);return r?new dt([o,r]):o}return r||Ae}eq(t){if(this==t)return!0;if(!(t instanceof be)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return ls(this.localsInner(t))}localsInner(t){if(this==Ae)return jt;if(t.inlineContent||!this.local.some(nt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nt||n.push(this.local[r]);return n}forEachSet(t){t(this)}}be.empty=new be([],[]);be.removeOverlap=ls;const Ae=be.empty;class dt{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,gt));return dt.from(r)}forChild(t,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=Ae&&(i instanceof dt?r=r.concat(i.members):r.push(i))}return dt.from(r)}eq(t){if(!(t instanceof dt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let a=0;a<i.length;a++)n.push(i[a])}}return n?ls(r?n:n.sort(xt)):jt}static from(t){switch(t.length){case 0:return Ae;case 1:return t[0];default:return new dt(t.every(n=>n instanceof be)?t:t.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function ou(e,t,n,r,s,i,a){let o=e.slice();for(let d=0,u=i;d<n.maps.length;d++){let h=0;n.maps[d].forEach((p,m,v,b)=>{let x=b-v-(m-p);for(let w=0;w<o.length;w+=3){let S=o[w+1];if(S<0||p>S+u-h)continue;let M=o[w]+u-h;m>=M?o[w+1]=p<=M?-2:-1:p>=u&&x&&(o[w]+=x,o[w+1]+=x)}h+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<o.length;d+=3)if(o[d+1]<0){if(o[d+1]==-2){c=!0,o[d+1]=-1;continue}let u=n.map(e[d]+i),h=u-s;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(e[d+1]+i,-1),m=p-s,{index:v,offset:b}=r.content.findIndex(h),x=r.maybeChild(v);if(x&&b==h&&b+x.nodeSize==m){let w=o[d+2].mapInner(n,x,u+1,e[d]+i+1,a);w!=Ae?(o[d]=h,o[d+1]=m,o[d+2]=w):(o[d+1]=-2,c=!0)}else c=!0}if(c){let d=cu(o,e,t,n,s,i,a),u=In(d,r,0,a);t=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,p=0;h<u.children.length;h+=3){let m=u.children[h];for(;p<o.length&&o[p]<m;)p+=3;o.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new be(t.sort(xt),o)}function za(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new He(s.from+t,s.to+t,s.type))}return n}function cu(e,t,n,r,s,i,a){function o(c,d){for(let u=0;u<c.local.length;u++){let h=c.local[u].map(r,s,d);h?n.push(h):a.onRemove&&a.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)o(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&o(e[c+2],t[c]+i+1);return n}function Ba(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i=0,a;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),e[i]=null);return s}function _a(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function In(e,t,n,r){let s=[],i=!1;t.forEach((o,c)=>{let d=Ba(e,o,c+n);if(d){i=!0;let u=In(d,o,n+c+1,r);u!=Ae&&s.push(c,c+o.nodeSize,u)}});let a=za(i?_a(e):e,-n).sort(xt);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||s.length?new be(a,s):Ae}function xt(e,t){return e.from-t.from||e.to-t.to}function ls(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),ci(t,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),ci(t,s,r.copy(i.from,r.to)));break}}}return t}function ci(e,t,n){for(;t<e.length&&xt(n,e[t])>0;)t++;e.splice(t,0,n)}class me extends ae{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return me.valid(r)?new me(r):ae.near(r)}content(){return X.empty}eq(t){return t instanceof me&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(t.resolve(n.pos))}getBookmark(){return new os(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!du(t)||!uu(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&me.valid(t))return t;let s=t.pos,i=null;for(let a=t.depth;;a--){let o=t.node(a);if(n>0?t.indexAfter(a)<o.childCount:t.index(a)>0){i=o.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;s+=n;let c=t.doc.resolve(s);if(me.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!ee.isSelectable(i)){t=t.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let o=t.doc.resolve(s);if(me.valid(o))return o}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;ae.jsonID("gapcursor",me);class os{constructor(t){this.pos=t}map(t){return new os(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return me.valid(n)?new me(n):ae.near(n)}}function Va(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function du(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);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||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uu(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);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||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fu(){return new Un({props:{decorations:gu,createSelectionBetween(e,t,n){return t.pos==n.pos&&me.valid(n)?new me(n):null},handleClick:mu,handleKeyDown:hu,handleDOMEvents:{beforeinput:pu}}})}const hu=kd({ArrowLeft:hn("horiz",-1),ArrowRight:hn("horiz",1),ArrowUp:hn("vert",-1),ArrowDown:hn("vert",1)});function hn(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,i){let a=r.selection,o=t>0?a.$to:a.$from,c=a.empty;if(a instanceof ie){if(!i.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(t>0?o.after():o.before())}let d=me.findGapCursorFrom(o,t,c);return d?(s&&s(r.tr.setSelection(new me(d))),!0):!1}}function mu(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!me.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ee.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new me(r))),!0)}function pu(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof me))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=Z.empty;for(let a=r.length-1;a>=0;a--)s=Z.from(r[a].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new X(s,0,0));return i.setSelection(ie.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function gu(e){if(!(e.selection instanceof me))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",be.create(e.doc,[He.widget(e.selection.head,t,{key:"gapcursor"})])}const xu=V.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[fu()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=V.callOrReturn(V.getExtensionField(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Rt={bold:{category:"mark",extension:pc,priority:100},italic:{category:"mark",extension:vc,priority:100},strike:{category:"mark",extension:Nc,priority:100},underline:{category:"mark",extension:Eo.Underline,priority:100},code:{category:"mark",extension:jc,priority:100},textColor:{category:"mark",extension:To.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Do.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Io.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ec,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ic,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Oc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:$o.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Gc,priority:100},blockquote:{category:"node",extension:Zc,priority:100},horizontalRule:{category:"node",extension:Xc,priority:100},hardBreak:{category:"node",extension:ed,priority:100},undo:{category:"extension",extension:Ys,priority:50},redo:{category:"extension",extension:Ys,priority:50},textAlign:{category:"extension",extension:Lo.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}},yu=[dd,ud,Tc,Mc.configure({HTMLAttributes:{}}),Lc.configure({HTMLAttributes:{}}),Oo.TaskItem.configure({nested:!0}),md,xu];function bu(e){const t=[],n=new Set,r=new Set;yu.forEach(o=>{o&&(t.push(o),r.add(o.name))});const s=e.map(o=>Yt(o)),i=new Set;return s.forEach(o=>{const c=Rt[o];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c||c.extension===null)return;const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),s.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c){console.warn(`Extension config not found for modifier: ${o}`);return}if(c.extension===null){n.add(o);return}const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),t.sort((o,c)=>{const d=Object.values(Rt).find(m=>m?.extension?.name===o.name),u=Object.values(Rt).find(m=>m?.extension?.name===c.name),h=d?.priority??100;return(u?.priority??100)-h})}const Ha={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"]},he={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"}},Qe={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},de={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},vu={h1:`font-size: ${he.fontSize["4xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h2:`font-size: ${he.fontSize["2xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h3:`font-size: ${he.fontSize.xl}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h4:`font-size: ${he.fontSize.lg}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h5:`font-size: ${he.fontSize.base}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h6:`font-size: ${he.fontSize.sm}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,p:`min-height: ${he.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,li:`display: list-item; margin: ${de.xs} 0;`,strong:`font-weight: ${he.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Qe.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${he.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${he.fontFamily.mono};`,pre:`background: ${Qe.neutral.gray[800]}; border-radius: ${de.sm}; color: ${Qe.neutral.gray[100]}; font-family: ${he.fontFamily.mono}; margin: ${de.lg} 0; padding: 0.75rem ${de.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Qe.neutral.gray[300]}; margin: ${de.lg} 0; padding-left: ${de.md}; color: ${Qe.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Qe.neutral.gray[200]}; margin: ${de.xl} 0;`,a:`color: ${Qe.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Qe.palettes.warning[200]}; border-radius: ${de.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${de.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},wu={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 ku(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(wu)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(vu)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.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 a=i.indexOf(">");return`${i.slice(0,a)} style="${r}"${i.slice(a)}`}})}return t}const Nu=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Jr.useCurrentEditor();return l.jsx(dc,{editor:s,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},Su=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=Jr.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(a=>a.length>0).length;return l.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&l.jsxs("span",{children:[s," characters"]}),t&&l.jsxs("span",{children:[i," words"]})]})},Pr=y.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:o=!0,modifiers:c=Ha.full,variant:d="bordered",initialContent:u,content:h,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:w=!0,...S}=e,{zoom:M,setZoom:N}=lc(),j=Ts.lineHeight,T=n*j,$=s?void 0:r*j,W=y.useMemo(()=>bu(c),[c]),{Component:D,label:R,shouldLabelBeOutside:E,getBaseProps:C,getLabelProps:I,getInputWrapperProps:F}=f.useInput({...S,variant:d,ref:t,isMultiline:!0}),H=R?l.jsx("label",{...I(),children:R}):null,Q=y.useCallback(({editor:Y})=>{const te=Y.getHTML(),oe=w?ku(te):te,ce=Y.getJSON(),P=Y.getText(),_=P.length,G=P.split(/\s+/).filter(Se=>Se.length>0).length,ne={html:oe,json:ce,text:P,characters:_,words:G};if(p?.(ne),m?.(ne),"onChange"in S&&typeof S.onChange=="function"){const Se={target:{value:oe},currentTarget:{value:oe}};S.onChange(Se)}},[p,m,S,w]);return l.jsxs(D,{...C(),children:[E?H:null,l.jsx("div",{...F(),className:f.cn(F().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:$?`${$+Ts.toolbarHeight}px`:void 0,overflow:$?"auto":void 0},children:l.jsx(Jr.EditorProvider,{editable:!b&&!x,slotBefore:o?l.jsx(Nu,{modifiers:c,zoom:M,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:l.jsx(Su,{showCharacterCount:i,showWordCount:a}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${T}px`,fontSize:`${M}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:W,content:h||u||e.defaultValue||"",onUpdate:Q})})]})});Pr.displayName="TipTapEditor";const Ua=y.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=e;return n==="tiptap"?l.jsx(Pr,{...s,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),l.jsx(Pr,{...s,variant:r,ref:t}))});Ua.displayName="RichTextArea";function Cu(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const di=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],ju={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},qa=({presetAmounts:e=di,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:a="en-US",showCustomAmount:o=!0,minCustomAmount:c=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:h=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:w="md",className:S="",showCard:M=!0})=>{const N={...ju,...u},j=Array.isArray(e)?e:di,T={2:"grid-cols-2",3:"grid-cols-3"},$={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},W=`${T[h]} ${$[p]}`,[D,R]=Yr(t,n,r),[E,C]=y.useState(""),[I,F]=y.useState(!1),[H,Q]=y.useState(0),Y=y.useCallback(_=>{if(m)return;const G={amount:_.amount,isCustom:!1,presetId:_.id};R(G),C(""),F(!1),Q(ne=>ne+1),s?.(G)},[m,R,s]),te=y.useCallback(_=>{if(m)return;if(C(_!==void 0?String(_):""),s){R(null);return}if(_===void 0||isNaN(_)){R(null);return}R({amount:_,isCustom:!0})},[m,R,s]),oe=y.useCallback(()=>{if(m)return;const _=E!==""?parseFloat(E):void 0;_===void 0||isNaN(_)||s?.({amount:_,isCustom:!0})},[m,E,s]),ce=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),P=l.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[N.title&&l.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:N.title}),j.length>0&&l.jsx("div",{className:f.cn("grid gap-3",W),"data-testid":"donation-amounts-presets",children:j.map(_=>{const G=D!==null&&!D.isCustom&&D.presetId===_.id;return l.jsx(K,{color:G?"primary":b,variant:G?"solid":v,className:"w-full",onPress:()=>Y(_),isDisabled:m,"data-testid":`donation-amounts-preset-${_.id}`,children:_.label||Cu(_.amount,a,i)},_.id)})}),o&&l.jsxs("div",{className:"flex gap-3 items-start",children:[l.jsx(f.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:s?()=>{R(null),F(!0)}:void 0,variant:x,radius:"full",size:w,minValue:c,maxValue:d,step:.01,formatOptions:ce,value:E!==""?parseFloat(E):void 0,onValueChange:te,isDisabled:m,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-${H}`:D?.isCustom===!1?D.presetId:"custom"),s&&l.jsx(K,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:oe,isDisabled:m||!I,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return M?l.jsx(f.Card,{className:f.cn("w-full",S),"data-testid":"donation-amounts-card",children:l.jsx(f.CardBody,{children:P})}):l.jsx("div",{className:f.cn("w-full",S),"data-testid":"donation-amounts-plain",children:P})};qa.displayName="DonationAmounts";const Au=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},Mu=e=>{switch(e){case"warning":return J.Clock;case"error":return J.AlertCircle;case"success":return J.CheckCircle;default:return J.Clock}},Eu=e=>{switch(e){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"}},Wa=y.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:a="Your cart expires in:",showIcon:o=!0,icon:c,position:d="fixed",autoStart:u=!0,formatTime:h=Au,className:p,...m},v)=>{const[b,x]=Yr(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),y.useEffect(()=>{if(!u||b<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{x(T=>T<=1?(w.current&&(clearInterval(w.current),w.current=null),S.current||(S.current=!0,r?.()),0):T-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(S.current=!1)},[b]);const M=c||Mu(s),N=Eu(i),j={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return l.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${a} ${h(b)}`,"data-testid":"expire-cart-timer",className:f.cn("w-full text-white z-50",N,j[d],p),...m,children:l.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:l.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[l.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[o&&l.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:l.jsx(M,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),l.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:a})]}),l.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:l.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${h(b)}`,"data-testid":"expire-cart-timer-value",children:h(b)})})]})})})});Wa.displayName="ExpireCartTimer";function Tu(e,t){const n=e.icons,r=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const o=r[a]&&r[a].parent,c=o&&i(o);c&&(s[a]=[o].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ka=Object.freeze({left:0,top:0,width:16,height:16}),$n=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),cs=Object.freeze({...Ka,...$n}),Rr=Object.freeze({...cs,body:"",hidden:!1});function Du(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function ui(e,t){const n=Du(e,t);for(const r in Rr)r in $n?r in e&&!(r in n)&&(n[r]=$n[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function Iu(e,t,n){const r=e.icons,s=e.aliases||Object.create(null);let i={};function a(o){i=ui(r[o]||s[o],i)}return a(t),n.forEach(a),ui(e,i)}function Ja(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const r=Tu(e);for(const s in r){const i=r[s];i&&(t(s,Iu(e,s,i)),n.push(s))}return n}const $u={provider:"",aliases:{},not_found:{},...Ka};function fr(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Ya(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!fr(e,$u))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!fr(i,Rr))return null}const r=t.aliases||Object.create(null);for(const s in r){const i=r[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!r[a]||!fr(i,Rr))return null}return t}const fi=Object.create(null);function Ou(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Tt(e,t){const n=fi[e]||(fi[e]=Object.create(null));return n[t]||(n[t]=Ou(e,t))}function Ga(e,t){return Ya(t)?Ja(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function Lu(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Qa=/^[a-z0-9]+(-[a-z0-9]+)*$/,Kn=(e,t,n,r="")=>{const s=e.split(":");if(e.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 o=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:r,prefix:c,name:o};return t&&!vn(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const o={provider:r,prefix:a.shift(),name:a.join("-")};return t&&!vn(o)?null:o}if(n&&r===""){const o={provider:r,prefix:"",name:i};return t&&!vn(o,n)?null:o}return null},vn=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let tn=!1;function Za(e){return typeof e=="boolean"&&(tn=e),tn}function hi(e){const t=typeof e=="string"?Kn(e,!0,tn):e;if(t){const n=Tt(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Fu(e,t){const n=Kn(e,!0,tn);if(!n)return!1;const r=Tt(n.provider,n.prefix);return t?Lu(r,n.name,t):(r.missing.add(n.name),!0)}function Pu(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),tn&&!t&&!e.prefix){let s=!1;return Ya(e)&&(e.prefix="",Ja(e,(i,a)=>{Fu(i,a)&&(s=!0)})),s}const n=e.prefix;if(!vn({prefix:n,name:"a"}))return!1;const r=Tt(t,n);return!!Ga(r,e)}const Xa=Object.freeze({width:null,height:null}),el=Object.freeze({...Xa,...$n}),Ru=/(-?[0-9.]*[0-9]+[0-9.]*)/g,zu=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function mi(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Ru);if(r===null||!r.length)return e;const s=[];let i=r.shift(),a=zu.test(i);for(;;){if(a){const o=parseFloat(i);isNaN(o)?s.push(i):s.push(Math.ceil(o*t*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function Bu(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const s=e.indexOf(">",r),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,r).trim()+e.slice(a+1)}return{defs:n,content:e}}function _u(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Vu(e,t,n){const r=Bu(e);return _u(r.defs,t+r.content+n)}const Hu=e=>e==="unset"||e==="undefined"||e==="none";function Uu(e,t){const n={...cs,...e},r={...el,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],w=b.hFlip,S=b.vFlip;let M=b.rotate;w?S?M+=2:(x.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),x.push("scale(-1 1)"),s.top=s.left=0):S&&(x.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),x.push("scale(1 -1)"),s.top=s.left=0);let N;switch(M<0&&(M-=Math.floor(M/4)*4),M=M%4,M){case 1:N=s.height/2+s.top,x.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:x.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,x.unshift("rotate(-90 "+N.toString()+" "+N.toString()+")");break}M%2===1&&(s.left!==s.top&&(N=s.left,s.left=s.top,s.top=N),s.width!==s.height&&(N=s.width,s.width=s.height,s.height=N)),x.length&&(i=Vu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,o=r.height,c=s.width,d=s.height;let u,h;a===null?(h=o===null?"1em":o==="auto"?d:o,u=mi(h,c/d)):(u=a==="auto"?c:a,h=o===null?mi(u,d/c):o==="auto"?d:o);const p={},m=(b,x)=>{Hu(x)||(p[b]=x.toString())};m("width",u),m("height",h);const v=[s.left,s.top,c,d];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const qu=/\sid="(\S+)"/g,Wu="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Ku=0;function Ju(e,t=Wu){const n=[];let r;for(;r=qu.exec(e);)n.push(r[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(Ku++).toString(),o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+o+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const zr=Object.create(null);function Yu(e,t){zr[e]=t}function Br(e){return zr[e]||zr[""]}function ds(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const us=Object.create(null),zt=["https://api.simplesvg.com","https://api.unisvg.com"],wn=[];for(;zt.length>0;)zt.length===1||Math.random()>.5?wn.push(zt.shift()):wn.push(zt.pop());us[""]=ds({resources:["https://api.iconify.design"].concat(wn)});function Gu(e,t){const n=ds(t);return n===null?!1:(us[e]=n,!0)}function fs(e){return us[e]}const Qu=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let pi=Qu();function Zu(e,t){const n=fs(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Xu(e){return e===404}const ef=(e,t,n)=>{const r=[],s=Zu(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},o=0;return n.forEach((c,d)=>{o+=c.length+1,o>=s&&d>0&&(r.push(a),a={type:i,provider:e,prefix:t,icons:[]},o=c.length),a.icons.push(c)}),r.push(a),r};function tf(e){if(typeof e=="string"){const t=fs(e);if(t)return t.path}return"/"}const nf=(e,t,n)=>{if(!pi){n("abort",424);return}let r=tf(t.provider);switch(t.type){case"icons":{const i=t.prefix,o=t.icons.join(","),c=new URLSearchParams({icons:o});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;pi(e+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Xu(a)?"abort":"next",a)});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)})},rf={prepare:ef,send:nf};function tl(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==t))})}function sf(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,o=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||tl([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let af=0;function lf(e,t,n){const r=af++,s=tl.bind(null,n,r);if(!t.pending.length)return s;const i={id:r,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function of(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.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 e.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,a=s.prefix,o=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=Tt(i,a));let u;o in d.icons?u=t.loaded:a===""||d.missing.has(o)?u=t.missing:u=t.pending;const h={provider:i,prefix:a,name:o};u.push(h)}),t}function cf(e,t=!0,n=!1){const r=[];return e.forEach(s=>{const i=typeof s=="string"?Kn(s,t,n):s;i&&r.push(i)}),r}const df={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function uf(e,t,n,r){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let T=e.resources.slice(0);for(a=[];T.length>1;){const $=Math.floor(Math.random()*T.length);a.push(T[$]),T=T.slice(0,$).concat(T.slice($+1))}a=a.concat(T)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const o=Date.now();let c="pending",d=0,u,h=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){h&&(clearTimeout(h),h=null)}function b(){c==="pending"&&(c="aborted"),v(),p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function x(T,$){$&&(m=[]),typeof T=="function"&&m.push(T)}function w(){return{startTime:o,payload:t,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function S(){c="failed",m.forEach(T=>{T(void 0,u)})}function M(){p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function N(T,$,W){const D=$!=="success";switch(p=p.filter(R=>R!==T),c){case"pending":break;case"failed":if(D||!e.dataAfterTimeout)return;break;default:return}if($==="abort"){u=W,S();return}if(D){u=W,p.length||(a.length?j():S());return}if(v(),M(),!e.random){const R=e.resources.indexOf(T.resource);R!==-1&&R!==e.index&&(e.index=R)}c="completed",m.forEach(R=>{R(W)})}function j(){if(c!=="pending")return;v();const T=a.shift();if(T===void 0){if(p.length){h=setTimeout(()=>{v(),c==="pending"&&(M(),S())},e.timeout);return}S();return}const $={status:"pending",resource:T,callback:(W,D)=>{N($,W,D)}};p.push($),d++,h=setTimeout(j,e.rotate),n(T,t,$.callback)}return setTimeout(j),w}function nl(e){const t={...df,...e};let n=[];function r(){n=n.filter(o=>o().status==="pending")}function s(o,c,d){const u=uf(t,o,c,(h,p)=>{r(),d&&d(h,p)});return n.push(u),u}function i(o){return n.find(c=>o(c))||null}return{query:s,find:i,setIndex:o=>{t.index=o},getIndex:()=>t.index,cleanup:r}}function gi(){}const hr=Object.create(null);function ff(e){if(!hr[e]){const t=fs(e);if(!t)return;const n=nl(t),r={config:t,redundancy:n};hr[e]=r}return hr[e]}function hf(e,t,n){let r,s;if(typeof e=="string"){const i=Br(e);if(!i)return n(void 0,424),gi;s=i.send;const a=ff(e);a&&(r=a.redundancy)}else{const i=ds(e);if(i){r=nl(i);const a=e.resources?e.resources[0]:"",o=Br(a);o&&(s=o.send)}}return!r||!s?(n(void 0,424),gi):r.query(t,s,n)().abort}function xi(){}function mf(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,sf(e)}))}function pf(e){const t=[],n=[];return e.forEach(r=>{(r.match(Qa)?t:n).push(r)}),{valid:t,invalid:n}}function Bt(e,t,n){function r(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ga(e,n).length){r();return}}catch(s){console.error(s)}r(),mf(e)}function yi(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function gf(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){yi(e.loadIcons(s,r,n),u=>{Bt(e,s,u)});return}if(i){s.forEach(u=>{const h=i(u,r,n);yi(h,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Bt(e,[u],m)})});return}const{valid:a,invalid:o}=pf(s);if(o.length&&Bt(e,o,null),!a.length)return;const c=r.match(Qa)?Br(n):null;if(!c){Bt(e,a,null);return}c.prepare(n,r,a).forEach(u=>{hf(n,u,h=>{Bt(e,u.icons,h)})})}))}const xf=(e,t)=>{const n=cf(e,!0,Za()),r=of(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,xi)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,o;return r.pending.forEach(c=>{const{provider:d,prefix:u}=c;if(u===o&&d===a)return;a=d,o=u,i.push(Tt(d,u));const h=s[d]||(s[d]=Object.create(null));h[u]||(h[u]=[])}),r.pending.forEach(c=>{const{provider:d,prefix:u,name:h}=c,p=Tt(d,u),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(h)||(m.add(h),s[d][u].push(h))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&gf(c,d)}),t?lf(t,r,i):xi};function yf(e,t){const n={...e};for(const r in t){const s=t[r],i=typeof s;r in Xa?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const bf=/[\s,]+/;function vf(e,t){t.split(bf).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function wf(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:r(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return t}function kf(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Nf(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Sf(e){return"data:image/svg+xml,"+Nf(e)}function Cf(e){return'url("'+Sf(e)+'")'}let Wt;function jf(){try{Wt=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Wt=null}}function Af(e){return Wt===void 0&&jf(),Wt?Wt.createHTML(e):e}const rl={...el,inline:!1},Mf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ef={display:"inline-block"},_r={backgroundColor:"currentColor"},sl={backgroundColor:"transparent"},bi={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},vi={WebkitMask:_r,mask:_r,background:sl};for(const e in vi){const t=vi[e];for(const n in bi)t[e+n]=bi[n]}const Tf={...rl,inline:!0};function wi(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Df=(e,t,n)=>{const r=t.inline?Tf:rl,s=yf(r,t),i=t.mode||"svg",a={},o=t.style||{},c={...i==="svg"?Mf:{}};if(n){const x=Kn(n,!1,!0);if(x){const w=["iconify"],S=["provider","prefix"];for(const M of S)x[M]&&w.push("iconify--"+x[M]);c.className=w.join(" ")}}for(let x in t){const w=t[x];if(w!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[x]=(c[x]?c[x]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":s[x]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&vf(s,w);break;case"color":a.color=w;break;case"rotate":typeof w=="string"?s[x]=wf(w):typeof w=="number"&&(s[x]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=w)}}const d=Uu(e,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...o},Object.assign(c,u);let x=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Af(Ju(d.body,w?()=>w+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:h,width:p,height:m}=e,v=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),b=kf(h,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":Cf(b),width:wi(u.width),height:wi(u.height),...Ef,...v?_r:sl,...o},y.createElement("span",c)};Za(!0);Yu("",rf);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Pu(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Gu(n,s)||console.error(r)}catch{console.error(r)}}}}function il(e){const[t,n]=y.useState(!!e.ssr),[r,s]=y.useState({});function i(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const b=hi(v);if(b)return{name:v,data:b}}return{name:""}}const[a,o]=y.useState(i(!!e.ssr));function c(){const m=r.callback;m&&(m(),s({}))}function d(m){if(JSON.stringify(a)!==JSON.stringify(m))return c(),o(m),!0}function u(){var m;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=hi(v);if(d({name:v,data:b}))if(b===void 0){const x=xf([v],u);s({callback:x})}else b&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{t&&u()},[e.icon,t]);const{name:h,data:p}=a;return p?Df({...cs,...p},e,h):e.children?e.children:e.fallback?e.fallback:y.createElement("span",{})}const U=y.forwardRef((e,t)=>il({...e,_ref:t}));y.forwardRef((e,t)=>il({inline:!0,...e,_ref:t}));const mr=({icon:e,children:t,testId:n})=>l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[l.jsx(U,{icon:e,width:20,className:"text-default-500"}),l.jsx("span",{children:t})]}),If=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:o=!1,compact:c=!1,imageLoading:d="eager",showMoreButtonClassName:u,labels:h})=>{const[p,m]=y.useState(!1),[v,b]=y.useState(!1),x=y.useRef(null);return y.useEffect(()=>{const w=()=>{if(x.current){const S=x.current.scrollHeight>x.current.clientHeight;b(S)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[a]),l.jsxs(f.Card,{className:f.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[l.jsxs(f.CardHeader,{className:f.cn("pt-2 pb-0 flex-col items-start",c?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&n&&l.jsx("div",{className:f.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:l.jsx(f.Image,{removeWrapper:!0,loading:d,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),l.jsx("h2",{className:f.cn("font-semibold text-gray-800",c?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),l.jsxs(f.CardBody,{className:f.cn("space-y-3",c?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[l.jsx("h3",{className:f.cn("font-semibold text-base text-gray-700",c?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),l.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&l.jsx(mr,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&l.jsx(mr,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&l.jsx(mr,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),a&&l.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{ref:x,className:f.cn("text-sm text-gray-700 leading-relaxed transition-all",c?"text-xs":"",!p&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:a}}),!p&&v&&l.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"})]}),(v||p)&&l.jsx("div",{className:"flex justify-end mt-1",children:l.jsx(K,{onPress:()=>m(!p),variant:"light",className:f.cn("text-primary",u),size:c?"sm":"md",startContent:l.jsx(U,{icon:p?"solar:eye-closed-linear":"solar:eye-linear",width:c?16:20}),"data-testid":"event-details-toggle-description",children:p?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function al(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function $f(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const Of={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached",ruleBlocked:"Unavailable for selected ticket options",disabled:"Ticket selection is unavailable"},mn=e=>typeof e=="number"&&!isNaN(e),On=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:a,slots:o,isDisabled:c=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:h=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:w="default",compact:S=!1,isSoldOut:M,isMaxReached:N,isRuleBlocked:j,statusTone:T="default",statusLabel:$,disabledReason:W,disabled:D})=>{const R=y.useMemo(()=>({...Of,...a}),[a]),[E,C]=y.useState(n),I=t!==void 0?t:E,F=!!(c||D),H=S||!!e.compact,Q=y.useMemo(()=>typeof M=="boolean"?M:typeof e.isSoldOut=="boolean"?e.isSoldOut:!mn(e.totalTicketsSold)||!mn(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[M,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),Y=y.useMemo(()=>typeof N=="boolean"?N:typeof e.isMaxReached=="boolean"?e.isMaxReached:Q||!mn(e.ticketsAllowed)?!1:I>=e.ticketsAllowed-(e.totalTicketsSold??0),[N,e.isMaxReached,Q,e.ticketsAllowed,e.totalTicketsSold,I]),te=y.useMemo(()=>typeof j=="boolean"?j:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[j,e.isRuleBlocked]),oe=W||e.disabledReason,ce=F||Q||te,P=ue=>{if(ce||ue>0&&Y)return;const Te=Math.max(0,I+ue);t===void 0&&C(Te),r?.(e.id,Te)},_=y.useMemo(()=>{if(Q)return"soldOut";if(te)return"ruleBlocked";if(F)return"disabled"},[Q,te,F]),G=y.useMemo(()=>T||(Q||te?"danger":Y?"warning":"default"),[T,Q,te,Y]),ne=y.useMemo(()=>{if(_)return _==="ruleBlocked"?$||oe||R.ruleBlocked:_==="soldOut"?$||oe||R.soldOut:_==="disabled"?$||oe||R.disabled:$||R.maxReached},[_,$,oe,R]),Se={soldOut:"danger",ruleBlocked:G,disabled:"default",maxReached:"warning"},at={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},$t=()=>o?.renderName?o.renderName(e.name,e):l.jsx("h2",{"data-testid":"offer-card-name",className:f.cn("text-base font-medium",H&&"text-sm",b.name),children:e.name}),Ot=()=>{if(!v)return null;const ue=al(e.price,i,s);return o?.renderPrice?o.renderPrice(e.price,ue,e):l.jsx("p",{"data-testid":"offer-card-price",className:f.cn("text-primary text-base mt-1",H&&"text-sm mt-0.5",b.price),children:ue})},on=()=>!p||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):l.jsx("p",{"data-testid":"offer-card-description",className:f.cn("mb-4 text-sm text-gray-700 leading-relaxed",H&&"mb-2 text-xs text-gray-600",b.description),children:e.description}),Lt=()=>{if(!m||!mn(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ue=e.numberOfPeople===1?R.person:R.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ue,e):l.jsxs("p",{"data-testid":"offer-card-people-count",className:f.cn("text-sm text-gray-600 flex items-center mt-2",H&&"mt-1 text-xs",b.peopleCount),children:[l.jsx(U,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ue]})},Ft=()=>{const ue=I===0||ce,Te=Y||ce;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:I,onIncrement:()=>P(1),onDecrement:()=>P(-1),isDecrementDisabled:ue,isIncrementDisabled:Te,isDisabled:ce}):l.jsxs("div",{className:f.cn("flex items-center gap-2",b.quantitySelector),children:[l.jsx(K,{"data-testid":"offer-card-decrement-button",onPress:()=>P(-1),isDisabled:ue,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Decrease quantity",children:l.jsx(U,{icon:"gravity-ui:minus",width:16})}),l.jsx("span",{"data-testid":"offer-card-quantity",className:f.cn("min-w-[2rem] text-center font-medium",H&&"text-sm"),children:I}),l.jsx(K,{"data-testid":"offer-card-increment-button",onPress:()=>P(1),isDisabled:Te,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Increase quantity",children:l.jsx(U,{icon:"gravity-ui:plus",width:16})})]})},cn=(ue,Te)=>o?.renderDisabledState?o.renderDisabledState(ue,Te):ue==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(Te):ue==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(Te):l.jsx(f.Chip,{"data-testid":at[ue],color:Se[ue],variant:ue==="maxReached"?"flat":"solid",className:f.cn("gap-2 px-4",ue==="maxReached"?"h-8":"h-10",ue==="soldOut"&&b.soldOut,ue==="maxReached"&&b.maxReachedAlert,H&&"h-8"),startContent:l.jsx(U,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:l.jsx("span",{className:"font-medium text-sm",children:Te})}),Pt=l.jsxs("div",{className:f.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",H?"gap-1":"gap-2"),children:[l.jsxs("div",{className:f.cn("h-full col-span-2",ce||Y?"opacity-50 pointer-events-none select-none":""),children:[$t(),Ot(),l.jsxs("div",{className:f.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",H?"mb-1":"mb-2"),children:[Lt(),on()]})]}),l.jsx("div",{className:f.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",H&&"space-x-1 pb-1 md:p-1",b.compactFooter),children:_&&ne?cn(_,ne):Ft()})]}),wt=Y&&!Q&&!te&&!F?l.jsx(Pe.motion.div,{className:f.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",b.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:cn("maxReached",ne||R.maxReached)}):null;return h?l.jsxs(f.Card,{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx(f.CardBody,{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx(f.CardFooter,{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]}):l.jsxs("div",{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx("div",{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx("div",{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]})};On.displayName="OfferCard";const ll=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const o=i();return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:o})}const a=l.jsxs("div",{"data-testid":"offer-card-empty-content",className:f.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[l.jsx(U,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:f.cn("mb-4",s.icon)}),l.jsx("h3",{"data-testid":"offer-card-empty-message",className:f.cn("text-lg",s.message),children:e})]});return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:a})};ll.displayName="OfferCardEmpty";const Lf={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ol=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Lf,...t},a=l.jsx(f.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-error-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:a})};ol.displayName="OfferCardError";const Ff={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},cl=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=Ff[t];return l.jsx("div",{"data-testid":"offer-card-skeleton-container",className:f.cn(r,n.base),children:Array.from({length:e}).map((s,i)=>l.jsxs(f.Card,{"data-testid":`offer-card-skeleton-${i}`,className:f.cn("w-full",n.card),children:[l.jsx(f.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:l.jsxs("div",{className:"space-y-2 w-full",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),l.jsx(f.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[l.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),l.jsx("div",{className:"flex items-start justify-end",children:l.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};cl.displayName="OfferCardSkeleton";const dl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},ul={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"}}},Pf={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},fl=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:s,onQuantityChange:i,currency:a="USD",locale:o="en-US",labels:c,slots:d,isDisabled:u=!1,buttonVariant:h="bordered",buttonColor:p="default",showCard:m=!0,animated:v=!0,gap:b=2,compact:x=!1,classNames:w={}})=>{const[S,M]=y.useState(r),N=n!==void 0?n:S,j=y.useCallback((E,C)=>{const I={...N,[E]:Math.max(0,C)};n===void 0&&M(I),s?.(I),i?.(E,I[E])},[N,n,s,i]),T=[...e].sort((E,C)=>(E.position??0)-(C.position??0)),$=E=>{const C=t?t(E):E,I=(N??{})[C.id]||0;return{offer:C,quantity:I,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x}},W=Pf[b],D=f.cn("grid mx-auto pt-2",W,w.base),R=E=>{const C=$(E);return l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:C.onQuantityChange,currency:C.currency,locale:C.locale,labels:C.labels,slots:C.slots,isDisabled:C.isDisabled,buttonVariant:C.buttonVariant,buttonColor:C.buttonColor,showCard:C.showCard,compact:C.compact,classNames:w.card},C.offer.id)};return v?l.jsx(Pe.motion.div,{"data-testid":"offer-card-list",className:D,variants:dl,initial:"hidden",animate:"show",children:l.jsx(Pe.AnimatePresence,{children:T.map(E=>{const C=$(E);return l.jsx(Pe.motion.div,{"data-testid":`offer-card-list-item-${C.offer.id}`,className:w.cardWrapper,variants:ul,exit:{opacity:0,y:-20},transition:{duration:.3},children:l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x||C.offer.compact,classNames:w.card})},C.offer.id)})})}):l.jsx("div",{"data-testid":"offer-card-list",className:D,children:T.map(R)})};fl.displayName="OfferCardList";var an=e=>e.type==="checkbox",mt=e=>e instanceof Date,Ee=e=>e==null;const hl=e=>typeof e=="object";var ye=e=>!Ee(e)&&!Array.isArray(e)&&hl(e)&&!mt(e),ml=e=>ye(e)&&e.target?an(e.target)?e.target.checked:e.target.value:e,Rf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,pl=(e,t)=>e.has(Rf(t)),zf=e=>{const t=e.constructor&&e.constructor.prototype;return ye(t)&&t.hasOwnProperty("isPrototypeOf")},hs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(hs&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(ye(e)&&zf(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=pe(e[s]));return r}var Jn=e=>/^\w*$/.test(e),fe=e=>e===void 0,ms=e=>Array.isArray(e)?e.filter(Boolean):[],ps=e=>ms(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,t,n)=>{if(!t||!ye(e))return n;const r=(Jn(t)?[t]:ps(t)).reduce((s,i)=>Ee(s)?s:s[i],e);return fe(r)||r===e?fe(e[t])?n:e[t]:r},De=e=>typeof e=="boolean",Me=e=>typeof e=="function",le=(e,t,n)=>{let r=-1;const s=Jn(t)?[t]:ps(t),i=s.length,a=i-1;for(;++r<i;){const o=s[r];let c=n;if(r!==a){const d=e[o];c=ye(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const Ln={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},We={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},gl=y.createContext(null);gl.displayName="HookFormControlContext";const gs=()=>y.useContext(gl);var xl=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(s,i,{get:()=>{const a=i;return t._proxyFormState[a]!==ze.all&&(t._proxyFormState[a]=!r||ze.all),n&&(n[a]=!0),e[a]}});return s};const xs=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Bf(e){const t=gs(),{control:n=t,disabled:r,name:s,exact:i}=e||{},[a,o]=y.useState(n._formState),c=y.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return xs(()=>n._subscribe({name:s,formState:c.current,exact:i,callback:d=>{!r&&o({...n._formState,...d})}}),[s,r,i]),y.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),y.useMemo(()=>xl(a,n,c.current,!1),[a,n])}var $e=e=>typeof e=="string",Vr=(e,t,n,r,s)=>$e(e)?(r&&t.watch.add(e),z(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),z(n,i))):(r&&(t.watchAll=!0),n),Hr=e=>Ee(e)||!hl(e);function Be(e,t,n=new WeakSet){if(Hr(e)||Hr(t))return Object.is(e,t);if(mt(e)&&mt(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const o=t[i];if(mt(a)&&mt(o)||ye(a)&&ye(o)||Array.isArray(a)&&Array.isArray(o)?!Be(a,o,n):!Object.is(a,o))return!1}}return!0}function _f(e){const t=gs(),{control:n=t,name:r,defaultValue:s,disabled:i,exact:a,compute:o}=e||{},c=y.useRef(s),d=y.useRef(o),u=y.useRef(void 0),h=y.useRef(n),p=y.useRef(r);d.current=o;const[m,v]=y.useState(()=>{const N=n._getWatch(r,c.current);return d.current?d.current(N):N}),b=y.useCallback(N=>{const j=Vr(r,n._names,N||n._formValues,!1,c.current);return d.current?d.current(j):j},[n._formValues,n._names,r]),x=y.useCallback(N=>{if(!i){const j=Vr(r,n._names,N||n._formValues,!1,c.current);if(d.current){const T=d.current(j);Be(T,u.current)||(v(T),u.current=T)}else v(j)}},[n._formValues,n._names,i,r]);xs(()=>((h.current!==n||!Be(p.current,r))&&(h.current=n,p.current=r,x()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:N=>{x(N.values)}})),[n,a,r,x]),y.useEffect(()=>n._removeUnmounted());const w=h.current!==n,S=p.current,M=y.useMemo(()=>{if(i)return null;const N=!w&&!Be(S,r);return w||N?b():null},[i,w,r,S,b]);return M!==null?M:m}function Vf(e){const t=gs(),{name:n,disabled:r,control:s=t,shouldUnregister:i,defaultValue:a,exact:o=!0}=e,c=pl(s._names.array,n),d=y.useMemo(()=>z(s._formValues,n,z(s._defaultValues,n,a)),[s,n,a]),u=_f({control:s,name:n,defaultValue:d,exact:o}),h=Bf({control:s,name:n,exact:o}),p=y.useRef(e),m=y.useRef(void 0),v=y.useRef(s.register(n,{...e.rules,value:u,...De(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const b=y.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(h.errors,n)},isDirty:{enumerable:!0,get:()=>!!z(h.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!z(h.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!z(h.validatingFields,n)},error:{enumerable:!0,get:()=>z(h.errors,n)}}),[h,n]),x=y.useCallback(N=>v.current.onChange({target:{value:ml(N),name:n},type:Ln.CHANGE}),[n]),w=y.useCallback(()=>v.current.onBlur({target:{value:z(s._formValues,n),name:n},type:Ln.BLUR}),[n,s._formValues]),S=y.useCallback(N=>{const j=z(s._fields,n);j&&j._f&&N&&(j._f.ref={focus:()=>Me(N.focus)&&N.focus(),select:()=>Me(N.select)&&N.select(),setCustomValidity:T=>Me(N.setCustomValidity)&&N.setCustomValidity(T),reportValidity:()=>Me(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),M=y.useMemo(()=>({name:n,value:u,...De(r)||h.disabled?{disabled:h.disabled||r}:{},onChange:x,onBlur:w,ref:S}),[n,r,h.disabled,x,w,S,u]);return y.useEffect(()=>{const N=s._options.shouldUnregister||i,j=m.current;j&&j!==n&&!c&&s.unregister(j),s.register(n,{...p.current.rules,...De(p.current.disabled)?{disabled:p.current.disabled}:{}});const T=($,W)=>{const D=z(s._fields,$);D&&D._f&&(D._f.mount=W)};if(T(n,!0),N){const $=pe(z(s._options.defaultValues,n,p.current.defaultValue));le(s._defaultValues,n,$),fe(z(s._formValues,n))&&le(s._formValues,n,$)}return!c&&s.register(n),m.current=n,()=>{(c?N&&!s._state.action:N)?s.unregister(n):T(n,!1)}},[n,s,c,i]),y.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),y.useMemo(()=>({field:M,formState:h,fieldState:b}),[M,h,b])}const Hf=y.createContext(null);Hf.displayName="HookFormContext";var Uf=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Kt=e=>Array.isArray(e)?e:[e],ki=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function yl(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&ye(s)&&i){const a=yl(s,i);ye(a)&&(n[r]=a)}else e[r]&&(n[r]=i)}return n}var je=e=>ye(e)&&!Object.keys(e).length,ys=e=>e.type==="file",Fn=e=>{if(!hs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bl=e=>e.type==="select-multiple",bs=e=>e.type==="radio",qf=e=>bs(e)||an(e),pr=e=>Fn(e)&&e.isConnected;function Wf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=fe(e)?r++:e[t[r++]];return e}function Kf(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function ge(e,t){const n=Array.isArray(t)?t:Jn(t)?[t]:ps(t),r=n.length===1?e:Wf(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ye(r)&&je(r)||Array.isArray(r)&&Kf(r))&&ge(e,n.slice(0,-1)),e}var Jf=e=>{for(const t in e)if(Me(e[t]))return!0;return!1};function vl(e){return Array.isArray(e)||ye(e)&&!Jf(e)}function Ur(e,t={}){for(const n in e){const r=e[n];vl(r)?(t[n]=Array.isArray(r)?[]:{},Ur(r,t[n])):fe(r)||(t[n]=!0)}return t}function At(e,t,n){n||(n=Ur(t));for(const r in e){const s=e[r];if(vl(s))fe(t)||Hr(n[r])?n[r]=Ur(s,Array.isArray(s)?[]:{}):At(s,Ee(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Be(s,i)}}return n}const Ni={value:!1,isValid:!1},Si={value:!0,isValid:!0};var wl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?Si:{value:e[0].value,isValid:!0}:Si:Ni}return Ni},kl=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fe(e)?e:t?e===""?NaN:e&&+e:n&&$e(e)?new Date(e):r?r(e):e;const Ci={isValid:!1,value:null};var Nl=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Ci):Ci;function ji(e){const t=e.ref;return ys(t)?t.files:bs(t)?Nl(e.refs).value:bl(t)?[...t.selectedOptions].map(({value:n})=>n):an(t)?wl(e.refs).value:kl(fe(t.value)?e.ref.value:t.value,e)}var Yf=(e,t,n,r)=>{const s={};for(const i of e){const a=z(t,i);a&&le(s,i,a._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Pn=e=>e instanceof RegExp,_t=e=>fe(e)?e:Pn(e)?e.source:ye(e)?Pn(e.value)?e.value.source:e.value:e,Ai=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched});const Mi="AsyncFunction";var Gf=e=>!!e&&!!e.validate&&!!(Me(e.validate)&&e.validate.constructor.name===Mi||ye(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Mi)),Qf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ei=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Jt=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=z(e,s);if(i){const{_f:a,...o}=i;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],s)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Jt(o,t))break}else if(ye(o)&&Jt(o,t))break}}};function Ti(e,t,n){const r=z(e,n);if(r||Jn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=z(t,i),o=z(e,i);if(a&&!Array.isArray(a)&&n!==i)return{name:n};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};s.pop()}return{name:n}}var Zf=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return je(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(a=>t[a]===(!r||ze.all))},Xf=(e,t,n)=>!e||!t||e===t||Kt(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),eh=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,th=(e,t)=>!ms(z(e,t)).length&&ge(e,t),nh=(e,t,n)=>{const r=Kt(z(e,n));return le(r,"root",t[n]),le(e,n,r),e};function Di(e,t,n="validate"){if($e(e)||Array.isArray(e)&&e.every($e)||De(e)&&!e)return{type:n,message:$e(e)?e:"",ref:t}}var Nt=e=>ye(e)&&!Pn(e)?e:{value:e,message:""},Ii=async(e,t,n,r,s,i)=>{const{ref:a,refs:o,required:c,maxLength:d,minLength:u,min:h,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:w}=e._f,S=z(n,b);if(!w||t.has(b))return{};const M=o?o[0]:a,N=C=>{s&&M.reportValidity&&(M.setCustomValidity(De(C)?"":C||""),M.reportValidity())},j={},T=bs(a),$=an(a),W=T||$,D=(x||ys(a))&&fe(a.value)&&fe(S)||Fn(a)&&a.value===""||S===""||Array.isArray(S)&&!S.length,R=Uf.bind(null,b,r,j),E=(C,I,F,H=We.maxLength,Q=We.minLength)=>{const Y=C?I:F;j[b]={type:C?H:Q,message:Y,ref:a,...R(C?H:Q,Y)}};if(i?!Array.isArray(S)||!S.length:c&&(!W&&(D||Ee(S))||De(S)&&!S||$&&!wl(o).isValid||T&&!Nl(o).isValid)){const{value:C,message:I}=$e(c)?{value:!!c,message:c}:Nt(c);if(C&&(j[b]={type:We.required,message:I,ref:M,...R(We.required,I)},!r))return N(I),j}if(!D&&(!Ee(h)||!Ee(p))){let C,I;const F=Nt(p),H=Nt(h);if(!Ee(S)&&!isNaN(S)){const Q=a.valueAsNumber||S&&+S;Ee(F.value)||(C=Q>F.value),Ee(H.value)||(I=Q<H.value)}else{const Q=a.valueAsDate||new Date(S),Y=ce=>new Date(new Date().toDateString()+" "+ce),te=a.type=="time",oe=a.type=="week";$e(F.value)&&S&&(C=te?Y(S)>Y(F.value):oe?S>F.value:Q>new Date(F.value)),$e(H.value)&&S&&(I=te?Y(S)<Y(H.value):oe?S<H.value:Q<new Date(H.value))}if((C||I)&&(E(!!C,F.message,H.message,We.max,We.min),!r))return N(j[b].message),j}if((d||u)&&!D&&($e(S)||i&&Array.isArray(S))){const C=Nt(d),I=Nt(u),F=!Ee(C.value)&&S.length>+C.value,H=!Ee(I.value)&&S.length<+I.value;if((F||H)&&(E(F,C.message,I.message),!r))return N(j[b].message),j}if(m&&!D&&$e(S)){const{value:C,message:I}=Nt(m);if(Pn(C)&&!S.match(C)&&(j[b]={type:We.pattern,message:I,ref:a,...R(We.pattern,I)},!r))return N(I),j}if(v){if(Me(v)){const C=await v(S,n),I=Di(C,M);if(I&&(j[b]={...I,...R(We.validate,I.message)},!r))return N(I.message),j}else if(ye(v)){let C={};for(const I in v){if(!je(C)&&!r)break;const F=Di(await v[I](S,n),M,I);F&&(C={...F,...R(I,F.message)},N(F.message),r&&(j[b]=C))}if(!je(C)&&(j[b]={ref:M,...C},!r))return j}}return N(!0),j};const rh={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function sh(e={}){let t={...rh,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Me(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=ye(t.defaultValues)||ye(t.values)?pe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:pe(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...u};let p={...h};const m={array:ki(),state:ki()},v=t.criteriaMode===ze.all,b=g=>k=>{clearTimeout(d),d=setTimeout(g,k)},x=async g=>{if(!a.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||g)){let k;t.resolver?(k=je((await W()).errors),w()):k=await R(r,!0),k!==n.isValid&&m.state.next({isValid:k})}},w=(g,k)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(o.mount)).forEach(A=>{A&&(k?le(n.validatingFields,A,k):ge(n.validatingFields,A))}),m.state.next({validatingFields:n.validatingFields,isValidating:!je(n.validatingFields)}))},S=(g,k=[],A,B,L=!0,O=!0)=>{if(B&&A&&!t.disabled){if(a.action=!0,O&&Array.isArray(z(r,g))){const q=A(z(r,g),B.argA,B.argB);L&&le(r,g,q)}if(O&&Array.isArray(z(n.errors,g))){const q=A(z(n.errors,g),B.argA,B.argB);L&&le(n.errors,g,q),th(n.errors,g)}if((h.touchedFields||p.touchedFields)&&O&&Array.isArray(z(n.touchedFields,g))){const q=A(z(n.touchedFields,g),B.argA,B.argB);L&&le(n.touchedFields,g,q)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=At(s,i)),m.state.next({name:g,isDirty:C(g,k),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else le(i,g,k)},M=(g,k)=>{le(n.errors,g,k),m.state.next({errors:n.errors})},N=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,k,A,B)=>{const L=z(r,g);if(L){const O=z(i,g,fe(A)?z(s,g):A);fe(O)||B&&B.defaultChecked||k?le(i,g,k?O:ji(L._f)):H(g,O),a.mount&&!a.action&&x()}},T=(g,k,A,B,L)=>{let O=!1,q=!1;const re={name:g};if(!t.disabled){if(!A||B){(h.isDirty||p.isDirty)&&(q=n.isDirty,n.isDirty=re.isDirty=C(),O=q!==re.isDirty);const se=Be(z(s,g),k);q=!!z(n.dirtyFields,g),se?ge(n.dirtyFields,g):le(n.dirtyFields,g,!0),re.dirtyFields=n.dirtyFields,O=O||(h.dirtyFields||p.dirtyFields)&&q!==!se}if(A){const se=z(n.touchedFields,g);se||(le(n.touchedFields,g,A),re.touchedFields=n.touchedFields,O=O||(h.touchedFields||p.touchedFields)&&se!==A)}O&&L&&m.state.next(re)}return O?re:{}},$=(g,k,A,B)=>{const L=z(n.errors,g),O=(h.isValid||p.isValid)&&De(k)&&n.isValid!==k;if(t.delayError&&A?(c=b(()=>M(g,A)),c(t.delayError)):(clearTimeout(d),c=null,A?le(n.errors,g,A):ge(n.errors,g)),(A?!Be(L,A):L)||!je(B)||O){const q={...B,...O&&De(k)?{isValid:k}:{},errors:n.errors,name:g};n={...n,...q},m.state.next(q)}},W=async g=>(w(g,!0),await t.resolver(i,t.context,Yf(g||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),D=async g=>{const{errors:k}=await W(g);if(w(g),g)for(const A of g){const B=z(k,A);B?le(n.errors,A,B):ge(n.errors,A)}else n.errors=k;return k},R=async(g,k,A={valid:!0})=>{for(const B in g){const L=g[B];if(L){const{_f:O,...q}=L;if(O){const re=o.array.has(O.name),se=L._f&&Gf(L._f);se&&h.validatingFields&&w([O.name],!0);const Ce=await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation&&!k,re);if(se&&h.validatingFields&&w([O.name]),Ce[O.name]&&(A.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(z(Ce,O.name)?re?nh(n.errors,Ce,O.name):le(n.errors,O.name,Ce[O.name]):ge(n.errors,O.name))}!je(q)&&await R(q,k,A)}}return A.valid},E=()=>{for(const g of o.unMount){const k=z(r,g);k&&(k._f.refs?k._f.refs.every(A=>!pr(A)):!pr(k._f.ref))&&Ot(g)}o.unMount=new Set},C=(g,k)=>!t.disabled&&(g&&k&&le(i,g,k),!Be(P(),s)),I=(g,k,A)=>Vr(g,o,{...a.mount?i:fe(k)?s:$e(g)?{[g]:k}:k},A,k),F=g=>ms(z(a.mount?i:s,g,t.shouldUnregister?z(s,g,[]):[])),H=(g,k,A={})=>{const B=z(r,g);let L=k;if(B){const O=B._f;O&&(!O.disabled&&le(i,g,kl(k,O)),L=Fn(O.ref)&&Ee(k)?"":k,bl(O.ref)?[...O.ref.options].forEach(q=>q.selected=L.includes(q.value)):O.refs?an(O.ref)?O.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(L)?q.checked=!!L.find(re=>re===q.value):q.checked=L===q.value||!!L)}):O.refs.forEach(q=>q.checked=q.value===L):ys(O.ref)?O.ref.value="":(O.ref.value=L,O.ref.type||m.state.next({name:g,values:pe(i)})))}(A.shouldDirty||A.shouldTouch)&&T(g,L,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&ce(g)},Q=(g,k,A)=>{for(const B in k){if(!k.hasOwnProperty(B))return;const L=k[B],O=g+"."+B,q=z(r,O);(o.array.has(g)||ye(L)||q&&!q._f)&&!mt(L)?Q(O,L,A):H(O,L,A)}},Y=(g,k,A={})=>{const B=z(r,g),L=o.array.has(g),O=pe(k);le(i,g,O),L?(m.array.next({name:g,values:pe(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&A.shouldDirty&&m.state.next({name:g,dirtyFields:At(s,i),isDirty:C(g,O)})):B&&!B._f&&!Ee(O)?Q(g,O,A):H(g,O,A),Ei(g,o)?m.state.next({...n,name:g,values:pe(i)}):m.state.next({name:a.mount?g:void 0,values:pe(i)})},te=async g=>{a.mount=!0;const k=g.target;let A=k.name,B=!0;const L=z(r,A),O=se=>{B=Number.isNaN(se)||mt(se)&&isNaN(se.getTime())||Be(se,z(i,A,se))},q=Ai(t.mode),re=Ai(t.reValidateMode);if(L){let se,Ce;const lt=k.type?ji(L._f):ml(g),Ge=g.type===Ln.BLUR||g.type===Ln.FOCUS_OUT,jo=!Qf(L._f)&&!t.resolver&&!z(n.errors,A)&&!L._f.deps||eh(Ge,z(n.touchedFields,A),n.isSubmitted,re,q),Gn=Ei(A,o,Ge);le(i,A,lt),Ge?(!k||!k.readOnly)&&(L._f.onBlur&&L._f.onBlur(g),c&&c(0)):L._f.onChange&&L._f.onChange(g);const Qn=T(A,lt,Ge),Ao=!je(Qn)||Gn;if(!Ge&&m.state.next({name:A,type:g.type,values:pe(i)}),jo)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ge&&x():Ge||x()),Ao&&m.state.next({name:A,...Gn?{}:Qn});if(!Ge&&Gn&&m.state.next({...n}),t.resolver){const{errors:Ms}=await W([A]);if(w([A]),O(lt),B){const Mo=Ti(n.errors,r,A),Es=Ti(Ms,r,Mo.name||A);se=Es.error,A=Es.name,Ce=je(Ms)}}else w([A],!0),se=(await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation))[A],w([A]),O(lt),B&&(se?Ce=!1:(h.isValid||p.isValid)&&(Ce=await R(r,!0)));B&&(L._f.deps&&(!Array.isArray(L._f.deps)||L._f.deps.length>0)&&ce(L._f.deps),$(A,Ce,se,Qn))}},oe=(g,k)=>{if(z(n.errors,k)&&g.focus)return g.focus(),1},ce=async(g,k={})=>{let A,B;const L=Kt(g);if(t.resolver){const O=await D(fe(g)?g:L);A=je(O),B=g?!L.some(q=>z(O,q)):A}else g?(B=(await Promise.all(L.map(async O=>{const q=z(r,O);return await R(q&&q._f?{[O]:q}:q)}))).every(Boolean),!(!B&&!n.isValid)&&x()):B=A=await R(r);return m.state.next({...!$e(g)||(h.isValid||p.isValid)&&A!==n.isValid?{}:{name:g},...t.resolver||!g?{isValid:A}:{},errors:n.errors}),k.shouldFocus&&!B&&Jt(r,oe,g?L:o.mount),B},P=(g,k)=>{let A={...a.mount?i:s};return k&&(A=yl(k.dirtyFields?n.dirtyFields:n.touchedFields,A)),fe(g)?A:$e(g)?z(A,g):g.map(B=>z(A,B))},_=(g,k)=>({invalid:!!z((k||n).errors,g),isDirty:!!z((k||n).dirtyFields,g),error:z((k||n).errors,g),isValidating:!!z(n.validatingFields,g),isTouched:!!z((k||n).touchedFields,g)}),G=g=>{g&&Kt(g).forEach(k=>ge(n.errors,k)),m.state.next({errors:g?n.errors:{}})},ne=(g,k,A)=>{const B=(z(r,g,{_f:{}})._f||{}).ref,L=z(n.errors,g)||{},{ref:O,message:q,type:re,...se}=L;le(n.errors,g,{...se,...k,ref:B}),m.state.next({name:g,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&B&&B.focus&&B.focus()},Se=(g,k)=>Me(g)?m.state.subscribe({next:A=>"values"in A&&g(I(void 0,k),A)}):I(g,k,!0),at=g=>m.state.subscribe({next:k=>{Xf(g.name,k.name,g.exact)&&Zf(k,g.formState||h,Co,g.reRenderRoot)&&g.callback({values:{...i},...n,...k,defaultValues:s})}}).unsubscribe,$t=g=>(a.mount=!0,p={...p,...g.formState},at({...g,formState:{...u,...g.formState}})),Ot=(g,k={})=>{for(const A of g?Kt(g):o.mount)o.mount.delete(A),o.array.delete(A),k.keepValue||(ge(r,A),ge(i,A)),!k.keepError&&ge(n.errors,A),!k.keepDirty&&ge(n.dirtyFields,A),!k.keepTouched&&ge(n.touchedFields,A),!k.keepIsValidating&&ge(n.validatingFields,A),!t.shouldUnregister&&!k.keepDefaultValue&&ge(s,A);m.state.next({values:pe(i)}),m.state.next({...n,...k.keepDirty?{isDirty:C()}:{}}),!k.keepIsValid&&x()},on=({disabled:g,name:k})=>{if(De(g)&&a.mount||g||o.disabled.has(k)){const L=o.disabled.has(k)!==!!g;g?o.disabled.add(k):o.disabled.delete(k),L&&a.mount&&!a.action&&x()}},Lt=(g,k={})=>{let A=z(r,g);const B=De(k.disabled)||De(t.disabled);return le(r,g,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:g}},name:g,mount:!0,...k}}),o.mount.add(g),A?on({disabled:De(k.disabled)?k.disabled:t.disabled,name:g}):j(g,!0,k.value),{...B?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:_t(k.min),max:_t(k.max),minLength:_t(k.minLength),maxLength:_t(k.maxLength),pattern:_t(k.pattern)}:{},name:g,onChange:te,onBlur:te,ref:L=>{if(L){Lt(g,k),A=z(r,g);const O=fe(L.value)&&L.querySelectorAll&&L.querySelectorAll("input,select,textarea")[0]||L,q=qf(O),re=A._f.refs||[];if(q?re.find(se=>se===O):O===A._f.ref)return;le(r,g,{_f:{...A._f,...q?{refs:[...re.filter(pr),O,...Array.isArray(z(s,g))?[{}]:[]],ref:{type:O.type,name:g}}:{ref:O}}}),j(g,!1,void 0,O)}else A=z(r,g,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(pl(o.array,g)&&a.action)&&o.unMount.add(g)}}},Ft=()=>t.shouldFocusError&&Jt(r,oe,o.mount),cn=g=>{De(g)&&(m.state.next({disabled:g}),Jt(r,(k,A)=>{const B=z(r,A);B&&(k.disabled=B._f.disabled||g,Array.isArray(B._f.refs)&&B._f.refs.forEach(L=>{L.disabled=B._f.disabled||g}))},0,!1))},Pt=(g,k)=>async A=>{let B;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let L=pe(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:O,values:q}=await W();w(),n.errors=O,L=pe(q)}else await R(r);if(o.disabled.size)for(const O of o.disabled)ge(L,O);if(ge(n.errors,"root"),je(n.errors)){m.state.next({errors:{}});try{await g(L,A)}catch(O){B=O}}else k&&await k({...n.errors},A),Ft(),setTimeout(Ft);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:je(n.errors)&&!B,submitCount:n.submitCount+1,errors:n.errors}),B)throw B},wt=(g,k={})=>{z(r,g)&&(fe(k.defaultValue)?Y(g,pe(z(s,g))):(Y(g,k.defaultValue),le(s,g,pe(k.defaultValue))),k.keepTouched||ge(n.touchedFields,g),k.keepDirty||(ge(n.dirtyFields,g),n.isDirty=k.defaultValue?C(g,pe(z(s,g))):C()),k.keepError||(ge(n.errors,g),h.isValid&&x()),m.state.next({...n}))},ue=(g,k={})=>{const A=g?pe(g):s,B=pe(A),L=je(g),O=L?s:B;if(k.keepDefaultValues||(s=A),!k.keepValues){if(k.keepDirtyValues){const q=new Set([...o.mount,...Object.keys(At(s,i))]);for(const re of Array.from(q)){const se=z(n.dirtyFields,re),Ce=z(i,re),lt=z(O,re);se&&!fe(Ce)?le(O,re,Ce):!se&&!fe(lt)&&Y(re,lt)}}else{if(hs&&fe(g))for(const q of o.mount){const re=z(r,q);if(re&&re._f){const se=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(Fn(se)){const Ce=se.closest("form");if(Ce){Ce.reset();break}}}}if(k.keepFieldsRef)for(const q of o.mount)Y(q,z(O,q));else r={}}i=t.shouldUnregister?k.keepDefaultValues?pe(s):{}:pe(O),m.array.next({values:{...O}}),m.state.next({values:{...O}})}o={mount:k.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!h.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!je(O),a.watch=!!t.shouldUnregister,a.keepIsValid=!!k.keepIsValid,a.action=!1,k.keepErrors||(n.errors={}),m.state.next({submitCount:k.keepSubmitCount?n.submitCount:0,isDirty:L?!1:k.keepDirty?n.isDirty:!!(k.keepDefaultValues&&!Be(g,s)),isSubmitted:k.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:k.keepDirtyValues?k.keepDefaultValues&&i?At(s,i):n.dirtyFields:k.keepDefaultValues&&g?At(s,g):k.keepDirty?n.dirtyFields:{},touchedFields:k.keepTouched?n.touchedFields:{},errors:k.keepErrors?n.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Te=(g,k)=>ue(Me(g)?g(i):g,{...t.resetOptions,...k}),So=(g,k={})=>{const A=z(r,g),B=A&&A._f;if(B){const L=B.refs?B.refs[0]:B.ref;L.focus&&setTimeout(()=>{L.focus(),k.shouldSelect&&Me(L.select)&&L.select()})}},Co=g=>{n={...n,...g}},As={control:{register:Lt,unregister:Ot,getFieldState:_,handleSubmit:Pt,setError:ne,_subscribe:at,_runSchema:W,_updateIsValidating:w,_focusError:Ft,_getWatch:I,_getDirty:C,_setValid:x,_setFieldArray:S,_setDisabledField:on,_setErrors:N,_getFieldArray:F,_reset:ue,_resetDefaultValues:()=>Me(t.defaultValues)&&t.defaultValues().then(g=>{Te(g,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:cn,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return a},set _state(g){a=g},get _defaultValues(){return s},get _names(){return o},set _names(g){o=g},get _formState(){return n},get _options(){return t},set _options(g){t={...t,...g}}},subscribe:$t,trigger:ce,register:Lt,handleSubmit:Pt,watch:Se,setValue:Y,getValues:P,reset:Te,resetField:wt,clearErrors:G,unregister:Ot,setError:ne,setFocus:So,getFieldState:_};return{...As,formControl:As}}function ih(e={}){const t=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:Me(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Me(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Me(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...o}=sh(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,xs(()=>{const a=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(o=>({...o,isReady:!0})),i._formState.isReady=!0,a},[i]),y.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),y.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),y.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),y.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),y.useEffect(()=>{if(i._proxyFormState.isDirty){const a=i._getDirty();a!==r.isDirty&&i._subjects.state.next({isDirty:a})}},[i,r.isDirty]),y.useEffect(()=>{var a;e.values&&!Be(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=e.values,s(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),y.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()}),t.current.formState=y.useMemo(()=>xl(r,i),[i,r]),t.current}function ah(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function lh(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function oh(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function ch(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function dh(e,t,n=.001){const r=e-t,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function vs(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}vs();const uh={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:"$"},gr=()=>({id:vs(),amount:0,glAccount:null,isTaxDeductible:!1}),Sl=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:o,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:h=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:w,rules:S})=>{const M={...uh,...m},N=x!==void 0&&w!==void 0,j=ih({defaultValues:{_internal:t||gr()}}),T=Vf({control:N?x:j.control,name:N?w:"_internal",rules:N?S:void 0}),[$,W]=y.useState(t||gr()),D=N?T.field.value??gr():e??$,R=N&&!!T.fieldState?.error,E=N&&(T.fieldState?.isTouched??!1),C=R||E,I=C&&(!D.amount||D.amount<=0),F=C&&!D.glAccount,[H,Q]=y.useState(D.glAccount?.name||""),Y=y.useCallback(ne=>{const Se={...D,...ne};N&&T.field.onChange(Se),!N&&e===void 0&&W(Se),i?.(Se)},[D,e,i,N,T]),te=y.useCallback(ne=>{const Se=ne||0;Y({amount:Se}),a?.(Se)},[Y,a]),oe=y.useCallback(ne=>{Q(ne),s?.(ne)},[s]),ce=y.useCallback(ne=>{if(ne===null){Y({glAccount:null}),o?.(null);return}const at=n.find($t=>String($t.id)===String(ne))||null;Y({glAccount:at}),o?.(at)},[n,Y,o]),P=y.useCallback(()=>{Q(""),Y({glAccount:null}),o?.(null)},[Y,o]),_=y.useCallback(ne=>{Y({isTaxDeductible:ne}),c?.(ne)},[Y,c]),G=y.useCallback(()=>{d?.()},[d]);return l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:f.cn(v.base),children:l.jsxs(f.CardBody,{className:f.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[l.jsx("div",{className:f.cn("shrink-0",v.amountContainer),children:l.jsx(f.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.amount,l.jsx(f.Tooltip,{content:M.amountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:D.amount||void 0,onValueChange:te,labelPlacement:"outside",placeholder:M.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:I,errorMessage:I?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:l.jsx("div",{className:"pointer-events-none flex items-center",children:l.jsx("span",{className:"text-default-400 text-small",children:M.currencySymbol})})})}),l.jsx("div",{className:f.cn("grow",v.glAccountContainer),children:l.jsx(f.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.glAccount,l.jsx(f.Tooltip,{content:M.glAccountTooltip,children:l.jsx(U,{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:D.glAccount?.name??H,selectedKey:D.glAccount?.id??null,isDisabled:p,isInvalid:F,errorMessage:F?"GL Account is required":void 0,listboxProps:{emptyContent:r?M.searching:M.noGlAccountsFound},placeholder:M.glAccountPlaceholder,onInputChange:oe,onSelectionChange:ce,onClear:P,className:v.glAccountInput,children:ne=>l.jsx(f.AutocompleteItem,{textValue:ne.name,children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{children:ne.name}),ne.code&&l.jsx("span",{className:"text-xs text-default-400",children:ne.code})]})},ne.id)})}),l.jsx("div",{className:f.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:l.jsx(f.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:D.isTaxDeductible,onValueChange:_,isDisabled:p||!h,className:v.taxDeductibleCheckbox,children:M.taxDeductible})}),l.jsx("div",{className:f.cn("shrink-0 pt-6",v.deleteContainer),children:l.jsx(K,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:G,startContent:l.jsx(U,{icon:"solar:trash-bin-trash-linear",width:16}),className:f.cn("text-danger",v.deleteButton),children:M.deleteButton})})]})})};Sl.displayName="RevenueDistributionCard";const Cl=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return l.jsx(l.Fragment,{children:i()});const a=l.jsxs("div",{className:f.cn("flex flex-col items-center justify-center py-8",s.content),children:[l.jsx(U,{icon:t,width:n,className:f.cn("text-default-300 mb-4",s.icon)}),l.jsx("p",{className:f.cn("text-default-500 text-sm text-center",s.message),children:e})]});return r?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:a})};Cl.displayName="RevenueDistributionEmpty";const fh={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},jl=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...fh,...t},a=l.jsx(f.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:a})};jl.displayName="RevenueDistributionError";const Al=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,a)=>a),s=i=>l.jsxs("div",{className:f.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[l.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-14 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),l.jsxs("div",{className:"grow flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-20 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-full rounded-lg"})]}),l.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[l.jsx(f.Skeleton,{className:"h-5 w-5 rounded-full"}),l.jsx(f.Skeleton,{className:"h-4 w-24 rounded-md"})]}),l.jsx("div",{className:"shrink-0 pb-2",children:l.jsx(f.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?l.jsx("div",{className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:l.jsx(f.CardBody,{children:s(i)})},i))}):l.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Al.displayName="RevenueDistributionSkeleton";function Rn({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:o}){return l.jsx(f.Modal,{isOpen:e,size:"md",placement:"center",classNames:{base:"max-w-[440px] rounded-3xl",closeButton:"right-5 top-5 text-zinc-500"},onOpenChange:c=>!c&&a(),children:l.jsxs(f.ModalContent,{children:[l.jsxs(f.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&l.jsx("span",{className:f.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),l.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),l.jsx(f.ModalBody,{className:"px-7 pb-3 pt-4",children:l.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:a,children:t.cancel}),l.jsx(K,{type:"button",color:s,radius:"full",className:f.cn("h-10 text-sm font-normal text-white",s==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:o,children:t.confirm})]})]})})}const hh={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select at least two funds and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Percentages must total 100%",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},Ml={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},Vt={...Ml,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},mh={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},$i=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),ph=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,gh=e=>e.fund!==null;function xh({mode:e,assignments:t,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:o=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:h,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...hh,...r},w=t.filter(gh),S=w.length>0,M=y.useMemo(()=>t.reduce((P,_)=>P+Number(_.percentage||0),0),[t]),N=Math.round(M*100)/100,j=e==="split"&&t.some(P=>!P.fund||Number(P.percentage||0)<=0),T=e==="split"&&S&&(N!==100||j),$=e==="split"&&S&&N>=100,W=e==="split"||!S,[D,R]=y.useState(null),[E,C]=y.useState(!1),I=P=>{if(P!==e){if(P==="single"){const _=w[0]?.fund??null;h([{id:t[0]?.id??crypto.randomUUID(),fund:_,percentage:_?100:0}])}else{const _=w[0];h([{id:_?.id??crypto.randomUUID(),fund:_?.fund??null,percentage:_?.fund?50:0},$i()])}u(P)}},F=(P,_)=>{h(t.map(G=>G.id===P?{...G,..._}:G))},H=()=>{$||h([...t,$i()])},Q=P=>{if(!(t.length<=2)){if(!a){h(t.filter(_=>_.id!==P));return}R(P)}},Y=()=>{if(!D||t.length<=2){R(null);return}h(t.filter(P=>P.id!==D)),R(null)},te=()=>{if(!i){if(!a){b();return}C(!0)}},oe=()=>{C(!1),b()},ce=P=>{const _=c??t.find(G=>!G.fund)?.id??t[0]?.id;_&&(h(t.map(G=>G.id===_?{...G,fund:P,percentage:e==="single"?100:G.percentage}:G)),m())};return l.jsxs("div",{className:f.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:f.cn("w-full gap-0 px-0",s?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",s?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:P=>v?.(!(P==="all"||Array.from(P).length>0)),children:l.jsx(f.AccordionItem,{"aria-label":x.title,title:x.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",s?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(yh,{mode:e,labels:x,onModeChange:I,className:s?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:i,onPress:te,children:x.saveAssignment})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ml,color:"default",variant:"flat",title:e==="single"?x.emptySingle:x.emptySplit}),S&&l.jsx(bh,{mode:e,assignments:t,labels:x,total:M,hasTotalError:T,onSelectFund:P=>p(P),onRemoveFund:Q,onPercentageChange:(P,_)=>F(P,{percentage:ph(_)})}),W&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-base font-normal text-white disabled:opacity-50",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),isDisabled:$,onPress:()=>e==="split"&&S?H():p(),children:e==="split"&&S?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),o&&l.jsx(vh,{funds:n,labels:x,selectedFundIds:t.map(P=>P.fund?.id).filter(Boolean),onSelect:ce,onClose:m}),l.jsx(Rn,{isOpen:E,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>C(!1),onConfirm:oe}),l.jsx(Rn,{isOpen:D!==null,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>R(null),onConfirm:Y})]})}function yh({mode:e,labels:t,className:n,onModeChange:r}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:s=>r(s),children:[l.jsx(f.Tab,{title:t.singleFund},"single"),l.jsx(f.Tab,{title:t.splitFunds},"split")]})}function bh({mode:e,assignments:t,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:o}){return l.jsxs("div",{className:"flex flex-col gap-3",children:[t.map((c,d)=>l.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[l.jsx("div",{className:f.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&e==="single"?"justify-between":"gap-4"),children:c.fund?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),l.jsx(K,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):l.jsx(K,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),e==="split"&&l.jsx("label",{className:"flex w-48 flex-none items-center",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:u=>o(c.id,Number(u.target.value)),endContent:l.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:mh})}),e==="split"&&t.length>2&&l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:f.cn("h-10 w-10 flex-none p-0",d<2?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:d<2,onPress:()=>a(c.id),"aria-label":n.removeFund,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),e==="split"&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:s?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:s?"warning":"success",variant:"flat",classNames:{...Vt,base:f.cn(Vt.base,s?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:f.cn(Vt.iconWrapper,s?"text-warning-700":"text-success-700"),alertIcon:f.cn(Vt.alertIcon,s?"text-warning-700":"text-success-700"),title:f.cn(Vt.title,s?"text-warning-700":"text-success-700")},title:s?`${n.totalError} (${n.total} ${Number(r.toFixed(2))}%)`:`${n.total} ${Number(r.toFixed(2))}%`})]})}function vh({funds:e,labels:t,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),o=e.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return l.jsx(f.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",classNames:{base:"max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:c=>!c&&s(),children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),l.jsxs(f.ModalBody,{className:"px-6 pb-6",children:[l.jsx(f.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:i,placeholder:t.searchPlaceholder,onChange:c=>a(c.target.value),startContent:l.jsx(U,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),l.jsxs("div",{className:"mt-4 overflow-auto",children:[l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[l.jsx("span",{children:t.glCode}),l.jsx("span",{children:t.accountName}),l.jsx("span",{children:t.type}),l.jsx("span",{children:t.actions})]}),o.length===0&&l.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),o.map(c=>{const d=n.includes(c.id);return l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[l.jsx("span",{children:c.glCode}),l.jsx("span",{children:c.accountName}),c.type?l.jsx("span",{className:"w-fit rounded-full bg-warning-50 px-3 py-1 text-sm font-medium text-warning-500",children:c.type}):l.jsx("span",{className:"text-sm text-zinc-400",children:"-"}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",isDisabled:d,onPress:()=>r(c),children:t.select})]},c.id)})]})]})]})})}function wh(){return l.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const kh={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function Nh({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const o={...kh,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return l.jsx("div",{className:f.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",a),children:l.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[l.jsx(xr,{label:o.totalAmount,value:c.format(e)}),l.jsx(xr,{label:o.remainingBalance,value:c.format(t)}),l.jsx(xr,{label:o.amountReceived,value:c.format(n)})]})})}function xr({label:e,value:t}){return l.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[l.jsx("span",{className:"font-medium text-zinc-700",children:e}),l.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function yr(e,t){return e-t*Math.floor(e/t)}const El=1721426;function pn(e,t,n,r){t=ws(e,t);let s=t-1,i=-2;return n<=2?i=0:kn(t)&&(i=-1),El-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function kn(e){return e%4===0&&(e%100!==0||e%400===0)}function ws(e,t){return e==="BC"?1-t:t}function Sh(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const Ch={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class Yn{fromJulianDay(t){let n=t,r=n-El,s=Math.floor(r/146097),i=yr(r,146097),a=Math.floor(i/36524),o=yr(i,36524),c=Math.floor(o/1461),d=yr(o,1461),u=Math.floor(d/365),h=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=Sh(h),v=n-pn(p,m,1,1),b=2;n<pn(p,m,3,1)?b=0:kn(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),w=n-pn(p,m,x,1)+1;return new nn(p,m,x,w)}toJulianDay(t){return pn(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return Ch[kn(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return kn(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function jh(e,t){var n,r,s,i;return(i=(s=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&s!==void 0?s:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function Tl(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Ah(e,t){return Oi(e)-Oi(t)}function Oi(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let br=null;function Dl(){return br==null&&(br=new Intl.DateTimeFormat().resolvedOptions().timeZone),br}function Li(e){e=ks(e,new Yn);let t=ws(e.era,e.year);return Il(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Il(e,t,n,r,s,i,a){let o=new Date;return o.setUTCHours(r,s,i,a),o.setUTCFullYear(e,t-1,n),o.getTime()}function Fi(e,t){if(t==="UTC")return 0;if(e>0&&t===Dl())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:o}=$l(e,t);return Il(n,r,s,i,a,o,0)-Math.floor(e/1e3)*1e3}const Pi=new Map;function $l(e,t){let n=Pi.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Pi.set(t,n));let r=n.formatToParts(new Date(e)),s={};for(let i of r)i.type!=="literal"&&(s[i.type]=i.value);return{year:s.era==="BC"||s.era==="B"?-s.year+1:+s.year,month:+s.month,day:+s.day,hour:s.hour==="24"?0:+s.hour,minute:+s.minute,second:+s.second}}const Ri=864e5;function Mh(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>Eh(e,t,i))}function Eh(e,t,n){let r=$l(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Th(e,t,n="compatible"){let r=Ll(e);if(t==="UTC")return Li(r);if(t===Dl()&&n==="compatible"){r=ks(r,new Yn);let c=new Date,d=ws(r.era,r.year);return c.setFullYear(d,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let s=Li(r),i=Fi(s-Ri,t),a=Fi(s+Ri,t),o=Mh(r,t,s-i,s-a);if(o.length===1)return o[0];if(o.length>1)switch(n){case"compatible":case"earlier":return o[0];case"later":return o[o.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(s-i,s-a);case"compatible":case"later":return Math.max(s-i,s-a);case"reject":throw new RangeError("No such absolute time found")}}function Ol(e,t,n="compatible"){return new Date(Th(e,t,n))}function Ll(e,t){let n=0,r=0,s=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:s,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:s,millisecond:i}=t),new zn(e.calendar,e.era,e.year,e.month,e.day,n,r,s,i)}function ks(e,t){if(jh(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,Dt(r),r}function Ns(e,t){let n=e.copy(),r="hour"in n?Fh(n,t):0;qr(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Wr(n),Fl(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,Dh(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let s=n.calendar.getYearsInEra(n);if(n.year>s){var i,a;let c=(i=(a=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(a,n);n.year=s,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let o=n.calendar.getMonthsInYear(n);return n.month>o&&(n.month=o,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function qr(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Wr(e){for(;e.month<1;)qr(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,qr(e,1)}function Dh(e){for(;e.day<1;)e.month--,Wr(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Wr(e)}function Fl(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function Dt(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),Fl(e)}function Ih(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function Pl(e,t){return Ns(e,Ih(t))}function Rl(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),Dt(n),n}function $h(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),Lh(n),n}function Oh(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=gn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=gn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=gn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=gn(e.hour,24),t}function Lh(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function gn(e,t){let n=e%t;return n<0&&(n+=t),n}function Fh(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Oh(e)}function zl(e,t,n,r){let s=e.copy();switch(t){case"era":{let o=e.calendar.getEras(),c=o.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=tt(c,n,0,o.length-1,r?.round),s.era=o[c],Dt(s);break}case"year":var i,a;!((i=(a=s.calendar).isInverseEra)===null||i===void 0)&&i.call(a,s)&&(n=-n),s.year=tt(e.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,e);break;case"month":s.month=tt(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":s.day=tt(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(s),Dt(s),s}function Ph(e,t,n,r){let s=e.copy();switch(t){case"hour":{let i=e.hour,a=0,o=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,o=c?23:11}s.hour=tt(i,n,a,o,r?.round);break}case"minute":s.minute=tt(e.minute,n,0,59,r?.round);break;case"second":s.second=tt(e.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=tt(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return s}function tt(e,t,n,r,s=!1){if(s){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const Rh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,zh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Bh(e){let t=e.match(Rh);if(!t)throw zh.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new nn(vr(t[1],0,9999),vr(t[2],1,12),1);return n.day=vr(t[3],1,n.calendar.getDaysInMonth(n)),n}function vr(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function _h(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function Bl(e){let t=ks(e,new Yn),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Vh(e){return`${Bl(e)}T${_h(e)}`}function Hh(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _l(e,t,n){Hh(e,t),t.set(e,n)}function Vl(e){let t=typeof e[0]=="object"?e.shift():new Yn,n;if(typeof e[0]=="string")n=e.shift();else{let a=t.getEras();n=a[a.length-1]}let r=e.shift(),s=e.shift(),i=e.shift();return[t,n,r,s,i]}var Uh=new WeakMap;class nn{copy(){return this.era?new nn(this.calendar,this.era,this.year,this.month,this.day):new nn(this.calendar,this.year,this.month,this.day)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl(this,t)}cycle(t,n,r){return zl(this,t,n,r)}toDate(t){return Ol(this,t)}toString(){return Bl(this)}compare(t){return Tl(this,t)}constructor(...t){_l(this,Uh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,Dt(this)}}var qh=new WeakMap;class zn{copy(){return this.era?new zn(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new zn(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl($h(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return zl(this,t,n,r);default:return Ph(this,t,n,r)}}toDate(t,n){return Ol(this,t,n)}toString(){return Vh(this)}compare(t){let n=Tl(this,t);return n===0?Ah(this,Ll(t)):n}constructor(...t){_l(this,qh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,Dt(this)}}const Wh={monthly:1,quarterly:3,annual:12};function Hl(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,a=new Date(`${t.firstInstallmentDate}T00:00:00`),o=Wh[t.frequency];return Array.from({length:n},(c,d)=>{const u=new Date(a);return u.setMonth(a.getMonth()+d*o),{id:crypto.randomUUID(),dueDate:u.toISOString().slice(0,10),amount:(r+(d<i?1:0))/100}})}const Kh={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount"},Jh=["monthly","quarterly","annual"],Ul={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-950"},Bn={label:"text-sm font-normal text-zinc-950",inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Yh={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},zi=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Kr=e=>Math.round(e*100)/100,Gh=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},ql=e=>{if(!e)return null;try{return Bh(e)}catch{return null}};function Qh({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:o,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:h,onInstallmentsChange:p,onSave:m}){const v={...Kh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=e==="automatic"?Hl(t,i):s,w=y.useMemo(()=>Kr(x.reduce((T,$)=>T+Number($.amount||0),0)),[x]),S=T=>{T!==e&&(u(T),T==="manual"&&s.length===0&&p([zi()]))},M=(T,$)=>{s.find(D=>D.id===T)?.status!=="paid"&&p(s.map(D=>D.id===T?{...D,...$}:D))},N=()=>{p([...s,zi()])},j=T=>{s.find(W=>W.id===T)?.status!=="paid"&&p(s.filter(W=>W.id!==T))};return l.jsx("div",{className:f.cn("vvt-ps font-sans text-zinc-900",o?.root),children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:f.cn("w-full gap-0 px-0",o?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",o?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":v.title,title:v.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",o?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(Zh,{mode:e,labels:v,onModeChange:S,isDisabled:d,className:o?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-36 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:m,children:v.saveInstallments})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&l.jsx(Xh,{settings:i,labels:v,onSettingsChange:h}),x.length===0&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ul,color:"default",variant:"flat",title:e==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&l.jsx(em,{mode:e,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:M,onRemoveInstallment:j}),e==="manual"&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:N,children:v.addInstallment})}),l.jsx(nm,{total:w,donationAmount:t,difference:Kr(t-w),hasTotalError:e==="manual"&&Math.abs(t-w)>.009,mode:e,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function Zh({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:s}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>s(i),children:[l.jsx(f.Tab,{title:t.automaticMode},"automatic"),l.jsx(f.Tab,{title:t.manualMode},"manual")]})}function Xh({settings:e,labels:t,onSettingsChange:n}){return l.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[l.jsx("div",{className:"min-w-0",children:l.jsx(f.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...e,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:Bn})}),l.jsx("div",{className:"min-w-0",children:l.jsx(yt,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...e,frequency:s})},classNames:Yh,children:Jh.map(r=>l.jsx(f.SelectItem,{textValue:t[r],children:t[r]},r))})}),l.jsx("div",{className:"min-w-0",children:l.jsx(f.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:ql(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:l.jsx(U,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:Bn})})]})}function em({mode:e,installments:t,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return e==="automatic"?l.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:l.jsx("div",{className:f.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((o,c)=>l.jsxs("div",{className:f.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",c===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{children:["#",c+1]}),l.jsx("span",{children:"▪"}),l.jsx("span",{children:Gh(o.dueDate,s)}),c===0&&l.jsx(f.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),l.jsx("span",{className:"text-zinc-950",children:r.format(o.amount)})]},o.id))})}):l.jsx("div",{className:"flex flex-col gap-2",children:t.map((o,c)=>l.jsxs("div",{className:"flex w-full items-center gap-4",children:[l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:o.status==="paid",value:ql(o.dueDate),onChange:d=>i(o.id,{dueDate:d?d.toString():""}),classNames:Bn})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:o.status==="paid",value:String(o.amount||""),onChange:d=>i(o.id,{amount:Kr(Number(d.target.value||0))}),startContent:l.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:Bn})}),l.jsx(tm,{isDisabled:t.length<=1,isPaid:o.status==="paid",label:n.deleteInstallment,onRemove:()=>a(o.id)})]},o.id))})}function tm({isDisabled:e,isPaid:t,label:n,onRemove:r}){const s=l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?l.jsx(f.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:l.jsx("span",{className:"inline-flex",children:s})}):s}function nm({total:e,donationAmount:t,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const o=i>0?e/i:0,c=s==="automatic"?l.jsxs("span",{children:["Saving will create ",l.jsx("strong",{children:i})," scheduled payment records of"," ",l.jsx("strong",{children:a.format(o)})," each."]}):l.jsxs("span",{children:["Total scheduled: ",l.jsx("strong",{children:a.format(e)})," /"," ",l.jsx("strong",{children:a.format(t)}),"."]}),d=s==="automatic"?`Total: ${a.format(e)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Ul,endContent:l.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function rm(){return l.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[l.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[l.jsx(f.Skeleton,{className:"h-4 w-36 rounded-md"}),l.jsx(f.Skeleton,{className:"h-9 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-9 w-36 rounded-full"})]}),l.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const Bi={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},_i={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},sm={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:l.jsxs(l.Fragment,{children:["Are you sure you want to delete this payment? ",l.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."};function im({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:o}){const c={...sm,...r},[d,u]=y.useState(""),h=new Intl.NumberFormat(n,{style:"currency",currency:t}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?e.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Vi(v.dueDate,n),b,_i[b]??b].join(" ").toLowerCase().includes(m)}):e},[n,e,d]);return l.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":c.title,title:c.title,children:l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[l.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[l.jsxs("div",{className:"w-full max-w-[280px]",children:[l.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:c.searchLabel}),l.jsx(f.Input,{variant:"bordered",size:"sm",value:d,placeholder:c.searchPlaceholder,onChange:m=>u(m.target.value),startContent:l.jsx(U,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}})]}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",size:"sm",className:"h-8 border-zinc-200 bg-white px-3 text-sm font-normal text-zinc-900",startContent:l.jsx(U,{icon:"solar:pen-outline",className:"size-4"}),isLoading:s,onPress:i,children:c.editInstallments})]}),l.jsx("div",{className:"w-full overflow-hidden",children:l.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"w-[6%]"}),l.jsx("col",{className:"w-[25%]"}),l.jsx("col",{className:"w-[12%]"}),l.jsx("col",{className:"w-[16%]"}),l.jsx("col",{className:"w-[17%]"}),l.jsx("col",{className:"w-[24%]"})]}),l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[l.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.installmentId}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.amount}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.scheduledDate}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.status}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.actions})]})}),l.jsxs("tbody",{children:[p.map((m,v)=>{const b=m.status??"scheduled";return l.jsxs("tr",{className:"text-zinc-500",children:[l.jsx("td",{className:"px-2 py-3",children:v+1}),l.jsx("td",{className:"px-2 py-3",children:l.jsx("span",{className:"block max-w-full truncate",children:m.id||`PMT-${v+1}`})}),l.jsx("td",{className:"px-2 py-3",children:h.format(m.amount)}),l.jsx("td",{className:"px-2 py-3",children:Vi(m.dueDate,n)}),l.jsx("td",{className:"px-2 py-3",children:l.jsx(f.Chip,{size:"sm",radius:"full",className:f.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Bi[b]??Bi.scheduled),startContent:l.jsx(lm,{status:b}),children:_i[b]??b})}),l.jsx("td",{className:"px-2 py-3",children:l.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[l.jsx(K,{type:"button",size:"sm",radius:"full",className:"h-9 min-w-[104px] shrink-0 bg-brand px-3 text-sm font-medium text-white disabled:opacity-50",isDisabled:b==="paid"||b==="fulfilled",startContent:l.jsx(U,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(m),children:c.payNow}),l.jsx(am,{isPaid:b==="paid"||b==="fulfilled",labels:c,onDelete:()=>o(m.id)})]})})]},m.id)}),p.length===0&&l.jsx("tr",{children:l.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:c.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function am({isPaid:e,labels:t,onDelete:n}){const[r,s]=y.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs(f.Dropdown,{placement:"bottom-end",radius:"lg",children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:l.jsx(U,{icon:"solar:menu-dots-bold",className:"size-4"})})}),l.jsxs(f.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!e&&s(!0)},children:[l.jsx(f.DropdownSection,{title:"Actions",showDivider:!0,children:l.jsx(f.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:l.jsx(U,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),l.jsx(f.DropdownSection,{title:t.dangerZone,children:l.jsx(f.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),l.jsx(Rn,{isOpen:r,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:l.jsx(U,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function lm({status:e}){return e==="paid"||e==="fulfilled"?l.jsx(U,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?l.jsx(U,{icon:"solar:close-circle-bold",className:"size-3"}):l.jsx(U,{icon:"solar:calendar-outline",className:"size-3"})}function Vi(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const om={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},cm=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:o=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:h=""})=>{const p=Array.isArray(e)?e:[],[m,v]=y.useState(o),[b,x]=y.useState(a),w={...om,...s};y.useEffect(()=>{v(o)},[o]);const S=N=>{if(N===m){c&&u?.(N);return}v(N),u?.(N)},M=N=>{x(N),d?.(N)};return l.jsxs("div",{className:f.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",h),"data-testid":"membership-select-cards",children:[l.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),l.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&l.jsx(Zl,{title:w.renewalTitle,description:w.renewalDescription,value:b,onValueChange:M}),l.jsx("div",{className:f.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":f.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(N=>l.jsx(Wl,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:t,currency:n,isSelected:m===N.id,onSelect:S},N.id))})]})},Wl=({itemKey:e,name:t,type:n,price:r,locale:s="en-US",currency:i="USD",showPrice:a=!0,isSelected:o=!1,onSelect:c,compact:d=!1,isDisabled:u=!1,disabledReason:h,statusLabel:p,statusTone:m="default",className:v=""})=>{const b=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),x=!!c&&!u,w=h||p,S=()=>{x&&c?.(e)};return l.jsx(f.Card,{shadow:"none",isPressable:!!c,onPress:S,className:f.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",u?"opacity-60":"",d?"rounded-2xl":"",v),"data-testid":"item-card","data-selected":o,isDisabled:u,children:l.jsxs("div",{className:f.cn("px-4 py-8 flex gap-6 items-center justify-between",d&&"px-3 py-3 gap-4"),children:[l.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[l.jsx("p",{className:f.cn("font-semibold text-left",d?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&l.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:l.jsx("p",{className:"text-center",children:n})}),w&&l.jsx(f.Chip,{"data-testid":"item-card-status",color:m,size:"sm",variant:"flat",className:"px-2",children:w})]}),a&&l.jsx("p",{className:f.cn("font-semibold text-right",d?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:b})]})})},Hi="w-full bg-gray-100",Ui={variant:"light",color:"default"},Kl=({id:e,title:t,media:n,imageUrl:r,imageAlt:s,imageClassName:i="",imageAspect:a="aspect-[4/3]",meta:o=[],price:c,action:d,footer:u,onPress:h,isPressable:p=!1,isDisabled:m=!1,compact:v=!1,className:b="",bodyClassName:x="",footerClassName:w="",dataTestId:S})=>{const M=!!(c&&c.value),N=!!d?.label,j=p&&!!h&&!N,T=!j,$=N?{variant:d?.variant??Ui.variant,color:d?.color??Ui.color,size:d?.size??"sm",isDisabled:m||d?.isDisabled,startContent:d?.icon?l.jsx(U,{icon:d.icon,width:16}):void 0}:null,W=n??(r?l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,i),children:l.jsx(f.Image,{removeWrapper:!0,src:r,alt:s||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:l.jsx(U,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return l.jsxs(f.Card,{"data-testid":S||`catalog-item-card-${e??"item"}`,className:f.cn("w-full overflow-hidden",b),isPressable:j,onPress:h,isDisabled:m,shadow:"sm",radius:"lg",children:[l.jsx("div",{children:W}),l.jsxs(f.CardBody,{className:f.cn("gap-3",v?"p-3":"p-4",x),children:[l.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:f.cn("line-clamp-2 text-base font-semibold text-gray-900",v?"text-sm":""),children:t}),o.length>0?l.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((D,R)=>l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(U,{icon:D.icon,className:"size-4 text-gray-400",width:16}),l.jsx("span",{children:D.label})]},`${D.label}-${R}`))}):null,(M||N)&&l.jsxs("div",{className:f.cn("flex items-center justify-end gap-2 pt-1 text-sm",v?"pt-0.5":"",w),children:[M?l.jsxs("span",{className:f.cn("mr-auto text-gray-500",v?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[c?.label&&l.jsxs("span",{children:[c.label," "]}),l.jsx("span",{className:"font-semibold text-brand",children:c?.value})]}):l.jsx("span",{className:"ml-auto","aria-hidden":!0}),N&&T?l.jsx(K,{className:f.cn("rounded-full",d?.className),onPress:d?.onPress,variant:$?.variant,color:$?.color,size:$?.size,startContent:$?.startContent,isDisabled:$?.isDisabled,"aria-label":d?.ariaLabel||d?.label,children:d?.label}):null]}),u?l.jsx("div",{className:"pt-1",children:u}):null]})]})};Kl.displayName="CatalogItemCard";const dm={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},um={empty:"border-default-200 bg-white",error:"border-danger-200 bg-white",success:"border-success-100 bg-success-50/40",loading:"border-default-200 bg-white"},fm={empty:"bg-default-100 text-default-400",error:"bg-danger-50 text-danger-600",success:"bg-success-100 text-success-700",loading:"bg-primary-50 text-primary"},hm={empty:"status",error:"alert",success:"status",loading:"status"},mm={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function pm(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return l.jsx(f.Spinner,{size:"lg",color:"primary",className:r.spinner});if(y.isValidElement(t))return l.jsx(l.Fragment,{children:t});const s=typeof t=="string"?t:dm[e];return s?l.jsx(U,{icon:s,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function It({variant:e="empty",title:t,titleAs:n="p",description:r,icon:s,actions:i,role:a=hm[e],ariaLive:o=mm[e],iconSize:c=24,className:d,classNames:u={},"data-testid":h="feedback-state"}){const p=pm(e,s,c,u);return l.jsxs("div",{role:a,"aria-live":o,"data-variant":e,"data-testid":h,className:f.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",um[e],d,u.base),children:[p?l.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:f.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",fm[e],u.iconWrapper),children:p}):null,l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[l.jsx(n,{"data-testid":`${h}-title`,className:f.cn("text-base font-medium text-default-900",u.title),children:t}),r?l.jsx("p",{"data-testid":`${h}-description`,className:f.cn("max-w-sm text-sm text-default-600",u.description),children:r}):null]}),i?l.jsx("div",{"data-testid":`${h}-actions`,className:f.cn("mt-1 flex flex-wrap items-center justify-center gap-2",u.actions),children:i}):null]})}function Jl(e){return l.jsx(It,{...e,variant:"empty"})}function Yl(e){return l.jsx(It,{...e,variant:"error"})}function Gl(e){return l.jsx(It,{...e,variant:"loading"})}function Ql(e){return l.jsx(It,{...e,variant:"success"})}It.displayName="FeedbackState";Jl.displayName="EmptyState";Yl.displayName="ErrorState";Gl.displayName="LoadingState";Ql.displayName="SuccessState";const Zl=({title:e,value:t,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return l.jsxs("div",{className:f.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[e&&l.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&l.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),l.jsx(f.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},gm={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"},xm=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Xl=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),ym=e=>e.reduce((t,n)=>t+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),Ss=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),qi=(e,t,n)=>{const r={};let s=n?t??ym(e):0;for(const{exhibition:i,dateGroup:a,ticket:o}of Ss(e)){r[i.id]??={},r[i.id][a.id]??={};const c=n?Math.min(o.max,s):0;r[i.id][a.id][o.id]={id:o.id,selectedQuantity:c,originalPrice:o.originalPrice,discountedPrice:o.price},s-=c}return r},Wi=(e,t,n)=>`${e}::${t}::${n}`,bm=(e,t,n)=>{const r=Xl(t);for(const{exhibition:s,dateGroup:i,ticket:a}of Ss(e)){const o=t[s.id]?.[i.id]?.[a.id]?.selectedQuantity??0,c=n===void 0?a.max:Math.min(a.max,n-(r-o));if(c>0&&o<c)return!1}return!0},vm=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(t,Math.min(n,e)),[a,o]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),h=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=t||r?.(i-1)},m=N=>{if(s)return;o(N.target.value);const j=parseInt(N.target.value,10);isNaN(j)||r?.(Math.max(t,Math.min(n,j)))},v=N=>{const j=parseInt(N.target.value,10);if(d(!1),isNaN(j)){r?.(t);return}const T=Math.max(t,Math.min(n,j));T!==j?r?.(T):o(String(T))},b=i<=t,x=i>=n,w="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",S="bg-primary hover:bg-primary/80",M="bg-primary/40 cursor-not-allowed";return l.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[l.jsx("button",{type:"button",onClick:p,disabled:s||b,className:f.cn(w,s||b?M:S),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),l.jsx("input",{type:"number",value:u,onChange:m,onFocus:()=>d(!0),onBlur:v,disabled:s,min:t,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"}),l.jsx("button",{type:"button",onClick:h,disabled:s||x,className:f.cn(w,s||x?M:S),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},wm=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!t)};return l.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:f.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:[l.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[l.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),l.jsx("span",{className:f.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&l.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"})})]}),l.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},km=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const o=()=>{if(!r||s===void 0)return e.max;const h=r();return Math.min(e.max,s-(h-t))},c=i?.locale??"en-US",d=i?.currency??"USD",u=xm(c,d);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[l.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[l.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?l.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[l.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(e.originalPrice)}),l.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(e.price)})]})]}),e.membershipName?l.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:e.membershipName,children:l.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,l.jsx("div",{className:"text-sm text-zinc-500",children:l.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[a.ticketsAllowedToRedeem," ",e.max]})})]}),l.jsx(vm,{initialQuantity:t,minQuantity:0,maxQuantity:o(),onChange:n})]}),e.membershipAlert?l.jsx(f.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:l.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},Nm=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c})=>l.jsxs("div",{className:f.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[l.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((d,u)=>l.jsxs("div",{children:[l.jsx(km,{item:d,quantity:s(e,t.id,d.id),onChange:h=>r(e,t.id,d.id,h),getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c}),u<t.tickets.length-1?l.jsx(f.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),Sm=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),h=t.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(t.id,v.id,x.id),0),0),p=t.dates.some(m=>m.tickets.length>0);return l.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[l.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-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:l.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[l.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[h," ",o.ticketsSelectedToRedeem]}),l.jsx("span",{className:f.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:l.jsx(U,{icon:"mdi:chevron-down"})})]})]})}),l.jsx("div",{id:`upgrade-items-${t.id}`,className:f.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&l.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?t.dates.map((m,v)=>l.jsx(Nm,{exhibitionId:t.id,dateGroup:m,isLast:v===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o},m.id)):l.jsx("div",{className:"px-5 py-10 text-center",children:l.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},Cm=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const o=y.useMemo(()=>s??[],[s]),c={...gm,...n},[d,u]=y.useState(()=>qi(o,t,!0)),h=y.useRef(!1),p=y.useMemo(()=>{const S=Ss(o).map(({exhibition:M,dateGroup:N,ticket:j})=>[Wi(M.id,N.id,j.id),j]);return new Map(S)},[o]),m=bm(o,d,t),v=(S,M,N)=>d[S]?.[M]?.[N]?.selectedQuantity??0,b=()=>Xl(d),x=(S,M,N,j)=>{const T=v(S,M,N),$=b()-T;if(t!==void 0&&$+j>t)return;const W=p.get(Wi(S,M,N));if(!W)return;const D={...d,[S]:{...d[S],[M]:{...d[S]?.[M],[N]:{id:N,selectedQuantity:j,originalPrice:W.originalPrice,discountedPrice:W.price}}}};u(D),a?.(D)},w=S=>{const M=qi(o,t,S);u(M),a?.(M)};return y.useEffect(()=>{!h.current&&m&&(a?.(d),h.current=!0)},[m,d,a]),l.jsxs("div",{className:f.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[l.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[l.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),l.jsx(wm,{label:c.selectAllButtonLabel,checked:m,onChange:w})]}),o.map(S=>l.jsx(Sm,{title:S.exhibitionName,exhibition:S,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},S.id))]})},wr={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},kr=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},jm=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const s=e[r.id]??[];n[r.id]=s.length>0?s[0]:null}return n},Am=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,eo=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:s="default",triggerSize:i="sm",triggerClassName:a,popoverClassName:o,className:c,sections:d,onConfirm:u,onClear:h,appliedCount:p,countAriaLabel:m,countDisplay:v="badge",confirmLabel:b=wr.confirm,clearLabel:x=wr.clear,isOpen:w,defaultOpen:S=!1,onOpenChange:M,isDisabled:N=!1,closeOnConfirm:j=!0,keepOpenAfterClear:T=!1})=>{const[$,W]=y.useState(S),[D,R]=y.useState(()=>kr(d)),E=w??$,C=p??d.filter(P=>Am(P)).length,I=P=>{P&&R(kr(d)),w||W(P),M?.(P)},F=(P,_)=>{R(G=>({...G,[P.id]:_}))},H=(P,_)=>{R(G=>({...G,[P.id]:_?[_]:[]}))},Q=async()=>{R(kr(d.map(P=>P.type==="checkbox"?{...P,selectedValues:[]}:{...P,selectedValue:null}))),await h(),T||I(!1)},Y=async()=>{const P=jm(D,d);await u(P),j&&I(!1)},te=P=>{if(P.type==="checkbox")return l.jsx(f.CheckboxGroup,{label:P.label,value:D[P.id]??[],onValueChange:G=>F(P,G),children:P.options.map(G=>l.jsx(f.Checkbox,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id);const _=D[P.id]?.[0]??"";return l.jsx(f.RadioGroup,{label:P.label,value:_,onValueChange:G=>H(P,G||null),children:P.options.map(G=>l.jsx(f.Radio,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id)},oe=y.useMemo(()=>C>0?m?.(C)||`${C} filters applied`:void 0,[m,C]),ce=y.useMemo(()=>C===0?e||wr.noLabel:m?m(C):`${e} (${C})`,[C,e,m]);return l.jsx("div",{className:c,children:l.jsxs(f.Popover,{isOpen:E,onOpenChange:I,placement:"bottom-end",children:[l.jsx(f.PopoverTrigger,{children:l.jsxs(K,{isDisabled:N,variant:r,color:s,size:i,className:a,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":E,children:[l.jsx(U,{icon:n,width:16}),l.jsx("span",{children:e}),v==="badge"&&C>0?l.jsx("span",{className:"ml-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-xs font-medium text-white","aria-label":oe,children:C}):v==="summary"&&ce!==e?l.jsx("span",{className:"text-xs",children:ce}):null]})}),l.jsx(f.PopoverContent,{className:o,children:l.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[d.map(P=>te(P)),l.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[l.jsx(K,{variant:"light",color:"default",size:"sm",onPress:Q,children:x}),l.jsx(K,{color:"primary",size:"sm",onPress:Y,children:b})]})]})})]})})};eo.displayName="FilterPopover";const Mm="No sessions available for this date",Em=e=>e==="sold-out"||e==="closed"?"danger":"success",Tm=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},Ki=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",Dm=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,to=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:s,quickDates:i,selectedSessionId:a=null,onSessionSelect:o,emptyStateMessage:c=Mm,statusLabel:d,statusTone:u,sessionAriaLabel:h,dayButtonClassName:p,calendarSlot:m,dayGroupAriaLabel:v,sessionGridAriaLabel:b,className:x,headingClassName:w,subheadingClassName:S})=>{const M=Dm(n,r),N=n.find(D=>D.date===M),j=i??n.map(D=>({date:D.date,label:D.label})),T=N?.sessions??[],$=D=>D===M?"solid":"bordered",W=D=>{if(!Ki(D)){if(D.id===a){o(null);return}o(D.id)}};return l.jsxs("section",{className:f.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",x),"data-testid":"session-timeline-root",children:[l.jsxs("header",{className:"flex flex-col gap-1",children:[l.jsx("h2",{className:f.cn("text-base font-semibold text-gray-900",w),children:e}),t?l.jsx("p",{className:f.cn("text-sm text-gray-700",S),children:t}):null]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":v||"Session days",children:[j.map(D=>l.jsx(K,{size:"sm",variant:$(D.date),color:"default",className:f.cn("rounded-full",p),isDisabled:D.isDisabled,onPress:()=>{s(D.date)},children:l.jsx("span",{children:D.label})},D.date)),m?l.jsx("div",{children:m}):null]}),l.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":b||"Sessions",children:[T.length===0?l.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:c}):null,T.map(D=>{const R=Ki(D),E=D.id===a;return l.jsx("li",{className:"rounded-xl",children:l.jsx(f.Card,{shadow:"sm",radius:"lg",isPressable:!R,onPress:()=>{W(D)},"aria-disabled":R,"aria-pressed":R?void 0:E,className:f.cn("w-full",R?"bg-gray-100 opacity-70":"",E?"w-full ring-2 ring-gray-900":""),"aria-label":h?h(D,{isSelected:E,isUnavailable:R}):R?`${D.startTime} ${D.endTime} sold out`:`${D.startTime} ${D.endTime} available`,children:l.jsxs(f.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[l.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[D.startTime," – ",D.endTime]}),l.jsx(f.Chip,{size:"sm",color:u?u(D):Em(D.status),variant:"flat",children:d?d(D):Tm(D)})]})})},D.id)})]})]})};to.displayName="SessionTimeline";const Im=350,$m={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}"},Nr=(e,t)=>Object.entries(t).reduce((n,[r,s])=>n.replace(`{${r}}`,s),e),Om=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:a=!1,maxAmount:o,autoFocus:c=!1,className:d,"data-testid":u="cash-tender-form"})=>{const h={...$m,...i},p=Gr(e.currency,s),m=t!==void 0,[v,b]=y.useState(n??null),x=m?t:v,w=y.useMemo(()=>{const I=typeof x=="number"&&Number.isFinite(x)?x:0,F=Cr(I,e.value,e.currency,s);return{received:I,change:F>0?F:0,isValid:I>=e.value&&I>0}},[x,e.value,e.currency,s]),S=y.useCallback(I=>{const F=I.currentTarget;requestAnimationFrame(()=>{F.isConnected&&F.select()})},[]),M=y.useCallback(I=>{if(a)return;const F=I.replace(/[^\d.,]/g,"").replace(",","."),H=F===""?null:Number.parseFloat(F),Q=H===null||Number.isNaN(H)?null:H;if(Q!==null&&o!==void 0&&Q>o)return;m||b(Q);const Y=typeof Q=="number"&&Number.isFinite(Q)?Q:0,te=Cr(Y,e.value,e.currency,s);r?.({received:Y,change:te>0?te:0,isValid:Y>=e.value&&Y>0})},[m,a,e.value,e.currency,s,r,o]),N=x==null?"":String(x),j=w.isValid&&w.change>0,T=!w.isValid&&w.received>0,$=rt(w.change,s,e.currency),W=rt(e.value,s,e.currency),[D,R]=y.useState(""),E=y.useRef(null);y.useEffect(()=>{E.current&&clearTimeout(E.current);const I=j?Nr(h.changeMessageTemplate,{change:$}):"",F=j?Im:0;return E.current=setTimeout(()=>R(I),F),()=>{E.current&&clearTimeout(E.current)}},[j,$,h.changeMessageTemplate]);const C=`${u}-received`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",d),"data-testid":u,children:[l.jsx(f.Input,{id:C,label:h.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:I=>M(I.target.value),onFocus:S,placeholder:h.receivedPlaceholder,isDisabled:a,isInvalid:T,errorMessage:T?Nr(h.insufficientMessageTemplate,{due:W}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&l.jsx(f.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:h.changeLabel,description:Nr(h.changeMessageTemplate,{change:$}),icon:l.jsx(U,{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"}}),l.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:D})]})},Lm={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Ji=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},no=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:a=!1,isDisabled:o=!1,checkNumberMaxLength:c=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:h,"data-testid":p="check-tender-form"})=>{const m={...Lm,...s},v=t!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Ji()}),[w,S]=y.useState(!!n?.checkNumber),M=y.useMemo(()=>v?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??Ji()}:b,[v,t,b]),N=y.useCallback(E=>{v||x(E);const C=E.checkNumber.trim(),I={amount:e.value,checkNumber:C,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:C.length>0&&e.value>0};r?.(I)},[v,e.value,i,r]),j=y.useCallback(E=>C=>{o||(E==="checkNumber"&&C.length>0&&S(!0),N({...M,[E]:C}))},[M,N,o]),T=y.useCallback(()=>{o||S(!0)},[o]),$=w&&M.checkNumber.trim()==="",W=`${p}-check-number`,D=`${p}-bank-name`,R=`${p}-date`;return l.jsxs("div",{className:f.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",h),"data-testid":p,children:[l.jsx(f.Input,{id:W,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:M.checkNumber,onChange:E=>j("checkNumber")(E.target.value),onBlur:T,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:$,errorMessage:$?m.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&l.jsx(f.Input,{id:D,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:M.bankName,onChange:E=>j("bankName")(E.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&l.jsx(f.Input,{id:R,label:m.dateLabel,labelPlacement:"outside",type:"date",value:M.date,onChange:E=>j("date")(E.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};no.displayName="CheckTenderForm";const Fm={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Pm=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],ro=({dueAmount:e,methodOptions:t=Pm,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:o=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...Fm,...i},h=n!==void 0,[p,m]=y.useState({method:r?.method??"",reference:r?.reference??""}),v=y.useMemo(()=>h?{method:n?.method??"",reference:n?.reference??""}:p,[h,n,p]),b=y.useCallback(j=>t.find(T=>T.value===j)?.label??"",[t]),x=y.useCallback(j=>{h||m(j);const T=b(j.method),$={amount:e.value,method:j.method,description:T,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.($)},[h,e.value,s,b]),w=y.useCallback(j=>{if(o)return;const T=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:T})},[v,x,o]),S=y.useCallback(j=>{o||x({...v,reference:j})},[v,x,o]),M=`${d}-method`,N=`${d}-reference`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",c),"data-testid":d,children:[l.jsx(yt,{id:M,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:w,isDisabled:o,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:t.map(j=>l.jsx(f.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&l.jsx(f.Input,{id:N,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:v.reference,onChange:j=>S(j.target.value),placeholder:u.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};ro.displayName="OtherTenderForm";const Rm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},zm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Bm={pending:"warning",recorded:"success",failed:"danger"},_m=e=>e==="pending"||e==="recorded",Vm=e=>`#${e+1}`,so=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":o="split-payment-summary"})=>{const c={...Rm,...s},{collected:d,remaining:u,isComplete:h}=y.useMemo(()=>{const m=t.reduce((b,x)=>_m(x.status)?b+x.amount:b,0),v=Math.max(e.value-m,0);return{collected:m,remaining:v,isComplete:m>=e.value&&e.value>0}},[t,e.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return l.jsxs("div",{className:f.cn("flex flex-col gap-4",a),"data-testid":o,children:[l.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[l.jsx("div",{className:"text-sm text-default-600",children:h?c.completeLabel:c.remainingLabel}),l.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:rt(h?d:u,r,e.currency)})]}),!i&&t.length>0&&l.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[l.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((m,v)=>l.jsx(Hm,{index:v,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:p(m.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${o}-row-${v}`},m.id))]})]})};so.displayName="SplitPaymentSummary";const Hm=({index:e,tender:t,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:o,recordedTooltip:c,dataTestId:d})=>{const u=i?l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":o,"data-testid":`${d}-remove`,className:f.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return l.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:[l.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:Vm(e)}),l.jsx(U,{icon:zm[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),l.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:t.label}),l.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:rt(t.amount,n,r)}),l.jsx(f.Chip,{size:"sm",radius:"full",variant:"flat",color:Bm[t.status],startContent:t.status==="recorded"?l.jsx(U,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?l.jsx(U,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:a}),u&&(s?u:l.jsx(f.Tooltip,{content:c,placement:"left",children:l.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},Um=`
|
|
9
|
+
${f?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
+
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),s.jsx(d.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:s.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:l,"aria-label":"Zoom in",children:s.jsx(Y.ZoomIn,{size:16})})})]})}function Ja({editor:e,isDisabled:t=!1}){const[n,r]=g.useState(!1),[a,i]=g.useState(""),[l,o]=g.useState(""),[c,u]=g.useState(!1),f=e.isActive("link"),x=h=>{if(h){const{from:C,to:v}=e.state.selection,p=e.isActive("link");let b="";if(p){const $=e.schema.marks.link,w=e.state.doc.resolve(C),k=kn.getMarkRange(w,$);k&&(b=e.state.doc.textBetween(k.from,k.to,""))}else b=e.state.doc.textBetween(C,v,"");const N=e.getAttributes("link").href||"";i(b),o(N),u(p)}r(h)},y=()=>{if(l.trim()){const{from:h,to:C}=e.state.selection,v=e.schema.marks.link,p=e.state.doc.resolve(h),b=kn.getMarkRange(p,v),N=b?.from??h,$=b?.to??C,w=e.state.doc.textBetween(N,$,"");a.trim()&&a!==w?e.chain().focus().setTextSelection({from:N,to:$}).deleteSelection().insertContent(`<a href="${l.trim()}">${a.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:l.trim()}).run()}r(!1)};return s.jsxs(d.Popover,{isOpen:n,onOpenChange:x,placement:"bottom",children:[s.jsx(d.PopoverTrigger,{children:s.jsx(q,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:s.jsx(Y.Link,{size:16})})}),s.jsx(d.PopoverContent,{children:s.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[s.jsx(d.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:a,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(d.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:l,onChange:h=>o(h.target.value),onKeyDown:h=>h.key==="Enter"&&y(),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(q,{size:"sm",color:"primary",onPress:y,isDisabled:!l.trim(),children:c?"Update":"Apply"})]})})]})}function Xa({children:e,id:t,label:n,className:r,useButtonGroup:a=!0}){return a?s.jsx(d.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):s.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function ps(e,t){const n=g.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(o=>tt(o)))).forEach(o=>{const c=Ce[o];if(c)try{const u=c.canExecute?.(e)??!0,f=c.isActive?.(e)??!1;i[o]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${o}`,u),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,a]=g.useState(n);return g.useEffect(()=>{if(!e)return;const i=()=>{const l={};Array.from(new Set(t.map(c=>tt(c)))).forEach(c=>{const u=Ce[c];if(u)try{const f=u.canExecute?.(e)??!0,x=u.isActive?.(e)??!1;l[c]={isActive:x,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${c}`,f),l[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),a(l)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function gs(e,t){const n=g.useCallback((l,o)=>{if(!e)return;const c=Ce[l];if(c)try{c.execute({editor:e,config:o}),t?.({type:"toggle",modifier:l})}catch(u){console.warn(`Failed to execute command for modifier: ${l}`,u)}},[e,t]),r=g.useCallback(l=>{n(l)},[n]),a=g.useCallback((l,o)=>{if(!e)return!1;const c=Ce[l];try{return c?.canExecute?.(e,o)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${l}`,u),!1}},[e]),i=g.useCallback((l,o)=>{if(!e)return!1;const c=Ce[l];try{return c?.isActive?.(e,o)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${l}`,u),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:a,isActive:i}}function ei(e=ue.default){const[t,n]=g.useState(e),r=g.useCallback((o=ue.step)=>{n(c=>Math.min(ue.max,c+o))},[]),a=g.useCallback((o=ue.step)=>{n(c=>Math.max(ue.min,c-o))},[]),i=g.useCallback(()=>{n(ue.default)},[]),l=g.useCallback(o=>{const c=Math.max(ue.min,Math.min(ue.max,o));n(c)},[]);return{zoom:t,setZoom:l,zoomIn:r,zoomOut:a,resetZoom:i,isMinZoom:t<=ue.min,isMaxZoom:t>=ue.max,isDefaultZoom:t===ue.default}}const ti=["bold","italic","strike","underline","code"];function ni({editor:e,modifiers:t,onToolbarAction:n}){const r=ps(e,t),{toggleModifier:a}=gs(e,n);if(!e)return null;const i=t.map(l=>tt(l)).filter(l=>ti.includes(l));return i.length===0?null:s.jsx(Xa,{id:"text-formatting",label:"Text formatting",children:i.map(l=>{const o=r[l],c=Pe(l);return s.jsx(Me,{icon:c,label:l.charAt(0).toUpperCase()+l.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>a(l)},l)})})}function si({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:a=!0,className:i,onToolbarAction:l}){const o=ps(e,t),{toggleModifier:c,executeCommand:u}=gs(e,l);if(!e)return null;const f=t.map(F=>tt(F)),x=f.some(F=>["bold","italic","strike","underline","code"].includes(F)),y=f.some(F=>["textColor","highlight"].includes(F)),h=f.includes("heading"),C=f.includes("textAlign"),v=f.some(F=>["bulletList","orderedList","taskList"].includes(F)),p=f.includes("blockquote"),b=f.includes("codeBlock"),N=f.includes("link"),$=f.includes("horizontalRule"),w=f.some(F=>["undo","redo"].includes(F)),k=n!==void 0&&r!==void 0,M=a?"sticky top-0 z-10":"";return s.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:s.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[x&&s.jsxs(s.Fragment,{children:[s.jsx(ni,{editor:e,modifiers:t,onToolbarAction:l}),(y||h||C||v||p||b||N||$||w||k)&&s.jsx(Ie,{})]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&s.jsx(Dn,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),f.includes("highlight")&&s.jsx(Dn,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(h||C||v||p||b||N||$||w||k)&&s.jsx(Ie,{})]}),h&&s.jsxs(s.Fragment,{children:[s.jsx(Ua,{editor:e}),(C||v||p||b||N||$||w||k)&&s.jsx(Ie,{})]}),C&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(F=>{const W=Qa[F],I=e.isActive({textAlign:F});return s.jsx(Me,{icon:W,label:`Align ${F}`,isActive:I,onClick:()=>u("textAlign",{type:"textAlign",alignment:F})},F)})}),(v||p||b||N||$||w||k)&&s.jsx(Ie,{})]}),v&&s.jsxs(s.Fragment,{children:[s.jsx(Ha,{editor:e,types:f.filter(F=>["bulletList","orderedList","taskList"].includes(F))}),(p||b||N||$||w||k)&&s.jsx(Ie,{})]}),(p||b||N||$)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[p&&s.jsx(Me,{icon:Pe("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>c("blockquote")}),b&&s.jsx(Me,{icon:Pe("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),N&&s.jsx(Ja,{editor:e,isDisabled:o.link?.isDisabled}),$&&s.jsx(Me,{icon:Pe("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(w||k)&&s.jsx(Ie,{})]}),w&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&s.jsx(Me,{icon:Pe("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>c("undo")}),f.includes("redo")&&s.jsx(Me,{icon:Pe("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>c("redo")})]}),k&&s.jsx(Ie,{})]}),k&&s.jsx(Za,{zoom:n,onZoomChange:F=>{r?.(F),l?.({type:"zoom",modifier:`${F}%`})}})]})})}const Ye={bold:{category:"mark",extension:ra.Bold,priority:100},italic:{category:"mark",extension:aa.Italic,priority:100},strike:{category:"mark",extension:ia.Strike,priority:100},underline:{category:"mark",extension:la.Underline,priority:100},code:{category:"mark",extension:oa.Code,priority:100},textColor:{category:"mark",extension:ca.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:da.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:ua.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:ma.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:xa.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:pa.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:ga.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:va.CodeBlock,priority:100},blockquote:{category:"node",extension:ja.Blockquote,priority:100},horizontalRule:{category:"node",extension:wa.HorizontalRule,priority:100},hardBreak:{category:"node",extension:Na.HardBreak,priority:100},undo:{category:"extension",extension:An.History,priority:50},redo:{category:"extension",extension:An.History,priority:50},textAlign:{category:"extension",extension:Ca.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}},ri=[Sa.Document,ka.Text,ha.Paragraph,fa.TextStyle.configure({HTMLAttributes:{}}),ya.ListItem.configure({HTMLAttributes:{}}),ba.TaskItem.configure({nested:!0}),Aa.Dropcursor,$a.Gapcursor];function ai(e){const t=[],n=new Set,r=new Set;ri.forEach(o=>{o&&(t.push(o),r.add(o.name))});const a=e.map(o=>tt(o)),i=new Set;return a.forEach(o=>{const c=Ye[o];c?.requiredExtensions&&c.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(o=>{if(n.has(o))return;const c=Ye[o];if(!c||c.extension===null)return;const u=c.extension.name;if(r.has(u)){n.add(o);return}const f=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(f),n.add(o),r.add(u)}),a.forEach(o=>{if(n.has(o))return;const c=Ye[o];if(!c){console.warn(`Extension config not found for modifier: ${o}`);return}if(c.extension===null){n.add(o);return}const u=c.extension.name;if(r.has(u)){n.add(o);return}const f=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(f),n.add(o),r.add(u)}),t.sort((o,c)=>{const u=Object.values(Ye).find(h=>h?.extension?.name===o.name),f=Object.values(Ye).find(h=>h?.extension?.name===c.name),x=u?.priority??100;return(f?.priority??100)-x})}const bs={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"]},le={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"}},ke={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},re={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},ii={h1:`font-size: ${le.fontSize["4xl"]}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,h2:`font-size: ${le.fontSize["2xl"]}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,h3:`font-size: ${le.fontSize.xl}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,h4:`font-size: ${le.fontSize.lg}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,h5:`font-size: ${le.fontSize.base}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,h6:`font-size: ${le.fontSize.sm}; font-weight: ${le.fontWeight.semibold}; line-height: ${le.lineHeight.tight}; margin: ${re.md} 0 ${re.sm} 0;`,p:`min-height: ${le.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${re.xl}; margin: ${re.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${re.xl}; margin: ${re.md} 0;`,li:`display: list-item; margin: ${re.xs} 0;`,strong:`font-weight: ${le.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${ke.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${le.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${le.fontFamily.mono};`,pre:`background: ${ke.neutral.gray[800]}; border-radius: ${re.sm}; color: ${ke.neutral.gray[100]}; font-family: ${le.fontFamily.mono}; margin: ${re.lg} 0; padding: 0.75rem ${re.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${ke.neutral.gray[300]}; margin: ${re.lg} 0; padding-left: ${re.md}; color: ${ke.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${ke.neutral.gray[200]}; margin: ${re.xl} 0;`,a:`color: ${ke.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${ke.palettes.warning[200]}; border-radius: ${re.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${re.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},li={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 oi(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(li)){const a=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(a,(i,l)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${l} style="${r}">`)}for(const[n,r]of Object.entries(ii)){const a=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(a,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 l=i.indexOf(">");return`${i.slice(0,l)} style="${r}"${i.slice(l)}`}})}return t}const ci=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:a}=tn.useCurrentEditor();return s.jsx(si,{editor:a,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},di=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=tn.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),a=r.length,i=r.split(/\s+/).filter(l=>l.length>0).length;return s.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&s.jsxs("span",{children:[a," characters"]}),t&&s.jsxs("span",{children:[i," words"]})]})},qt=g.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:a=!1,showCharacterCount:i=!1,showWordCount:l=!1,showToolbar:o=!0,modifiers:c=bs.full,variant:u="bordered",initialContent:f,content:x,onContentChange:y,onUpdate:h,onToolbarAction:C,isReadOnly:v=!1,isDisabled:p=!1,includeInlineStyles:b=!0,...N}=e,{zoom:$,setZoom:w}=ei(),k=$n.lineHeight,M=n*k,F=a?void 0:r*k,W=g.useMemo(()=>ai(c),[c]),{Component:I,label:P,shouldLabelBeOutside:D,getBaseProps:S,getLabelProps:E,getInputWrapperProps:L}=d.useInput({...N,variant:u,ref:t,isMultiline:!0}),R=P?s.jsx("label",{...E(),children:P}):null,G=g.useCallback(({editor:Q})=>{const J=Q.getHTML(),se=b?oi(J):J,K=Q.getJSON(),B=Q.getText(),U=B.length,Z=B.split(/\s+/).filter(fe=>fe.length>0).length,X={html:se,json:K,text:B,characters:U,words:Z};if(y?.(X),h?.(X),"onChange"in N&&typeof N.onChange=="function"){const fe={target:{value:se},currentTarget:{value:se}};N.onChange(fe)}},[y,h,N,b]);return s.jsxs(I,{...S(),children:[D?R:null,s.jsx("div",{...L(),className:d.cn(L().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:F?`${F+$n.toolbarHeight}px`:void 0,overflow:F?"auto":void 0},children:s.jsx(tn.EditorProvider,{editable:!v&&!p,slotBefore:o?s.jsx(ci,{modifiers:c,zoom:$,onZoomChange:w,onToolbarAction:C}):void 0,slotAfter:s.jsx(di,{showCharacterCount:i,showWordCount:l}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${$}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:W,content:x||f||e.defaultValue||"",onUpdate:G})})]})});qt.displayName="TipTapEditor";const ys=g.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...a}=e;return n==="tiptap"?s.jsx(qt,{...a,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),s.jsx(qt,{...a,variant:r,ref:t}))});ys.displayName="RichTextArea";function ui(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const En=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],fi={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},vs=({presetAmounts:e=En,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:a,currency:i="USD",locale:l="en-US",showCustomAmount:o=!0,minCustomAmount:c=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:x=2,desktopColumns:y=3,isDisabled:h=!1,buttonVariant:C="bordered",buttonColor:v="default",inputVariant:p="bordered",size:b="md",className:N="",showCard:$=!0})=>{const w={...fi,...f},k=Array.isArray(e)?e:En,M={2:"grid-cols-2",3:"grid-cols-3"},F={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},W=`${M[x]} ${F[y]}`,[I,P]=nn(t,n,r),[D,S]=g.useState(""),[E,L]=g.useState(!1),[R,G]=g.useState(0),Q=g.useCallback(U=>{if(h)return;const Z={amount:U.amount,isCustom:!1,presetId:U.id};P(Z),S(""),L(!1),G(X=>X+1),a?.(Z)},[h,P,a]),J=g.useCallback(U=>{if(h)return;if(S(U!==void 0?String(U):""),a){P(null);return}if(U===void 0||isNaN(U)){P(null);return}P({amount:U,isCustom:!0})},[h,P,a]),se=g.useCallback(()=>{if(h)return;const U=D!==""?parseFloat(D):void 0;U===void 0||isNaN(U)||a?.({amount:U,isCustom:!0})},[h,D,a]),K=g.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),B=s.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[w.title&&s.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:w.title}),k.length>0&&s.jsx("div",{className:d.cn("grid gap-3",W),"data-testid":"donation-amounts-presets",children:k.map(U=>{const Z=I!==null&&!I.isCustom&&I.presetId===U.id;return s.jsx(q,{color:Z?"primary":v,variant:Z?"solid":C,className:"w-full",onPress:()=>Q(U),isDisabled:h,"data-testid":`donation-amounts-preset-${U.id}`,children:U.label||ui(U.amount,l,i)},U.id)})}),o&&s.jsxs("div",{className:"flex gap-3 items-start",children:[s.jsx(d.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,onInput:a?()=>{P(null),L(!0)}:void 0,variant:p,radius:"full",size:b,minValue:c,maxValue:u,step:.01,formatOptions:K,value:D!==""?parseFloat(D):void 0,onValueChange:J,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},a?`custom-${R}`:I?.isCustom===!1?I.presetId:"custom"),a&&s.jsx(q,{color:"primary",variant:"solid",radius:"full",size:b,className:"shrink-0",onPress:se,isDisabled:h||!E,"data-testid":"donation-amounts-add-button",children:w.addDonationButton})]})]});return $?s.jsx(d.Card,{className:d.cn("w-full",N),"data-testid":"donation-amounts-card",children:s.jsx(d.CardBody,{children:B})}):s.jsx("div",{className:d.cn("w-full",N),"data-testid":"donation-amounts-plain",children:B})};vs.displayName="DonationAmounts";const mi=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},hi=e=>{switch(e){case"warning":return Y.Clock;case"error":return Y.AlertCircle;case"success":return Y.CheckCircle;default:return Y.Clock}},xi=e=>{switch(e){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"}},js=g.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:a="info",color:i="primary",message:l="Your cart expires in:",showIcon:o=!0,icon:c,position:u="fixed",autoStart:f=!0,formatTime:x=mi,className:y,...h},C)=>{const[v,p]=nn(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),b=g.useRef(null),N=g.useRef(!1);g.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]),g.useEffect(()=>{if(!f||v<=0){b.current&&(clearInterval(b.current),b.current=null);return}return b.current=setInterval(()=>{p(M=>M<=1?(b.current&&(clearInterval(b.current),b.current=null),N.current||(N.current=!0,r?.()),0):M-1)},1e3),()=>{b.current&&(clearInterval(b.current),b.current=null)}},[f,v,p,r]),g.useEffect(()=>{v>0&&(N.current=!1)},[v]);const $=c||hi(a),w=xi(i),k={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return s.jsx("div",{ref:C,role:"banner","aria-live":"polite","aria-label":`${l} ${x(v)}`,"data-testid":"expire-cart-timer",className:d.cn("w-full text-white z-50",w,k[u],y),...h,children:s.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[o&&s.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:s.jsx($,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),s.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:l})]}),s.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:s.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${x(v)}`,"data-testid":"expire-cart-timer-value",children:x(v)})})]})})})});js.displayName="ExpireCartTimer";function pi(e,t){const n=e.icons,r=e.aliases||Object.create(null),a=Object.create(null);function i(l){if(n[l])return a[l]=[];if(!(l in a)){a[l]=null;const o=r[l]&&r[l].parent,c=o&&i(o);c&&(a[l]=[o].concat(c))}return a[l]}return Object.keys(n).concat(Object.keys(r)).forEach(i),a}const ws=Object.freeze({left:0,top:0,width:16,height:16}),ht=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),rn=Object.freeze({...ws,...ht}),Wt=Object.freeze({...rn,body:"",hidden:!1});function gi(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function In(e,t){const n=gi(e,t);for(const r in Wt)r in ht?r in e&&!(r in n)&&(n[r]=ht[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function bi(e,t,n){const r=e.icons,a=e.aliases||Object.create(null);let i={};function l(o){i=In(r[o]||a[o],i)}return l(t),n.forEach(l),In(e,i)}function Ns(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(a=>{t(a,null),n.push(a)});const r=pi(e);for(const a in r){const i=r[a];i&&(t(a,bi(e,a,i)),n.push(a))}return n}const yi={provider:"",aliases:{},not_found:{},...ws};function It(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Cs(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!It(e,yi))return null;const n=t.icons;for(const a in n){const i=n[a];if(!a||typeof i.body!="string"||!It(i,Wt))return null}const r=t.aliases||Object.create(null);for(const a in r){const i=r[a],l=i.parent;if(!a||typeof l!="string"||!n[l]&&!r[l]||!It(i,Wt))return null}return t}const Mn=Object.create(null);function vi(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function ze(e,t){const n=Mn[e]||(Mn[e]=Object.create(null));return n[t]||(n[t]=vi(e,t))}function Ss(e,t){return Cs(t)?Ns(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function ji(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const ks=/^[a-z0-9]+(-[a-z0-9]+)*$/,wt=(e,t,n,r="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;r=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const o=a.pop(),c=a.pop(),u={provider:a.length>0?a[0]:r,prefix:c,name:o};return t&&!ut(u)?null:u}const i=a[0],l=i.split("-");if(l.length>1){const o={provider:r,prefix:l.shift(),name:l.join("-")};return t&&!ut(o)?null:o}if(n&&r===""){const o={provider:r,prefix:"",name:i};return t&&!ut(o,n)?null:o}return null},ut=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let nt=!1;function As(e){return typeof e=="boolean"&&(nt=e),nt}function Fn(e){const t=typeof e=="string"?wt(e,!0,nt):e;if(t){const n=ze(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function wi(e,t){const n=wt(e,!0,nt);if(!n)return!1;const r=ze(n.provider,n.prefix);return t?ji(r,n.name,t):(r.missing.add(n.name),!0)}function Ni(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),nt&&!t&&!e.prefix){let a=!1;return Cs(e)&&(e.prefix="",Ns(e,(i,l)=>{wi(i,l)&&(a=!0)})),a}const n=e.prefix;if(!ut({prefix:n,name:"a"}))return!1;const r=ze(t,n);return!!Ss(r,e)}const $s=Object.freeze({width:null,height:null}),Ds=Object.freeze({...$s,...ht}),Ci=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Si=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Tn(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Ci);if(r===null||!r.length)return e;const a=[];let i=r.shift(),l=Si.test(i);for(;;){if(l){const o=parseFloat(i);isNaN(o)?a.push(i):a.push(Math.ceil(o*t*n)/n)}else a.push(i);if(i=r.shift(),i===void 0)return a.join("");l=!l}}function ki(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const a=e.indexOf(">",r),i=e.indexOf("</"+t);if(a===-1||i===-1)break;const l=e.indexOf(">",i);if(l===-1)break;n+=e.slice(a+1,i).trim(),e=e.slice(0,r).trim()+e.slice(l+1)}return{defs:n,content:e}}function Ai(e,t){return e?"<defs>"+e+"</defs>"+t:t}function $i(e,t,n){const r=ki(e);return Ai(r.defs,t+r.content+n)}const Di=e=>e==="unset"||e==="undefined"||e==="none";function Ei(e,t){const n={...rn,...e},r={...Ds,...t},a={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(v=>{const p=[],b=v.hFlip,N=v.vFlip;let $=v.rotate;b?N?$+=2:(p.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),p.push("scale(-1 1)"),a.top=a.left=0):N&&(p.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),p.push("scale(1 -1)"),a.top=a.left=0);let w;switch($<0&&($-=Math.floor($/4)*4),$=$%4,$){case 1:w=a.height/2+a.top,p.unshift("rotate(90 "+w.toString()+" "+w.toString()+")");break;case 2:p.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:w=a.width/2+a.left,p.unshift("rotate(-90 "+w.toString()+" "+w.toString()+")");break}$%2===1&&(a.left!==a.top&&(w=a.left,a.left=a.top,a.top=w),a.width!==a.height&&(w=a.width,a.width=a.height,a.height=w)),p.length&&(i=$i(i,'<g transform="'+p.join(" ")+'">',"</g>"))});const l=r.width,o=r.height,c=a.width,u=a.height;let f,x;l===null?(x=o===null?"1em":o==="auto"?u:o,f=Tn(x,c/u)):(f=l==="auto"?c:l,x=o===null?Tn(f,u/c):o==="auto"?u:o);const y={},h=(v,p)=>{Di(p)||(y[v]=p.toString())};h("width",f),h("height",x);const C=[a.left,a.top,c,u];return y.viewBox=C.join(" "),{attributes:y,viewBox:C,body:i}}const Ii=/\sid="(\S+)"/g,Mi="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Fi=0;function Ti(e,t=Mi){const n=[];let r;for(;r=Ii.exec(e);)n.push(r[1]);if(!n.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const l=typeof t=="function"?t(i):t+(Fi++).toString(),o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+o+')([")]|\\.[a-z])',"g"),"$1"+l+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const Yt=Object.create(null);function Li(e,t){Yt[e]=t}function Gt(e){return Yt[e]||Yt[""]}function an(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ln=Object.create(null),Ge=["https://api.simplesvg.com","https://api.unisvg.com"],ft=[];for(;Ge.length>0;)Ge.length===1||Math.random()>.5?ft.push(Ge.shift()):ft.push(Ge.pop());ln[""]=an({resources:["https://api.iconify.design"].concat(ft)});function _i(e,t){const n=an(t);return n===null?!1:(ln[e]=n,!0)}function on(e){return ln[e]}const Pi=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Ln=Pi();function Oi(e,t){const n=on(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let a=0;n.resources.forEach(l=>{a=Math.max(a,l.length)});const i=t+".json?icons=";r=n.maxURL-a-n.path.length-i.length}return r}function zi(e){return e===404}const Ri=(e,t,n)=>{const r=[],a=Oi(e,t),i="icons";let l={type:i,provider:e,prefix:t,icons:[]},o=0;return n.forEach((c,u)=>{o+=c.length+1,o>=a&&u>0&&(r.push(l),l={type:i,provider:e,prefix:t,icons:[]},o=c.length),l.icons.push(c)}),r.push(l),r};function Bi(e){if(typeof e=="string"){const t=on(e);if(t)return t.path}return"/"}const Vi=(e,t,n)=>{if(!Ln){n("abort",424);return}let r=Bi(t.provider);switch(t.type){case"icons":{const i=t.prefix,o=t.icons.join(","),c=new URLSearchParams({icons:o});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let a=503;Ln(e+r).then(i=>{const l=i.status;if(l!==200){setTimeout(()=>{n(zi(l)?"abort":"next",l)});return}return a=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",a)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",a)})},Ui={prepare:Ri,send:Vi};function Es(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(a=>a.id!==t))})}function Hi(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,a=e.prefix;t.forEach(i=>{const l=i.icons,o=l.pending.length;l.pending=l.pending.filter(c=>{if(c.prefix!==a)return!0;const u=c.name;if(e.icons[u])l.loaded.push({provider:r,prefix:a,name:u});else if(e.missing.has(u))l.missing.push({provider:r,prefix:a,name:u});else return n=!0,!0;return!1}),l.pending.length!==o&&(n||Es([e],i.id),i.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),i.abort))})}))}let qi=0;function Wi(e,t,n){const r=qi++,a=Es.bind(null,n,r);if(!t.pending.length)return a;const i={id:r,icons:t,callback:e,abort:a};return n.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(i)}),a}function Yi(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((a,i)=>a.provider!==i.provider?a.provider.localeCompare(i.provider):a.prefix!==i.prefix?a.prefix.localeCompare(i.prefix):a.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(a=>{if(r.name===a.name&&r.prefix===a.prefix&&r.provider===a.provider)return;r=a;const i=a.provider,l=a.prefix,o=a.name,c=n[i]||(n[i]=Object.create(null)),u=c[l]||(c[l]=ze(i,l));let f;o in u.icons?f=t.loaded:l===""||u.missing.has(o)?f=t.missing:f=t.pending;const x={provider:i,prefix:l,name:o};f.push(x)}),t}function Gi(e,t=!0,n=!1){const r=[];return e.forEach(a=>{const i=typeof a=="string"?wt(a,t,n):a;i&&r.push(i)}),r}const Qi={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ki(e,t,n,r){const a=e.resources.length,i=e.random?Math.floor(Math.random()*a):e.index;let l;if(e.random){let M=e.resources.slice(0);for(l=[];M.length>1;){const F=Math.floor(Math.random()*M.length);l.push(M[F]),M=M.slice(0,F).concat(M.slice(F+1))}l=l.concat(M)}else l=e.resources.slice(i).concat(e.resources.slice(0,i));const o=Date.now();let c="pending",u=0,f,x=null,y=[],h=[];typeof r=="function"&&h.push(r);function C(){x&&(clearTimeout(x),x=null)}function v(){c==="pending"&&(c="aborted"),C(),y.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),y=[]}function p(M,F){F&&(h=[]),typeof M=="function"&&h.push(M)}function b(){return{startTime:o,payload:t,status:c,queriesSent:u,queriesPending:y.length,subscribe:p,abort:v}}function N(){c="failed",h.forEach(M=>{M(void 0,f)})}function $(){y.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),y=[]}function w(M,F,W){const I=F!=="success";switch(y=y.filter(P=>P!==M),c){case"pending":break;case"failed":if(I||!e.dataAfterTimeout)return;break;default:return}if(F==="abort"){f=W,N();return}if(I){f=W,y.length||(l.length?k():N());return}if(C(),$(),!e.random){const P=e.resources.indexOf(M.resource);P!==-1&&P!==e.index&&(e.index=P)}c="completed",h.forEach(P=>{P(W)})}function k(){if(c!=="pending")return;C();const M=l.shift();if(M===void 0){if(y.length){x=setTimeout(()=>{C(),c==="pending"&&($(),N())},e.timeout);return}N();return}const F={status:"pending",resource:M,callback:(W,I)=>{w(F,W,I)}};y.push(F),u++,x=setTimeout(k,e.rotate),n(M,t,F.callback)}return setTimeout(k),b}function Is(e){const t={...Qi,...e};let n=[];function r(){n=n.filter(o=>o().status==="pending")}function a(o,c,u){const f=Ki(t,o,c,(x,y)=>{r(),u&&u(x,y)});return n.push(f),f}function i(o){return n.find(c=>o(c))||null}return{query:a,find:i,setIndex:o=>{t.index=o},getIndex:()=>t.index,cleanup:r}}function _n(){}const Mt=Object.create(null);function Zi(e){if(!Mt[e]){const t=on(e);if(!t)return;const n=Is(t),r={config:t,redundancy:n};Mt[e]=r}return Mt[e]}function Ji(e,t,n){let r,a;if(typeof e=="string"){const i=Gt(e);if(!i)return n(void 0,424),_n;a=i.send;const l=Zi(e);l&&(r=l.redundancy)}else{const i=an(e);if(i){r=Is(i);const l=e.resources?e.resources[0]:"",o=Gt(l);o&&(a=o.send)}}return!r||!a?(n(void 0,424),_n):r.query(t,a,n)().abort}function Pn(){}function Xi(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Hi(e)}))}function el(e){const t=[],n=[];return e.forEach(r=>{(r.match(ks)?t:n).push(r)}),{valid:t,invalid:n}}function Qe(e,t,n){function r(){const a=e.pendingIcons;t.forEach(i=>{a&&a.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ss(e,n).length){r();return}}catch(a){console.error(a)}r(),Xi(e)}function On(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function tl(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const i=e.loadIcon;if(e.loadIcons&&(a.length>1||!i)){On(e.loadIcons(a,r,n),f=>{Qe(e,a,f)});return}if(i){a.forEach(f=>{const x=i(f,r,n);On(x,y=>{const h=y?{prefix:r,icons:{[f]:y}}:null;Qe(e,[f],h)})});return}const{valid:l,invalid:o}=el(a);if(o.length&&Qe(e,o,null),!l.length)return;const c=r.match(ks)?Gt(n):null;if(!c){Qe(e,l,null);return}c.prepare(n,r,l).forEach(f=>{Ji(n,f,x=>{Qe(e,f.icons,x)})})}))}const nl=(e,t)=>{const n=Gi(e,!0,As()),r=Yi(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,Pn)}),()=>{c=!1}}const a=Object.create(null),i=[];let l,o;return r.pending.forEach(c=>{const{provider:u,prefix:f}=c;if(f===o&&u===l)return;l=u,o=f,i.push(ze(u,f));const x=a[u]||(a[u]=Object.create(null));x[f]||(x[f]=[])}),r.pending.forEach(c=>{const{provider:u,prefix:f,name:x}=c,y=ze(u,f),h=y.pendingIcons||(y.pendingIcons=new Set);h.has(x)||(h.add(x),a[u][f].push(x))}),i.forEach(c=>{const u=a[c.provider][c.prefix];u.length&&tl(c,u)}),t?Wi(t,r,i):Pn};function sl(e,t){const n={...e};for(const r in t){const a=t[r],i=typeof a;r in $s?(a===null||a&&(i==="string"||i==="number"))&&(n[r]=a):i===typeof n[r]&&(n[r]=r==="rotate"?a%4:a)}return n}const rl=/[\s,]+/;function al(e,t){t.split(rl).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function il(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(a){for(;a<0;)a+=4;return a%4}if(n===""){const a=parseInt(e);return isNaN(a)?0:r(a)}else if(n!==e){let a=0;switch(n){case"%":a=25;break;case"deg":a=90}if(a){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/a,i%1===0?r(i):0)}}return t}function ll(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function ol(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function cl(e){return"data:image/svg+xml,"+ol(e)}function dl(e){return'url("'+cl(e)+'")'}let Je;function ul(){try{Je=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Je=null}}function fl(e){return Je===void 0&&ul(),Je?Je.createHTML(e):e}const Ms={...Ds,inline:!1},ml={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},hl={display:"inline-block"},Qt={backgroundColor:"currentColor"},Fs={backgroundColor:"transparent"},zn={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Rn={WebkitMask:Qt,mask:Qt,background:Fs};for(const e in Rn){const t=Rn[e];for(const n in zn)t[e+n]=zn[n]}const xl={...Ms,inline:!0};function Bn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const pl=(e,t,n)=>{const r=t.inline?xl:Ms,a=sl(r,t),i=t.mode||"svg",l={},o=t.style||{},c={...i==="svg"?ml:{}};if(n){const p=wt(n,!1,!0);if(p){const b=["iconify"],N=["provider","prefix"];for(const $ of N)p[$]&&b.push("iconify--"+p[$]);c.className=b.join(" ")}}for(let p in t){const b=t[p];if(b!==void 0)switch(p){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[p]=(c[p]?c[p]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":a[p]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&al(a,b);break;case"color":l.color=b;break;case"rotate":typeof b=="string"?a[p]=il(b):typeof b=="number"&&(a[p]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:r[p]===void 0&&(c[p]=b)}}const u=Ei(e,a),f=u.attributes;if(a.inline&&(l.verticalAlign="-0.125em"),i==="svg"){c.style={...l,...o},Object.assign(c,f);let p=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:fl(Ti(u.body,b?()=>b+"ID"+p++:"iconifyReact"))},g.createElement("svg",c)}const{body:x,width:y,height:h}=e,C=i==="mask"||(i==="bg"?!1:x.indexOf("currentColor")!==-1),v=ll(x,{...f,width:y+"",height:h+""});return c.style={...l,"--svg":dl(v),width:Bn(f.width),height:Bn(f.height),...hl,...C?Qt:Fs,...o},g.createElement("span",c)};As(!0);Li("",Ui);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Ni(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const a=t[n];if(typeof a!="object"||!a||a.resources===void 0)continue;_i(n,a)||console.error(r)}catch{console.error(r)}}}}function Ts(e){const[t,n]=g.useState(!!e.ssr),[r,a]=g.useState({});function i(h){if(h){const C=e.icon;if(typeof C=="object")return{name:"",data:C};const v=Fn(C);if(v)return{name:C,data:v}}return{name:""}}const[l,o]=g.useState(i(!!e.ssr));function c(){const h=r.callback;h&&(h(),a({}))}function u(h){if(JSON.stringify(l)!==JSON.stringify(h))return c(),o(h),!0}function f(){var h;const C=e.icon;if(typeof C=="object"){u({name:"",data:C});return}const v=Fn(C);if(u({name:C,data:v}))if(v===void 0){const p=nl([C],f);a({callback:p})}else v&&((h=e.onLoad)===null||h===void 0||h.call(e,C))}g.useEffect(()=>(n(!0),c),[]),g.useEffect(()=>{t&&f()},[e.icon,t]);const{name:x,data:y}=l;return y?pl({...rn,...y},e,x):e.children?e.children:e.fallback?e.fallback:g.createElement("span",{})}const V=g.forwardRef((e,t)=>Ts({...e,_ref:t}));g.forwardRef((e,t)=>Ts({inline:!0,...e,_ref:t}));const Ft=({icon:e,children:t,testId:n})=>s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[s.jsx(V,{icon:e,width:20,className:"text-default-500"}),s.jsx("span",{children:t})]}),gl=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:a,location:i,description:l,showImage:o=!1,compact:c=!1,imageLoading:u="eager",showMoreButtonClassName:f,labels:x})=>{const[y,h]=g.useState(!1),[C,v]=g.useState(!1),p=g.useRef(null);return g.useEffect(()=>{const b=()=>{if(p.current){const N=p.current.scrollHeight>p.current.clientHeight;v(N)}};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[l]),s.jsxs(d.Card,{className:d.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[s.jsxs(d.CardHeader,{className:d.cn("pt-2 pb-0 flex-col items-start",c?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&n&&s.jsx("div",{className:d.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:s.jsx(d.Image,{removeWrapper:!0,loading:u,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),s.jsx("h2",{className:d.cn("font-semibold text-gray-800",c?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),s.jsxs(d.CardBody,{className:d.cn("space-y-3",c?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[s.jsx("h3",{className:d.cn("font-semibold text-base text-gray-700",c?"text-sm":""),"data-testid":"event-details-info-label",children:x.eventInformation}),s.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&s.jsx(Ft,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),a&&s.jsx(Ft,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:a}),i&&s.jsx(Ft,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&s.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{ref:p,className:d.cn("text-sm text-gray-700 leading-relaxed transition-all",c?"text-xs":"",!y&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!y&&C&&s.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"})]}),(C||y)&&s.jsx("div",{className:"flex justify-end mt-1",children:s.jsx(q,{onPress:()=>h(!y),variant:"light",className:d.cn("text-primary",f),size:c?"sm":"md",startContent:s.jsx(V,{icon:y?"solar:eye-closed-linear":"solar:eye-linear",width:c?16:20}),"data-testid":"event-details-toggle-description",children:y?x.showLess||"Hide":x.showMore||"Show"})})]})]})]})};function Ls(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function bl(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}const yl={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached",ruleBlocked:"Unavailable for selected ticket options",disabled:"Ticket selection is unavailable"},ot=e=>typeof e=="number"&&!isNaN(e),xt=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:a="USD",locale:i="en-US",labels:l,slots:o,isDisabled:c=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:x=!0,showDescription:y=!0,showPeopleCount:h=!0,showPrice:C=!0,classNames:v={},"data-testid":p,selectedColor:b="default",compact:N=!1,isSoldOut:$,isMaxReached:w,isRuleBlocked:k,statusTone:M="default",statusLabel:F,disabledReason:W,disabled:I})=>{const P=g.useMemo(()=>({...yl,...l}),[l]),[D,S]=g.useState(n),E=t!==void 0?t:D,L=!!(c||I),R=N||!!e.compact,G=g.useMemo(()=>typeof $=="boolean"?$:typeof e.isSoldOut=="boolean"?e.isSoldOut:!ot(e.totalTicketsSold)||!ot(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[$,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),Q=g.useMemo(()=>typeof w=="boolean"?w:typeof e.isMaxReached=="boolean"?e.isMaxReached:G||!ot(e.ticketsAllowed)?!1:E>=e.ticketsAllowed-(e.totalTicketsSold??0),[w,e.isMaxReached,G,e.ticketsAllowed,e.totalTicketsSold,E]),J=g.useMemo(()=>typeof k=="boolean"?k:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[k,e.isRuleBlocked]),se=W||e.disabledReason,K=L||G||J,B=ae=>{if(K||ae>0&&Q)return;const ge=Math.max(0,E+ae);t===void 0&&S(ge),r?.(e.id,ge)},U=g.useMemo(()=>{if(G)return"soldOut";if(J)return"ruleBlocked";if(L)return"disabled"},[G,J,L]),Z=g.useMemo(()=>M||(G||J?"danger":Q?"warning":"default"),[M,G,J,Q]),X=g.useMemo(()=>{if(U)return U==="ruleBlocked"?F||se||P.ruleBlocked:U==="soldOut"?F||se||P.soldOut:U==="disabled"?F||se||P.disabled:F||P.maxReached},[U,F,se,P]),fe={soldOut:"danger",ruleBlocked:Z,disabled:"default",maxReached:"warning"},De={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},Ve=()=>o?.renderName?o.renderName(e.name,e):s.jsx("h2",{"data-testid":"offer-card-name",className:d.cn("text-base font-medium",R&&"text-sm",v.name),children:e.name}),Ue=()=>{if(!C)return null;const ae=Ls(e.price,i,a);return o?.renderPrice?o.renderPrice(e.price,ae,e):s.jsx("p",{"data-testid":"offer-card-price",className:d.cn("text-primary text-base mt-1",R&&"text-sm mt-0.5",v.price),children:ae})},it=()=>!y||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):s.jsx("p",{"data-testid":"offer-card-description",className:d.cn("mb-4 text-sm text-gray-700 leading-relaxed",R&&"mb-2 text-xs text-gray-600",v.description),children:e.description}),He=()=>{if(!h||!ot(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ae=e.numberOfPeople===1?P.person:P.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ae,e):s.jsxs("p",{"data-testid":"offer-card-people-count",className:d.cn("text-sm text-gray-600 flex items-center mt-2",R&&"mt-1 text-xs",v.peopleCount),children:[s.jsx(V,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ae]})},qe=()=>{const ae=E===0||K,ge=Q||K;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:E,onIncrement:()=>B(1),onDecrement:()=>B(-1),isDecrementDisabled:ae,isIncrementDisabled:ge,isDisabled:K}):s.jsxs("div",{className:d.cn("flex items-center gap-2",v.quantitySelector),children:[s.jsx(q,{"data-testid":"offer-card-decrement-button",onPress:()=>B(-1),isDisabled:ae,variant:u,color:E>0?b:f,radius:"full",isIconOnly:!0,size:R?"md":"sm","aria-label":"Decrease quantity",children:s.jsx(V,{icon:"gravity-ui:minus",width:16})}),s.jsx("span",{"data-testid":"offer-card-quantity",className:d.cn("min-w-[2rem] text-center font-medium",R&&"text-sm"),children:E}),s.jsx(q,{"data-testid":"offer-card-increment-button",onPress:()=>B(1),isDisabled:ge,variant:u,color:E>0?b:f,radius:"full",isIconOnly:!0,size:R?"md":"sm","aria-label":"Increase quantity",children:s.jsx(V,{icon:"gravity-ui:plus",width:16})})]})},lt=(ae,ge)=>o?.renderDisabledState?o.renderDisabledState(ae,ge):ae==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(ge):ae==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(ge):s.jsx(d.Chip,{"data-testid":De[ae],color:fe[ae],variant:ae==="maxReached"?"flat":"solid",className:d.cn("gap-2 px-4",ae==="maxReached"?"h-8":"h-10",ae==="soldOut"&&v.soldOut,ae==="maxReached"&&v.maxReachedAlert,R&&"h-8"),startContent:s.jsx(V,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:s.jsx("span",{className:"font-medium text-sm",children:ge})}),We=s.jsxs("div",{className:d.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",R?"gap-1":"gap-2"),children:[s.jsxs("div",{className:d.cn("h-full col-span-2",K||Q?"opacity-50 pointer-events-none select-none":""),children:[Ve(),Ue(),s.jsxs("div",{className:d.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",R?"mb-1":"mb-2"),children:[He(),it()]})]}),s.jsx("div",{className:d.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",R&&"space-x-1 pb-1 md:p-1",v.compactFooter),children:U&&X?lt(U,X):qe()})]}),Le=Q&&!G&&!J&&!L?s.jsx(ve.motion.div,{className:d.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",v.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:lt("maxReached",X||P.maxReached)}):null;return x?s.jsxs(d.Card,{className:d.cn("w-full",R&&v.compact,v.base),"data-testid":p||`offer-card-${e.id}`,children:[s.jsx(d.CardBody,{className:d.cn("pt-1 pb-0",R?"pb-0.5":"",v.body),children:We}),s.jsx(ve.AnimatePresence,{children:Le&&s.jsx(d.CardFooter,{className:d.cn("w-full mt-0 pt-0",R?"pt-1":"",v.footer),children:Le})})]}):s.jsxs("div",{className:d.cn("w-full",R&&v.compact,v.base),"data-testid":p||`offer-card-${e.id}`,children:[s.jsx("div",{className:d.cn("pt-1 pb-0",R?"pb-0.5":"",v.body),children:We}),s.jsx(ve.AnimatePresence,{children:Le&&s.jsx("div",{className:d.cn("w-full mt-0 pt-0",R?"pt-1":"",v.footer),children:Le})})]})};xt.displayName="OfferCard";const _s=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i){const o=i();return r?s.jsx(d.Card,{"data-testid":"offer-card-empty",className:d.cn("w-full",a.base),children:s.jsx(d.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):s.jsx("div",{"data-testid":"offer-card-empty",className:d.cn("w-full",a.base),children:o})}const l=s.jsxs("div",{"data-testid":"offer-card-empty-content",className:d.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",a.content),children:[s.jsx(V,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:d.cn("mb-4",a.icon)}),s.jsx("h3",{"data-testid":"offer-card-empty-message",className:d.cn("text-lg",a.message),children:e})]});return r?s.jsx(d.Card,{"data-testid":"offer-card-empty",className:d.cn("w-full",a.base),children:s.jsx(d.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):s.jsx("div",{"data-testid":"offer-card-empty",className:d.cn("w-full",a.base),children:l})};_s.displayName="OfferCardEmpty";const vl={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},Ps=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...vl,...t},l=s.jsx(d.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(d.Card,{"data-testid":"offer-card-error",className:d.cn("w-full",a.base),children:s.jsx(d.CardBody,{"data-testid":"offer-card-error-body",children:l})}):s.jsx("div",{"data-testid":"offer-card-error",className:d.cn("w-full",a.base),children:l})};Ps.displayName="OfferCardError";const jl={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Os=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=jl[t];return s.jsx("div",{"data-testid":"offer-card-skeleton-container",className:d.cn(r,n.base),children:Array.from({length:e}).map((a,i)=>s.jsxs(d.Card,{"data-testid":`offer-card-skeleton-${i}`,className:d.cn("w-full",n.card),children:[s.jsx(d.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:s.jsxs("div",{className:"space-y-2 w-full",children:[s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),s.jsx(d.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[s.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),s.jsx("div",{className:"flex items-start justify-end",children:s.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),s.jsx(d.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Os.displayName="OfferCardSkeleton";const zs={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},Rs={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"}}},wl={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},Bs=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:a,onQuantityChange:i,currency:l="USD",locale:o="en-US",labels:c,slots:u,isDisabled:f=!1,buttonVariant:x="bordered",buttonColor:y="default",showCard:h=!0,animated:C=!0,gap:v=2,compact:p=!1,classNames:b={}})=>{const[N,$]=g.useState(r),w=n!==void 0?n:N,k=g.useCallback((D,S)=>{const E={...w,[D]:Math.max(0,S)};n===void 0&&$(E),a?.(E),i?.(D,E[D])},[w,n,a,i]),M=[...e].sort((D,S)=>(D.position??0)-(S.position??0)),F=D=>{const S=t?t(D):D,E=(w??{})[S.id]||0;return{offer:S,quantity:E,onQuantityChange:k,currency:l,locale:o,labels:c,slots:u,isDisabled:f,buttonVariant:x,buttonColor:y,showCard:h,compact:p}},W=wl[v],I=d.cn("grid mx-auto pt-2",W,b.base),P=D=>{const S=F(D);return s.jsx(xt,{offer:S.offer,quantity:S.quantity,onQuantityChange:S.onQuantityChange,currency:S.currency,locale:S.locale,labels:S.labels,slots:S.slots,isDisabled:S.isDisabled,buttonVariant:S.buttonVariant,buttonColor:S.buttonColor,showCard:S.showCard,compact:S.compact,classNames:b.card},S.offer.id)};return C?s.jsx(ve.motion.div,{"data-testid":"offer-card-list",className:I,variants:zs,initial:"hidden",animate:"show",children:s.jsx(ve.AnimatePresence,{children:M.map(D=>{const S=F(D);return s.jsx(ve.motion.div,{"data-testid":`offer-card-list-item-${S.offer.id}`,className:b.cardWrapper,variants:Rs,exit:{opacity:0,y:-20},transition:{duration:.3},children:s.jsx(xt,{offer:S.offer,quantity:S.quantity,onQuantityChange:k,currency:l,locale:o,labels:c,slots:u,isDisabled:f,buttonVariant:x,buttonColor:y,showCard:h,compact:p||S.offer.compact,classNames:b.card})},S.offer.id)})})}):s.jsx("div",{"data-testid":"offer-card-list",className:I,children:M.map(P)})};Bs.displayName="OfferCardList";var rt=e=>e.type==="checkbox",Fe=e=>e instanceof Date,pe=e=>e==null;const Vs=e=>typeof e=="object";var de=e=>!pe(e)&&!Array.isArray(e)&&Vs(e)&&!Fe(e),Us=e=>de(e)&&e.target?rt(e.target)?e.target.checked:e.target.value:e,Nl=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Hs=(e,t)=>e.has(Nl(t)),Cl=e=>{const t=e.constructor&&e.constructor.prototype;return de(t)&&t.hasOwnProperty("isPrototypeOf")},cn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function oe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(cn&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(de(e)&&Cl(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=oe(e[a]));return r}var Nt=e=>/^\w*$/.test(e),ie=e=>e===void 0,dn=e=>Array.isArray(e)?e.filter(Boolean):[],un=e=>dn(e.replace(/["|']|\]/g,"").split(/\.|\[/)),O=(e,t,n)=>{if(!t||!de(e))return n;const r=(Nt(t)?[t]:un(t)).reduce((a,i)=>pe(a)?a:a[i],e);return ie(r)||r===e?ie(e[t])?n:e[t]:r},be=e=>typeof e=="boolean",xe=e=>typeof e=="function",ne=(e,t,n)=>{let r=-1;const a=Nt(t)?[t]:un(t),i=a.length,l=i-1;for(;++r<i;){const o=a[r];let c=n;if(r!==l){const u=e[o];c=de(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const pt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},je={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ne={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},qs=g.createContext(null);qs.displayName="HookFormControlContext";const fn=()=>g.useContext(qs);var Ws=(e,t,n,r=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const l=i;return t._proxyFormState[l]!==je.all&&(t._proxyFormState[l]=!r||je.all),n&&(n[l]=!0),e[l]}});return a};const mn=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Sl(e){const t=fn(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[l,o]=g.useState(n._formState),c=g.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return mn(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!r&&o({...n._formState,...u})}}),[a,r,i]),g.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),g.useMemo(()=>Ws(l,n,c.current,!1),[l,n])}var ye=e=>typeof e=="string",Kt=(e,t,n,r,a)=>ye(e)?(r&&t.watch.add(e),O(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),O(n,i))):(r&&(t.watchAll=!0),n),Zt=e=>pe(e)||!Vs(e);function we(e,t,n=new WeakSet){if(Zt(e)||Zt(t))return Object.is(e,t);if(Fe(e)&&Fe(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const l=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const o=t[i];if(Fe(l)&&Fe(o)||de(l)&&de(o)||Array.isArray(l)&&Array.isArray(o)?!we(l,o,n):!Object.is(l,o))return!1}}return!0}function kl(e){const t=fn(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:l,compute:o}=e||{},c=g.useRef(a),u=g.useRef(o),f=g.useRef(void 0),x=g.useRef(n),y=g.useRef(r);u.current=o;const[h,C]=g.useState(()=>{const w=n._getWatch(r,c.current);return u.current?u.current(w):w}),v=g.useCallback(w=>{const k=Kt(r,n._names,w||n._formValues,!1,c.current);return u.current?u.current(k):k},[n._formValues,n._names,r]),p=g.useCallback(w=>{if(!i){const k=Kt(r,n._names,w||n._formValues,!1,c.current);if(u.current){const M=u.current(k);we(M,f.current)||(C(M),f.current=M)}else C(k)}},[n._formValues,n._names,i,r]);mn(()=>((x.current!==n||!we(y.current,r))&&(x.current=n,y.current=r,p()),n._subscribe({name:r,formState:{values:!0},exact:l,callback:w=>{p(w.values)}})),[n,l,r,p]),g.useEffect(()=>n._removeUnmounted());const b=x.current!==n,N=y.current,$=g.useMemo(()=>{if(i)return null;const w=!b&&!we(N,r);return b||w?v():null},[i,b,r,N,v]);return $!==null?$:h}function Al(e){const t=fn(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:l,exact:o=!0}=e,c=Hs(a._names.array,n),u=g.useMemo(()=>O(a._formValues,n,O(a._defaultValues,n,l)),[a,n,l]),f=kl({control:a,name:n,defaultValue:u,exact:o}),x=Sl({control:a,name:n,exact:o}),y=g.useRef(e),h=g.useRef(void 0),C=g.useRef(a.register(n,{...e.rules,value:f,...be(e.disabled)?{disabled:e.disabled}:{}}));y.current=e;const v=g.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!O(x.errors,n)},isDirty:{enumerable:!0,get:()=>!!O(x.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!O(x.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!O(x.validatingFields,n)},error:{enumerable:!0,get:()=>O(x.errors,n)}}),[x,n]),p=g.useCallback(w=>C.current.onChange({target:{value:Us(w),name:n},type:pt.CHANGE}),[n]),b=g.useCallback(()=>C.current.onBlur({target:{value:O(a._formValues,n),name:n},type:pt.BLUR}),[n,a._formValues]),N=g.useCallback(w=>{const k=O(a._fields,n);k&&k._f&&w&&(k._f.ref={focus:()=>xe(w.focus)&&w.focus(),select:()=>xe(w.select)&&w.select(),setCustomValidity:M=>xe(w.setCustomValidity)&&w.setCustomValidity(M),reportValidity:()=>xe(w.reportValidity)&&w.reportValidity()})},[a._fields,n]),$=g.useMemo(()=>({name:n,value:f,...be(r)||x.disabled?{disabled:x.disabled||r}:{},onChange:p,onBlur:b,ref:N}),[n,r,x.disabled,p,b,N,f]);return g.useEffect(()=>{const w=a._options.shouldUnregister||i,k=h.current;k&&k!==n&&!c&&a.unregister(k),a.register(n,{...y.current.rules,...be(y.current.disabled)?{disabled:y.current.disabled}:{}});const M=(F,W)=>{const I=O(a._fields,F);I&&I._f&&(I._f.mount=W)};if(M(n,!0),w){const F=oe(O(a._options.defaultValues,n,y.current.defaultValue));ne(a._defaultValues,n,F),ie(O(a._formValues,n))&&ne(a._formValues,n,F)}return!c&&a.register(n),h.current=n,()=>{(c?w&&!a._state.action:w)?a.unregister(n):M(n,!1)}},[n,a,c,i]),g.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),g.useMemo(()=>({field:$,formState:x,fieldState:v}),[$,x,v])}const $l=g.createContext(null);$l.displayName="HookFormContext";var Dl=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Xe=e=>Array.isArray(e)?e:[e],Vn=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function Ys(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&de(a)&&i){const l=Ys(a,i);de(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var he=e=>de(e)&&!Object.keys(e).length,hn=e=>e.type==="file",gt=e=>{if(!cn)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Gs=e=>e.type==="select-multiple",xn=e=>e.type==="radio",El=e=>xn(e)||rt(e),Tt=e=>gt(e)&&e.isConnected;function Il(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ie(e)?r++:e[t[r++]];return e}function Ml(e){for(const t in e)if(e.hasOwnProperty(t)&&!ie(e[t]))return!1;return!0}function ce(e,t){const n=Array.isArray(t)?t:Nt(t)?[t]:un(t),r=n.length===1?e:Il(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(de(r)&&he(r)||Array.isArray(r)&&Ml(r))&&ce(e,n.slice(0,-1)),e}var Fl=e=>{for(const t in e)if(xe(e[t]))return!0;return!1};function Qs(e){return Array.isArray(e)||de(e)&&!Fl(e)}function Jt(e,t={}){for(const n in e){const r=e[n];Qs(r)?(t[n]=Array.isArray(r)?[]:{},Jt(r,t[n])):ie(r)||(t[n]=!0)}return t}function Oe(e,t,n){n||(n=Jt(t));for(const r in e){const a=e[r];if(Qs(a))ie(t)||Zt(n[r])?n[r]=Jt(a,Array.isArray(a)?[]:{}):Oe(a,pe(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!we(a,i)}}return n}const Un={value:!1,isValid:!1},Hn={value:!0,isValid:!0};var Ks=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ie(e[0].attributes.value)?ie(e[0].value)||e[0].value===""?Hn:{value:e[0].value,isValid:!0}:Hn:Un}return Un},Zs=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ie(e)?e:t?e===""?NaN:e&&+e:n&&ye(e)?new Date(e):r?r(e):e;const qn={isValid:!1,value:null};var Js=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,qn):qn;function Wn(e){const t=e.ref;return hn(t)?t.files:xn(t)?Js(e.refs).value:Gs(t)?[...t.selectedOptions].map(({value:n})=>n):rt(t)?Ks(e.refs).value:Zs(ie(t.value)?e.ref.value:t.value,e)}var Tl=(e,t,n,r)=>{const a={};for(const i of e){const l=O(t,i);l&&ne(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},bt=e=>e instanceof RegExp,Ke=e=>ie(e)?e:bt(e)?e.source:de(e)?bt(e.value)?e.value.source:e.value:e,Yn=e=>({isOnSubmit:!e||e===je.onSubmit,isOnBlur:e===je.onBlur,isOnChange:e===je.onChange,isOnAll:e===je.all,isOnTouch:e===je.onTouched});const Gn="AsyncFunction";var Ll=e=>!!e&&!!e.validate&&!!(xe(e.validate)&&e.validate.constructor.name===Gn||de(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Gn)),_l=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Qn=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const et=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=O(e,a);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],a)&&!r)return!0;if(l.ref&&t(l.ref,l.name)&&!r)return!0;if(et(o,t))break}else if(de(o)&&et(o,t))break}}};function Kn(e,t,n){const r=O(e,n);if(r||Nt(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=O(t,i),o=O(e,i);if(l&&!Array.isArray(l)&&n!==i)return{name:n};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};a.pop()}return{name:n}}var Pl=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return he(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||je.all))},Ol=(e,t,n)=>!e||!t||e===t||Xe(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),zl=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,Rl=(e,t)=>!dn(O(e,t)).length&&ce(e,t),Bl=(e,t,n)=>{const r=Xe(O(e,n));return ne(r,"root",t[n]),ne(e,n,r),e};function Zn(e,t,n="validate"){if(ye(e)||Array.isArray(e)&&e.every(ye)||be(e)&&!e)return{type:n,message:ye(e)?e:"",ref:t}}var _e=e=>de(e)&&!bt(e)?e:{value:e,message:""},Jn=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:u,minLength:f,min:x,max:y,pattern:h,validate:C,name:v,valueAsNumber:p,mount:b}=e._f,N=O(n,v);if(!b||t.has(v))return{};const $=o?o[0]:l,w=S=>{a&&$.reportValidity&&($.setCustomValidity(be(S)?"":S||""),$.reportValidity())},k={},M=xn(l),F=rt(l),W=M||F,I=(p||hn(l))&&ie(l.value)&&ie(N)||gt(l)&&l.value===""||N===""||Array.isArray(N)&&!N.length,P=Dl.bind(null,v,r,k),D=(S,E,L,R=Ne.maxLength,G=Ne.minLength)=>{const Q=S?E:L;k[v]={type:S?R:G,message:Q,ref:l,...P(S?R:G,Q)}};if(i?!Array.isArray(N)||!N.length:c&&(!W&&(I||pe(N))||be(N)&&!N||F&&!Ks(o).isValid||M&&!Js(o).isValid)){const{value:S,message:E}=ye(c)?{value:!!c,message:c}:_e(c);if(S&&(k[v]={type:Ne.required,message:E,ref:$,...P(Ne.required,E)},!r))return w(E),k}if(!I&&(!pe(x)||!pe(y))){let S,E;const L=_e(y),R=_e(x);if(!pe(N)&&!isNaN(N)){const G=l.valueAsNumber||N&&+N;pe(L.value)||(S=G>L.value),pe(R.value)||(E=G<R.value)}else{const G=l.valueAsDate||new Date(N),Q=K=>new Date(new Date().toDateString()+" "+K),J=l.type=="time",se=l.type=="week";ye(L.value)&&N&&(S=J?Q(N)>Q(L.value):se?N>L.value:G>new Date(L.value)),ye(R.value)&&N&&(E=J?Q(N)<Q(R.value):se?N<R.value:G<new Date(R.value))}if((S||E)&&(D(!!S,L.message,R.message,Ne.max,Ne.min),!r))return w(k[v].message),k}if((u||f)&&!I&&(ye(N)||i&&Array.isArray(N))){const S=_e(u),E=_e(f),L=!pe(S.value)&&N.length>+S.value,R=!pe(E.value)&&N.length<+E.value;if((L||R)&&(D(L,S.message,E.message),!r))return w(k[v].message),k}if(h&&!I&&ye(N)){const{value:S,message:E}=_e(h);if(bt(S)&&!N.match(S)&&(k[v]={type:Ne.pattern,message:E,ref:l,...P(Ne.pattern,E)},!r))return w(E),k}if(C){if(xe(C)){const S=await C(N,n),E=Zn(S,$);if(E&&(k[v]={...E,...P(Ne.validate,E.message)},!r))return w(E.message),k}else if(de(C)){let S={};for(const E in C){if(!he(S)&&!r)break;const L=Zn(await C[E](N,n),$,E);L&&(S={...L,...P(E,L.message)},w(L.message),r&&(k[v]=S))}if(!he(S)&&(k[v]={ref:$,...S},!r))return k}}return w(!0),k};const Vl={mode:je.onSubmit,reValidateMode:je.onChange,shouldFocusError:!0};function Ul(e={}){let t={...Vl,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:xe(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=de(t.defaultValues)||de(t.values)?oe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:oe(a),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...f};let y={...x};const h={array:Vn(),state:Vn()},C=t.criteriaMode===je.all,v=m=>j=>{clearTimeout(u),u=setTimeout(m,j)},p=async m=>{if(!l.keepIsValid&&!t.disabled&&(x.isValid||y.isValid||m)){let j;t.resolver?(j=he((await W()).errors),b()):j=await P(r,!0),j!==n.isValid&&h.state.next({isValid:j})}},b=(m,j)=>{!t.disabled&&(x.isValidating||x.validatingFields||y.isValidating||y.validatingFields)&&((m||Array.from(o.mount)).forEach(A=>{A&&(j?ne(n.validatingFields,A,j):ce(n.validatingFields,A))}),h.state.next({validatingFields:n.validatingFields,isValidating:!he(n.validatingFields)}))},N=(m,j=[],A,z,_=!0,T=!0)=>{if(z&&A&&!t.disabled){if(l.action=!0,T&&Array.isArray(O(r,m))){const H=A(O(r,m),z.argA,z.argB);_&&ne(r,m,H)}if(T&&Array.isArray(O(n.errors,m))){const H=A(O(n.errors,m),z.argA,z.argB);_&&ne(n.errors,m,H),Rl(n.errors,m)}if((x.touchedFields||y.touchedFields)&&T&&Array.isArray(O(n.touchedFields,m))){const H=A(O(n.touchedFields,m),z.argA,z.argB);_&&ne(n.touchedFields,m,H)}(x.dirtyFields||y.dirtyFields)&&(n.dirtyFields=Oe(a,i)),h.state.next({name:m,isDirty:S(m,j),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ne(i,m,j)},$=(m,j)=>{ne(n.errors,m,j),h.state.next({errors:n.errors})},w=m=>{n.errors=m,h.state.next({errors:n.errors,isValid:!1})},k=(m,j,A,z)=>{const _=O(r,m);if(_){const T=O(i,m,ie(A)?O(a,m):A);ie(T)||z&&z.defaultChecked||j?ne(i,m,j?T:Wn(_._f)):R(m,T),l.mount&&!l.action&&p()}},M=(m,j,A,z,_)=>{let T=!1,H=!1;const ee={name:m};if(!t.disabled){if(!A||z){(x.isDirty||y.isDirty)&&(H=n.isDirty,n.isDirty=ee.isDirty=S(),T=H!==ee.isDirty);const te=we(O(a,m),j);H=!!O(n.dirtyFields,m),te?ce(n.dirtyFields,m):ne(n.dirtyFields,m,!0),ee.dirtyFields=n.dirtyFields,T=T||(x.dirtyFields||y.dirtyFields)&&H!==!te}if(A){const te=O(n.touchedFields,m);te||(ne(n.touchedFields,m,A),ee.touchedFields=n.touchedFields,T=T||(x.touchedFields||y.touchedFields)&&te!==A)}T&&_&&h.state.next(ee)}return T?ee:{}},F=(m,j,A,z)=>{const _=O(n.errors,m),T=(x.isValid||y.isValid)&&be(j)&&n.isValid!==j;if(t.delayError&&A?(c=v(()=>$(m,A)),c(t.delayError)):(clearTimeout(u),c=null,A?ne(n.errors,m,A):ce(n.errors,m)),(A?!we(_,A):_)||!he(z)||T){const H={...z,...T&&be(j)?{isValid:j}:{},errors:n.errors,name:m};n={...n,...H},h.state.next(H)}},W=async m=>(b(m,!0),await t.resolver(i,t.context,Tl(m||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),I=async m=>{const{errors:j}=await W(m);if(b(m),m)for(const A of m){const z=O(j,A);z?ne(n.errors,A,z):ce(n.errors,A)}else n.errors=j;return j},P=async(m,j,A={valid:!0})=>{for(const z in m){const _=m[z];if(_){const{_f:T,...H}=_;if(T){const ee=o.array.has(T.name),te=_._f&&Ll(_._f);te&&x.validatingFields&&b([T.name],!0);const me=await Jn(_,o.disabled,i,C,t.shouldUseNativeValidation&&!j,ee);if(te&&x.validatingFields&&b([T.name]),me[T.name]&&(A.valid=!1,j||e.shouldUseNativeValidation))break;!j&&(O(me,T.name)?ee?Bl(n.errors,me,T.name):ne(n.errors,T.name,me[T.name]):ce(n.errors,T.name))}!he(H)&&await P(H,j,A)}}return A.valid},D=()=>{for(const m of o.unMount){const j=O(r,m);j&&(j._f.refs?j._f.refs.every(A=>!Tt(A)):!Tt(j._f.ref))&&Ue(m)}o.unMount=new Set},S=(m,j)=>!t.disabled&&(m&&j&&ne(i,m,j),!we(B(),a)),E=(m,j,A)=>Kt(m,o,{...l.mount?i:ie(j)?a:ye(m)?{[m]:j}:j},A,j),L=m=>dn(O(l.mount?i:a,m,t.shouldUnregister?O(a,m,[]):[])),R=(m,j,A={})=>{const z=O(r,m);let _=j;if(z){const T=z._f;T&&(!T.disabled&&ne(i,m,Zs(j,T)),_=gt(T.ref)&&pe(j)?"":j,Gs(T.ref)?[...T.ref.options].forEach(H=>H.selected=_.includes(H.value)):T.refs?rt(T.ref)?T.refs.forEach(H=>{(!H.defaultChecked||!H.disabled)&&(Array.isArray(_)?H.checked=!!_.find(ee=>ee===H.value):H.checked=_===H.value||!!_)}):T.refs.forEach(H=>H.checked=H.value===_):hn(T.ref)?T.ref.value="":(T.ref.value=_,T.ref.type||h.state.next({name:m,values:oe(i)})))}(A.shouldDirty||A.shouldTouch)&&M(m,_,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&K(m)},G=(m,j,A)=>{for(const z in j){if(!j.hasOwnProperty(z))return;const _=j[z],T=m+"."+z,H=O(r,T);(o.array.has(m)||de(_)||H&&!H._f)&&!Fe(_)?G(T,_,A):R(T,_,A)}},Q=(m,j,A={})=>{const z=O(r,m),_=o.array.has(m),T=oe(j);ne(i,m,T),_?(h.array.next({name:m,values:oe(i)}),(x.isDirty||x.dirtyFields||y.isDirty||y.dirtyFields)&&A.shouldDirty&&h.state.next({name:m,dirtyFields:Oe(a,i),isDirty:S(m,T)})):z&&!z._f&&!pe(T)?G(m,T,A):R(m,T,A),Qn(m,o)?h.state.next({...n,name:m,values:oe(i)}):h.state.next({name:l.mount?m:void 0,values:oe(i)})},J=async m=>{l.mount=!0;const j=m.target;let A=j.name,z=!0;const _=O(r,A),T=te=>{z=Number.isNaN(te)||Fe(te)&&isNaN(te.getTime())||we(te,O(i,A,te))},H=Yn(t.mode),ee=Yn(t.reValidateMode);if(_){let te,me;const Ee=j.type?Wn(_._f):Us(m),Se=m.type===pt.BLUR||m.type===pt.FOCUS_OUT,ta=!_l(_._f)&&!t.resolver&&!O(n.errors,A)&&!_._f.deps||zl(Se,O(n.touchedFields,A),n.isSubmitted,ee,H),kt=Qn(A,o,Se);ne(i,A,Ee),Se?(!j||!j.readOnly)&&(_._f.onBlur&&_._f.onBlur(m),c&&c(0)):_._f.onChange&&_._f.onChange(m);const At=M(A,Ee,Se),na=!he(At)||kt;if(!Se&&h.state.next({name:A,type:m.type,values:oe(i)}),ta)return(x.isValid||y.isValid)&&(t.mode==="onBlur"?Se&&p():Se||p()),na&&h.state.next({name:A,...kt?{}:At});if(!Se&&kt&&h.state.next({...n}),t.resolver){const{errors:Cn}=await W([A]);if(b([A]),T(Ee),z){const sa=Kn(n.errors,r,A),Sn=Kn(Cn,r,sa.name||A);te=Sn.error,A=Sn.name,me=he(Cn)}}else b([A],!0),te=(await Jn(_,o.disabled,i,C,t.shouldUseNativeValidation))[A],b([A]),T(Ee),z&&(te?me=!1:(x.isValid||y.isValid)&&(me=await P(r,!0)));z&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&K(_._f.deps),F(A,me,te,At))}},se=(m,j)=>{if(O(n.errors,j)&&m.focus)return m.focus(),1},K=async(m,j={})=>{let A,z;const _=Xe(m);if(t.resolver){const T=await I(ie(m)?m:_);A=he(T),z=m?!_.some(H=>O(T,H)):A}else m?(z=(await Promise.all(_.map(async T=>{const H=O(r,T);return await P(H&&H._f?{[T]:H}:H)}))).every(Boolean),!(!z&&!n.isValid)&&p()):z=A=await P(r);return h.state.next({...!ye(m)||(x.isValid||y.isValid)&&A!==n.isValid?{}:{name:m},...t.resolver||!m?{isValid:A}:{},errors:n.errors}),j.shouldFocus&&!z&&et(r,se,m?_:o.mount),z},B=(m,j)=>{let A={...l.mount?i:a};return j&&(A=Ys(j.dirtyFields?n.dirtyFields:n.touchedFields,A)),ie(m)?A:ye(m)?O(A,m):m.map(z=>O(A,z))},U=(m,j)=>({invalid:!!O((j||n).errors,m),isDirty:!!O((j||n).dirtyFields,m),error:O((j||n).errors,m),isValidating:!!O(n.validatingFields,m),isTouched:!!O((j||n).touchedFields,m)}),Z=m=>{m&&Xe(m).forEach(j=>ce(n.errors,j)),h.state.next({errors:m?n.errors:{}})},X=(m,j,A)=>{const z=(O(r,m,{_f:{}})._f||{}).ref,_=O(n.errors,m)||{},{ref:T,message:H,type:ee,...te}=_;ne(n.errors,m,{...te,...j,ref:z}),h.state.next({name:m,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&z&&z.focus&&z.focus()},fe=(m,j)=>xe(m)?h.state.subscribe({next:A=>"values"in A&&m(E(void 0,j),A)}):E(m,j,!0),De=m=>h.state.subscribe({next:j=>{Ol(m.name,j.name,m.exact)&&Pl(j,m.formState||x,ea,m.reRenderRoot)&&m.callback({values:{...i},...n,...j,defaultValues:a})}}).unsubscribe,Ve=m=>(l.mount=!0,y={...y,...m.formState},De({...m,formState:{...f,...m.formState}})),Ue=(m,j={})=>{for(const A of m?Xe(m):o.mount)o.mount.delete(A),o.array.delete(A),j.keepValue||(ce(r,A),ce(i,A)),!j.keepError&&ce(n.errors,A),!j.keepDirty&&ce(n.dirtyFields,A),!j.keepTouched&&ce(n.touchedFields,A),!j.keepIsValidating&&ce(n.validatingFields,A),!t.shouldUnregister&&!j.keepDefaultValue&&ce(a,A);h.state.next({values:oe(i)}),h.state.next({...n,...j.keepDirty?{isDirty:S()}:{}}),!j.keepIsValid&&p()},it=({disabled:m,name:j})=>{if(be(m)&&l.mount||m||o.disabled.has(j)){const _=o.disabled.has(j)!==!!m;m?o.disabled.add(j):o.disabled.delete(j),_&&l.mount&&!l.action&&p()}},He=(m,j={})=>{let A=O(r,m);const z=be(j.disabled)||be(t.disabled);return ne(r,m,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:m}},name:m,mount:!0,...j}}),o.mount.add(m),A?it({disabled:be(j.disabled)?j.disabled:t.disabled,name:m}):k(m,!0,j.value),{...z?{disabled:j.disabled||t.disabled}:{},...t.progressive?{required:!!j.required,min:Ke(j.min),max:Ke(j.max),minLength:Ke(j.minLength),maxLength:Ke(j.maxLength),pattern:Ke(j.pattern)}:{},name:m,onChange:J,onBlur:J,ref:_=>{if(_){He(m,j),A=O(r,m);const T=ie(_.value)&&_.querySelectorAll&&_.querySelectorAll("input,select,textarea")[0]||_,H=El(T),ee=A._f.refs||[];if(H?ee.find(te=>te===T):T===A._f.ref)return;ne(r,m,{_f:{...A._f,...H?{refs:[...ee.filter(Tt),T,...Array.isArray(O(a,m))?[{}]:[]],ref:{type:T.type,name:m}}:{ref:T}}}),k(m,!1,void 0,T)}else A=O(r,m,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||j.shouldUnregister)&&!(Hs(o.array,m)&&l.action)&&o.unMount.add(m)}}},qe=()=>t.shouldFocusError&&et(r,se,o.mount),lt=m=>{be(m)&&(h.state.next({disabled:m}),et(r,(j,A)=>{const z=O(r,A);z&&(j.disabled=z._f.disabled||m,Array.isArray(z._f.refs)&&z._f.refs.forEach(_=>{_.disabled=z._f.disabled||m}))},0,!1))},We=(m,j)=>async A=>{let z;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let _=oe(i);if(h.state.next({isSubmitting:!0}),t.resolver){const{errors:T,values:H}=await W();b(),n.errors=T,_=oe(H)}else await P(r);if(o.disabled.size)for(const T of o.disabled)ce(_,T);if(ce(n.errors,"root"),he(n.errors)){h.state.next({errors:{}});try{await m(_,A)}catch(T){z=T}}else j&&await j({...n.errors},A),qe(),setTimeout(qe);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:he(n.errors)&&!z,submitCount:n.submitCount+1,errors:n.errors}),z)throw z},Le=(m,j={})=>{O(r,m)&&(ie(j.defaultValue)?Q(m,oe(O(a,m))):(Q(m,j.defaultValue),ne(a,m,oe(j.defaultValue))),j.keepTouched||ce(n.touchedFields,m),j.keepDirty||(ce(n.dirtyFields,m),n.isDirty=j.defaultValue?S(m,oe(O(a,m))):S()),j.keepError||(ce(n.errors,m),x.isValid&&p()),h.state.next({...n}))},ae=(m,j={})=>{const A=m?oe(m):a,z=oe(A),_=he(m),T=_?a:z;if(j.keepDefaultValues||(a=A),!j.keepValues){if(j.keepDirtyValues){const H=new Set([...o.mount,...Object.keys(Oe(a,i))]);for(const ee of Array.from(H)){const te=O(n.dirtyFields,ee),me=O(i,ee),Ee=O(T,ee);te&&!ie(me)?ne(T,ee,me):!te&&!ie(Ee)&&Q(ee,Ee)}}else{if(cn&&ie(m))for(const H of o.mount){const ee=O(r,H);if(ee&&ee._f){const te=Array.isArray(ee._f.refs)?ee._f.refs[0]:ee._f.ref;if(gt(te)){const me=te.closest("form");if(me){me.reset();break}}}}if(j.keepFieldsRef)for(const H of o.mount)Q(H,O(T,H));else r={}}i=t.shouldUnregister?j.keepDefaultValues?oe(a):{}:oe(T),h.array.next({values:{...T}}),h.state.next({values:{...T}})}o={mount:j.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!x.isValid||!!j.keepIsValid||!!j.keepDirtyValues||!t.shouldUnregister&&!he(T),l.watch=!!t.shouldUnregister,l.keepIsValid=!!j.keepIsValid,l.action=!1,j.keepErrors||(n.errors={}),h.state.next({submitCount:j.keepSubmitCount?n.submitCount:0,isDirty:_?!1:j.keepDirty?n.isDirty:!!(j.keepDefaultValues&&!we(m,a)),isSubmitted:j.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:_?{}:j.keepDirtyValues?j.keepDefaultValues&&i?Oe(a,i):n.dirtyFields:j.keepDefaultValues&&m?Oe(a,m):j.keepDirty?n.dirtyFields:{},touchedFields:j.keepTouched?n.touchedFields:{},errors:j.keepErrors?n.errors:{},isSubmitSuccessful:j.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},ge=(m,j)=>ae(xe(m)?m(i):m,{...t.resetOptions,...j}),Xr=(m,j={})=>{const A=O(r,m),z=A&&A._f;if(z){const _=z.refs?z.refs[0]:z.ref;_.focus&&setTimeout(()=>{_.focus(),j.shouldSelect&&xe(_.select)&&_.select()})}},ea=m=>{n={...n,...m}},Nn={control:{register:He,unregister:Ue,getFieldState:U,handleSubmit:We,setError:X,_subscribe:De,_runSchema:W,_updateIsValidating:b,_focusError:qe,_getWatch:E,_getDirty:S,_setValid:p,_setFieldArray:N,_setDisabledField:it,_setErrors:w,_getFieldArray:L,_reset:ae,_resetDefaultValues:()=>xe(t.defaultValues)&&t.defaultValues().then(m=>{ge(m,t.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:D,_disableForm:lt,_subjects:h,_proxyFormState:x,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(m){l=m},get _defaultValues(){return a},get _names(){return o},set _names(m){o=m},get _formState(){return n},get _options(){return t},set _options(m){t={...t,...m}}},subscribe:Ve,trigger:K,register:He,handleSubmit:We,watch:fe,setValue:Q,getValues:B,reset:ge,resetField:Le,clearErrors:Z,unregister:Ue,setError:X,setFocus:Xr,getFieldState:U};return{...Nn,formControl:Nn}}function Hl(e={}){const t=g.useRef(void 0),n=g.useRef(void 0),[r,a]=g.useState({isDirty:!1,isValidating:!1,isLoading:xe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:xe(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!xe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Ul(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,mn(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[i]),g.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),g.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),g.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),g.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),g.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),g.useEffect(()=>{var l;e.values&&!we(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),n.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),g.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()}),t.current.formState=g.useMemo(()=>Ws(r,i),[i,r]),t.current}function ql(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function Wl(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function Yl(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Gl(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}function Ql(e,t,n=.001){const r=e-t,a=Math.abs(r)<=n;return{difference:r,isBalanced:a,isUnderAllocated:!a&&r>0,isOverAllocated:!a&&r<0}}function pn(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}pn();const Kl={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:"$"},Lt=()=>({id:pn(),amount:0,glAccount:null,isTaxDeductible:!1}),Xs=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:a,onDistributionChange:i,onAmountChange:l,onGlAccountChange:o,onTaxDeductibleChange:c,onDelete:u,canDelete:f=!0,canEditTaxDeductible:x=!0,isDisabled:y=!1,labels:h,classNames:C={},"data-testid":v,control:p,name:b,rules:N})=>{const $={...Kl,...h},w=p!==void 0&&b!==void 0,k=Hl({defaultValues:{_internal:t||Lt()}}),M=Al({control:w?p:k.control,name:w?b:"_internal",rules:w?N:void 0}),[F,W]=g.useState(t||Lt()),I=w?M.field.value??Lt():e??F,P=w&&!!M.fieldState?.error,D=w&&(M.fieldState?.isTouched??!1),S=P||D,E=S&&(!I.amount||I.amount<=0),L=S&&!I.glAccount,[R,G]=g.useState(I.glAccount?.name||""),Q=g.useCallback(X=>{const fe={...I,...X};w&&M.field.onChange(fe),!w&&e===void 0&&W(fe),i?.(fe)},[I,e,i,w,M]),J=g.useCallback(X=>{const fe=X||0;Q({amount:fe}),l?.(fe)},[Q,l]),se=g.useCallback(X=>{G(X),a?.(X)},[a]),K=g.useCallback(X=>{if(X===null){Q({glAccount:null}),o?.(null);return}const De=n.find(Ve=>String(Ve.id)===String(X))||null;Q({glAccount:De}),o?.(De)},[n,Q,o]),B=g.useCallback(()=>{G(""),Q({glAccount:null}),o?.(null)},[Q,o]),U=g.useCallback(X=>{Q({isTaxDeductible:X}),c?.(X)},[Q,c]),Z=g.useCallback(()=>{u?.()},[u]);return s.jsx(d.Card,{radius:"md",shadow:"sm","data-testid":v||"revenue-distribution-card",className:d.cn(C.base),children:s.jsxs(d.CardBody,{className:d.cn("flex flex-row flex-nowrap items-start gap-4",C.body),children:[s.jsx("div",{className:d.cn("shrink-0",C.amountContainer),children:s.jsx(d.NumberInput,{"data-testid":`${v||"revenue-distribution-card"}-amount-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[$.amount,s.jsx(d.Tooltip,{content:$.amountTooltip,children:s.jsx(V,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:I.amount||void 0,onValueChange:J,labelPlacement:"outside",placeholder:$.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:y,isInvalid:E,errorMessage:E?"Amount is required":void 0,minValue:0,step:.01,className:C.amountInput,startContent:s.jsx("div",{className:"pointer-events-none flex items-center",children:s.jsx("span",{className:"text-default-400 text-small",children:$.currencySymbol})})})}),s.jsx("div",{className:d.cn("grow",C.glAccountContainer),children:s.jsx(d.Autocomplete,{"data-testid":`${v||"revenue-distribution-card"}-gl-account-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[$.glAccount,s.jsx(d.Tooltip,{content:$.glAccountTooltip,children:s.jsx(V,{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:I.glAccount?.name??R,selectedKey:I.glAccount?.id??null,isDisabled:y,isInvalid:L,errorMessage:L?"GL Account is required":void 0,listboxProps:{emptyContent:r?$.searching:$.noGlAccountsFound},placeholder:$.glAccountPlaceholder,onInputChange:se,onSelectionChange:K,onClear:B,className:C.glAccountInput,children:X=>s.jsx(d.AutocompleteItem,{textValue:X.name,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:X.name}),X.code&&s.jsx("span",{className:"text-xs text-default-400",children:X.code})]})},X.id)})}),s.jsx("div",{className:d.cn("shrink-0 pt-6 flex items-center",C.taxDeductibleContainer),children:s.jsx(d.Checkbox,{radius:"full","data-testid":`${v||"revenue-distribution-card"}-tax-deductible`,isSelected:I.isTaxDeductible,onValueChange:U,isDisabled:y||!x,className:C.taxDeductibleCheckbox,children:$.taxDeductible})}),s.jsx("div",{className:d.cn("shrink-0 pt-6",C.deleteContainer),children:s.jsx(q,{"data-testid":`${v||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:y||!f,onPress:Z,startContent:s.jsx(V,{icon:"solar:trash-bin-trash-linear",width:16}),className:d.cn("text-danger",C.deleteButton),children:$.deleteButton})})]})})};Xs.displayName="RevenueDistributionCard";const er=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i)return s.jsx(s.Fragment,{children:i()});const l=s.jsxs("div",{className:d.cn("flex flex-col items-center justify-center py-8",a.content),children:[s.jsx(V,{icon:t,width:n,className:d.cn("text-default-300 mb-4",a.icon)}),s.jsx("p",{className:d.cn("text-default-500 text-sm text-center",a.message),children:e})]});return r?s.jsx(d.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:d.cn("w-full",a.base),children:s.jsx(d.CardBody,{children:l})}):s.jsx("div",{"data-testid":"revenue-distribution-empty",className:d.cn("w-full",a.base),children:l})};er.displayName="RevenueDistributionEmpty";const Zl={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},tr=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...Zl,...t},l=s.jsx(d.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(d.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:d.cn("w-full",a.base),children:s.jsx(d.CardBody,{children:l})}):s.jsx("div",{"data-testid":"revenue-distribution-error",className:d.cn("w-full",a.base),children:l})};tr.displayName="RevenueDistributionError";const nr=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,l)=>l),a=i=>s.jsxs("div",{className:d.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[s.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(d.Skeleton,{className:"h-4 w-14 rounded-md"}),s.jsx(d.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(d.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),s.jsxs("div",{className:"grow flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(d.Skeleton,{className:"h-4 w-20 rounded-md"}),s.jsx(d.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(d.Skeleton,{className:"h-10 w-full rounded-lg"})]}),s.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[s.jsx(d.Skeleton,{className:"h-5 w-5 rounded-full"}),s.jsx(d.Skeleton,{className:"h-4 w-24 rounded-md"})]}),s.jsx("div",{className:"shrink-0 pb-2",children:s.jsx(d.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?s.jsx("div",{className:d.cn("flex flex-col gap-3",n.base),children:r.map(i=>s.jsx(d.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:s.jsx(d.CardBody,{children:a(i)})},i))}):s.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:d.cn("flex flex-col gap-3",n.base),children:r.map(i=>a(i))})};nr.displayName="RevenueDistributionSkeleton";function Ct({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:a="danger",iconTone:i="danger",portalContainer:l,shouldBlockScroll:o,classNames:c,onClose:u,onConfirm:f}){return s.jsx(d.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:l,shouldBlockScroll:o,classNames:{...c,base:d.cn("max-w-[440px] rounded-3xl",c?.base),closeButton:d.cn("right-5 top-5 text-zinc-500",c?.closeButton)},onOpenChange:x=>!x&&u(),children:s.jsxs(d.ModalContent,{children:[s.jsxs(d.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&s.jsx("span",{className:d.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),s.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),s.jsx(d.ModalBody,{className:"px-7 pb-3 pt-4",children:s.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),s.jsxs(d.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[s.jsx(q,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:u,children:t.cancel}),s.jsx(q,{type:"button",size:"md",color:a,radius:"full",className:d.cn("h-10 text-sm font-normal text-white",a==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:f,children:t.confirm})]})]})})}const Jl=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function Xl({mode:e,assignments:t}){const n=t.filter(i=>i.fund),r=n.reduce((i,l)=>i+Number(l.percentage||0),0),a=t.some(i=>!i.fund||Number(i.percentage||0)<=0);return n.length>=1&&!a&&Math.round(r*100)/100===100}const eo={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select a fund and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Select a fund for each row and enter percentages that total 100%.",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},sr={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},Ze={...sr,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},to={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},no={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},so=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,ro=e=>e.fund!==null;function ao({assignments:e,funds:t,labels:n,classNames:r,isSaving:a=!1,hasSavedAssignments:i=!1,isFundPickerOpen:l=!1,activeAssignmentId:o=null,footer:c,onAssignmentsChange:u,onOpenFundPicker:f,onCloseFundPicker:x,onCollapseChange:y,onSave:h}){const[C,v]=g.useState(null),p={...eo,...n},N=e.filter(ro).length>0,$=g.useMemo(()=>e.reduce((K,B)=>K+Number(B.percentage||0),0),[e]),w=Math.round($*100)/100,k=e.some(K=>!K.fund||Number(K.percentage||0)<=0),M=N&&(w!==100||k),F=`${p.totalError} (${p.total} ${Number($.toFixed(2))}%)`,W=Xl({mode:"split",assignments:e}),I=N&&w>=100,[P,D]=g.useState(!1),[S,E]=g.useState(!1),L=(K,B)=>{u(e.map(U=>U.id===K?{...U,...B}:U))},R=()=>{I||u([...e,Jl()])},G=K=>{e.length<=1||u(e.filter(B=>B.id!==K))},Q=()=>{if(!a){if(!W){E(!0);return}if(!i){h();return}D(!0)}},J=()=>{D(!1),h()},se=K=>{const B=o??e.find(U=>!U.fund)?.id??e[0]?.id;B&&(u(e.map(U=>U.id===B?{...U,fund:K}:U)),x())};return s.jsxs("div",{ref:v,className:d.cn("vvt-pa relative font-sans text-zinc-900",l&&"min-h-[560px]",r?.root),children:[s.jsx(d.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:d.cn("w-full gap-0 px-0",r?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:d.cn("px-4 py-4",r?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:K=>y?.(!(K==="all"||Array.from(K).length>0)),children:s.jsx(d.AccordionItem,{"aria-label":p.title,title:p.title,children:s.jsxs("div",{className:d.cn("flex w-full flex-col gap-4",r?.content),children:[s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!N&&s.jsx(d.Alert,{icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:sr,color:"default",variant:"flat",title:p.emptySplit}),N&&s.jsx(io,{assignments:e,labels:p,total:$,hasTotalError:S&&!W||M,validationMessage:F,onSelectFund:K=>f(K),onRemoveFund:G,onPercentageChange:(K,B)=>L(K,{percentage:so(B)})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx(q,{type:"button",size:"lg",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-lg font-normal text-white disabled:opacity-50",startContent:s.jsx(Y.Plus,{className:"size-5",strokeWidth:2}),isDisabled:I,onPress:()=>N?R():f(),children:N?p.addFund:p.assignSpecificFund}),s.jsx(q,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:a?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:a,onPress:Q,children:p.saveAssignment})]})]}),c]})},"installment-fund-assignment")}),l&&s.jsx(lo,{funds:t,labels:p,selectedFundIds:e.map(K=>K.fund?.id).filter(Boolean),portalContainer:C??void 0,onSelect:se,onClose:x}),s.jsx(Ct,{isOpen:P,labels:{title:p.modifyAssignedFundsTitle,description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:p.modifyAssignedFundsDescription}),s.jsx("p",{className:"mt-3",children:p.modifyAssignedFundsWarning})]}),cancel:p.modifyAssignedFundsCancel,confirm:p.modifyAssignedFundsConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:C??void 0,shouldBlockScroll:!1,classNames:no,onClose:()=>D(!1),onConfirm:J})]})}function io({assignments:e,labels:t,total:n,hasTotalError:r,validationMessage:a,onSelectFund:i,onRemoveFund:l,onPercentageChange:o}){return s.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((c,u)=>s.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[s.jsx("div",{className:d.cn("flex min-h-11 min-w-0 flex-1 items-center","gap-4"),children:c.fund?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),s.jsx(q,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):s.jsx(q,{type:"button",size:"lg",variant:"light",radius:"full",className:"justify-start px-4 text-lg font-normal text-zinc-900",startContent:s.jsx(Y.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:t.assignSpecificFund})}),s.jsx("label",{className:"flex w-48 flex-none items-center",children:s.jsx(d.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:f=>o(c.id,Number(f.target.value)),endContent:s.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:to})}),e.length>1&&s.jsx(q,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:d.cn("h-10 w-10 flex-none p-0",u===0?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:u===0,onPress:()=>l(c.id),"aria-label":t.removeFund,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),s.jsx(d.Alert,{icon:s.jsx(V,{icon:r?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:r?"warning":"success",variant:"flat",classNames:{...Ze,base:d.cn(Ze.base,r?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:d.cn(Ze.iconWrapper,r?"text-warning-700":"text-success-700"),alertIcon:d.cn(Ze.alertIcon,r?"text-warning-700":"text-success-700"),title:d.cn(Ze.title,r?"text-warning-700":"text-success-700")},title:r?a:`${t.total} ${Number(n.toFixed(2))}%`})]})}function lo({funds:e,labels:t,selectedFundIds:n,portalContainer:r,onSelect:a,onClose:i}){const[l,o]=g.useState(""),c=e.filter(u=>{if(n.includes(u.id))return!1;const f=l.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return s.jsx(d.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:r,classNames:{wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl",base:"max-h-[calc(100%-2rem)] max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:u=>!u&&i(),children:s.jsxs(d.ModalContent,{className:"max-h-full",children:[s.jsx(d.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),s.jsxs(d.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[s.jsx(d.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:l,placeholder:t.searchPlaceholder,onChange:u=>o(u.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),s.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[s.jsx("span",{children:t.glCode}),s.jsx("span",{children:t.accountName}),s.jsx("span",{children:t.actions})]}),c.length===0&&s.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),c.map(u=>s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[s.jsx("span",{children:u.glCode}),s.jsx("span",{children:u.accountName}),s.jsx(q,{type:"button",size:"sm",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",onPress:()=>a(u),children:t.select})]},u.id))]})]})]})})}function oo(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(d.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(d.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(d.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(d.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(d.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(d.Skeleton,{className:"h-8 w-full rounded-xl"})]}),s.jsx(d.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const co={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function uo({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:a="en-US",labels:i,className:l}){const o={...co,...i},c=new Intl.NumberFormat(a,{style:"currency",currency:r});return s.jsx("div",{className:d.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",l),children:s.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[s.jsx(_t,{label:o.totalAmount,value:c.format(e)}),s.jsx(_t,{label:o.remainingBalance,value:c.format(t)}),s.jsx(_t,{label:o.amountReceived,value:c.format(n)})]})})}function _t({label:e,value:t}){return s.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[s.jsx("span",{className:"font-medium text-zinc-700",children:e}),s.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function Pt(e,t){return e-t*Math.floor(e/t)}const rr=1721426;function ct(e,t,n,r){t=gn(e,t);let a=t-1,i=-2;return n<=2?i=0:mt(t)&&(i=-1),rr-1+365*a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)+Math.floor((367*n-362)/12+i+r)}function mt(e){return e%4===0&&(e%100!==0||e%400===0)}function gn(e,t){return e==="BC"?1-t:t}function fo(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const mo={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class St{fromJulianDay(t){let n=t,r=n-rr,a=Math.floor(r/146097),i=Pt(r,146097),l=Math.floor(i/36524),o=Pt(i,36524),c=Math.floor(o/1461),u=Pt(o,1461),f=Math.floor(u/365),x=a*400+l*100+c*4+f+(l!==4&&f!==4?1:0),[y,h]=fo(x),C=n-ct(y,h,1,1),v=2;n<ct(y,h,3,1)?v=0:mt(h)&&(v=1);let p=Math.floor(((C+v)*12+373)/367),b=n-ct(y,h,p,1)+1;return new st(y,h,p,b)}toJulianDay(t){return ct(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return mo[mt(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return mt(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function ho(e,t){var n,r,a,i;return(i=(a=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&a!==void 0?a:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function ar(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function xo(e,t){return Xn(e)-Xn(t)}function Xn(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let Ot=null;function ir(){return Ot==null&&(Ot=new Intl.DateTimeFormat().resolvedOptions().timeZone),Ot}function es(e){e=bn(e,new St);let t=gn(e.era,e.year);return lr(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function lr(e,t,n,r,a,i,l){let o=new Date;return o.setUTCHours(r,a,i,l),o.setUTCFullYear(e,t-1,n),o.getTime()}function ts(e,t){if(t==="UTC")return 0;if(e>0&&t===ir())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:a,hour:i,minute:l,second:o}=or(e,t);return lr(n,r,a,i,l,o,0)-Math.floor(e/1e3)*1e3}const ns=new Map;function or(e,t){let n=ns.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),ns.set(t,n));let r=n.formatToParts(new Date(e)),a={};for(let i of r)i.type!=="literal"&&(a[i.type]=i.value);return{year:a.era==="BC"||a.era==="B"?-a.year+1:+a.year,month:+a.month,day:+a.day,hour:a.hour==="24"?0:+a.hour,minute:+a.minute,second:+a.second}}const ss=864e5;function po(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>go(e,t,i))}function go(e,t,n){let r=or(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function bo(e,t,n="compatible"){let r=dr(e);if(t==="UTC")return es(r);if(t===ir()&&n==="compatible"){r=bn(r,new St);let c=new Date,u=gn(r.era,r.year);return c.setFullYear(u,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let a=es(r),i=ts(a-ss,t),l=ts(a+ss,t),o=po(r,t,a-i,a-l);if(o.length===1)return o[0];if(o.length>1)switch(n){case"compatible":case"earlier":return o[0];case"later":return o[o.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(a-i,a-l);case"compatible":case"later":return Math.max(a-i,a-l);case"reject":throw new RangeError("No such absolute time found")}}function cr(e,t,n="compatible"){return new Date(bo(e,t,n))}function dr(e,t){let n=0,r=0,a=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:a,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:a,millisecond:i}=t),new yt(e.calendar,e.era,e.year,e.month,e.day,n,r,a,i)}function bn(e,t){if(ho(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,Re(r),r}function yn(e,t){let n=e.copy(),r="hour"in n?Co(n,t):0;Xt(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,en(n),ur(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,yo(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let a=n.calendar.getYearsInEra(n);if(n.year>a){var i,l;let c=(i=(l=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(l,n);n.year=a,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let o=n.calendar.getMonthsInYear(n);return n.month>o&&(n.month=o,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function Xt(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function en(e){for(;e.month<1;)Xt(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,Xt(e,1)}function yo(e){for(;e.day<1;)e.month--,en(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,en(e)}function ur(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function Re(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),ur(e)}function vo(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function fr(e,t){return yn(e,vo(t))}function mr(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),Re(n),n}function jo(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),No(n),n}function wo(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=dt(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=dt(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=dt(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=dt(e.hour,24),t}function No(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function dt(e,t){let n=e%t;return n<0&&(n+=t),n}function Co(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,wo(e)}function hr(e,t,n,r){let a=e.copy();switch(t){case"era":{let o=e.calendar.getEras(),c=o.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=Ae(c,n,0,o.length-1,r?.round),a.era=o[c],Re(a);break}case"year":var i,l;!((i=(l=a.calendar).isInverseEra)===null||i===void 0)&&i.call(l,a)&&(n=-n),a.year=Ae(e.year,n,-1/0,9999,r?.round),a.year===-1/0&&(a.year=1),a.calendar.balanceYearMonth&&a.calendar.balanceYearMonth(a,e);break;case"month":a.month=Ae(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":a.day=Ae(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(a),Re(a),a}function So(e,t,n,r){let a=e.copy();switch(t){case"hour":{let i=e.hour,l=0,o=23;if(r?.hourCycle===12){let c=i>=12;l=c?12:0,o=c?23:11}a.hour=Ae(i,n,l,o,r?.round);break}case"minute":a.minute=Ae(e.minute,n,0,59,r?.round);break;case"second":a.second=Ae(e.second,n,0,59,r?.round);break;case"millisecond":a.millisecond=Ae(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return a}function Ae(e,t,n,r,a=!1){if(a){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const ko=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,Ao=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function $o(e){let t=e.match(ko);if(!t)throw Ao.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new st(zt(t[1],0,9999),zt(t[2],1,12),1);return n.day=zt(t[3],1,n.calendar.getDaysInMonth(n)),n}function zt(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function Do(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function xr(e){let t=bn(e,new St),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Eo(e){return`${xr(e)}T${Do(e)}`}function Io(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pr(e,t,n){Io(e,t),t.set(e,n)}function gr(e){let t=typeof e[0]=="object"?e.shift():new St,n;if(typeof e[0]=="string")n=e.shift();else{let l=t.getEras();n=l[l.length-1]}let r=e.shift(),a=e.shift(),i=e.shift();return[t,n,r,a,i]}var Mo=new WeakMap;class st{copy(){return this.era?new st(this.calendar,this.era,this.year,this.month,this.day):new st(this.calendar,this.year,this.month,this.day)}add(t){return yn(this,t)}subtract(t){return fr(this,t)}set(t){return mr(this,t)}cycle(t,n,r){return hr(this,t,n,r)}toDate(t){return cr(this,t)}toString(){return xr(this)}compare(t){return ar(this,t)}constructor(...t){pr(this,Mo,{writable:!0,value:void 0});let[n,r,a,i,l]=gr(t);this.calendar=n,this.era=r,this.year=a,this.month=i,this.day=l,Re(this)}}var Fo=new WeakMap;class yt{copy(){return this.era?new yt(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new yt(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return yn(this,t)}subtract(t){return fr(this,t)}set(t){return mr(jo(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return hr(this,t,n,r);default:return So(this,t,n,r)}}toDate(t,n){return cr(this,t,n)}toString(){return Eo(this)}compare(t){let n=ar(this,t);return n===0?xo(this,dr(t)):n}constructor(...t){pr(this,Fo,{writable:!0,value:void 0});let[n,r,a,i,l]=gr(t);this.calendar=n,this.era=r,this.year=a,this.month=i,this.day=l,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,Re(this)}}const To={monthly:1,quarterly:3,annual:12},Lo=e=>{const[t,n,r]=e.split("-").map(Number);return{year:t,month:n,day:r}},_o=(e,t)=>new Date(e,t+1,0).getDate(),Po=e=>{const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},Oo=(e,t)=>{const{year:n,month:r,day:a}=Lo(e),i=r-1+t,l=n+Math.floor(i/12),o=(i%12+12)%12,c=Math.min(a,_o(l,o));return new Date(l,o,c)};function br(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,l=To[t.frequency];return Array.from({length:n},(o,c)=>{const u=Oo(t.firstInstallmentDate,c*l);return{id:crypto.randomUUID(),dueDate:Po(u),amount:(r+(c<i?1:0))/100}})}function zo(e){return new Set(e.map((t,n)=>{const r=e[n+1]?.dueDate;return t.dueDate&&r&&t.dueDate>r?t.id:null}).filter(t=>!!t))}const Ro={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount",totalIncreaseWarning:"Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationTitle:"Update Donation Total",totalIncreaseConfirmationDescription:"The scheduled payments total is greater than the current donation/contribution total. Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationCancel:"Cancel",totalIncreaseConfirmationConfirm:"Save Payments",dateOrderError:"Payment date must be on or before the next payment date.",amountGreaterThanZeroError:"Payment amount must be greater than 0."},Bo=["monthly","quarterly","annual"],yr={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-950"},vt={label:"text-sm font-normal text-zinc-950",inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Vo={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},Uo={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},rs=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),vr=e=>Math.round(e*100)/100,Ho=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},jr=e=>{if(!e)return null;try{return $o(e)}catch{return null}};function qo({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:a,automaticSettings:i,labels:l,classNames:o,isSaving:c=!1,isModeSwitchDisabled:u=!1,onModeChange:f,onAutomaticSettingsChange:x,onInstallmentsChange:y,onSave:h}){const[C,v]=g.useState(null),p={...Ro,...l},b=g.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),N=e==="automatic"?br(t,i):a,$=g.useMemo(()=>vr(N.reduce((E,L)=>E+Number(L.amount||0),0)),[N]),w=e==="manual"&&$-t>.009,[k,M]=g.useState(!1),F=E=>{E!==e&&(f(E),E==="manual"&&a.length===0&&y([rs()]))},W=(E,L)=>{a.find(G=>G.id===E)?.status!=="paid"&&y(a.map(G=>G.id===E?{...G,...L}:G))},I=()=>{y([...a,rs()])},P=E=>{a.find(R=>R.id===E)?.status!=="paid"&&y(a.filter(R=>R.id!==E))},D=()=>{if(!c){if(w){M(!0);return}h()}},S=()=>{M(!1),h()};return s.jsxs("div",{ref:v,className:d.cn("vvt-ps relative font-sans text-zinc-900",o?.root),children:[s.jsx(d.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:d.cn("w-full gap-0 px-0",o?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:d.cn("px-4 py-4",o?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:s.jsx(d.AccordionItem,{"aria-label":p.title,title:p.title,children:s.jsxs("div",{className:d.cn("flex w-full flex-col gap-4",o?.content),children:[s.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[s.jsx(Wo,{mode:e,labels:p,onModeChange:F,isDisabled:u,className:o?.tabs}),s.jsx(q,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-36 bg-brand px-4 text-sm font-medium text-white",startContent:c?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:D,children:p.saveInstallments})]}),s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&s.jsx(Yo,{settings:i,labels:p,onSettingsChange:x}),N.length===0&&s.jsx(d.Alert,{icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:yr,color:"default",variant:"flat",title:e==="automatic"?p.emptyAutomatic:p.emptyManual}),N.length>0&&s.jsx(Go,{mode:e,installments:N,labels:p,formatter:b,locale:r,onUpdateInstallment:W,onRemoveInstallment:P}),e==="manual"&&s.jsx("div",{className:"flex flex-wrap gap-3",children:s.jsx(q,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(Y.Plus,{className:"size-5",strokeWidth:2}),onPress:I,children:p.addInstallment})}),s.jsx(Ko,{total:$,donationAmount:t,hasTotalIncreaseWarning:w,mode:e,installmentCount:N.length,formatter:b,labels:p})]})]})},"installment-schedule")}),s.jsx(Ct,{isOpen:k,labels:{title:p.totalIncreaseConfirmationTitle,description:p.totalIncreaseConfirmationDescription,cancel:p.totalIncreaseConfirmationCancel,confirm:p.totalIncreaseConfirmationConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",isConfirming:c,portalContainer:C??void 0,shouldBlockScroll:!1,classNames:Uo,onClose:()=>M(!1),onConfirm:S})]})}function Wo({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:a}){return s.jsxs(d.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:d.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>a(i),children:[s.jsx(d.Tab,{title:t.automaticMode},"automatic"),s.jsx(d.Tab,{title:t.manualMode},"manual")]})}function Yo({settings:e,labels:t,onSettingsChange:n}){return s.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[s.jsx("div",{className:"min-w-0",children:s.jsx(d.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const a=r.target.value;n({...e,numberOfInstallments:a===""?0:Math.max(1,Number(a))})},classNames:vt})}),s.jsx("div",{className:"min-w-0",children:s.jsx(Te,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const a=Array.from(r)[0];typeof a=="string"&&n({...e,frequency:a})},classNames:Vo,children:Bo.map(r=>s.jsx(d.SelectItem,{textValue:t[r],children:t[r]},r))})}),s.jsx("div",{className:"min-w-0",children:s.jsx(d.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:jr(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:s.jsx(V,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:vt})})]})}function Go({mode:e,installments:t,labels:n,formatter:r,locale:a,onUpdateInstallment:i,onRemoveInstallment:l}){const o=zo(t),c=new Set(t.map(u=>Number(u.amount||0)<=0?u.id:null).filter(u=>!!u));return e==="automatic"?s.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:s.jsx("div",{className:d.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((u,f)=>s.jsxs("div",{className:d.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",f===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{children:["#",f+1]}),s.jsx("span",{children:"▪"}),s.jsx("span",{children:Ho(u.dueDate,a)}),f===0&&t.length>1&&s.jsx(d.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),s.jsx("span",{className:"text-zinc-950",children:r.format(u.amount)})]},u.id))})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.map((u,f)=>{const x=o.has(u.id),y=c.has(u.id);return s.jsx("div",{className:"flex w-full flex-col gap-1",children:s.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[s.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:f+1}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(d.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${f+1}`,isDisabled:u.status==="paid",isInvalid:x,errorMessage:x?n.dateOrderError:void 0,value:jr(u.dueDate),onChange:h=>i(u.id,{dueDate:h?h.toString():""}),classNames:vt})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(d.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:u.status==="paid",isInvalid:y,errorMessage:y?n.amountGreaterThanZeroError:void 0,value:String(u.amount||""),onChange:h=>i(u.id,{amount:vr(Number(h.target.value||0))}),startContent:s.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:vt})}),s.jsx(Qo,{isDisabled:t.length<=1,isPaid:u.status==="paid",label:n.deleteInstallment,onRemove:()=>l(u.id)})]})},u.id)})})}function Qo({isDisabled:e,isPaid:t,label:n,onRemove:r}){const a=s.jsx(q,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?s.jsx(d.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:s.jsx("span",{className:"inline-flex",children:a})}):a}function Ko({total:e,donationAmount:t,hasTotalIncreaseWarning:n,mode:r,installmentCount:a,formatter:i,labels:l}){const o=a>0?e/a:0,c=n?s.jsx("span",{children:l.totalIncreaseWarning}):r==="automatic"?s.jsxs("span",{children:["Saving will create ",s.jsx("strong",{children:a})," scheduled payment records of"," ",s.jsx("strong",{children:i.format(o)})," each."]}):s.jsxs("span",{children:["Total scheduled: ",s.jsx("strong",{children:i.format(e)})," /"," ",s.jsx("strong",{children:i.format(t)}),"."]}),u=r==="automatic"?`Total: ${i.format(e)}`:n?`New total: ${i.format(e)}`:`Remaining: ${i.format(0)}`;return s.jsx(d.Alert,{icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:n?"warning":"default",variant:"flat",classNames:yr,endContent:s.jsx("span",{className:"whitespace-nowrap",children:u}),title:c})}function Zo(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(d.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(d.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(d.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(d.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[s.jsx(d.Skeleton,{className:"h-4 w-36 rounded-md"}),s.jsx(d.Skeleton,{className:"h-9 w-full rounded-xl"})]}),s.jsx(d.Skeleton,{className:"h-9 w-36 rounded-full"})]}),s.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(d.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(d.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const as={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},is={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},Jo={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:s.jsxs(s.Fragment,{children:["Are you sure you want to delete this payment? ",s.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Xo={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function ec({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:a=!1,onEditInstallments:i,onPayInstallment:l,onDeleteInstallment:o}){const[c,u]=g.useState(null),f={...Jo,...r},[x,y]=g.useState(""),h=new Intl.NumberFormat(n,{style:"currency",currency:t}),C=g.useMemo(()=>{const v=x.trim().toLowerCase();return v?e.filter(p=>{const b=p.status??"scheduled";return[p.id,p.amount,p.dueDate,ls(p.dueDate,n),b,is[b]??b].join(" ").toLowerCase().includes(v)}):e},[n,e,x]);return s.jsx("div",{ref:u,className:"vvt-ps relative w-full font-sans text-zinc-900",children:s.jsx(d.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:s.jsx(d.AccordionItem,{"aria-label":f.title,title:f.title,children:s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[s.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[s.jsxs("div",{className:"w-full max-w-[280px]",children:[s.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:f.searchLabel}),s.jsx(d.Input,{variant:"bordered",size:"sm",value:x,placeholder:f.searchPlaceholder,onChange:v=>y(v.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}})]}),s.jsx(q,{type:"button",variant:"bordered",radius:"full",size:"md",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(V,{icon:"solar:pen-outline",className:"size-4"}),isLoading:a,onPress:i,children:f.editInstallments})]}),s.jsx("div",{className:"w-full overflow-hidden",children:s.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-[6%]"}),s.jsx("col",{className:"w-[25%]"}),s.jsx("col",{className:"w-[12%]"}),s.jsx("col",{className:"w-[16%]"}),s.jsx("col",{className:"w-[17%]"}),s.jsx("col",{className:"w-[24%]"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[s.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-3 font-medium",children:f.installmentId}),s.jsx("th",{className:"px-2 py-3 font-medium",children:f.amount}),s.jsx("th",{className:"px-2 py-3 font-medium",children:f.scheduledDate}),s.jsx("th",{className:"px-2 py-3 font-medium",children:f.status}),s.jsx("th",{className:"px-2 py-3 font-medium",children:f.actions})]})}),s.jsxs("tbody",{children:[C.map((v,p)=>{const b=v.status??"scheduled";return s.jsxs("tr",{className:"text-zinc-500",children:[s.jsx("td",{className:"px-2 py-3",children:p+1}),s.jsx("td",{className:"px-2 py-3",children:s.jsx("span",{className:"block max-w-full truncate",children:v.id||`PMT-${p+1}`})}),s.jsx("td",{className:"px-2 py-3",children:h.format(v.amount)}),s.jsx("td",{className:"px-2 py-3",children:ls(v.dueDate,n)}),s.jsx("td",{className:"px-2 py-3",children:s.jsx(d.Chip,{size:"sm",radius:"full",className:d.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",as[b]??as.scheduled),startContent:s.jsx(nc,{status:b}),children:is[b]??b})}),s.jsx("td",{className:"px-2 py-3",children:s.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[s.jsx(q,{type:"button",size:"md",radius:"full",className:"h-10 min-w-[104px] shrink-0 bg-brand px-3 text-sm font-medium text-white disabled:opacity-50",isDisabled:b==="paid"||b==="fulfilled",startContent:s.jsx(V,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>l?.(v),children:f.payNow}),s.jsx(tc,{isPaid:b==="paid"||b==="fulfilled",labels:f,portalContainer:c??void 0,onDelete:()=>o(v.id)})]})})]},v.id)}),C.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:f.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function tc({isPaid:e,labels:t,portalContainer:n,onDelete:r}){const[a,i]=g.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs(d.Dropdown,{placement:"bottom-end",radius:"lg",children:[s.jsx(d.DropdownTrigger,{children:s.jsx(q,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:s.jsx(V,{icon:"solar:menu-dots-bold",className:"size-4"})})}),s.jsxs(d.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:l=>{l==="delete"&&!e&&i(!0)},children:[s.jsx(d.DropdownSection,{title:"Actions",showDivider:!0,children:s.jsx(d.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:s.jsx(V,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),s.jsx(d.DropdownSection,{title:t.dangerZone,children:s.jsx(d.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),s.jsx(Ct,{isOpen:a,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:s.jsx(V,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:n,shouldBlockScroll:!1,classNames:Xo,onClose:()=>i(!1),onConfirm:()=>{i(!1),r()}})]})}function nc({status:e}){return e==="paid"||e==="fulfilled"?s.jsx(V,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?s.jsx(V,{icon:"solar:close-circle-bold",className:"size-3"}):s.jsx(V,{icon:"solar:calendar-outline",className:"size-3"})}function ls(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const sc={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},rc=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:a,showRenewal:i=!0,defaultRenewalValue:l=!1,initialSelectedMembershipId:o=null,allowReselect:c=!0,onRenewalChange:u,onCardSelect:f,className:x=""})=>{const y=Array.isArray(e)?e:[],[h,C]=g.useState(o),[v,p]=g.useState(l),b={...sc,...a};g.useEffect(()=>{C(o)},[o]);const N=w=>{if(w===h){c&&f?.(w);return}C(w),f?.(w)},$=w=>{p(w),u?.(w)};return s.jsxs("div",{className:d.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",x),"data-testid":"membership-select-cards",children:[s.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),s.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:b.title}),i&&s.jsx($r,{title:b.renewalTitle,description:b.renewalDescription,value:v,onValueChange:$}),s.jsx("div",{className:d.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":d.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:y.map(w=>s.jsx(wr,{itemKey:w.id,name:w.name,type:w.type,price:w.price,locale:t,currency:n,isSelected:h===w.id,onSelect:N},w.id))})]})},wr=({itemKey:e,name:t,type:n,price:r,locale:a="en-US",currency:i="USD",showPrice:l=!0,isSelected:o=!1,onSelect:c,compact:u=!1,isDisabled:f=!1,disabledReason:x,statusLabel:y,statusTone:h="default",className:C=""})=>{const v=new Intl.NumberFormat(a,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),p=!!c&&!f,b=x||y,N=()=>{p&&c?.(e)};return s.jsx(d.Card,{shadow:"none",isPressable:!!c,onPress:N,className:d.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",C),"data-testid":"item-card","data-selected":o,isDisabled:f,children:s.jsxs("div",{className:d.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[s.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[s.jsx("p",{className:d.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&s.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:s.jsx("p",{className:"text-center",children:n})}),b&&s.jsx(d.Chip,{"data-testid":"item-card-status",color:h,size:"sm",variant:"flat",className:"px-2",children:b})]}),l&&s.jsx("p",{className:d.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:v})]})})},os="w-full bg-gray-100",cs={variant:"light",color:"default"},Nr=({id:e,title:t,media:n,imageUrl:r,imageAlt:a,imageClassName:i="",imageAspect:l="aspect-[4/3]",meta:o=[],price:c,action:u,footer:f,onPress:x,isPressable:y=!1,isDisabled:h=!1,compact:C=!1,className:v="",bodyClassName:p="",footerClassName:b="",dataTestId:N})=>{const $=!!(c&&c.value),w=!!u?.label,k=y&&!!x&&!w,M=!k,F=w?{variant:u?.variant??cs.variant,color:u?.color??cs.color,size:u?.size??"sm",isDisabled:h||u?.isDisabled,startContent:u?.icon?s.jsx(V,{icon:u.icon,width:16}):void 0}:null,W=n??(r?s.jsx("div",{className:d.cn("relative overflow-hidden rounded-xl",l,os,i),children:s.jsx(d.Image,{removeWrapper:!0,src:r,alt:a||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):s.jsx("div",{className:d.cn("relative overflow-hidden rounded-xl",l,os,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:s.jsx(V,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return s.jsxs(d.Card,{"data-testid":N||`catalog-item-card-${e??"item"}`,className:d.cn("w-full overflow-hidden",v),isPressable:k,onPress:x,isDisabled:h,shadow:"sm",radius:"lg",children:[s.jsx("div",{children:W}),s.jsxs(d.CardBody,{className:d.cn("gap-3",C?"p-3":"p-4",p),children:[s.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:d.cn("line-clamp-2 text-base font-semibold text-gray-900",C?"text-sm":""),children:t}),o.length>0?s.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((I,P)=>s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(V,{icon:I.icon,className:"size-4 text-gray-400",width:16}),s.jsx("span",{children:I.label})]},`${I.label}-${P}`))}):null,($||w)&&s.jsxs("div",{className:d.cn("flex items-center justify-end gap-2 pt-1 text-sm",C?"pt-0.5":"",b),children:[$?s.jsxs("span",{className:d.cn("mr-auto text-gray-500",C?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[c?.label&&s.jsxs("span",{children:[c.label," "]}),s.jsx("span",{className:"font-semibold text-brand",children:c?.value})]}):s.jsx("span",{className:"ml-auto","aria-hidden":!0}),w&&M?s.jsx(q,{className:d.cn("rounded-full",u?.className),onPress:u?.onPress,variant:F?.variant,color:F?.color,size:F?.size,startContent:F?.startContent,isDisabled:F?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?s.jsx("div",{className:"pt-1",children:f}):null]})]})};Nr.displayName="CatalogItemCard";const ac={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},ic={empty:"border-default-200 bg-white",error:"border-danger-200 bg-white",success:"border-success-100 bg-success-50/40",loading:"border-default-200 bg-white"},lc={empty:"bg-default-100 text-default-400",error:"bg-danger-50 text-danger-600",success:"bg-success-100 text-success-700",loading:"bg-primary-50 text-primary"},oc={empty:"status",error:"alert",success:"status",loading:"status"},cc={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function dc(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return s.jsx(d.Spinner,{size:"lg",color:"primary",className:r.spinner});if(g.isValidElement(t))return s.jsx(s.Fragment,{children:t});const a=typeof t=="string"?t:ac[e];return a?s.jsx(V,{icon:a,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function Be({variant:e="empty",title:t,titleAs:n="p",description:r,icon:a,actions:i,role:l=oc[e],ariaLive:o=cc[e],iconSize:c=24,className:u,classNames:f={},"data-testid":x="feedback-state"}){const y=dc(e,a,c,f);return s.jsxs("div",{role:l,"aria-live":o,"data-variant":e,"data-testid":x,className:d.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",ic[e],u,f.base),children:[y?s.jsx("span",{"aria-hidden":"true","data-testid":`${x}-icon`,className:d.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",lc[e],f.iconWrapper),children:y}):null,s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsx(n,{"data-testid":`${x}-title`,className:d.cn("text-base font-medium text-default-900",f.title),children:t}),r?s.jsx("p",{"data-testid":`${x}-description`,className:d.cn("max-w-sm text-sm text-default-600",f.description),children:r}):null]}),i?s.jsx("div",{"data-testid":`${x}-actions`,className:d.cn("mt-1 flex flex-wrap items-center justify-center gap-2",f.actions),children:i}):null]})}function Cr(e){return s.jsx(Be,{...e,variant:"empty"})}function Sr(e){return s.jsx(Be,{...e,variant:"error"})}function kr(e){return s.jsx(Be,{...e,variant:"loading"})}function Ar(e){return s.jsx(Be,{...e,variant:"success"})}Be.displayName="FeedbackState";Cr.displayName="EmptyState";Sr.displayName="ErrorState";kr.displayName="LoadingState";Ar.displayName="SuccessState";const $r=({title:e,value:t,description:n,onValueChange:r,className:a=""})=>{const i=g.useId();return s.jsxs("div",{className:d.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",a),"data-testid":"toggle",children:[s.jsxs("div",{className:"flex flex-col items-start",children:[e&&s.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&s.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),s.jsx(d.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},uc={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"},fc=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Dr=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,a)=>r+Object.values(a).reduce((i,l)=>i+l.selectedQuantity,0),0),0),mc=e=>e.reduce((t,n)=>t+n.dates.reduce((r,a)=>r+a.tickets.reduce((i,l)=>i+l.max,0),0),0),vn=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),ds=(e,t,n)=>{const r={};let a=n?t??mc(e):0;for(const{exhibition:i,dateGroup:l,ticket:o}of vn(e)){r[i.id]??={},r[i.id][l.id]??={};const c=n?Math.min(o.max,a):0;r[i.id][l.id][o.id]={id:o.id,selectedQuantity:c,originalPrice:o.originalPrice,discountedPrice:o.price},a-=c}return r},us=(e,t,n)=>`${e}::${t}::${n}`,hc=(e,t,n)=>{const r=Dr(t);for(const{exhibition:a,dateGroup:i,ticket:l}of vn(e)){const o=t[a.id]?.[i.id]?.[l.id]?.selectedQuantity??0,c=n===void 0?l.max:Math.min(l.max,n-(r-o));if(c>0&&o<c)return!1}return!0},xc=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:a=!1})=>{const i=Math.max(t,Math.min(n,e)),[l,o]=g.useState(()=>String(i)),[c,u]=g.useState(!1),f=c?l:String(i),x=()=>{a||i>=n||r?.(i+1)},y=()=>{a||i<=t||r?.(i-1)},h=w=>{if(a)return;o(w.target.value);const k=parseInt(w.target.value,10);isNaN(k)||r?.(Math.max(t,Math.min(n,k)))},C=w=>{const k=parseInt(w.target.value,10);if(u(!1),isNaN(k)){r?.(t);return}const M=Math.max(t,Math.min(n,k));M!==k?r?.(M):o(String(M))},v=i<=t,p=i>=n,b="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",$="bg-primary/40 cursor-not-allowed";return s.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[s.jsx("button",{type:"button",onClick:y,disabled:a||v,className:d.cn(b,a||v?$:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),s.jsx("input",{type:"number",value:f,onChange:h,onFocus:()=>u(!0),onBlur:C,disabled:a,min:t,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"}),s.jsx("button",{type:"button",onClick:x,disabled:a||p,className:d.cn(b,a||p?$:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},pc=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const a=()=>{r||n?.(!t)};return s.jsxs("button",{type:"button",onClick:a,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:d.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:[s.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),s.jsx("span",{className:d.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&s.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"})})]}),s.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},gc=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:a,settings:i,labels:l})=>{const o=()=>{if(!r||a===void 0)return e.max;const x=r();return Math.min(e.max,a-(x-t))},c=i?.locale??"en-US",u=i?.currency??"USD",f=fc(c,u);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?s.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:f.format(e.originalPrice)}),s.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?s.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:e.membershipName,children:s.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,s.jsx("div",{className:"text-sm text-zinc-500",children:s.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[l.ticketsAllowedToRedeem," ",e.max]})})]}),s.jsx(xc,{initialQuantity:t,minQuantity:0,maxQuantity:o(),onChange:n})]}),e.membershipAlert?s.jsx(d.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:s.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},bc=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:a,getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:c})=>s.jsxs("div",{className:d.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[s.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((u,f)=>s.jsxs("div",{children:[s.jsx(gc,{item:u,quantity:a(e,t.id,u.id),onChange:x=>r(e,t.id,u.id,x),getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:c}),f<t.tickets.length-1?s.jsx(d.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),yc=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:l,labels:o,initialExpanded:c=!1})=>{const[u,f]=g.useState(c),x=t.dates.reduce((h,C)=>h+C.tickets.reduce((v,p)=>v+r(t.id,C.id,p.id),0),0),y=t.dates.some(h=>h.tickets.length>0);return s.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[s.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:()=>f(!u),"aria-expanded":u,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:s.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[s.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[x," ",o.ticketsSelectedToRedeem]}),s.jsx("span",{className:d.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:s.jsx(V,{icon:"mdi:chevron-down"})})]})]})}),s.jsx("div",{id:`upgrade-items-${t.id}`,className:d.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&s.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:y?t.dates.map((h,C)=>s.jsx(bc,{exhibitionId:t.id,dateGroup:h,isLast:C===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:l,labels:o},h.id)):s.jsx("div",{className:"px-5 py-10 text-center",children:s.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},vc=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:a,className:i="",onSelectionChange:l})=>{const o=g.useMemo(()=>a??[],[a]),c={...uc,...n},[u,f]=g.useState(()=>ds(o,t,!0)),x=g.useRef(!1),y=g.useMemo(()=>{const N=vn(o).map(({exhibition:$,dateGroup:w,ticket:k})=>[us($.id,w.id,k.id),k]);return new Map(N)},[o]),h=hc(o,u,t),C=(N,$,w)=>u[N]?.[$]?.[w]?.selectedQuantity??0,v=()=>Dr(u),p=(N,$,w,k)=>{const M=C(N,$,w),F=v()-M;if(t!==void 0&&F+k>t)return;const W=y.get(us(N,$,w));if(!W)return;const I={...u,[N]:{...u[N],[$]:{...u[N]?.[$],[w]:{id:w,selectedQuantity:k,originalPrice:W.originalPrice,discountedPrice:W.price}}}};f(I),l?.(I)},b=N=>{const $=ds(o,t,N);f($),l?.($)};return g.useEffect(()=>{!x.current&&h&&(l?.(u),x.current=!0)},[h,u,l]),s.jsxs("div",{className:d.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[s.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[s.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),s.jsx(pc,{label:c.selectAllButtonLabel,checked:h,onChange:b})]}),o.map(N=>s.jsx(yc,{title:N.exhibitionName,exhibition:N,onQuantityChange:p,getTicketQuantity:C,getTotalSelectedTickets:v,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},N.id))]})},Rt={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Bt=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},jc=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const a=e[r.id]??[];n[r.id]=a.length>0?a[0]:null}return n},wc=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,Er=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:a="default",triggerSize:i="sm",triggerClassName:l,popoverClassName:o,className:c,sections:u,onConfirm:f,onClear:x,appliedCount:y,countAriaLabel:h,countDisplay:C="badge",confirmLabel:v=Rt.confirm,clearLabel:p=Rt.clear,isOpen:b,defaultOpen:N=!1,onOpenChange:$,isDisabled:w=!1,closeOnConfirm:k=!0,keepOpenAfterClear:M=!1})=>{const[F,W]=g.useState(N),[I,P]=g.useState(()=>Bt(u)),D=b??F,S=y??u.filter(B=>wc(B)).length,E=B=>{B&&P(Bt(u)),b||W(B),$?.(B)},L=(B,U)=>{P(Z=>({...Z,[B.id]:U}))},R=(B,U)=>{P(Z=>({...Z,[B.id]:U?[U]:[]}))},G=async()=>{P(Bt(u.map(B=>B.type==="checkbox"?{...B,selectedValues:[]}:{...B,selectedValue:null}))),await x(),M||E(!1)},Q=async()=>{const B=jc(I,u);await f(B),k&&E(!1)},J=B=>{if(B.type==="checkbox")return s.jsx(d.CheckboxGroup,{label:B.label,value:I[B.id]??[],onValueChange:Z=>L(B,Z),children:B.options.map(Z=>s.jsx(d.Checkbox,{value:Z.value,isDisabled:Z.isDisabled,children:Z.label},Z.value))},B.id);const U=I[B.id]?.[0]??"";return s.jsx(d.RadioGroup,{label:B.label,value:U,onValueChange:Z=>R(B,Z||null),children:B.options.map(Z=>s.jsx(d.Radio,{value:Z.value,isDisabled:Z.isDisabled,children:Z.label},Z.value))},B.id)},se=g.useMemo(()=>S>0?h?.(S)||`${S} filters applied`:void 0,[h,S]),K=g.useMemo(()=>S===0?e||Rt.noLabel:h?h(S):`${e} (${S})`,[S,e,h]);return s.jsx("div",{className:c,children:s.jsxs(d.Popover,{isOpen:D,onOpenChange:E,placement:"bottom-end",children:[s.jsx(d.PopoverTrigger,{children:s.jsxs(q,{isDisabled:w,variant:r,color:a,size:i,className:l,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":D,children:[s.jsx(V,{icon:n,width:16}),s.jsx("span",{children:e}),C==="badge"&&S>0?s.jsx("span",{className:"ml-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-xs font-medium text-white","aria-label":se,children:S}):C==="summary"&&K!==e?s.jsx("span",{className:"text-xs",children:K}):null]})}),s.jsx(d.PopoverContent,{className:o,children:s.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(B=>J(B)),s.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[s.jsx(q,{variant:"light",color:"default",size:"sm",onPress:G,children:p}),s.jsx(q,{color:"primary",size:"sm",onPress:Q,children:v})]})]})})]})})};Er.displayName="FilterPopover";const Nc="No sessions available for this date",Cc=e=>e==="sold-out"||e==="closed"?"danger":"success",Sc=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},fs=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",kc=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,Ir=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:a,quickDates:i,selectedSessionId:l=null,onSessionSelect:o,emptyStateMessage:c=Nc,statusLabel:u,statusTone:f,sessionAriaLabel:x,dayButtonClassName:y,calendarSlot:h,dayGroupAriaLabel:C,sessionGridAriaLabel:v,className:p,headingClassName:b,subheadingClassName:N})=>{const $=kc(n,r),w=n.find(I=>I.date===$),k=i??n.map(I=>({date:I.date,label:I.label})),M=w?.sessions??[],F=I=>I===$?"solid":"bordered",W=I=>{if(!fs(I)){if(I.id===l){o(null);return}o(I.id)}};return s.jsxs("section",{className:d.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",p),"data-testid":"session-timeline-root",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsx("h2",{className:d.cn("text-base font-semibold text-gray-900",b),children:e}),t?s.jsx("p",{className:d.cn("text-sm text-gray-700",N),children:t}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":C||"Session days",children:[k.map(I=>s.jsx(q,{size:"sm",variant:F(I.date),color:"default",className:d.cn("rounded-full",y),isDisabled:I.isDisabled,onPress:()=>{a(I.date)},children:s.jsx("span",{children:I.label})},I.date)),h?s.jsx("div",{children:h}):null]}),s.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":v||"Sessions",children:[M.length===0?s.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:c}):null,M.map(I=>{const P=fs(I),D=I.id===l;return s.jsx("li",{className:"rounded-xl",children:s.jsx(d.Card,{shadow:"sm",radius:"lg",isPressable:!P,onPress:()=>{W(I)},"aria-disabled":P,"aria-pressed":P?void 0:D,className:d.cn("w-full",P?"bg-gray-100 opacity-70":"",D?"w-full ring-2 ring-gray-900":""),"aria-label":x?x(I,{isSelected:D,isUnavailable:P}):P?`${I.startTime} ${I.endTime} sold out`:`${I.startTime} ${I.endTime} available`,children:s.jsxs(d.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[s.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[I.startTime," – ",I.endTime]}),s.jsx(d.Chip,{size:"sm",color:f?f(I):Cc(I.status),variant:"flat",children:u?u(I):Sc(I)})]})})},I.id)})]})]})};Ir.displayName="SessionTimeline";const Ac=350,$c={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}"},Vt=(e,t)=>Object.entries(t).reduce((n,[r,a])=>n.replace(`{${r}}`,a),e),Dc=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:a="en-US",labels:i,isDisabled:l=!1,maxAmount:o,autoFocus:c=!1,className:u,"data-testid":f="cash-tender-form"})=>{const x={...$c,...i},y=sn(e.currency,a),h=t!==void 0,[C,v]=g.useState(n??null),p=h?t:C,b=g.useMemo(()=>{const E=typeof p=="number"&&Number.isFinite(p)?p:0,L=Ht(E,e.value,e.currency,a);return{received:E,change:L>0?L:0,isValid:E>=e.value&&E>0}},[p,e.value,e.currency,a]),N=g.useCallback(E=>{const L=E.currentTarget;requestAnimationFrame(()=>{L.isConnected&&L.select()})},[]),$=g.useCallback(E=>{if(l)return;const L=E.replace(/[^\d.,]/g,"").replace(",","."),R=L===""?null:Number.parseFloat(L),G=R===null||Number.isNaN(R)?null:R;if(G!==null&&o!==void 0&&G>o)return;h||v(G);const Q=typeof G=="number"&&Number.isFinite(G)?G:0,J=Ht(Q,e.value,e.currency,a);r?.({received:Q,change:J>0?J:0,isValid:Q>=e.value&&Q>0})},[h,l,e.value,e.currency,a,r,o]),w=p==null?"":String(p),k=b.isValid&&b.change>0,M=!b.isValid&&b.received>0,F=$e(b.change,a,e.currency),W=$e(e.value,a,e.currency),[I,P]=g.useState(""),D=g.useRef(null);g.useEffect(()=>{D.current&&clearTimeout(D.current);const E=k?Vt(x.changeMessageTemplate,{change:F}):"",L=k?Ac:0;return D.current=setTimeout(()=>P(E),L),()=>{D.current&&clearTimeout(D.current)}},[k,F,x.changeMessageTemplate]);const S=`${f}-received`;return s.jsxs("div",{className:d.cn("flex flex-col gap-3",u),"data-testid":f,children:[s.jsx(d.Input,{id:S,label:x.receivedLabel,labelPlacement:"outside",type:"text",inputMode:y===0?"numeric":"decimal",pattern:y===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:w,onChange:E=>$(E.target.value),onFocus:N,placeholder:x.receivedPlaceholder,isDisabled:l,isInvalid:M,errorMessage:M?Vt(x.insufficientMessageTemplate,{due:W}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${f}-received-input`}),k&&s.jsx(d.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:x.changeLabel,description:Vt(x.changeMessageTemplate,{change:F}),icon:s.jsx(V,{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"}}),s.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:I})]})},Ec={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},ms=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},Mr=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:a,hideDate:i=!1,hideBankName:l=!1,isDisabled:o=!1,checkNumberMaxLength:c=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:x,"data-testid":y="check-tender-form"})=>{const h={...Ec,...a},C=t!==void 0,[v,p]=g.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??ms()}),[b,N]=g.useState(!!n?.checkNumber),$=g.useMemo(()=>C?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??ms()}:v,[C,t,v]),w=g.useCallback(D=>{C||p(D);const S=D.checkNumber.trim(),E={amount:e.value,checkNumber:S,bankName:D.bankName.trim()||void 0,date:i?void 0:D.date,isValid:S.length>0&&e.value>0};r?.(E)},[C,e.value,i,r]),k=g.useCallback(D=>S=>{o||(D==="checkNumber"&&S.length>0&&N(!0),w({...$,[D]:S}))},[$,w,o]),M=g.useCallback(()=>{o||N(!0)},[o]),F=b&&$.checkNumber.trim()==="",W=`${y}-check-number`,I=`${y}-bank-name`,P=`${y}-date`;return s.jsxs("div",{className:d.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",x),"data-testid":y,children:[s.jsx(d.Input,{id:W,label:h.checkNumberLabel,labelPlacement:"outside",type:"text",value:$.checkNumber,onChange:D=>k("checkNumber")(D.target.value),onBlur:M,placeholder:h.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:F,errorMessage:F?h.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${y}-check-number-input`}),!l&&s.jsx(d.Input,{id:I,label:h.bankNameLabel,labelPlacement:"outside",type:"text",value:$.bankName,onChange:D=>k("bankName")(D.target.value),placeholder:h.bankNamePlaceholder,maxLength:u,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${y}-bank-name-input`}),!i&&s.jsx(d.Input,{id:P,label:h.dateLabel,labelPlacement:"outside",type:"date",value:$.date,onChange:D=>k("date")(D.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${y}-date-input`,className:"sm:col-span-2"})]})};Mr.displayName="CheckTenderForm";const Ic={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Mc=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Fr=({dueAmount:e,methodOptions:t=Mc,value:n,defaultValue:r,onChange:a,labels:i,showReference:l=!1,isDisabled:o=!1,className:c,"data-testid":u="other-tender-form"})=>{const f={...Ic,...i},x=n!==void 0,[y,h]=g.useState({method:r?.method??"",reference:r?.reference??""}),C=g.useMemo(()=>x?{method:n?.method??"",reference:n?.reference??""}:y,[x,n,y]),v=g.useCallback(k=>t.find(M=>M.value===k)?.label??"",[t]),p=g.useCallback(k=>{x||h(k);const M=v(k.method),F={amount:e.value,method:k.method,description:M,reference:k.reference.trim()||void 0,isValid:k.method!==""};a?.(F)},[x,e.value,a,v]),b=g.useCallback(k=>{if(o)return;const M=typeof k=="string"?k:Array.from(k)[0]?.toString()??"";p({...C,method:M})},[C,p,o]),N=g.useCallback(k=>{o||p({...C,reference:k})},[C,p,o]),$=`${u}-method`,w=`${u}-reference`;return s.jsxs("div",{className:d.cn("flex flex-col gap-3",c),"data-testid":u,children:[s.jsx(Te,{id:$,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:C.method?[C.method]:[],onSelectionChange:b,isDisabled:o,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${u}-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:t.map(k=>s.jsx(d.SelectItem,{"data-testid":`${u}-method-option-${k.value}`,children:k.label},k.value))}),l&&s.jsx(d.Input,{id:w,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:C.reference,onChange:k=>N(k.target.value),placeholder:f.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};Fr.displayName="OtherTenderForm";const Fc={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},Tc={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Lc={pending:"warning",recorded:"success",failed:"danger"},_c=e=>e==="pending"||e==="recorded",Pc=e=>`#${e+1}`,Tr=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:a,hideCollectedList:i=!1,className:l,"data-testid":o="split-payment-summary"})=>{const c={...Fc,...a},{collected:u,remaining:f,isComplete:x}=g.useMemo(()=>{const h=t.reduce((v,p)=>_c(p.status)?v+p.amount:v,0),C=Math.max(e.value-h,0);return{collected:h,remaining:C,isComplete:h>=e.value&&e.value>0}},[t,e.value]),y=h=>h==="pending"?c.statusPending:h==="recorded"?c.statusRecorded:c.statusFailed;return s.jsxs("div",{className:d.cn("flex flex-col gap-4",l),"data-testid":o,children:[s.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[s.jsx("div",{className:"text-sm text-default-600",children:x?c.completeLabel:c.remainingLabel}),s.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:$e(x?u:f,r,e.currency)})]}),!i&&t.length>0&&s.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[s.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((h,C)=>s.jsx(Oc,{index:C,tender:h,locale:r,currency:e.currency,removable:!!n&&h.status!=="recorded",onRemove:n?()=>n(h.id):void 0,statusLabel:y(h.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${o}-row-${C}`},h.id))]})]})};Tr.displayName="SplitPaymentSummary";const Oc=({index:e,tender:t,locale:n,currency:r,removable:a,onRemove:i,statusLabel:l,removeAriaLabel:o,recordedTooltip:c,dataTestId:u})=>{const f=i?s.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!a,"aria-label":o,"data-testid":`${u}-remove`,className:d.cn(a?"text-default-700 hover:bg-default-200":"text-default-300"),children:s.jsx(V,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return s.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":u,children:[s.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:Pc(e)}),s.jsx(V,{icon:Tc[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:t.label}),s.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:$e(t.amount,n,r)}),s.jsx(d.Chip,{size:"sm",radius:"full",variant:"flat",color:Lc[t.status],startContent:t.status==="recorded"?s.jsx(V,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?s.jsx(V,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:l}),f&&(a?f:s.jsx(d.Tooltip,{content:c,placement:"left",children:s.jsx("span",{tabIndex:0,"aria-label":c,children:f})}))]})},zc=`
|
|
20
11
|
@keyframes pp-modal-in {
|
|
21
12
|
from { opacity: 0; transform: scale(0.96); }
|
|
22
13
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -41,5 +32,5 @@
|
|
|
41
32
|
from { opacity: 0; transform: translateY(-6px); }
|
|
42
33
|
to { opacity: 1; transform: translateY(0); }
|
|
43
34
|
}
|
|
44
|
-
`,io=y.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>l.jsxs(l.Fragment,{children:[l.jsx("style",{children:Um}),l.jsx("div",{ref:i,"data-testid":s,style:r,className:f.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"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:e})]}));io.displayName="ModalShell";const ao=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>l.jsxs("header",{className:f.cn("flex items-center justify-between",s),"data-testid":i,children:[l.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:l.jsx(U,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});ao.displayName="ModalShellHeader";const lo=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>l.jsx("footer",{className:f.cn("mt-2 gap-3",t===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:e});lo.displayName="ModalShellFooter";const qm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Wm={1:"grid-cols-1",2:"grid-cols-2"},Sr=e=>typeof e=="string"?l.jsx(U,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,oo=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:o,"data-testid":c="tile-select"})=>{const d=e.find(u=>u.key===t);return l.jsxs("div",{className:f.cn("flex flex-col gap-3",o),"data-testid":c,children:[r&&l.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),l.jsx("div",{className:"md:hidden",children:l.jsx(yt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:d?l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(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:e.map(u=>l.jsx(f.SelectItem,{isDisabled:u.isDisabled,startContent:l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(u.icon)}),"data-testid":u["data-testid"]??`${c}-${u.key}-mobile`,children:u.label},u.key))})}),l.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:s,className:f.cn("hidden md:grid gap-3",Wm[a],qm[i]),children:e.map(u=>{const h=t===u.key;return l.jsxs(K,{variant:"bordered",radius:"lg","aria-pressed":h,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${c}-${u.key}`,className:f.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",h?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[l.jsx("span",{"aria-hidden":"true",children:Sr(u.icon)}),l.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};oo.displayName="TileSelect";const Km={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},co=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=Km[r];return l.jsxs("div",{"data-testid":i,className:f.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[l.jsx("div",{className:"text-sm text-default-600",children:t}),l.jsx("div",{className:f.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:rt(e.value,n,e.currency)})]})};co.displayName="PaymentTotalBanner";const Jm={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},uo=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>l.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:f.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Jm[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:[l.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]"}),l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&l.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});uo.displayName="LoadingOverlay";const Cs=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:a="left",className:o,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const d=a==="center";return l.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:f.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]",o),children:[l.jsx(U,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),l.jsxs("div",{className:f.cn("flex flex-col",d?"items-center":"flex-1"),children:[l.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),l.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:rt(e.value,r,e.currency)}),n&&l.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${c}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Cs.displayName="PaymentCashChangeBanner";const fo=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:a="en-US",closeLabel:o="Close",onClose:c,className:d,"data-testid":u="payment-success-view"})=>{const h=!!(s&&s.value>0);return l.jsxs("div",{"data-testid":u,className:f.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:[l.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:l.jsx(U,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:e}),l.jsx("p",{className:"text-default-700",children:t}),n&&r&&l.jsxs("p",{className:"text-default-700",children:[n,l.jsx("br",{}),l.jsx("strong",{className:"font-semibold",children:r})]})]}),h&&s&&l.jsx(Cs,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&l.jsx(K,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:o})]})};fo.displayName="PaymentSuccessView";const ho=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:c,autoFocus:d,maxAmount:u,className:h,"data-testid":p="payment-sub-amount-input"})=>{const m=`${p}-input`,v=y.useCallback(x=>{if(u!==void 0){const w=Number.parseFloat(x.replace(",","."));if(Number.isFinite(w)&&w>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const w=x.currentTarget;requestAnimationFrame(()=>{w.isConnected&&w.select()})},[]);return l.jsxs("div",{className:f.cn("flex flex-col gap-3 border-t border-default-100 pt-5",h),"data-testid":p,children:[l.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:e}),l.jsx(f.Input,{id:m,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:x=>v(x.target.value),onFocus:b,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:o?c:void 0,variant:"bordered",radius:"lg","aria-invalid":o||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};ho.displayName="PaymentSubAmountInput";const mo=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:o,"data-testid":c="confirm-dialog"})=>l.jsx(f.Modal,{isOpen:e,onOpenChange:d=>{d||o()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),l.jsx(f.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[l.jsx(K,{variant:"bordered",radius:"full",onPress:o,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),l.jsx(K,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});mo.displayName="ConfirmDialog";const Ym=60,Gm=(e,t,n=Ym)=>t?e>n:e<-n,po=(e,t)=>Math.max(0,Math.min(e,t)),Qm=(e,t,n)=>po(e-t,n),Zm=(e,t,n)=>e!==null?po(e,n):t?n:0,Xm=e=>e?"":"transition-[height] duration-300 ease-out",ep=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(Qm(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{Gm(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),ln=(e,t)=>rt(e.value,t,e.currency),js=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const s=!!e.children&&e.children.length>0;return l.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&l.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,l.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:f.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),l.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&l.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)}),n&&l.jsx(K,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:l.jsx(U,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&l.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&l.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.from}),l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.to})]}),s&&l.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>l.jsx(js,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};js.displayName="SummaryItemRow";const go=({fee:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-service-fee",className:f.cn("flex items-center justify-between gap-2",n),children:[l.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[l.jsx("span",{"aria-hidden":"true",className:f.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&l.jsx("span",{className:"size-2 rounded-full bg-primary"})}),l.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),l.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)})]});go.displayName="SummaryServiceFeeRow";const xo=({row:e,locale:t,emphasized:n})=>l.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[l.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:f.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),l.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:ln(e.amount,t)})]});xo.displayName="SummaryTotalsLineRow";const yo=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:s,locale:i,onRemoveItem:a,removeAriaLabel:o,emptyState:c,classNames:d})=>{const u=(n?.length??0)>0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{"data-testid":"summary-prices",className:f.cn("flex items-center justify-between text-xs text-default-500",d.prices),children:[l.jsx("span",{children:e}),t!=null&&l.jsx("span",{children:t})]}),u?l.jsx("div",{className:f.cn("flex flex-col gap-4",d.items),children:n.map(h=>l.jsx(js,{item:h,locale:i,onRemove:a,removeAriaLabel:o},h.id))}):l.jsx("div",{"data-testid":"summary-empty",children:c}),r&&l.jsxs(l.Fragment,{children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsx(go,{fee:r,locale:i,className:d.serviceFee})]}),s&&s.length>0&&l.jsx("div",{className:f.cn("flex flex-col gap-4",d.totalsRows),children:s.map((h,p)=>l.jsx(xo,{row:h,locale:i,emphasized:p===0},h.key))})]})};yo.displayName="SummaryBody";const bo=({total:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-total",className:f.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[l.jsx("span",{children:e.label??"Total"}),l.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:ln(e.amount,t)})]});bo.displayName="SummaryGrandTotalRow";const _n=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>l.jsx(K,{color:"primary",radius:"full",className:f.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});_n.displayName="SummaryPrimaryCta";const vo=({title:e,total:t,locale:n,open:r,progress:s,dragging:i,toggleAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsx("h2",{children:l.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":a,onClick:o,className:f.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[l.jsxs("span",{"aria-hidden":!r,style:{opacity:s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),l.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:f.cn("shrink-0 text-foreground",c.closeButton),children:l.jsx(U,{icon:"lucide:x",width:20,height:20})})]}),l.jsxs("span",{"aria-hidden":r,style:{opacity:1-s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{children:t.label??"Total"}),l.jsx("span",{className:"whitespace-nowrap",children:ln(t.amount,n)})]})]})});vo.displayName="SummaryCollapseHeader";const wo=({cart:e,ariaLabel:t,onPress:n,className:r})=>l.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:f.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[l.jsx(U,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&l.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});wo.displayName="SummaryCartButton";const ko=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:s,cart:i,cartAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsxs("div",{"data-testid":"summary-mobile-bar",className:f.cn("flex flex-col gap-4",c.mobileBar),children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsxs("div",{className:"grid",children:[l.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:f.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&l.jsx(wo,{cart:i,ariaLabel:a,className:c.cart,onPress:()=>{o?.(),i.onPress?.()}}),r&&l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&l.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:f.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("w-full",c.cta)})})]})]});ko.displayName="SummaryActionBar";const tp="(max-width: 767px)",np=e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,rp=(e=tp)=>{const[t,n]=y.useState(()=>np(e));return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),s=()=>n(r.matches);return s(),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t},No=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:s,serviceFee:i,rows:a,total:o,collapsible:c,isOpen:d,onToggleOpen:u,primaryAction:h,isLoading:p=!1,onRemoveItem:m,variant:v,cart:b,emptyState:x,labels:w,classNames:S={},"data-testid":M="summary",className:N})=>{const j=w?.removeAriaLabel??"Remove item",T=w?.toggleAriaLabel??"Toggle summary",$=w?.cartAriaLabel??"View cart",W=rp(),R=c??(v??(W?"mobile":"main"))==="mobile",E=!R||(d??!1),[C,I]=y.useState(0),[F,H]=y.useState(null),Q=y.useCallback(G=>{G&&I(G.scrollHeight)},[]),Y=ep({open:E,fullHeight:C,setDragHeight:H,onToggleOpen:u}),te=F!==null,oe=Zm(F,E,C),ce=C>0?Math.min(1,Math.max(0,oe/C)):E?1:0,P=l.jsx(bo,{total:o,locale:r,className:S.total}),_=l.jsx(yo,{pricesInLabel:t,currency:n,items:s,serviceFee:i,rows:a,locale:r,onRemoveItem:m,removeAriaLabel:j,emptyState:x,classNames:S});return R?l.jsxs(Pe.motion.section,{"data-testid":M,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:Y.onDrag,onDragEnd:Y.onDragEnd,className:f.cn("fixed inset-x-0 bottom-0 z-50 flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",N,S.base),children:[l.jsx(vo,{title:e,total:o,locale:r,open:E,progress:ce,dragging:te,toggleAriaLabel:T,onToggleOpen:u,classNames:S}),l.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!E,style:{height:oe},className:f.cn("overflow-hidden",!E&&"pointer-events-none",Xm(te)),children:l.jsxs("div",{ref:Q,className:"flex flex-col gap-4 pb-4",children:[_,l.jsx(f.Divider,{className:"bg-default-200"}),P]})}),l.jsx(ko,{open:E,progress:ce,dragging:te,primaryAction:h,isLoading:p,cart:b,cartAriaLabel:$,onToggleOpen:u,classNames:S})]}):l.jsxs("section",{"data-testid":M,className:f.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",N,S.base),children:[l.jsx("div",{className:f.cn("flex items-center justify-between",S.header),children:l.jsx("h2",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",S.title),children:e})}),_,l.jsx(f.Divider,{className:"bg-default-200"}),P,h&&l.jsx(_n,{action:h,disabledByLoading:p,className:f.cn("w-full",S.cta)})]})};No.displayName="Summary";exports.Button=K;exports.CashTenderForm=Om;exports.CatalogItemCard=Kl;exports.CheckTenderForm=no;exports.CommitmentDetails=Nh;exports.ConfirmDialog=mo;exports.ConfirmationModal=Rn;exports.ConfirmationPageTemplate=Vo;exports.DonationAmounts=qa;exports.EmptyState=Jl;exports.ErrorState=Yl;exports.EventDetails=If;exports.EventDetailsTemplate=qo;exports.ExpireCartTimer=Wa;exports.FeedbackState=It;exports.FilterPopover=eo;exports.Footer=Wo;exports.HeroUIProvider=Fo;exports.InstallmentFundAssignment=xh;exports.InstallmentFundAssignmentSkeleton=wh;exports.InstallmentSchedule=Qh;exports.InstallmentScheduleSkeleton=rm;exports.InstallmentTable=im;exports.ItemCard=Wl;exports.LoadingOverlay=uo;exports.LoadingState=Gl;exports.MembershipSelectCards=cm;exports.ModalShell=io;exports.ModalShellFooter=lo;exports.ModalShellHeader=ao;exports.Multiselect=Ko;exports.Navbar=_o;exports.OfferCard=On;exports.OfferCardEmpty=ll;exports.OfferCardError=ol;exports.OfferCardList=fl;exports.OfferCardSkeleton=cl;exports.OtherTenderForm=ro;exports.PaymentCashChangeBanner=Cs;exports.PaymentSubAmountInput=ho;exports.PaymentSuccessView=fo;exports.PaymentTotalBanner=co;exports.RICH_TEXT_PRESETS=Ha;exports.RevenueDistributionCard=Sl;exports.RevenueDistributionEmpty=Cl;exports.RevenueDistributionError=jl;exports.RevenueDistributionSkeleton=Al;exports.RichTextArea=Ua;exports.Select=yt;exports.SessionTimeline=to;exports.SplitPaymentSummary=so;exports.Stepper=Yi;exports.SuccessState=Ql;exports.Summary=No;exports.TicketSelection=Cm;exports.TileSelect=oo;exports.Toggle=Zl;exports.calculateAllocationDifference=dh;exports.computeChange=Cr;exports.currencyFractionDigits=Gr;exports.formatMoney=rt;exports.formatOfferCurrency=al;exports.formatRevenueAmount=ah;exports.formatRevenueCurrency=lh;exports.generateAutomaticInstallments=Hl;exports.generateDistributionId=vs;exports.getCurrencySymbol=oh;exports.offerCardVariants=ul;exports.offerListVariants=dl;exports.parseOfferCurrency=$f;exports.parseRevenueCurrency=ch;exports.roundToCurrency=Gi;Object.keys(f).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>f[e]})});
|
|
35
|
+
`,Lr=g.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":a="modal-shell"},i)=>s.jsxs(s.Fragment,{children:[s.jsx("style",{children:zc}),s.jsx("div",{ref:i,"data-testid":a,style:r,className:d.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"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:e})]}));Lr.displayName="ModalShell";const _r=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:a,"data-testid":i="modal-shell-header"})=>s.jsxs("header",{className:d.cn("flex items-center justify-between",a),"data-testid":i,children:[s.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&s.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:s.jsx(V,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});_r.displayName="ModalShellHeader";const Pr=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>s.jsx("footer",{className:d.cn("mt-2 gap-3",t===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:e});Pr.displayName="ModalShellFooter";const Rc={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Bc={1:"grid-cols-1",2:"grid-cols-2"},Ut=e=>typeof e=="string"?s.jsx(V,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,Or=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:a="Select an option",columnsDesktop:i=3,columnsMobile:l=2,className:o,"data-testid":c="tile-select"})=>{const u=e.find(f=>f.key===t);return s.jsxs("div",{className:d.cn("flex flex-col gap-3",o),"data-testid":c,children:[r&&s.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),s.jsx("div",{className:"md:hidden",children:s.jsx(Te,{"aria-label":r?void 0:a,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:f=>{const y=Array.from(f)[0];typeof y=="string"&&n(y)},placeholder:a,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:u?s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Ut(u.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:e.map(f=>s.jsx(d.SelectItem,{isDisabled:f.isDisabled,startContent:s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Ut(f.icon)}),"data-testid":f["data-testid"]??`${c}-${f.key}-mobile`,children:f.label},f.key))})}),s.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:a,className:d.cn("hidden md:grid gap-3",Bc[l],Rc[i]),children:e.map(f=>{const x=t===f.key;return s.jsxs(q,{variant:"bordered",radius:"lg","aria-pressed":x,"aria-label":f.label,isDisabled:f.isDisabled,onPress:()=>n(f.key),"data-testid":f["data-testid"]??`${c}-${f.key}`,className:d.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",x?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[s.jsx("span",{"aria-hidden":"true",children:Ut(f.icon)}),s.jsx("span",{className:"text-sm font-medium",children:f.label})]},f.key)})})]})};Or.displayName="TileSelect";const Vc={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},zr=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:a,"data-testid":i="payment-total-banner"})=>{const l=Vc[r];return s.jsxs("div",{"data-testid":i,className:d.cn("rounded-2xl px-6 py-5 text-center",l.wrapper,a),children:[s.jsx("div",{className:"text-sm text-default-600",children:t}),s.jsx("div",{className:d.cn("mt-1 text-4xl font-bold tracking-tight",l.amount),"data-testid":`${i}-amount`,children:$e(e.value,n,e.currency)})]})};zr.displayName="PaymentTotalBanner";const Uc={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Rr=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:a,"data-testid":i="loading-overlay"})=>s.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:d.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Uc[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",a),children:[s.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]"}),s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&s.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});Rr.displayName="LoadingOverlay";const jn=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:a,dismissAriaLabel:i="Dismiss",align:l="left",className:o,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const u=l==="center";return s.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:d.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",u?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",o),children:[s.jsx(V,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),s.jsxs("div",{className:d.cn("flex flex-col",u?"items-center":"flex-1"),children:[s.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),s.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:$e(e.value,r,e.currency)}),n&&s.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),a&&s.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:a,"aria-label":i,"data-testid":`${c}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:s.jsx(V,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};jn.displayName="PaymentCashChangeBanner";const Br=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:a,cashChangeLabel:i="Cash to return",locale:l="en-US",closeLabel:o="Close",onClose:c,className:u,"data-testid":f="payment-success-view"})=>{const x=!!(a&&a.value>0);return s.jsxs("div",{"data-testid":f,className:d.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",u),children:[s.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:s.jsx(V,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h2",{className:"text-2xl font-bold","data-testid":`${f}-title`,children:e}),s.jsx("p",{className:"text-default-700",children:t}),n&&r&&s.jsxs("p",{className:"text-default-700",children:[n,s.jsx("br",{}),s.jsx("strong",{className:"font-semibold",children:r})]})]}),x&&a&&s.jsx(jn,{cashChange:a,label:i,locale:l,align:"center",className:"max-w-[400px]","data-testid":`${f}-cash-change`}),c&&s.jsx(q,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${f}-close`,className:"mt-4 w-full",children:o})]})};Br.displayName="PaymentSuccessView";const Vr=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:a,placeholder:i,isDisabled:l,isInvalid:o,errorMessage:c,autoFocus:u,maxAmount:f,className:x,"data-testid":y="payment-sub-amount-input"})=>{const h=`${y}-input`,C=g.useCallback(p=>{if(f!==void 0){const b=Number.parseFloat(p.replace(",","."));if(Number.isFinite(b)&&b>f)return}a?.(p)},[f,a]),v=g.useCallback(p=>{const b=p.currentTarget;requestAnimationFrame(()=>{b.isConnected&&b.select()})},[]);return s.jsxs("div",{className:d.cn("flex flex-col gap-3 border-t border-default-100 pt-5",x),"data-testid":y,children:[s.jsx("h3",{className:"text-lg font-semibold","data-testid":`${y}-heading`,children:e}),s.jsx(d.Input,{id:h,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:p=>C(p.target.value),onFocus:v,placeholder:i,isDisabled:l,isInvalid:o,errorMessage:o?c:void 0,variant:"bordered",radius:"lg","aria-invalid":o||void 0,autoFocus:u,"data-testid":`${y}-field`})]})};Vr.displayName="PaymentSubAmountInput";const Ur=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:a="danger",dismissLabel:i,onConfirm:l,onDismiss:o,"data-testid":c="confirm-dialog"})=>s.jsx(d.Modal,{isOpen:e,onOpenChange:u=>{u||o()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:s.jsxs(d.ModalContent,{children:[s.jsx(d.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),s.jsx(d.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),s.jsxs(d.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[s.jsx(q,{variant:"bordered",radius:"full",onPress:o,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),s.jsx(q,{color:a,variant:"solid",radius:"full",onPress:l,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});Ur.displayName="ConfirmDialog";const Hc=60,qc=(e,t,n=Hc)=>t?e>n:e<-n,Hr=(e,t)=>Math.max(0,Math.min(e,t)),Wc=(e,t,n)=>Hr(e-t,n),Yc=(e,t,n)=>e!==null?Hr(e,n):t?n:0,Gc=e=>e?"":"transition-[height] duration-300 ease-out",Qc=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(Wc(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{qc(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),at=(e,t)=>$e(e.value,t,e.currency),wn=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const a=!!e.children&&e.children.length>0;return s.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&s.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,s.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:d.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),s.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&s.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:at(e.amount,t)}),n&&s.jsx(q,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:s.jsx(V,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&s.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[s.jsx(V,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&s.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[s.jsx(V,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),s.jsx("span",{children:e.dateRange.from}),s.jsx(V,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),s.jsx("span",{children:e.dateRange.to})]}),a&&s.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>s.jsx(wn,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};wn.displayName="SummaryItemRow";const qr=({fee:e,locale:t,className:n})=>s.jsxs("div",{"data-testid":"summary-service-fee",className:d.cn("flex items-center justify-between gap-2",n),children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[s.jsx("span",{"aria-hidden":"true",className:d.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&s.jsx("span",{className:"size-2 rounded-full bg-primary"})}),s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),s.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:at(e.amount,t)})]});qr.displayName="SummaryServiceFeeRow";const Wr=({row:e,locale:t,emphasized:n})=>s.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[s.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:d.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),s.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:at(e.amount,t)})]});Wr.displayName="SummaryTotalsLineRow";const Yr=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:a,locale:i,onRemoveItem:l,removeAriaLabel:o,emptyState:c,classNames:u})=>{const f=(n?.length??0)>0;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"summary-prices",className:d.cn("flex items-center justify-between text-xs text-default-500",u.prices),children:[s.jsx("span",{children:e}),t!=null&&s.jsx("span",{children:t})]}),f?s.jsx("div",{className:d.cn("flex flex-col gap-4",u.items),children:n.map(x=>s.jsx(wn,{item:x,locale:i,onRemove:l,removeAriaLabel:o},x.id))}):s.jsx("div",{"data-testid":"summary-empty",children:c}),r&&s.jsxs(s.Fragment,{children:[s.jsx(d.Divider,{className:"bg-default-200"}),s.jsx(qr,{fee:r,locale:i,className:u.serviceFee})]}),a&&a.length>0&&s.jsx("div",{className:d.cn("flex flex-col gap-4",u.totalsRows),children:a.map((x,y)=>s.jsx(Wr,{row:x,locale:i,emphasized:y===0},x.key))})]})};Yr.displayName="SummaryBody";const Gr=({total:e,locale:t,className:n})=>s.jsxs("div",{"data-testid":"summary-total",className:d.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[s.jsx("span",{children:e.label??"Total"}),s.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:at(e.amount,t)})]});Gr.displayName="SummaryGrandTotalRow";const jt=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>s.jsx(q,{color:"primary",radius:"full",className:d.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:s.jsx(V,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});jt.displayName="SummaryPrimaryCta";const Qr=({title:e,total:t,locale:n,open:r,progress:a,dragging:i,toggleAriaLabel:l,onToggleOpen:o,classNames:c})=>s.jsx("h2",{children:s.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":l,onClick:o,className:d.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[s.jsxs("span",{"aria-hidden":!r,style:{opacity:a},className:d.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[s.jsx("span",{"data-testid":"summary-title",className:d.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),s.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:d.cn("shrink-0 text-foreground",c.closeButton),children:s.jsx(V,{icon:"lucide:x",width:20,height:20})})]}),s.jsxs("span",{"aria-hidden":r,style:{opacity:1-a},className:d.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[s.jsx("span",{children:t.label??"Total"}),s.jsx("span",{className:"whitespace-nowrap",children:at(t.amount,n)})]})]})});Qr.displayName="SummaryCollapseHeader";const Kr=({cart:e,ariaLabel:t,onPress:n,className:r})=>s.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:d.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[s.jsx(V,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&s.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});Kr.displayName="SummaryCartButton";const Zr=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:a,cart:i,cartAriaLabel:l,onToggleOpen:o,classNames:c})=>s.jsxs("div",{"data-testid":"summary-mobile-bar",className:d.cn("flex flex-col gap-4",c.mobileBar),children:[s.jsx(d.Divider,{className:"bg-default-200"}),s.jsxs("div",{className:"grid",children:[s.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:d.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&s.jsx(Kr,{cart:i,ariaLabel:l,className:c.cart,onPress:()=>{o?.(),i.onPress?.()}}),r&&s.jsx(jt,{action:r,disabledByLoading:a,className:d.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&s.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:d.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:s.jsx(jt,{action:r,disabledByLoading:a,className:d.cn("w-full",c.cta)})})]})]});Zr.displayName="SummaryActionBar";const Kc="(max-width: 767px)",Zc=e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,Jc=(e=Kc)=>{const[t,n]=g.useState(()=>Zc(e));return g.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),a=()=>n(r.matches);return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t},Jr=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:a,serviceFee:i,rows:l,total:o,collapsible:c,isOpen:u,onToggleOpen:f,primaryAction:x,isLoading:y=!1,onRemoveItem:h,variant:C,cart:v,emptyState:p,labels:b,classNames:N={},"data-testid":$="summary",className:w})=>{const k=b?.removeAriaLabel??"Remove item",M=b?.toggleAriaLabel??"Toggle summary",F=b?.cartAriaLabel??"View cart",W=Jc(),P=c??(C??(W?"mobile":"main"))==="mobile",D=!P||(u??!1),[S,E]=g.useState(0),[L,R]=g.useState(null),G=g.useCallback(Z=>{Z&&E(Z.scrollHeight)},[]),Q=Qc({open:D,fullHeight:S,setDragHeight:R,onToggleOpen:f}),J=L!==null,se=Yc(L,D,S),K=S>0?Math.min(1,Math.max(0,se/S)):D?1:0,B=s.jsx(Gr,{total:o,locale:r,className:N.total}),U=s.jsx(Yr,{pricesInLabel:t,currency:n,items:a,serviceFee:i,rows:l,locale:r,onRemoveItem:h,removeAriaLabel:k,emptyState:p,classNames:N});return P?s.jsxs(ve.motion.section,{"data-testid":$,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:Q.onDrag,onDragEnd:Q.onDragEnd,className:d.cn("fixed inset-x-0 bottom-0 z-50 flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",w,N.base),children:[s.jsx(Qr,{title:e,total:o,locale:r,open:D,progress:K,dragging:J,toggleAriaLabel:M,onToggleOpen:f,classNames:N}),s.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!D,style:{height:se},className:d.cn("overflow-hidden",!D&&"pointer-events-none",Gc(J)),children:s.jsxs("div",{ref:G,className:"flex flex-col gap-4 pb-4",children:[U,s.jsx(d.Divider,{className:"bg-default-200"}),B]})}),s.jsx(Zr,{open:D,progress:K,dragging:J,primaryAction:x,isLoading:y,cart:v,cartAriaLabel:F,onToggleOpen:f,classNames:N})]}):s.jsxs("section",{"data-testid":$,className:d.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",w,N.base),children:[s.jsx("div",{className:d.cn("flex items-center justify-between",N.header),children:s.jsx("h2",{"data-testid":"summary-title",className:d.cn("text-xl font-semibold leading-7 text-foreground",N.title),children:e})}),U,s.jsx(d.Divider,{className:"bg-default-200"}),B,x&&s.jsx(jt,{action:x,disabledByLoading:y,className:d.cn("w-full",N.cta)})]})};Jr.displayName="Summary";exports.Button=q;exports.CashTenderForm=Dc;exports.CatalogItemCard=Nr;exports.CheckTenderForm=Mr;exports.CommitmentDetails=uo;exports.ConfirmDialog=Ur;exports.ConfirmationModal=Ct;exports.ConfirmationPageTemplate=La;exports.DonationAmounts=vs;exports.EmptyState=Cr;exports.ErrorState=Sr;exports.EventDetails=gl;exports.EventDetailsTemplate=Oa;exports.ExpireCartTimer=js;exports.FeedbackState=Be;exports.FilterPopover=Er;exports.Footer=za;exports.HeroUIProvider=Da;exports.InstallmentFundAssignment=ao;exports.InstallmentFundAssignmentSkeleton=oo;exports.InstallmentSchedule=qo;exports.InstallmentScheduleSkeleton=Zo;exports.InstallmentTable=ec;exports.ItemCard=wr;exports.LoadingOverlay=Rr;exports.LoadingState=kr;exports.MembershipSelectCards=rc;exports.ModalShell=Lr;exports.ModalShellFooter=Pr;exports.ModalShellHeader=_r;exports.Multiselect=Ra;exports.Navbar=Ta;exports.OfferCard=xt;exports.OfferCardEmpty=_s;exports.OfferCardError=Ps;exports.OfferCardList=Bs;exports.OfferCardSkeleton=Os;exports.OtherTenderForm=Fr;exports.PaymentCashChangeBanner=jn;exports.PaymentSubAmountInput=Vr;exports.PaymentSuccessView=Br;exports.PaymentTotalBanner=zr;exports.RICH_TEXT_PRESETS=bs;exports.RevenueDistributionCard=Xs;exports.RevenueDistributionEmpty=er;exports.RevenueDistributionError=tr;exports.RevenueDistributionSkeleton=nr;exports.RichTextArea=ys;exports.Select=Te;exports.SessionTimeline=Ir;exports.SplitPaymentSummary=Tr;exports.Stepper=hs;exports.SuccessState=Ar;exports.Summary=Jr;exports.TicketSelection=vc;exports.TileSelect=Or;exports.Toggle=$r;exports.calculateAllocationDifference=Ql;exports.computeChange=Ht;exports.currencyFractionDigits=sn;exports.formatMoney=$e;exports.formatOfferCurrency=Ls;exports.formatRevenueAmount=ql;exports.formatRevenueCurrency=Wl;exports.generateAutomaticInstallments=br;exports.generateDistributionId=pn;exports.getCurrencySymbol=Yl;exports.offerCardVariants=Rs;exports.offerListVariants=zs;exports.parseOfferCurrency=bl;exports.parseRevenueCurrency=Gl;exports.roundToCurrency=xs;Object.keys(d).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>d[e]})});
|
|
45
36
|
(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)}})();
|