@veevarts/design-system 2.11.0 → 2.12.0
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 +1 -1
- package/dist/index.js +42 -35
- package/dist/patterns/AdminToolbar/AdminToolbar.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ ${a}${n}
|
|
|
13
13
|
`,style:{backgroundColor:r},"aria-label":`Select color ${r}`,title:r},r)})})}const ad=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],nd=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Cs(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const Ce={min:50,max:200,step:10,default:100},nn={lineHeight:24,toolbarHeight:60},rd={bold:K.Bold,italic:K.Italic,strike:K.Strikethrough,underline:K.Underline,code:K.Code,textColor:K.Palette,highlight:K.Highlighter,link:K.Link2,paragraph:K.FileText,heading:K.Heading,bulletList:K.List,orderedList:K.ListOrdered,taskList:K.ListTodo,codeBlock:K.CodeSquare,blockquote:K.Quote,horizontalRule:K.Minus,clearMarks:K.Eraser,clearNodes:K.Eraser,undo:K.Undo2,redo:K.Redo2,hardBreak:K.CornerDownLeft,textAlign:K.AlignLeft},id={left:K.AlignLeft,center:K.AlignCenter,right:K.AlignRight,justify:K.AlignJustify};function pt(e){return rd[e]}function ld({value:e,onChange:s,onApply:a,placeholder:n="#000000"}){const[r,i]=p.useState(""),l=u=>{const f=u.target.value;s(f),r&&i("")},o=()=>{if(!e){i("Please enter a color");return}if(!Cs(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),a(e)},d=u=>{u.key==="Enter"&&(u.preventDefault(),o())};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Input,{type:"text",value:e,onChange:l,onKeyDown:d,placeholder:n,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!r,errorMessage:r,startContent:t.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:Cs(e)?e:"transparent"}})}),t.jsx(B,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!e||!Cs(e),children:t.jsx(K.Check,{size:16})})]}),t.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function rn({editor:e,type:s,allowCustomColor:a=!0,label:n,isDisabled:r=!1}){const[i,l]=p.useState(!1),[o,d]=p.useState(""),u=s==="textColor"?ad:nd,f=j=>{const b=Xe[s];b&&b.execute({editor:e,config:{type:s,color:j}}),l(!1),d("")},m=j=>{f(j)},h=()=>{const j=Xe[s];j&&j.execute({editor:e,config:{type:s,color:""}}),l(!1)},x=s==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),g=s==="textColor"?K.Palette:K.Highlighter;return t.jsxs(c.Popover,{isOpen:i,onOpenChange:l,placement:"top",offset:10,showArrow:!0,children:[t.jsx(c.PopoverTrigger,{children:t.jsx(B,{size:"sm",radius:"sm",variant:x?"solid":"bordered",color:x?"primary":"default",isIconOnly:!0,isDisabled:r,"aria-label":n,children:t.jsx(g,{size:16})})}),t.jsx(c.PopoverContent,{className:"w-64",children:t.jsxs("div",{className:"px-2 py-3 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-semibold",children:n}),t.jsx(B,{size:"sm",variant:"light",isIconOnly:!0,onPress:h,"aria-label":"Clear color",children:t.jsx(K.X,{size:16})})]}),t.jsx(sd,{colors:u,onColorSelect:f}),a&&t.jsxs(t.Fragment,{children:[t.jsx(c.Divider,{}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),t.jsx(ld,{value:o,onChange:d,onApply:m})]})]})]})})]})}function od({zoom:e,onZoomChange:s,min:a=Ce.min,max:n=Ce.max,step:r=Ce.step}){const i=()=>{const m=Math.max(a,e-r);s(m)},l=()=>{const m=Math.min(n,e+r);s(m)},o=()=>{s(Ce.default)},d=e<=a,u=e>=n,f=e===Ce.default;return t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:t.jsx(B,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:i,"aria-label":"Zoom out",children:t.jsx(K.ZoomOut,{size:16})})}),t.jsx(c.Tooltip,{content:f?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:t.jsxs("button",{type:"button",onClick:o,disabled:f,className:`
|
|
14
14
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
15
15
|
${f?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
16
|
-
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),t.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:t.jsx(B,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:l,"aria-label":"Zoom in",children:t.jsx(K.ZoomIn,{size:16})})})]})}function cd({editor:e,isDisabled:s=!1}){const[a,n]=p.useState(!1),[r,i]=p.useState(""),[l,o]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),m=x=>{if(x){const{from:g,to:j}=e.state.selection,b=e.isActive("link");let w="";if(b){const D=e.schema.marks.link,v=e.state.doc.resolve(g),S=Pa.getMarkRange(v,D);S&&(w=e.state.doc.textBetween(S.from,S.to,""))}else w=e.state.doc.textBetween(g,j,"");const N=e.getAttributes("link").href||"";i(w),o(N),u(b)}n(x)},h=()=>{if(l.trim()){const{from:x,to:g}=e.state.selection,j=e.schema.marks.link,b=e.state.doc.resolve(x),w=Pa.getMarkRange(b,j),N=w?.from??x,D=w?.to??g,v=e.state.doc.textBetween(N,D,"");r.trim()&&r!==v?e.chain().focus().setTextSelection({from:N,to:D}).deleteSelection().insertContent(`<a href="${l.trim()}">${r.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:l.trim()}).run()}n(!1)};return t.jsxs(c.Popover,{isOpen:a,onOpenChange:m,placement:"bottom",children:[t.jsx(c.PopoverTrigger,{children:t.jsx(B,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":"Link",children:t.jsx(K.Link,{size:16})})}),t.jsx(c.PopoverContent,{children:t.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:r,onChange:x=>i(x.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:l,onChange:x=>o(x.target.value),onKeyDown:x=>x.key==="Enter"&&h(),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(B,{size:"sm",color:"primary",onPress:h,isDisabled:!l.trim(),children:d?"Update":"Apply"})]})})]})}function dd({children:e,id:s,label:a,className:n,useButtonGroup:r=!0}){return r?t.jsx(c.ButtonGroup,{size:"sm",id:s,"aria-label":a,className:n,children:e}):t.jsx("div",{id:s,role:"group","aria-label":a,className:`flex items-center gap-2 ${n||""}`,children:e})}function kr(e,s){const a=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(s.map(o=>_t(o)))).forEach(o=>{const d=Xe[o];if(d)try{const u=d.canExecute?.(e)??!0,f=d.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,s]),[n,r]=p.useState(a);return p.useEffect(()=>{if(!e)return;const i=()=>{const l={};Array.from(new Set(s.map(d=>_t(d)))).forEach(d=>{const u=Xe[d];if(u)try{const f=u.canExecute?.(e)??!0,m=u.isActive?.(e)??!1;l[d]={isActive:m,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),l[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),r(l)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,s,a]),n}function Sr(e,s){const a=p.useCallback((l,o)=>{if(!e)return;const d=Xe[l];if(d)try{d.execute({editor:e,config:o}),s?.({type:"toggle",modifier:l})}catch(u){console.warn(`Failed to execute command for modifier: ${l}`,u)}},[e,s]),n=p.useCallback(l=>{a(l)},[a]),r=p.useCallback((l,o)=>{if(!e)return!1;const d=Xe[l];try{return d?.canExecute?.(e,o)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${l}`,u),!1}},[e]),i=p.useCallback((l,o)=>{if(!e)return!1;const d=Xe[l];try{return d?.isActive?.(e,o)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${l}`,u),!1}},[e]);return{executeCommand:a,toggleModifier:n,canExecute:r,isActive:i}}function ud(e=Ce.default){const[s,a]=p.useState(e),n=p.useCallback((o=Ce.step)=>{a(d=>Math.min(Ce.max,d+o))},[]),r=p.useCallback((o=Ce.step)=>{a(d=>Math.max(Ce.min,d-o))},[]),i=p.useCallback(()=>{a(Ce.default)},[]),l=p.useCallback(o=>{const d=Math.max(Ce.min,Math.min(Ce.max,o));a(d)},[]);return{zoom:s,setZoom:l,zoomIn:n,zoomOut:r,resetZoom:i,isMinZoom:s<=Ce.min,isMaxZoom:s>=Ce.max,isDefaultZoom:s===Ce.default}}const md=["bold","italic","strike","underline","code"];function fd({editor:e,modifiers:s,onToolbarAction:a}){const n=kr(e,s),{toggleModifier:r}=Sr(e,a);if(!e)return null;const i=s.map(l=>_t(l)).filter(l=>md.includes(l));return i.length===0?null:t.jsx(dd,{id:"text-formatting",label:"Text formatting",children:i.map(l=>{const o=n[l],d=pt(l);return t.jsx(ot,{icon:d,label:l.charAt(0).toUpperCase()+l.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(l)},l)})})}function xd({editor:e,modifiers:s,zoom:a=100,onZoomChange:n,sticky:r=!0,className:i,onToolbarAction:l}){const o=kr(e,s),{toggleModifier:d,executeCommand:u}=Sr(e,l);if(!e)return null;const f=s.map(k=>_t(k)),m=f.some(k=>["bold","italic","strike","underline","code"].includes(k)),h=f.some(k=>["textColor","highlight"].includes(k)),x=f.includes("heading"),g=f.includes("textAlign"),j=f.some(k=>["bulletList","orderedList","taskList"].includes(k)),b=f.includes("blockquote"),w=f.includes("codeBlock"),N=f.includes("link"),D=f.includes("horizontalRule"),v=f.some(k=>["undo","redo"].includes(k)),S=a!==void 0&&n!==void 0,M=r?"sticky top-0 z-10":"";return t.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:t.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx(fd,{editor:e,modifiers:s,onToolbarAction:l}),(h||x||g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&t.jsx(rn,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),f.includes("highlight")&&t.jsx(rn,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(x||g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),x&&t.jsxs(t.Fragment,{children:[t.jsx(ed,{editor:e}),(g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(k=>{const F=id[k],C=e.isActive({textAlign:k});return t.jsx(ot,{icon:F,label:`Align ${k}`,isActive:C,onClick:()=>u("textAlign",{type:"textAlign",alignment:k})},k)})}),(j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(td,{editor:e,types:f.filter(k=>["bulletList","orderedList","taskList"].includes(k))}),(b||w||N||D||v||S)&&t.jsx(lt,{})]}),(b||w||N||D)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[b&&t.jsx(ot,{icon:pt("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&t.jsx(ot,{icon:pt("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),N&&t.jsx(cd,{editor:e,isDisabled:o.link?.isDisabled}),D&&t.jsx(ot,{icon:pt("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(v||S)&&t.jsx(lt,{})]}),v&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&t.jsx(ot,{icon:pt("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&t.jsx(ot,{icon:pt("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>d("redo")})]}),S&&t.jsx(lt,{})]}),S&&t.jsx(od,{zoom:a,onZoomChange:k=>{n?.(k),l?.({type:"zoom",modifier:`${k}%`})}})]})})}const Ct={bold:{category:"mark",extension:zl.Bold,priority:100},italic:{category:"mark",extension:Bl.Italic,priority:100},strike:{category:"mark",extension:Vl.Strike,priority:100},underline:{category:"mark",extension:Ul.Underline,priority:100},code:{category:"mark",extension:Hl.Code,priority:100},textColor:{category:"mark",extension:ql.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Wl.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Yl.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Kl.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Zl.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Xl.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Jl.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:so.CodeBlock,priority:100},blockquote:{category:"node",extension:ao.Blockquote,priority:100},horizontalRule:{category:"node",extension:no.HorizontalRule,priority:100},hardBreak:{category:"node",extension:ro.HardBreak,priority:100},undo:{category:"extension",extension:Oa.History,priority:50},redo:{category:"extension",extension:Oa.History,priority:50},textAlign:{category:"extension",extension:io.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}},hd=[lo.Document,oo.Text,Ql.Paragraph,Gl.TextStyle.configure({HTMLAttributes:{}}),to.ListItem.configure({HTMLAttributes:{}}),eo.TaskItem.configure({nested:!0}),co.Dropcursor,uo.Gapcursor];function pd(e){const s=[],a=new Set,n=new Set;hd.forEach(o=>{o&&(s.push(o),n.add(o.name))});const r=e.map(o=>_t(o)),i=new Set;return r.forEach(o=>{const d=Ct[o];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(o=>{if(a.has(o))return;const d=Ct[o];if(!d||d.extension===null)return;const u=d.extension.name;if(n.has(u)){a.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;s.push(f),a.add(o),n.add(u)}),r.forEach(o=>{if(a.has(o))return;const d=Ct[o];if(!d){console.warn(`Extension config not found for modifier: ${o}`);return}if(d.extension===null){a.add(o);return}const u=d.extension.name;if(n.has(u)){a.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;s.push(f),a.add(o),n.add(u)}),s.sort((o,d)=>{const u=Object.values(Ct).find(x=>x?.extension?.name===o.name),f=Object.values(Ct).find(x=>x?.extension?.name===d.name),m=u?.priority??100;return(f?.priority??100)-m})}const $r={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"]},gd={h1:`font-size: ${fe.fontSize["4xl"]}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h2:`font-size: ${fe.fontSize["2xl"]}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h3:`font-size: ${fe.fontSize.xl}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h4:`font-size: ${fe.fontSize.lg}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h5:`font-size: ${fe.fontSize.base}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h6:`font-size: ${fe.fontSize.sm}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,p:`min-height: ${fe.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ue.xl}; margin: ${ue.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ue.xl}; margin: ${ue.md} 0;`,li:`display: list-item; margin: ${ue.xs} 0;`,strong:`font-weight: ${fe.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${we.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${fe.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${fe.fontFamily.mono};`,pre:`background: ${we.neutral.gray[800]}; border-radius: ${ue.sm}; color: ${we.neutral.gray[100]}; font-family: ${fe.fontFamily.mono}; margin: ${ue.lg} 0; padding: 0.75rem ${ue.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${we.neutral.gray[300]}; margin: ${ue.lg} 0; padding-left: ${ue.md}; color: ${we.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${we.neutral.gray[200]}; margin: ${ue.xl} 0;`,a:`color: ${we.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${we.palettes.warning[200]}; border-radius: ${ue.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ue.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},bd={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 yd(e){if(!e)return e;let s=e;for(const[a,n]of Object.entries(bd)){const r=new RegExp(`(<(?:ul|li)[^>]*data-type="${a}"[^>]*)>`,"gi");s=s.replace(r,(i,l)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${n}"`):`${l} style="${n}">`)}for(const[a,n]of Object.entries(gd)){const r=new RegExp(`<${a}(\\s[^>]*)?>`,"gi");s=s.replace(r,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${n}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${n}'`);{const l=i.indexOf(">");return`${i.slice(0,l)} style="${n}"${i.slice(l)}`}})}return s}const vd=({modifiers:e,zoom:s,onZoomChange:a,onToolbarAction:n})=>{const{editor:r}=ta.useCurrentEditor();return t.jsx(xd,{editor:r,modifiers:e,zoom:s,onZoomChange:a,onToolbarAction:n})},jd=({showCharacterCount:e,showWordCount:s})=>{const{editor:a}=ta.useCurrentEditor();if(!a||!e&&!s)return null;const n=a.getText(),r=n.length,i=n.split(/\s+/).filter(l=>l.length>0).length;return t.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&t.jsxs("span",{children:[r," characters"]}),s&&t.jsxs("span",{children:[i," words"]})]})},qs=p.forwardRef((e,s)=>{const{minRows:a=10,maxRows:n=30,disableAutosize:r=!1,showCharacterCount:i=!1,showWordCount:l=!1,showToolbar:o=!0,modifiers:d=$r.full,variant:u="bordered",initialContent:f,content:m,onContentChange:h,onUpdate:x,onToolbarAction:g,isReadOnly:j=!1,isDisabled:b=!1,includeInlineStyles:w=!0,...N}=e,{zoom:D,setZoom:v}=ud(),S=nn.lineHeight,M=a*S,k=r?void 0:n*S,F=p.useMemo(()=>pd(d),[d]),{Component:C,label:_,shouldLabelBeOutside:E,getBaseProps:A,getLabelProps:R,getInputWrapperProps:O}=c.useInput({...N,variant:u,ref:s,isMultiline:!0}),V=_?t.jsx("label",{...R(),children:_}):null,q=p.useCallback(({editor:I})=>{const J=I.getHTML(),W=w?yd(J):J,se=I.getJSON(),Y=I.getText(),Z=Y.length,Q=Y.split(/\s+/).filter(ne=>ne.length>0).length,ee={html:W,json:se,text:Y,characters:Z,words:Q};if(h?.(ee),x?.(ee),"onChange"in N&&typeof N.onChange=="function"){const ne={target:{value:W},currentTarget:{value:W}};N.onChange(ne)}},[h,x,N,w]);return t.jsxs(C,{...A(),children:[E?V:null,t.jsx("div",{...O(),className:c.cn(O().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:k?`${k+nn.toolbarHeight}px`:void 0,overflow:k?"auto":void 0},children:t.jsx(ta.EditorProvider,{editable:!j&&!b,slotBefore:o?t.jsx(vd,{modifiers:d,zoom:D,onZoomChange:v,onToolbarAction:g}):void 0,slotAfter:t.jsx(jd,{showCharacterCount:i,showWordCount:l}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${D}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:F,content:m||f||e.defaultValue||"",onUpdate:q})})]})});qs.displayName="TipTapEditor";const Ar=p.forwardRef((e,s)=>{const{adapter:a="tiptap",variant:n="bordered",...r}=e;return a==="tiptap"?t.jsx(qs,{...r,variant:n,ref:s}):(console.warn(`Adapter "${a}" is not supported. Using TipTap.`),t.jsx(qs,{...r,variant:n,ref:s}))});Ar.displayName="RichTextArea";function wd(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}const ln=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Nd={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Dr=({presetAmounts:e=ln,selectedDonation:s,defaultSelectedDonation:a=null,onChange:n,onAddDonation:r,currency:i="USD",locale:l="en-US",showCustomAmount:o=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:m=2,desktopColumns:h=3,isDisabled:x=!1,buttonVariant:g="bordered",buttonColor:j="default",inputVariant:b="bordered",size:w="md",className:N="",showCard:D=!0})=>{const v={...Nd,...f},S=Array.isArray(e)?e:ln,M={2:"grid-cols-2",3:"grid-cols-3"},k={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},F=`${M[m]} ${k[h]}`,[C,_]=ds(s,a,n),[E,A]=p.useState(""),[R,O]=p.useState(!1),[V,q]=p.useState(0),I=p.useCallback(Z=>{if(x)return;const Q={amount:Z.amount,isCustom:!1,presetId:Z.id};_(Q),A(""),O(!1),q(ee=>ee+1),r?.(Q)},[x,_,r]),J=p.useCallback(Z=>{if(x)return;if(A(Z!==void 0?String(Z):""),r){_(null);return}if(Z===void 0||isNaN(Z)){_(null);return}_({amount:Z,isCustom:!0})},[x,_,r]),W=p.useCallback(()=>{if(x)return;const Z=E!==""?parseFloat(E):void 0;Z===void 0||isNaN(Z)||r?.({amount:Z,isCustom:!0})},[x,E,r]),se=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=t.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[v.title&&t.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:v.title}),S.length>0&&t.jsx("div",{className:c.cn("grid gap-3",F),"data-testid":"donation-amounts-presets",children:S.map(Z=>{const Q=C!==null&&!C.isCustom&&C.presetId===Z.id;return t.jsx(B,{color:Q?"primary":j,variant:Q?"solid":g,className:"w-full",onPress:()=>I(Z),isDisabled:x,"data-testid":`donation-amounts-preset-${Z.id}`,children:Z.label||wd(Z.amount,l,i)},Z.id)})}),o&&t.jsxs("div",{className:"flex gap-3 items-start",children:[t.jsx(c.NumberInput,{placeholder:v.customAmountPlaceholder,"aria-label":v.customAmountAriaLabel,onInput:r?()=>{_(null),O(!0)}:void 0,variant:b,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:se,value:E!==""?parseFloat(E):void 0,onValueChange:J,isDisabled:x,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},r?`custom-${V}`:C?.isCustom===!1?C.presetId:"custom"),r&&t.jsx(B,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:W,isDisabled:x||!R,"data-testid":"donation-amounts-add-button",children:v.addDonationButton})]})]});return D?t.jsx(c.Card,{className:c.cn("w-full",N),"data-testid":"donation-amounts-card",children:t.jsx(c.CardBody,{children:Y})}):t.jsx("div",{className:c.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};Dr.displayName="DonationAmounts";const Cd=e=>{const s=Math.max(0,e),a=Math.floor(s/60).toString().padStart(2,"0"),n=(s%60).toString().padStart(2,"0");return`${a}:${n} minutes`},kd=e=>{switch(e){case"warning":return K.Clock;case"error":return K.AlertCircle;case"success":return K.CheckCircle;default:return K.Clock}},Sd=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"}},Er=p.forwardRef(({timeLeft:e,defaultTimeLeft:s=1200,onTimeChange:a,onExpire:n,variant:r="info",color:i="primary",message:l="Your cart expires in:",showIcon:o=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:m=Cd,className:h,...x},g)=>{const[j,b]=ds(e!==void 0?Math.max(0,e):void 0,Math.max(0,s),a),w=p.useRef(null),N=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||j<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{b(M=>M<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,n?.()),0):M-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,j,b,n]),p.useEffect(()=>{j>0&&(N.current=!1)},[j]);const D=d||kd(r),v=Sd(i),S={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return t.jsx("div",{ref:g,role:"banner","aria-live":"polite","aria-label":`${l} ${m(j)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",v,S[u],h),...x,children:t.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[t.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&&t.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:t.jsx(D,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),t.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:l})]}),t.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:t.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${m(j)}`,"data-testid":"expire-cart-timer-value",children:m(j)})})]})})})});Er.displayName="ExpireCartTimer";const ft=({icon:e,children:s,testId:a})=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":a,children:[t.jsx(P,{icon:e,width:20,className:"text-default-500"}),t.jsx("span",{children:s})]}),$d=({classes:e="",name:s,imageUrl:a,eventDate:n,eventTime:r,location:i,description:l,showImage:o=!1,compact:d=!1,layout:u="stacked",imageLoading:f="eager",showMoreButtonClassName:m,labels:h})=>{const[x,g]=p.useState(!1),[j,b]=p.useState(!1),w=p.useRef(null);return p.useEffect(()=>{const N=()=>{if(w.current){const D=w.current.scrollHeight>w.current.clientHeight;b(D)}};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[l]),u==="horizontal"?t.jsx(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:t.jsx(c.CardBody,{className:"p-0","data-testid":"event-details-horizontal-layout",children:t.jsxs("div",{className:"flex flex-col items-start gap-5 sm:flex-row sm:gap-8",children:[o&&a&&t.jsx("div",{className:"w-full shrink-0 overflow-hidden rounded-xl aspect-[3/2] sm:w-[360px]","data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:f,alt:`Event image for ${s}`,className:"w-full h-full object-cover object-center",src:a,"data-testid":"event-details-image"})}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"font-semibold text-2xl text-gray-800","data-testid":"event-details-title",children:s}),t.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:h.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[n&&t.jsx(ft,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:n}),r&&t.jsx(ft,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(ft,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:w,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&j&&t.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"})]}),(j||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(B,{onPress:()=>g(!x),variant:"light",className:c.cn("text-primary",m),size:"md",startContent:t.jsx(P,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:x?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})})}):t.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[t.jsxs(c.CardHeader,{className:c.cn("pt-2 pb-0 flex-col items-start",d?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&a&&t.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:f,alt:`Event image for ${s}`,className:"w-full h-full object-cover object-center",src:a,"data-testid":"event-details-image"})}),t.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:s})]}),t.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[t.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[n&&t.jsx(ft,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:n}),r&&t.jsx(ft,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(ft,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:w,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&j&&t.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"})]}),(j||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(B,{onPress:()=>g(!x),variant:"light",className:c.cn("text-primary",m),size:d?"sm":"md",startContent:t.jsx(P,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:x?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function Ws(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}function Ad(e){const s=e.replace(/[^\d.,-]/g,""),a=s.match(/,\d{1,2}$/);let n;a?n=s.replace(/\./g,"").replace(",","."):n=s.replace(/,/g,"");const r=parseFloat(n);return isNaN(r)?null:r}const Dd={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"},xt=e=>typeof e=="number"&&!isNaN(e),es=({offer:e,quantity:s,defaultQuantity:a=0,onQuantityChange:n,currency:r="USD",locale:i="en-US",labels:l,slots:o,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:m=!0,showDescription:h=!0,showPeopleCount:x=!0,showPrice:g=!0,priceDisplay:j,classNames:b={},"data-testid":w,selectedColor:N="default",selectionMode:D="stepper",compact:v=!1,isSoldOut:S,isMaxReached:M,isRuleBlocked:k,statusTone:F="default",statusLabel:C,disabledReason:_,disabled:E})=>{const A=p.useMemo(()=>({...Dd,...l}),[l]),[R,O]=p.useState(a),V=s!==void 0?s:R,q=!!(d||E),I=v||!!e.compact,J=D==="press-to-add",W=p.useMemo(()=>typeof S=="boolean"?S:typeof e.isSoldOut=="boolean"?e.isSoldOut:!xt(e.totalTicketsSold)||!xt(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[S,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),se=p.useMemo(()=>typeof M=="boolean"?M:typeof e.isMaxReached=="boolean"?e.isMaxReached:W||!xt(e.ticketsAllowed)?!1:V>=e.ticketsAllowed-(e.totalTicketsSold??0),[M,e.isMaxReached,W,e.ticketsAllowed,e.totalTicketsSold,V]),Y=p.useMemo(()=>typeof k=="boolean"?k:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[k,e.isRuleBlocked]),Z=_||e.disabledReason,Q=q||W||Y,ee=le=>{if(Q||le>0&&se)return;const ye=Math.max(0,V+le);s===void 0&&O(ye),n?.(e.id,ye)},ne=p.useMemo(()=>{if(W)return"soldOut";if(Y)return"ruleBlocked";if(q)return"disabled"},[W,Y,q]),X=p.useMemo(()=>F||(W||Y?"danger":se?"warning":"default"),[F,W,Y,se]),de=p.useMemo(()=>{if(ne)return ne==="ruleBlocked"?C||Z||A.ruleBlocked:ne==="soldOut"?C||Z||A.soldOut:ne==="disabled"?C||Z||A.disabled:C||A.maxReached},[ne,C,Z,A]),ae={soldOut:"danger",ruleBlocked:X,disabled:"default",maxReached:"warning"},Ie={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},Ee=()=>o?.renderName?o.renderName(e.name,e):t.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",I&&"text-sm",b.name),children:e.name}),Le=()=>{if(!g)return null;const le=j?.price??e.price,ye=j?.originalPrice,Ye=Ws(le,i,r);if(o?.renderPrice)return o.renderPrice(le,Ye,e);if(xt(ye)&&xt(le)&&ye>le){const $=Ws(ye,i,r);return t.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",I&&"mt-0.5",b.price),children:[t.jsxs("span",{className:"sr-only",children:["Original price ",$,", discounted price ",Ye]}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",I&&"text-xs",b.originalPrice),children:$}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",I&&"text-sm",b.discountedPrice),children:Ye})]})}return t.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",I&&"text-sm mt-0.5",b.price),children:Ye})},mt=()=>!h||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):t.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",I&&"mb-2 text-xs text-gray-600",b.description),children:e.description}),Ge=()=>{if(!x||!xt(e.numberOfPeople)||e.numberOfPeople<=0)return null;const le=e.numberOfPeople===1?A.person:A.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,le,e):t.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",I&&"mt-1 text-xs",b.peopleCount),children:[t.jsx(P,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",le]})},We=()=>{const le=V===0||Q,ye=se||Q;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:V,onIncrement:()=>ee(1),onDecrement:()=>ee(-1),isDecrementDisabled:le,isIncrementDisabled:ye,isDisabled:Q}):t.jsxs("div",{className:c.cn("flex items-center gap-2",b.quantitySelector),children:[t.jsx(B,{"data-testid":"offer-card-decrement-button",onPress:()=>ee(-1),isDisabled:le,variant:u,color:V>0?N:f,radius:"full",isIconOnly:!0,size:I?"md":"sm","aria-label":"Decrease quantity",children:t.jsx(P,{icon:"gravity-ui:minus",width:16})}),t.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",I&&"text-sm"),children:V}),t.jsx(B,{"data-testid":"offer-card-increment-button",onPress:()=>ee(1),isDisabled:ye,variant:u,color:V>0?N:f,radius:"full",isIconOnly:!0,size:I?"md":"sm","aria-label":"Increase quantity",children:t.jsx(P,{icon:"gravity-ui:plus",width:16})})]})},rt=(le,ye)=>o?.renderDisabledState?o.renderDisabledState(le,ye):le==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(ye):le==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(ye):t.jsx(c.Chip,{"data-testid":Ie[le],color:ae[le],variant:le==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",le==="maxReached"?"h-8":"h-10",le==="soldOut"&&b.soldOut,le==="maxReached"&&b.maxReachedAlert,I&&"h-8"),startContent:t.jsx(P,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:t.jsx("span",{className:"font-medium text-sm",children:ye})}),Je=t.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",I?"gap-1":"gap-2"),children:[t.jsxs("div",{className:c.cn("h-full col-span-2",Q||se?"opacity-50 pointer-events-none select-none":""),children:[Ee(),Le(),t.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",I?"mb-1":"mb-2"),children:[Ge(),mt()]})]}),!J&&t.jsx("div",{className:c.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",I&&"space-x-1 pb-1 md:p-1",b.compactFooter),children:ne&&de?rt(ne,de):We()})]}),Pe=se&&!W&&!Y&&!q?t.jsx(De.motion.div,{className:c.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:rt("maxReached",de||A.maxReached)}):null;return m?t.jsxs(c.Card,{className:c.cn("w-full",J&&!Q&&!se&&"cursor-pointer",I&&b.compact,b.base),"data-testid":w||`offer-card-${e.id}`,isPressable:J&&!Q&&!se,onPress:J&&!Q&&!se?()=>ee(1):void 0,children:[t.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",I?"pb-0.5":"",b.body),children:Je}),t.jsx(De.AnimatePresence,{children:Pe&&t.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",I?"pt-1":"",b.footer),children:Pe})})]}):t.jsxs("div",{className:c.cn("w-full",I&&b.compact,b.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx("div",{className:c.cn("pt-1 pb-0",I?"pb-0.5":"",b.body),children:Je}),t.jsx(De.AnimatePresence,{children:Pe&&t.jsx("div",{className:c.cn("w-full mt-0 pt-0",I?"pt-1":"",b.footer),children:Pe})})]})};es.displayName="OfferCard";const Fr=({message:e="No offers available.",icon:s="solar:ticket-sale-outline",iconSize:a=48,showCard:n=!0,classNames:r={},renderEmpty:i})=>{if(i){const o=i();return n?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:o})}const l=t.jsxs("div",{"data-testid":"offer-card-empty-content",className:c.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",r.content),children:[t.jsx(P,{"data-testid":"offer-card-empty-icon",icon:s,width:a,className:c.cn("mb-4",r.icon)}),t.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",r.message),children:e})]});return n?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:l})};Fr.displayName="OfferCardEmpty";const Ed={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},Lr=({error:e,labels:s,showCard:a=!0,color:n="danger",classNames:r={}})=>{const i={...Ed,...s},l=t.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:n,title:i.title,description:e||i.description,className:r.alert});return a?t.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:l})};Lr.displayName="OfferCardError";const Fd={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Mr=({quantity:e=2,gap:s=4,classNames:a={}})=>{const n=Fd[s];return t.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(n,a.base),children:Array.from({length:e}).map((r,i)=>t.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",a.card),children:[t.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:t.jsxs("div",{className:"space-y-2 w-full",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),t.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[t.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),t.jsx("div",{className:"flex items-start justify-end",children:t.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Mr.displayName="OfferCardSkeleton";const _r={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},Rr={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"}}},Ld={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},Tr=({offers:e=[],mapOffer:s,selection:a,defaultSelection:n={},onSelectionChange:r,onQuantityChange:i,currency:l="USD",locale:o="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:m="bordered",buttonColor:h="default",showCard:x=!0,animated:g=!0,gap:j=2,compact:b=!1,classNames:w={}})=>{const[N,D]=p.useState(n),v=a!==void 0?a:N,S=p.useCallback((E,A)=>{const R={...v,[E]:Math.max(0,A)};a===void 0&&D(R),r?.(R),i?.(E,R[E])},[v,a,r,i]),M=[...e].sort((E,A)=>(E.position??0)-(A.position??0)),k=E=>{const A=s?s(E):E,R=(v??{})[A.id]||0;return{offer:A,quantity:R,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:h,showCard:x,compact:b}},F=Ld[j],C=c.cn("grid mx-auto pt-2",F,w.base),_=E=>{const A=k(E);return t.jsx(es,{offer:A.offer,quantity:A.quantity,onQuantityChange:A.onQuantityChange,currency:A.currency,locale:A.locale,labels:A.labels,slots:A.slots,isDisabled:A.isDisabled,buttonVariant:A.buttonVariant,buttonColor:A.buttonColor,showCard:A.showCard,compact:A.compact,classNames:w.card},A.offer.id)};return g?t.jsx(De.motion.div,{"data-testid":"offer-card-list",className:C,variants:_r,initial:"hidden",animate:"show",children:t.jsx(De.AnimatePresence,{children:M.map(E=>{const A=k(E);return t.jsx(De.motion.div,{"data-testid":`offer-card-list-item-${A.offer.id}`,className:w.cardWrapper,variants:Rr,exit:{opacity:0,y:-20},transition:{duration:.3},children:t.jsx(es,{offer:A.offer,quantity:A.quantity,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:h,showCard:x,compact:b||A.offer.compact,classNames:w.card})},A.offer.id)})})}):t.jsx("div",{"data-testid":"offer-card-list",className:C,children:M.map(_)})};Tr.displayName="OfferCardList";var Tt=e=>e.type==="checkbox",ct=e=>e instanceof Date,Fe=e=>e==null;const Ir=e=>typeof e=="object";var be=e=>!Fe(e)&&!Array.isArray(e)&&Ir(e)&&!ct(e),Pr=e=>be(e)&&e.target?Tt(e.target)?e.target.checked:e.target.value:e,Md=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Or=(e,s)=>e.has(Md(s)),_d=e=>{const s=e.constructor&&e.constructor.prototype;return be(s)&&s.hasOwnProperty("isPrototypeOf")},ma=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function he(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(ma&&(e instanceof Blob||s))return e;const a=Array.isArray(e);if(!a&&!(be(e)&&_d(e)))return e;const n=a?[]:Object.create(Object.getPrototypeOf(e));for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=he(e[r]));return n}var us=e=>/^\w*$/.test(e),me=e=>e===void 0,fa=e=>Array.isArray(e)?e.filter(Boolean):[],xa=e=>fa(e.replace(/["|']|\]/g,"").split(/\.|\[/)),H=(e,s,a)=>{if(!s||!be(e))return a;const n=(us(s)?[s]:xa(s)).reduce((r,i)=>Fe(r)?r:r[i],e);return me(n)||n===e?me(e[s])?a:e[s]:n},Re=e=>typeof e=="boolean",Ae=e=>typeof e=="function",ce=(e,s,a)=>{let n=-1;const r=us(s)?[s]:xa(s),i=r.length,l=i-1;for(;++n<i;){const o=r[n];let d=a;if(n!==l){const u=e[o];d=be(u)||Array.isArray(u)?u:isNaN(+r[n+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=d,e=e[o]}};const ts={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ve={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ke={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},zr=p.createContext(null);zr.displayName="HookFormControlContext";const ha=()=>p.useContext(zr);var Br=(e,s,a,n=!0)=>{const r={defaultValues:s._defaultValues};for(const i in e)Object.defineProperty(r,i,{get:()=>{const l=i;return s._proxyFormState[l]!==Ve.all&&(s._proxyFormState[l]=!n||Ve.all),a&&(a[l]=!0),e[l]}});return r};const pa=typeof window<"u"?p.useLayoutEffect:p.useEffect;function Rd(e){const s=ha(),{control:a=s,disabled:n,name:r,exact:i}=e||{},[l,o]=p.useState(a._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return pa(()=>a._subscribe({name:r,formState:d.current,exact:i,callback:u=>{!n&&o({...a._formState,...u})}}),[r,n,i]),p.useEffect(()=>{d.current.isValid&&a._setValid(!0)},[a]),p.useMemo(()=>Br(l,a,d.current,!1),[l,a])}var Te=e=>typeof e=="string",Ys=(e,s,a,n,r)=>Te(e)?(n&&s.watch.add(e),H(a,e,r)):Array.isArray(e)?e.map(i=>(n&&s.watch.add(i),H(a,i))):(n&&(s.watchAll=!0),a),Gs=e=>Fe(e)||!Ir(e);function Ue(e,s,a=new WeakSet){if(Gs(e)||Gs(s))return Object.is(e,s);if(ct(e)&&ct(s))return Object.is(e.getTime(),s.getTime());const n=Object.keys(e),r=Object.keys(s);if(n.length!==r.length)return!1;if(a.has(e)||a.has(s))return!0;a.add(e),a.add(s);for(const i of n){const l=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=s[i];if(ct(l)&&ct(o)||be(l)&&be(o)||Array.isArray(l)&&Array.isArray(o)?!Ue(l,o,a):!Object.is(l,o))return!1}}return!0}function Td(e){const s=ha(),{control:a=s,name:n,defaultValue:r,disabled:i,exact:l,compute:o}=e||{},d=p.useRef(r),u=p.useRef(o),f=p.useRef(void 0),m=p.useRef(a),h=p.useRef(n);u.current=o;const[x,g]=p.useState(()=>{const v=a._getWatch(n,d.current);return u.current?u.current(v):v}),j=p.useCallback(v=>{const S=Ys(n,a._names,v||a._formValues,!1,d.current);return u.current?u.current(S):S},[a._formValues,a._names,n]),b=p.useCallback(v=>{if(!i){const S=Ys(n,a._names,v||a._formValues,!1,d.current);if(u.current){const M=u.current(S);Ue(M,f.current)||(g(M),f.current=M)}else g(S)}},[a._formValues,a._names,i,n]);pa(()=>((m.current!==a||!Ue(h.current,n))&&(m.current=a,h.current=n,b()),a._subscribe({name:n,formState:{values:!0},exact:l,callback:v=>{b(v.values)}})),[a,l,n,b]),p.useEffect(()=>a._removeUnmounted());const w=m.current!==a,N=h.current,D=p.useMemo(()=>{if(i)return null;const v=!w&&!Ue(N,n);return w||v?j():null},[i,w,n,N,j]);return D!==null?D:x}function Id(e){const s=ha(),{name:a,disabled:n,control:r=s,shouldUnregister:i,defaultValue:l,exact:o=!0}=e,d=Or(r._names.array,a),u=p.useMemo(()=>H(r._formValues,a,H(r._defaultValues,a,l)),[r,a,l]),f=Td({control:r,name:a,defaultValue:u,exact:o}),m=Rd({control:r,name:a,exact:o}),h=p.useRef(e),x=p.useRef(void 0),g=p.useRef(r.register(a,{...e.rules,value:f,...Re(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const j=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!H(m.errors,a)},isDirty:{enumerable:!0,get:()=>!!H(m.dirtyFields,a)},isTouched:{enumerable:!0,get:()=>!!H(m.touchedFields,a)},isValidating:{enumerable:!0,get:()=>!!H(m.validatingFields,a)},error:{enumerable:!0,get:()=>H(m.errors,a)}}),[m,a]),b=p.useCallback(v=>g.current.onChange({target:{value:Pr(v),name:a},type:ts.CHANGE}),[a]),w=p.useCallback(()=>g.current.onBlur({target:{value:H(r._formValues,a),name:a},type:ts.BLUR}),[a,r._formValues]),N=p.useCallback(v=>{const S=H(r._fields,a);S&&S._f&&v&&(S._f.ref={focus:()=>Ae(v.focus)&&v.focus(),select:()=>Ae(v.select)&&v.select(),setCustomValidity:M=>Ae(v.setCustomValidity)&&v.setCustomValidity(M),reportValidity:()=>Ae(v.reportValidity)&&v.reportValidity()})},[r._fields,a]),D=p.useMemo(()=>({name:a,value:f,...Re(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:b,onBlur:w,ref:N}),[a,n,m.disabled,b,w,N,f]);return p.useEffect(()=>{const v=r._options.shouldUnregister||i,S=x.current;S&&S!==a&&!d&&r.unregister(S),r.register(a,{...h.current.rules,...Re(h.current.disabled)?{disabled:h.current.disabled}:{}});const M=(k,F)=>{const C=H(r._fields,k);C&&C._f&&(C._f.mount=F)};if(M(a,!0),v){const k=he(H(r._options.defaultValues,a,h.current.defaultValue));ce(r._defaultValues,a,k),me(H(r._formValues,a))&&ce(r._formValues,a,k)}return!d&&r.register(a),x.current=a,()=>{(d?v&&!r._state.action:v)?r.unregister(a):M(a,!1)}},[a,r,d,i]),p.useEffect(()=>{r._setDisabledField({disabled:n,name:a})},[n,a,r]),p.useMemo(()=>({field:D,formState:m,fieldState:j}),[D,m,j])}const Pd=p.createContext(null);Pd.displayName="HookFormContext";var Od=(e,s,a,n,r)=>s?{...a[e],types:{...a[e]&&a[e].types?a[e].types:{},[n]:r||!0}}:{},Et=e=>Array.isArray(e)?e:[e],on=()=>{let e=[];return{get observers(){return e},next:r=>{for(const i of e)i.next&&i.next(r)},subscribe:r=>(e.push(r),{unsubscribe:()=>{e=e.filter(i=>i!==r)}}),unsubscribe:()=>{e=[]}}};function Vr(e,s){const a={};for(const n in e)if(e.hasOwnProperty(n)){const r=e[n],i=s[n];if(r&&be(r)&&i){const l=Vr(r,i);be(l)&&(a[n]=l)}else e[n]&&(a[n]=i)}return a}var Se=e=>be(e)&&!Object.keys(e).length,ga=e=>e.type==="file",ss=e=>{if(!ma)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},Ur=e=>e.type==="select-multiple",ba=e=>e.type==="radio",zd=e=>ba(e)||Tt(e),ks=e=>ss(e)&&e.isConnected;function Bd(e,s){const a=s.slice(0,-1).length;let n=0;for(;n<a;)e=me(e)?n++:e[s[n++]];return e}function Vd(e){for(const s in e)if(e.hasOwnProperty(s)&&!me(e[s]))return!1;return!0}function pe(e,s){const a=Array.isArray(s)?s:us(s)?[s]:xa(s),n=a.length===1?e:Bd(e,a),r=a.length-1,i=a[r];return n&&delete n[i],r!==0&&(be(n)&&Se(n)||Array.isArray(n)&&Vd(n))&&pe(e,a.slice(0,-1)),e}var Ud=e=>{for(const s in e)if(Ae(e[s]))return!0;return!1};function Hr(e){return Array.isArray(e)||be(e)&&!Ud(e)}function Ks(e,s={}){for(const a in e){const n=e[a];Hr(n)?(s[a]=Array.isArray(n)?[]:{},Ks(n,s[a])):me(n)||(s[a]=!0)}return s}function gt(e,s,a){a||(a=Ks(s));for(const n in e){const r=e[n];if(Hr(r))me(s)||Gs(a[n])?a[n]=Ks(r,Array.isArray(r)?[]:{}):gt(r,Fe(s)?{}:s[n],a[n]);else{const i=s[n];a[n]=!Ue(r,i)}}return a}const cn={value:!1,isValid:!1},dn={value:!0,isValid:!0};var qr=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(a=>a&&a.checked&&!a.disabled).map(a=>a.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!me(e[0].attributes.value)?me(e[0].value)||e[0].value===""?dn:{value:e[0].value,isValid:!0}:dn:cn}return cn},Wr=(e,{valueAsNumber:s,valueAsDate:a,setValueAs:n})=>me(e)?e:s?e===""?NaN:e&&+e:a&&Te(e)?new Date(e):n?n(e):e;const un={isValid:!1,value:null};var Yr=e=>Array.isArray(e)?e.reduce((s,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:s,un):un;function mn(e){const s=e.ref;return ga(s)?s.files:ba(s)?Yr(e.refs).value:Ur(s)?[...s.selectedOptions].map(({value:a})=>a):Tt(s)?qr(e.refs).value:Wr(me(s.value)?e.ref.value:s.value,e)}var Hd=(e,s,a,n)=>{const r={};for(const i of e){const l=H(s,i);l&&ce(r,i,l._f)}return{criteriaMode:a,names:[...e],fields:r,shouldUseNativeValidation:n}},as=e=>e instanceof RegExp,kt=e=>me(e)?e:as(e)?e.source:be(e)?as(e.value)?e.value.source:e.value:e,fn=e=>({isOnSubmit:!e||e===Ve.onSubmit,isOnBlur:e===Ve.onBlur,isOnChange:e===Ve.onChange,isOnAll:e===Ve.all,isOnTouch:e===Ve.onTouched});const xn="AsyncFunction";var qd=e=>!!e&&!!e.validate&&!!(Ae(e.validate)&&e.validate.constructor.name===xn||be(e.validate)&&Object.values(e.validate).find(s=>s.constructor.name===xn)),Wd=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),hn=(e,s,a)=>!a&&(s.watchAll||s.watch.has(e)||[...s.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Ft=(e,s,a,n)=>{for(const r of a||Object.keys(e)){const i=H(e,r);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&s(l.refs[0],r)&&!n)return!0;if(l.ref&&s(l.ref,l.name)&&!n)return!0;if(Ft(o,s))break}else if(be(o)&&Ft(o,s))break}}};function pn(e,s,a){const n=H(e,a);if(n||us(a))return{error:n,name:a};const r=a.split(".");for(;r.length;){const i=r.join("."),l=H(s,i),o=H(e,i);if(l&&!Array.isArray(l)&&a!==i)return{name:a};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};r.pop()}return{name:a}}var Yd=(e,s,a,n)=>{a(e);const{name:r,...i}=e;return Se(i)||Object.keys(i).length>=Object.keys(s).length||Object.keys(i).find(l=>s[l]===(!n||Ve.all))},Gd=(e,s,a)=>!e||!s||e===s||Et(e).some(n=>n&&(a?n===s:n.startsWith(s)||s.startsWith(n))),Kd=(e,s,a,n,r)=>r.isOnAll?!1:!a&&r.isOnTouch?!(s||e):(a?n.isOnBlur:r.isOnBlur)?!e:(a?n.isOnChange:r.isOnChange)?e:!0,Qd=(e,s)=>!fa(H(e,s)).length&&pe(e,s),Zd=(e,s,a)=>{const n=Et(H(e,a));return ce(n,"root",s[a]),ce(e,a,n),e};function gn(e,s,a="validate"){if(Te(e)||Array.isArray(e)&&e.every(Te)||Re(e)&&!e)return{type:a,message:Te(e)?e:"",ref:s}}var ht=e=>be(e)&&!as(e)?e:{value:e,message:""},bn=async(e,s,a,n,r,i)=>{const{ref:l,refs:o,required:d,maxLength:u,minLength:f,min:m,max:h,pattern:x,validate:g,name:j,valueAsNumber:b,mount:w}=e._f,N=H(a,j);if(!w||s.has(j))return{};const D=o?o[0]:l,v=A=>{r&&D.reportValidity&&(D.setCustomValidity(Re(A)?"":A||""),D.reportValidity())},S={},M=ba(l),k=Tt(l),F=M||k,C=(b||ga(l))&&me(l.value)&&me(N)||ss(l)&&l.value===""||N===""||Array.isArray(N)&&!N.length,_=Od.bind(null,j,n,S),E=(A,R,O,V=Ke.maxLength,q=Ke.minLength)=>{const I=A?R:O;S[j]={type:A?V:q,message:I,ref:l,..._(A?V:q,I)}};if(i?!Array.isArray(N)||!N.length:d&&(!F&&(C||Fe(N))||Re(N)&&!N||k&&!qr(o).isValid||M&&!Yr(o).isValid)){const{value:A,message:R}=Te(d)?{value:!!d,message:d}:ht(d);if(A&&(S[j]={type:Ke.required,message:R,ref:D,..._(Ke.required,R)},!n))return v(R),S}if(!C&&(!Fe(m)||!Fe(h))){let A,R;const O=ht(h),V=ht(m);if(!Fe(N)&&!isNaN(N)){const q=l.valueAsNumber||N&&+N;Fe(O.value)||(A=q>O.value),Fe(V.value)||(R=q<V.value)}else{const q=l.valueAsDate||new Date(N),I=se=>new Date(new Date().toDateString()+" "+se),J=l.type=="time",W=l.type=="week";Te(O.value)&&N&&(A=J?I(N)>I(O.value):W?N>O.value:q>new Date(O.value)),Te(V.value)&&N&&(R=J?I(N)<I(V.value):W?N<V.value:q<new Date(V.value))}if((A||R)&&(E(!!A,O.message,V.message,Ke.max,Ke.min),!n))return v(S[j].message),S}if((u||f)&&!C&&(Te(N)||i&&Array.isArray(N))){const A=ht(u),R=ht(f),O=!Fe(A.value)&&N.length>+A.value,V=!Fe(R.value)&&N.length<+R.value;if((O||V)&&(E(O,A.message,R.message),!n))return v(S[j].message),S}if(x&&!C&&Te(N)){const{value:A,message:R}=ht(x);if(as(A)&&!N.match(A)&&(S[j]={type:Ke.pattern,message:R,ref:l,..._(Ke.pattern,R)},!n))return v(R),S}if(g){if(Ae(g)){const A=await g(N,a),R=gn(A,D);if(R&&(S[j]={...R,..._(Ke.validate,R.message)},!n))return v(R.message),S}else if(be(g)){let A={};for(const R in g){if(!Se(A)&&!n)break;const O=gn(await g[R](N,a),D,R);O&&(A={...O,..._(R,O.message)},v(O.message),n&&(S[j]=A))}if(!Se(A)&&(S[j]={ref:D,...A},!n))return S}}return v(!0),S};const Xd={mode:Ve.onSubmit,reValidateMode:Ve.onChange,shouldFocusError:!0};function Jd(e={}){let s={...Xd,...e},a={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ae(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},r=be(s.defaultValues)||be(s.values)?he(s.defaultValues||s.values)||{}:{},i=s.shouldUnregister?{}:he(r),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},d,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...f};let h={...m};const x={array:on(),state:on()},g=s.criteriaMode===Ve.all,j=y=>$=>{clearTimeout(u),u=setTimeout(y,$)},b=async y=>{if(!l.keepIsValid&&!s.disabled&&(m.isValid||h.isValid||y)){let $;s.resolver?($=Se((await F()).errors),w()):$=await _(n,!0),$!==a.isValid&&x.state.next({isValid:$})}},w=(y,$)=>{!s.disabled&&(m.isValidating||m.validatingFields||h.isValidating||h.validatingFields)&&((y||Array.from(o.mount)).forEach(L=>{L&&($?ce(a.validatingFields,L,$):pe(a.validatingFields,L))}),x.state.next({validatingFields:a.validatingFields,isValidating:!Se(a.validatingFields)}))},N=(y,$=[],L,U,z=!0,T=!0)=>{if(U&&L&&!s.disabled){if(l.action=!0,T&&Array.isArray(H(n,y))){const G=L(H(n,y),U.argA,U.argB);z&&ce(n,y,G)}if(T&&Array.isArray(H(a.errors,y))){const G=L(H(a.errors,y),U.argA,U.argB);z&&ce(a.errors,y,G),Qd(a.errors,y)}if((m.touchedFields||h.touchedFields)&&T&&Array.isArray(H(a.touchedFields,y))){const G=L(H(a.touchedFields,y),U.argA,U.argB);z&&ce(a.touchedFields,y,G)}(m.dirtyFields||h.dirtyFields)&&(a.dirtyFields=gt(r,i)),x.state.next({name:y,isDirty:A(y,$),dirtyFields:a.dirtyFields,errors:a.errors,isValid:a.isValid})}else ce(i,y,$)},D=(y,$)=>{ce(a.errors,y,$),x.state.next({errors:a.errors})},v=y=>{a.errors=y,x.state.next({errors:a.errors,isValid:!1})},S=(y,$,L,U)=>{const z=H(n,y);if(z){const T=H(i,y,me(L)?H(r,y):L);me(T)||U&&U.defaultChecked||$?ce(i,y,$?T:mn(z._f)):V(y,T),l.mount&&!l.action&&b()}},M=(y,$,L,U,z)=>{let T=!1,G=!1;const re={name:y};if(!s.disabled){if(!L||U){(m.isDirty||h.isDirty)&&(G=a.isDirty,a.isDirty=re.isDirty=A(),T=G!==re.isDirty);const ie=Ue(H(r,y),$);G=!!H(a.dirtyFields,y),ie?pe(a.dirtyFields,y):ce(a.dirtyFields,y,!0),re.dirtyFields=a.dirtyFields,T=T||(m.dirtyFields||h.dirtyFields)&&G!==!ie}if(L){const ie=H(a.touchedFields,y);ie||(ce(a.touchedFields,y,L),re.touchedFields=a.touchedFields,T=T||(m.touchedFields||h.touchedFields)&&ie!==L)}T&&z&&x.state.next(re)}return T?re:{}},k=(y,$,L,U)=>{const z=H(a.errors,y),T=(m.isValid||h.isValid)&&Re($)&&a.isValid!==$;if(s.delayError&&L?(d=j(()=>D(y,L)),d(s.delayError)):(clearTimeout(u),d=null,L?ce(a.errors,y,L):pe(a.errors,y)),(L?!Ue(z,L):z)||!Se(U)||T){const G={...U,...T&&Re($)?{isValid:$}:{},errors:a.errors,name:y};a={...a,...G},x.state.next(G)}},F=async y=>(w(y,!0),await s.resolver(i,s.context,Hd(y||o.mount,n,s.criteriaMode,s.shouldUseNativeValidation))),C=async y=>{const{errors:$}=await F(y);if(w(y),y)for(const L of y){const U=H($,L);U?ce(a.errors,L,U):pe(a.errors,L)}else a.errors=$;return $},_=async(y,$,L={valid:!0})=>{for(const U in y){const z=y[U];if(z){const{_f:T,...G}=z;if(T){const re=o.array.has(T.name),ie=z._f&&qd(z._f);ie&&m.validatingFields&&w([T.name],!0);const ke=await bn(z,o.disabled,i,g,s.shouldUseNativeValidation&&!$,re);if(ie&&m.validatingFields&&w([T.name]),ke[T.name]&&(L.valid=!1,$||e.shouldUseNativeValidation))break;!$&&(H(ke,T.name)?re?Zd(a.errors,ke,T.name):ce(a.errors,T.name,ke[T.name]):pe(a.errors,T.name))}!Se(G)&&await _(G,$,L)}}return L.valid},E=()=>{for(const y of o.unMount){const $=H(n,y);$&&($._f.refs?$._f.refs.every(L=>!ks(L)):!ks($._f.ref))&&ae(y)}o.unMount=new Set},A=(y,$)=>!s.disabled&&(y&&$&&ce(i,y,$),!Ue(Y(),r)),R=(y,$,L)=>Ys(y,o,{...l.mount?i:me($)?r:Te(y)?{[y]:$}:$},L,$),O=y=>fa(H(l.mount?i:r,y,s.shouldUnregister?H(r,y,[]):[])),V=(y,$,L={})=>{const U=H(n,y);let z=$;if(U){const T=U._f;T&&(!T.disabled&&ce(i,y,Wr($,T)),z=ss(T.ref)&&Fe($)?"":$,Ur(T.ref)?[...T.ref.options].forEach(G=>G.selected=z.includes(G.value)):T.refs?Tt(T.ref)?T.refs.forEach(G=>{(!G.defaultChecked||!G.disabled)&&(Array.isArray(z)?G.checked=!!z.find(re=>re===G.value):G.checked=z===G.value||!!z)}):T.refs.forEach(G=>G.checked=G.value===z):ga(T.ref)?T.ref.value="":(T.ref.value=z,T.ref.type||x.state.next({name:y,values:he(i)})))}(L.shouldDirty||L.shouldTouch)&&M(y,z,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&se(y)},q=(y,$,L)=>{for(const U in $){if(!$.hasOwnProperty(U))return;const z=$[U],T=y+"."+U,G=H(n,T);(o.array.has(y)||be(z)||G&&!G._f)&&!ct(z)?q(T,z,L):V(T,z,L)}},I=(y,$,L={})=>{const U=H(n,y),z=o.array.has(y),T=he($);ce(i,y,T),z?(x.array.next({name:y,values:he(i)}),(m.isDirty||m.dirtyFields||h.isDirty||h.dirtyFields)&&L.shouldDirty&&x.state.next({name:y,dirtyFields:gt(r,i),isDirty:A(y,T)})):U&&!U._f&&!Fe(T)?q(y,T,L):V(y,T,L),hn(y,o)?x.state.next({...a,name:y,values:he(i)}):x.state.next({name:l.mount?y:void 0,values:he(i)})},J=async y=>{l.mount=!0;const $=y.target;let L=$.name,U=!0;const z=H(n,L),T=ie=>{U=Number.isNaN(ie)||ct(ie)&&isNaN(ie.getTime())||Ue(ie,H(i,L,ie))},G=fn(s.mode),re=fn(s.reValidateMode);if(z){let ie,ke;const it=$.type?mn(z._f):Pr(y),et=y.type===ts.BLUR||y.type===ts.FOCUS_OUT,Il=!Wd(z._f)&&!s.resolver&&!H(a.errors,L)&&!z._f.deps||Kd(et,H(a.touchedFields,L),a.isSubmitted,re,G),xs=hn(L,o,et);ce(i,L,it),et?(!$||!$.readOnly)&&(z._f.onBlur&&z._f.onBlur(y),d&&d(0)):z._f.onChange&&z._f.onChange(y);const hs=M(L,it,et),Pl=!Se(hs)||xs;if(!et&&x.state.next({name:L,type:y.type,values:he(i)}),Il)return(m.isValid||h.isValid)&&(s.mode==="onBlur"?et&&b():et||b()),Pl&&x.state.next({name:L,...xs?{}:hs});if(!et&&xs&&x.state.next({...a}),s.resolver){const{errors:Ta}=await F([L]);if(w([L]),T(it),U){const Ol=pn(a.errors,n,L),Ia=pn(Ta,n,Ol.name||L);ie=Ia.error,L=Ia.name,ke=Se(Ta)}}else w([L],!0),ie=(await bn(z,o.disabled,i,g,s.shouldUseNativeValidation))[L],w([L]),T(it),U&&(ie?ke=!1:(m.isValid||h.isValid)&&(ke=await _(n,!0)));U&&(z._f.deps&&(!Array.isArray(z._f.deps)||z._f.deps.length>0)&&se(z._f.deps),k(L,ke,ie,hs))}},W=(y,$)=>{if(H(a.errors,$)&&y.focus)return y.focus(),1},se=async(y,$={})=>{let L,U;const z=Et(y);if(s.resolver){const T=await C(me(y)?y:z);L=Se(T),U=y?!z.some(G=>H(T,G)):L}else y?(U=(await Promise.all(z.map(async T=>{const G=H(n,T);return await _(G&&G._f?{[T]:G}:G)}))).every(Boolean),!(!U&&!a.isValid)&&b()):U=L=await _(n);return x.state.next({...!Te(y)||(m.isValid||h.isValid)&&L!==a.isValid?{}:{name:y},...s.resolver||!y?{isValid:L}:{},errors:a.errors}),$.shouldFocus&&!U&&Ft(n,W,y?z:o.mount),U},Y=(y,$)=>{let L={...l.mount?i:r};return $&&(L=Vr($.dirtyFields?a.dirtyFields:a.touchedFields,L)),me(y)?L:Te(y)?H(L,y):y.map(U=>H(L,U))},Z=(y,$)=>({invalid:!!H(($||a).errors,y),isDirty:!!H(($||a).dirtyFields,y),error:H(($||a).errors,y),isValidating:!!H(a.validatingFields,y),isTouched:!!H(($||a).touchedFields,y)}),Q=y=>{y&&Et(y).forEach($=>pe(a.errors,$)),x.state.next({errors:y?a.errors:{}})},ee=(y,$,L)=>{const U=(H(n,y,{_f:{}})._f||{}).ref,z=H(a.errors,y)||{},{ref:T,message:G,type:re,...ie}=z;ce(a.errors,y,{...ie,...$,ref:U}),x.state.next({name:y,errors:a.errors,isValid:!1}),L&&L.shouldFocus&&U&&U.focus&&U.focus()},ne=(y,$)=>Ae(y)?x.state.subscribe({next:L=>"values"in L&&y(R(void 0,$),L)}):R(y,$,!0),X=y=>x.state.subscribe({next:$=>{Gd(y.name,$.name,y.exact)&&Yd($,y.formState||m,le,y.reRenderRoot)&&y.callback({values:{...i},...a,...$,defaultValues:r})}}).unsubscribe,de=y=>(l.mount=!0,h={...h,...y.formState},X({...y,formState:{...f,...y.formState}})),ae=(y,$={})=>{for(const L of y?Et(y):o.mount)o.mount.delete(L),o.array.delete(L),$.keepValue||(pe(n,L),pe(i,L)),!$.keepError&&pe(a.errors,L),!$.keepDirty&&pe(a.dirtyFields,L),!$.keepTouched&&pe(a.touchedFields,L),!$.keepIsValidating&&pe(a.validatingFields,L),!s.shouldUnregister&&!$.keepDefaultValue&&pe(r,L);x.state.next({values:he(i)}),x.state.next({...a,...$.keepDirty?{isDirty:A()}:{}}),!$.keepIsValid&&b()},Ie=({disabled:y,name:$})=>{if(Re(y)&&l.mount||y||o.disabled.has($)){const z=o.disabled.has($)!==!!y;y?o.disabled.add($):o.disabled.delete($),z&&l.mount&&!l.action&&b()}},Ee=(y,$={})=>{let L=H(n,y);const U=Re($.disabled)||Re(s.disabled);return ce(n,y,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:y}},name:y,mount:!0,...$}}),o.mount.add(y),L?Ie({disabled:Re($.disabled)?$.disabled:s.disabled,name:y}):S(y,!0,$.value),{...U?{disabled:$.disabled||s.disabled}:{},...s.progressive?{required:!!$.required,min:kt($.min),max:kt($.max),minLength:kt($.minLength),maxLength:kt($.maxLength),pattern:kt($.pattern)}:{},name:y,onChange:J,onBlur:J,ref:z=>{if(z){Ee(y,$),L=H(n,y);const T=me(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,G=zd(T),re=L._f.refs||[];if(G?re.find(ie=>ie===T):T===L._f.ref)return;ce(n,y,{_f:{...L._f,...G?{refs:[...re.filter(ks),T,...Array.isArray(H(r,y))?[{}]:[]],ref:{type:T.type,name:y}}:{ref:T}}}),S(y,!1,void 0,T)}else L=H(n,y,{}),L._f&&(L._f.mount=!1),(s.shouldUnregister||$.shouldUnregister)&&!(Or(o.array,y)&&l.action)&&o.unMount.add(y)}}},Le=()=>s.shouldFocusError&&Ft(n,W,o.mount),mt=y=>{Re(y)&&(x.state.next({disabled:y}),Ft(n,($,L)=>{const U=H(n,L);U&&($.disabled=U._f.disabled||y,Array.isArray(U._f.refs)&&U._f.refs.forEach(z=>{z.disabled=U._f.disabled||y}))},0,!1))},Ge=(y,$)=>async L=>{let U;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let z=he(i);if(x.state.next({isSubmitting:!0}),s.resolver){const{errors:T,values:G}=await F();w(),a.errors=T,z=he(G)}else await _(n);if(o.disabled.size)for(const T of o.disabled)pe(z,T);if(pe(a.errors,"root"),Se(a.errors)){x.state.next({errors:{}});try{await y(z,L)}catch(T){U=T}}else $&&await $({...a.errors},L),Le(),setTimeout(Le);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(a.errors)&&!U,submitCount:a.submitCount+1,errors:a.errors}),U)throw U},We=(y,$={})=>{H(n,y)&&(me($.defaultValue)?I(y,he(H(r,y))):(I(y,$.defaultValue),ce(r,y,he($.defaultValue))),$.keepTouched||pe(a.touchedFields,y),$.keepDirty||(pe(a.dirtyFields,y),a.isDirty=$.defaultValue?A(y,he(H(r,y))):A()),$.keepError||(pe(a.errors,y),m.isValid&&b()),x.state.next({...a}))},rt=(y,$={})=>{const L=y?he(y):r,U=he(L),z=Se(y),T=z?r:U;if($.keepDefaultValues||(r=L),!$.keepValues){if($.keepDirtyValues){const G=new Set([...o.mount,...Object.keys(gt(r,i))]);for(const re of Array.from(G)){const ie=H(a.dirtyFields,re),ke=H(i,re),it=H(T,re);ie&&!me(ke)?ce(T,re,ke):!ie&&!me(it)&&I(re,it)}}else{if(ma&&me(y))for(const G of o.mount){const re=H(n,G);if(re&&re._f){const ie=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(ss(ie)){const ke=ie.closest("form");if(ke){ke.reset();break}}}}if($.keepFieldsRef)for(const G of o.mount)I(G,H(T,G));else n={}}i=s.shouldUnregister?$.keepDefaultValues?he(r):{}:he(T),x.array.next({values:{...T}}),x.state.next({values:{...T}})}o={mount:$.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!$.keepIsValid||!!$.keepDirtyValues||!s.shouldUnregister&&!Se(T),l.watch=!!s.shouldUnregister,l.keepIsValid=!!$.keepIsValid,l.action=!1,$.keepErrors||(a.errors={}),x.state.next({submitCount:$.keepSubmitCount?a.submitCount:0,isDirty:z?!1:$.keepDirty?a.isDirty:!!($.keepDefaultValues&&!Ue(y,r)),isSubmitted:$.keepIsSubmitted?a.isSubmitted:!1,dirtyFields:z?{}:$.keepDirtyValues?$.keepDefaultValues&&i?gt(r,i):a.dirtyFields:$.keepDefaultValues&&y?gt(r,y):$.keepDirty?a.dirtyFields:{},touchedFields:$.keepTouched?a.touchedFields:{},errors:$.keepErrors?a.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?a.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},Je=(y,$)=>rt(Ae(y)?y(i):y,{...s.resetOptions,...$}),Pe=(y,$={})=>{const L=H(n,y),U=L&&L._f;if(U){const z=U.refs?U.refs[0]:U.ref;z.focus&&setTimeout(()=>{z.focus(),$.shouldSelect&&Ae(z.select)&&z.select()})}},le=y=>{a={...a,...y}},Ye={control:{register:Ee,unregister:ae,getFieldState:Z,handleSubmit:Ge,setError:ee,_subscribe:X,_runSchema:F,_updateIsValidating:w,_focusError:Le,_getWatch:R,_getDirty:A,_setValid:b,_setFieldArray:N,_setDisabledField:Ie,_setErrors:v,_getFieldArray:O,_reset:rt,_resetDefaultValues:()=>Ae(s.defaultValues)&&s.defaultValues().then(y=>{Je(y,s.resetOptions),x.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:mt,_subjects:x,_proxyFormState:m,get _fields(){return n},get _formValues(){return i},get _state(){return l},set _state(y){l=y},get _defaultValues(){return r},get _names(){return o},set _names(y){o=y},get _formState(){return a},get _options(){return s},set _options(y){s={...s,...y}}},subscribe:de,trigger:se,register:Ee,handleSubmit:Ge,watch:ne,setValue:I,getValues:Y,reset:Je,resetField:We,clearErrors:Q,unregister:ae,setError:ee,setFocus:Pe,getFieldState:Z};return{...Ye,formControl:Ye}}function eu(e={}){const s=p.useRef(void 0),a=p.useRef(void 0),[n,r]=p.useState({isDirty:!1,isValidating:!1,isLoading:Ae(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:Ae(e.defaultValues)?void 0:e.defaultValues});if(!s.current)if(e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!Ae(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Jd(e);s.current={...o,formState:n}}const i=s.current.control;return i._options=e,pa(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>r({...i._formState}),reRenderRoot:!0});return r(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[i]),p.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),p.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),p.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),p.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),p.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==n.isDirty&&i._subjects.state.next({isDirty:l})}},[i,n.isDirty]),p.useEffect(()=>{var l;e.values&&!Ue(e.values,a.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),a.current=e.values,r(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),p.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()}),s.current.formState=p.useMemo(()=>Br(n,i),[i,n]),s.current}function tu(e,s=3){return e%1===0?e.toString():e.toFixed(s).replace(/\.?0+$/,"")}function su(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}function au(e="USD",s="en-US"){try{return new Intl.NumberFormat(s,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function nu(e){const s=e.replace(/[^\d.,-]/g,""),a=s.match(/,\d{1,2}$/);let n;a?n=s.replace(/\./g,"").replace(",","."):n=s.replace(/,/g,"");const r=parseFloat(n);return isNaN(r)?null:r}function ru(e,s,a=.001){const n=e-s,r=Math.abs(n)<=a;return{difference:n,isBalanced:r,isUnderAllocated:!r&&n>0,isOverAllocated:!r&&n<0}}function ya(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}ya();const iu={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:"$"},Ss=()=>({id:ya(),amount:0,glAccount:null,isTaxDeductible:!1}),Gr=({distribution:e,defaultDistribution:s,glAccounts:a=[],isLoadingGlAccounts:n=!1,onSearchGlAccounts:r,onDistributionChange:i,onAmountChange:l,onGlAccountChange:o,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:m=!0,isDisabled:h=!1,labels:x,classNames:g={},"data-testid":j,control:b,name:w,rules:N})=>{const D={...iu,...x},v=b!==void 0&&w!==void 0,S=eu({defaultValues:{_internal:s||Ss()}}),M=Id({control:v?b:S.control,name:v?w:"_internal",rules:v?N:void 0}),[k,F]=p.useState(s||Ss()),C=v?M.field.value??Ss():e??k,_=v&&!!M.fieldState?.error,E=v&&(M.fieldState?.isTouched??!1),A=_||E,R=A&&(!C.amount||C.amount<=0),O=A&&!C.glAccount,[V,q]=p.useState(C.glAccount?.name||""),I=p.useCallback(ee=>{const ne={...C,...ee};v&&M.field.onChange(ne),!v&&e===void 0&&F(ne),i?.(ne)},[C,e,i,v,M]),J=p.useCallback(ee=>{const ne=ee||0;I({amount:ne}),l?.(ne)},[I,l]),W=p.useCallback(ee=>{q(ee),r?.(ee)},[r]),se=p.useCallback(ee=>{if(ee===null){I({glAccount:null}),o?.(null);return}const X=a.find(de=>String(de.id)===String(ee))||null;I({glAccount:X}),o?.(X)},[a,I,o]),Y=p.useCallback(()=>{q(""),I({glAccount:null}),o?.(null)},[I,o]),Z=p.useCallback(ee=>{I({isTaxDeductible:ee}),d?.(ee)},[I,d]),Q=p.useCallback(()=>{u?.()},[u]);return t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":j||"revenue-distribution-card",className:c.cn(g.base),children:t.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",g.body),children:[t.jsx("div",{className:c.cn("shrink-0",g.amountContainer),children:t.jsx(c.NumberInput,{"data-testid":`${j||"revenue-distribution-card"}-amount-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[D.amount,t.jsx(c.Tooltip,{content:D.amountTooltip,children:t.jsx(P,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:C.amount||void 0,onValueChange:J,labelPlacement:"outside",placeholder:D.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:h,isInvalid:R,errorMessage:R?"Amount is required":void 0,minValue:0,step:.01,className:g.amountInput,startContent:t.jsx("div",{className:"pointer-events-none flex items-center",children:t.jsx("span",{className:"text-default-400 text-small",children:D.currencySymbol})})})}),t.jsx("div",{className:c.cn("grow",g.glAccountContainer),children:t.jsx(c.Autocomplete,{"data-testid":`${j||"revenue-distribution-card"}-gl-account-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[D.glAccount,t.jsx(c.Tooltip,{content:D.glAccountTooltip,children:t.jsx(P,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:n,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:a,menuTrigger:"input",inputValue:C.glAccount?.name??V,selectedKey:C.glAccount?.id??null,isDisabled:h,isInvalid:O,errorMessage:O?"GL Account is required":void 0,listboxProps:{emptyContent:n?D.searching:D.noGlAccountsFound},placeholder:D.glAccountPlaceholder,onInputChange:W,onSelectionChange:se,onClear:Y,className:g.glAccountInput,children:ee=>t.jsx(c.AutocompleteItem,{textValue:ee.name,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:ee.name}),ee.code&&t.jsx("span",{className:"text-xs text-default-400",children:ee.code})]})},ee.id)})}),t.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",g.taxDeductibleContainer),children:t.jsx(c.Checkbox,{radius:"full","data-testid":`${j||"revenue-distribution-card"}-tax-deductible`,isSelected:C.isTaxDeductible,onValueChange:Z,isDisabled:h||!m,className:g.taxDeductibleCheckbox,children:D.taxDeductible})}),t.jsx("div",{className:c.cn("shrink-0 pt-6",g.deleteContainer),children:t.jsx(B,{"data-testid":`${j||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:h||!f,onPress:Q,startContent:t.jsx(P,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",g.deleteButton),children:D.deleteButton})})]})})};Gr.displayName="RevenueDistributionCard";const Kr=({message:e="No distributions configured",icon:s="solar:document-text-outline",iconSize:a=48,showCard:n=!0,classNames:r={},renderEmpty:i})=>{if(i)return t.jsx(t.Fragment,{children:i()});const l=t.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",r.content),children:[t.jsx(P,{icon:s,width:a,className:c.cn("text-default-300 mb-4",r.icon)}),t.jsx("p",{className:c.cn("text-default-500 text-sm text-center",r.message),children:e})]});return n?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:l})};Kr.displayName="RevenueDistributionEmpty";const lu={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Qr=({error:e,labels:s,showCard:a=!0,color:n="danger",classNames:r={}})=>{const i={...lu,...s},l=t.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:n,title:i.title,description:e||i.description,className:r.alert});return a?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:l})};Qr.displayName="RevenueDistributionError";const Zr=({rows:e=1,showCard:s=!0,classNames:a={}})=>{const n=Array.from({length:e},(i,l)=>l),r=i=>t.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",a.row),children:[t.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),t.jsxs("div",{className:"grow flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),t.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[t.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),t.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),t.jsx("div",{className:"shrink-0 pb-2",children:t.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return s?t.jsx("div",{className:c.cn("flex flex-col gap-3",a.base),children:n.map(i=>t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:t.jsx(c.CardBody,{children:r(i)})},i))}):t.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",a.base),children:n.map(i=>r(i))})};Zr.displayName="RevenueDistributionSkeleton";function va({isOpen:e,labels:s,icon:a,isConfirming:n=!1,confirmColor:r="danger",iconTone:i="danger",portalContainer:l,shouldBlockScroll:o,classNames:d,onClose:u,onConfirm:f}){return t.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:l,shouldBlockScroll:o,classNames:{...d,base:c.cn("max-w-[440px] rounded-3xl",d?.base),closeButton:c.cn("right-5 top-5 text-zinc-500",d?.closeButton)},onOpenChange:m=>!m&&u(),children:t.jsxs(c.ModalContent,{children:[t.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[a&&t.jsx("span",{className:c.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:a}),t.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:s.title})]}),t.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:t.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:s.description})}),t.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[t.jsx(B,{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:s.cancel}),t.jsx(B,{type:"button",size:"md",color:r,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",r==="danger"?"bg-danger-600":"bg-brand"),isLoading:n,onPress:f,children:s.confirm})]})]})})}const ou=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function yn(e){return!e.fund&&Number(e.percentage||0)<=0}function cu({mode:e,assignments:s}){const a=s.filter(i=>i.fund),n=a.reduce((i,l)=>i+Number(l.percentage||0),0),r=s.some(i=>!i.fund||Number(i.percentage||0)<=0);return a.length>=1&&!r&&Math.round(n*100)/100===100}const du={title:"Payment assignment",saved:"Saved",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"},Xr={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"},St={...Xr,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},uu={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"},mu={wrapper:"!absolute !inset-0 !z-50 !h-auto !w-auto !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 !h-auto !w-auto rounded-2xl"};function fu(){return t.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[t.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const xu=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,hu=e=>e.fund!==null;function pu({assignments:e,funds:s,labels:a,classNames:n,isSaving:r=!1,hasSavedAssignments:i=!1,showSavedIndicator:l=!1,isCollapsed:o,isFundPickerOpen:d=!1,activeAssignmentId:u=null,modalPortalContainer:f,footer:m,onAssignmentsChange:h,onOpenFundPicker:x,onCloseFundPicker:g,onCollapseChange:j,onSave:b}){const[w,N]=p.useState(null),D=f??w??void 0,v={...du,...a},S=e.filter(X=>!yn(X)),k=S.filter(hu).length>0,F=p.useMemo(()=>e.filter(X=>!yn(X)).reduce((X,de)=>X+Number(de.percentage||0),0),[e]),C=Math.round(F*100)/100,_=S.some(X=>!X.fund||Number(X.percentage||0)<=0),E=k&&(C!==100||_),A=`${v.totalError} (${v.total} ${Number(F.toFixed(2))}%)`,R=cu({mode:"split",assignments:e}),O=k&&C>=100,[V,q]=p.useState(!1),[I,J]=p.useState(!1),W=t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(fu,{}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:v.title}),l?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:v.saved}):null]}),se=(X,de)=>{h(e.map(ae=>ae.id===X?{...ae,...de}:ae))},Y=()=>{O||h([...e,ou()])},Z=X=>{e.length<=1||h(e.filter(de=>de.id!==X))},Q=()=>{if(!r){if(!R){J(!0);return}if(!i){b();return}q(!0)}},ee=()=>{q(!1),b()},ne=X=>{const de=u??e.find(ae=>!ae.fund)?.id??e[0]?.id;de&&(h(e.map(ae=>ae.id===de?{...ae,fund:X}:ae)),g())};return t.jsxs("div",{ref:N,className:c.cn("vvt-pa relative min-w-0 w-full font-sans text-zinc-900 [container-type:inline-size]",d&&!f&&"min-h-[560px]",n?.root),children:[t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:o===void 0?["installment-fund-assignment"]:void 0,selectedKeys:o===void 0?void 0:new Set(o?[]:["installment-fund-assignment"]),className:c.cn("w-full gap-0 px-0",n?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",n?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:X=>j?.(!(X==="all"||Array.from(X).length>0)),children:t.jsx(c.AccordionItem,{"aria-label":v.title,title:W,children:t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",n?.content),children:[t.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!k&&t.jsx(c.Alert,{icon:t.jsx(P,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Xr,color:"default",variant:"flat",title:v.emptySplit}),k&&t.jsx(gu,{assignments:e,labels:v,total:F,hasTotalError:I&&!R||E,validationMessage:A,onSelectFund:X=>x(X),onRemoveFund:Z,onPercentageChange:(X,de)=>se(X,{percentage:xu(de)})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx(B,{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 [@container(max-width:479px)]:w-full",startContent:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:O,onPress:()=>k?Y():x(),children:v.assignSpecificFund}),t.jsx(B,{type:"button","data-testid":"installment-fund-assignment-save-button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-40 px-4 text-sm font-medium [@container(max-width:479px)]:w-full",startContent:r?void 0:t.jsx(P,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:r,isDisabled:!R||r,onPress:Q,children:v.saveAssignment})]})]}),m]})},"installment-fund-assignment")}),d&&t.jsx(bu,{funds:s,labels:v,selectedFundIds:e.map(X=>X.fund?.id).filter(Boolean),portalContainer:D,onSelect:ne,onClose:g}),t.jsx(va,{isOpen:V,labels:{title:v.modifyAssignedFundsTitle,description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:v.modifyAssignedFundsDescription}),t.jsx("p",{className:"mt-3",children:v.modifyAssignedFundsWarning})]}),cancel:v.modifyAssignedFundsCancel,confirm:v.modifyAssignedFundsConfirm},icon:t.jsx(P,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:D,shouldBlockScroll:!1,classNames:mu,onClose:()=>q(!1),onConfirm:ee})]})}function gu({assignments:e,labels:s,total:a,hasTotalError:n,validationMessage:r,onSelectFund:i,onRemoveFund:l,onPercentageChange:o}){return t.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>t.jsxs("div",{"data-testid":"installment-fund-assignment-row",className:"flex min-h-15 w-full flex-wrap items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[t.jsx("div",{className:c.cn("flex min-h-11 min-w-0 basis-full items-center gap-2","[@container(min-width:560px)]:basis-0 [@container(min-width:560px)]:flex-1 [@container(min-width:560px)]:gap-4"),children:d.fund?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"min-w-0 break-words rounded-2xl bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[d.fund.glCode," - ",d.fund.accountName]}),t.jsx(B,{type:"button",variant:"light",color:"primary",radius:"full",className:"flex-none px-2 text-sm font-normal",onPress:()=>i(d.id),children:"Replace"})]}):t.jsx(B,{type:"button",size:"lg",variant:"light",radius:"full",className:"max-w-full justify-start px-4 text-lg font-normal text-zinc-900",startContent:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:s.assignSpecificFund})}),t.jsx("label",{className:"flex min-w-0 flex-1 items-center [@container(min-width:560px)]:w-48 [@container(min-width:560px)]:flex-none",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>o(d.id,Number(f.target.value)),endContent:t.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:uu})}),e.length>1&&t.jsx(B,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:c.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(d.id),"aria-label":s.removeFund,children:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),t.jsx(c.Alert,{icon:t.jsx(P,{icon:n?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:n?"warning":"success",variant:"flat",classNames:{...St,base:c.cn(St.base,n?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(St.iconWrapper,n?"text-warning-700":"text-success-700"),alertIcon:c.cn(St.alertIcon,n?"text-warning-700":"text-success-700"),title:c.cn(St.title,n?"text-warning-700":"text-success-700")},title:n?r:`${s.total} ${Number(a.toFixed(2))}%`})]})}function bu({funds:e,labels:s,selectedFundIds:a,portalContainer:n,onSelect:r,onClose:i}){const[l,o]=p.useState(""),d=e.filter(u=>{if(a.includes(u.id))return!1;const f=l.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return t.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:n,classNames:{wrapper:"!absolute !inset-0 !z-50 !h-auto !w-auto !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 !h-auto !w-auto rounded-2xl",base:"max-h-[calc(100%-2rem)] w-full max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:u=>!u&&i(),children:t.jsxs(c.ModalContent,{className:"max-h-full",children:[t.jsx(c.ModalHeader,{className:"px-6 pr-12 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:s.modalTitle}),t.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[t.jsx(c.Input,{variant:"bordered","aria-label":s.searchPlaceholder,value:l,placeholder:s.searchPlaceholder,onChange:u=>o(u.target.value),startContent:t.jsx(P,{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"}}),t.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto [container-type:inline-size]",children:[t.jsxs("div",{className:"hidden 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 [@container(min-width:520px)]:grid",children:[t.jsx("span",{children:s.glCode}),t.jsx("span",{children:s.accountName}),t.jsx("span",{children:s.actions})]}),d.length===0&&t.jsx("div",{className:"p-4 text-sm text-zinc-500",children:s.noFunds}),d.map(u=>t.jsxs("div",{"data-testid":"installment-fund-picker-row",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 border-b border-zinc-100 px-3 py-2.5 text-sm leading-5 text-zinc-900 last:border-b-0 [@container(min-width:520px)]:grid-cols-[1fr_1.3fr_0.6fr] [@container(min-width:520px)]:gap-5 [@container(min-width:520px)]:border-b-0",children:[t.jsx("span",{className:"col-start-1 row-start-1 font-medium [@container(min-width:520px)]:font-normal",children:u.glCode}),t.jsx("span",{className:"col-start-1 row-start-2 min-w-0 break-words text-zinc-600 [@container(min-width:520px)]:col-start-2 [@container(min-width:520px)]:row-start-1 [@container(min-width:520px)]:text-zinc-900",children:u.accountName}),t.jsx(B,{type:"button",size:"sm",variant:"bordered",radius:"full",className:"col-start-2 row-span-2 row-start-1 h-9 min-w-20 border-zinc-200 bg-white text-sm font-medium text-zinc-900 [@container(min-width:520px)]:col-start-3 [@container(min-width:520px)]:row-span-1 [@container(min-width:520px)]:min-w-24",onPress:()=>r(u),children:s.select})]},u.id))]})]})]})})}function yu(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const vu={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function ju({totalAmount:e,remainingBalance:s,amountReceived:a,currency:n="USD",locale:r="en-US",labels:i,className:l}){const o={...vu,...i},d=new Intl.NumberFormat(r,{style:"currency",currency:n});return t.jsx("div",{className:c.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",l),children:t.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[t.jsx($s,{label:o.totalAmount,value:d.format(e)}),t.jsx($s,{label:o.remainingBalance,value:d.format(s)}),t.jsx($s,{label:o.amountReceived,value:d.format(a)})]})})}function $s({label:e,value:s}){return t.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[t.jsx("span",{className:"font-medium text-zinc-700",children:e}),t.jsx("span",{className:"font-normal text-zinc-950",children:s})]})}const wu={monthly:1,quarterly:3,annual:12},Jr=e=>{const[s,a,n]=e.split("-").map(Number);return{year:s,month:a,day:n}},Nu=(e,s)=>new Date(e,s+1,0).getDate(),Cu=e=>{const s=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${s}-${a}-${n}`},ku=(e,s)=>{const{year:a,month:n,day:r}=Jr(e),i=n-1+s,l=a+Math.floor(i/12),o=(i%12+12)%12,d=Math.min(r,Nu(l,o));return new Date(l,o,d)},Su=(e,s)=>{const{year:a,month:n,day:r}=Jr(e),i=new Date(a,n-1,r);return i.setDate(i.getDate()+s),i};function ei(e,s){const a=Math.max(1,Math.floor(s.numberOfInstallments||1)),n=Math.round(e*100),r=Math.floor(n/a),i=n-r*a,l=wu[s.frequency];return Array.from({length:a},(o,d)=>{const u=s.frequency==="weekly"?Su(s.firstInstallmentDate,d*7):ku(s.firstInstallmentDate,d*(l??1));return{id:crypto.randomUUID(),dueDate:Cu(u),amount:(r+(d===0?i:0))/100}})}function $u(e){return new Set(e.map((s,a)=>{const n=e[a+1]?.dueDate;return s.dueDate&&n&&s.dueDate>n?s.id:null}).filter(s=>!!s))}function Au(e){return{missingDateRows:new Set(e.filter(s=>!s.dueDate).map(s=>s.id)),invalidDateRows:$u(e),invalidAmountRows:new Set(e.filter(s=>Number(s.amount||0)<=0).map(s=>s.id))}}function Du(e){return e.missingDateRows.size>0||e.invalidDateRows.size>0||e.invalidAmountRows.size>0}function Eu(e,s){const a=e[0];return!a||!s||a.dueDate===s?e:[{...a,dueDate:s},...e.slice(1)]}const Fu=new Set(["paid","partially_refunded","refunded"]);function dt(e){return e!==void 0&&Fu.has(e)}const Lu={title:"Payments",saved:"Saved",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",cancelEdit:"Cancel",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",dayOfMonth:"Day of month",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",weekly:"Weekly",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal the total 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.",dueDateRequiredError:"Payment date is required.",amountGreaterThanZeroError:"Payment amount must be greater than 0."},Mu=["weekly","monthly","quarterly","annual"],_u=Array.from({length:31},(e,s)=>s+1),Ru=["numberOfInstallments","frequency","firstInstallmentDate"],vn=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),ns=e=>Math.round(e*100)/100,Tu=(e,s)=>{const a=new Date(`${e}T00:00:00`);return Number.isNaN(a.getTime())?e:new Intl.DateTimeFormat(s,{month:"short",day:"numeric",year:"numeric"}).format(a)},ms=e=>{if(!e)return null;try{return Ac(e)}catch{return null}},Iu=e=>ms(e)?.day??1,Pu=(e,s)=>new Date(e,s,0).getDate(),Ou=(e,s)=>{const a=ms(e);if(!a)return e;const n=Math.min(s,Pu(a.year,a.month));return a.set({day:n}).toString()},jn=e=>{const s=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${s}`};function zu({mode:e,donationAmount:s,currency:a="USD",locale:n="en-US",installments:r,automaticSettings:i,defaultTab:l="automatic",showTitle:o=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:m=Ru,startDate:h,firstInstallmentDateOverride:x,labels:g,classNames:j,isSaving:b=!1,showSavedIndicator:w=!1,isModeSwitchDisabled:N=!1,onModeChange:D,onAutomaticSettingsChange:v,onInstallmentsChange:S,onSave:M,onCancel:k}){const[F,C]=p.useState(l),_={...Lu,...g},E=e??F,A=p.useMemo(()=>new Intl.NumberFormat(n,{style:"currency",currency:a}),[a,n]),R=p.useMemo(()=>({...i,firstInstallmentDate:m.includes("firstInstallmentDate")?i.firstInstallmentDate:m.includes("dayOfMonth")?i.firstInstallmentDate||h||"":h||i.firstInstallmentDate}),[i,m,h]),O=E==="automatic"?Eu(ei(s,R),m.includes("firstInstallmentDate")?void 0:x):r,V=p.useMemo(()=>ns(O.reduce((ae,Ie)=>ae+Number(Ie.amount||0),0)),[O]),q=Math.abs(V-s)>.009,I=ns(s-V)<=0,J=p.useMemo(()=>Au(r),[r]),W=E==="manual"&&Du(J),se=q||W,Y=o?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:_.title}),w?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:_.saved}):null]}):void 0,Z=ae=>{ae!==E&&(e||C(ae),D?.(ae),ae==="manual"&&r.length===0&&S([vn()]))},Q=(ae,Ie)=>{const Ee=r.find(Le=>Le.id===ae);dt(Ee?.status)||S(r.map(Le=>Le.id===ae?{...Le,...Ie}:Le))},ee=()=>{S([...r,vn()])},ne=ae=>{const Ie=r.find(Ee=>Ee.id===ae);dt(Ie?.status)||S(r.filter(Ee=>Ee.id!==ae))},X=()=>{b||se||M?.()},de=t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.content),children:[f||u||k?t.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?t.jsx(Bu,{mode:E,labels:_,onModeChange:Z,isDisabled:N,className:j?.tabs}):null,t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[k?t.jsx(B,{type:"button","data-testid":"installment-schedule-cancel-button",size:"md",variant:"bordered",radius:"full",className:"min-w-28",isDisabled:b,onPress:k,children:_.cancelEdit}):null,u?t.jsx(B,{type:"button","data-testid":"installment-schedule-save-button",size:"md",color:"primary",radius:"full",className:"min-w-36",startContent:b?void 0:t.jsx(P,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:b,isDisabled:b||se,onPress:X,children:_.saveInstallments}):null]})]}):null,t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.preview),children:[E==="automatic"&&t.jsx(Vu,{settings:R,inputs:m,labels:_,className:j?.controls,onSettingsChange:v}),O.length===0&&t.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:E==="automatic"?_.emptyAutomatic:_.emptyManual}),O.length>0&&t.jsx(Uu,{mode:E,installments:O,rowErrors:J,labels:_,formatter:A,locale:n,onUpdateInstallment:Q,onRemoveInstallment:ne}),E==="manual"&&t.jsx("div",{className:"flex flex-wrap gap-3",children:t.jsx(B,{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:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:I,onPress:ee,children:_.addInstallment})}),t.jsx(Yu,{total:V,donationAmount:s,hasTotalMismatch:q,mode:E,installments:O,formatter:A,labels:_,className:j?.summary})]})]});return t.jsx("div",{className:c.cn("vvt-ps relative font-sans text-zinc-900",j?.root),children:d?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",j?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",j?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":_.title,title:Y,children:de},"installment-schedule")}):de})}function Bu({mode:e,labels:s,className:a,isDisabled:n=!1,onModeChange:r}){return t.jsxs(c.Tabs,{"aria-label":s.title,selectedKey:e,isDisabled:n,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",a),onSelectionChange:i=>r(i),children:[t.jsx(c.Tab,{title:s.automaticMode},"automatic"),t.jsx(c.Tab,{title:s.manualMode},"manual")]})}function Vu({settings:e,inputs:s,labels:a,className:n,onSettingsChange:r}){const i=l=>{if(l==="numberOfInstallments")return t.jsx("div",{className:"min-w-0",children:t.jsx(c.Input,{variant:"bordered",label:a.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:o=>o.currentTarget.blur(),onChange:o=>{const d=o.target.value;r({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},l);if(l==="frequency")return t.jsx("div",{className:"min-w-0",children:t.jsx(He,{variant:"bordered",label:a.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:o=>{const d=Array.from(o)[0];typeof d=="string"&&r({...e,frequency:d})},children:Mu.map(o=>t.jsx(c.SelectItem,{textValue:a[o],children:a[o]},o))})},l);if(l==="dayOfMonth"){const o=String(Iu(e.firstInstallmentDate));return t.jsx("div",{className:"min-w-0",children:t.jsx(He,{variant:"bordered",label:a.dayOfMonth,labelPlacement:"outside",selectedKeys:[o],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&r({...e,firstInstallmentDate:Ou(e.firstInstallmentDate,u)})},children:_u.map(d=>t.jsx(c.SelectItem,{textValue:jn(d),children:jn(d)},String(d)))})},l)}return t.jsx("div",{className:"min-w-0",children:t.jsx(ua,{variant:"bordered",label:a.firstInstallmentDate,labelPlacement:"outside",value:ms(e.firstInstallmentDate),onChange:o=>r({...e,firstInstallmentDate:o?o.toString():""}),startContent:t.jsx(P,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},l)};return s.length===0?null:t.jsx("div",{className:c.cn("grid gap-4",n),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:s.map(i)})}function Uu({mode:e,installments:s,rowErrors:a,labels:n,formatter:r,locale:i,onUpdateInstallment:l,onRemoveInstallment:o}){return e==="automatic"?t.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:t.jsx("div",{className:c.cn("flex flex-col gap-3",s.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:s.map((d,u)=>t.jsxs("div",{className:c.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",u===0&&"border border-primary/25 bg-primary/5 text-primary"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["#",u+1]}),t.jsx("span",{children:"▪"}),t.jsx("span",{children:Tu(d.dueDate,i)}),u===0&&s.length>1&&t.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),t.jsx("span",{className:"text-zinc-950",children:r.format(d.amount)})]},d.id))})}):t.jsx("div",{className:"flex flex-col gap-2",children:s.map((d,u)=>{const f=a.missingDateRows.has(d.id),m=a.invalidDateRows.has(d.id),h=a.invalidAmountRows.has(d.id);return t.jsx("div",{className:"flex w-full flex-col gap-1",children:t.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[t.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:u+1}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(ua,{variant:"bordered","aria-label":`${n.dueDate} ${u+1}`,isDisabled:dt(d.status),isInvalid:f||m,errorMessage:f?n.dueDateRequiredError:m?n.dateOrderError:void 0,value:ms(d.dueDate),onChange:x=>l(d.id,{dueDate:x?x.toString():""})})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(qu,{amount:d.amount,ariaLabel:`${n.amount} ${u+1}`,isDisabled:dt(d.status),isInvalid:h,errorMessage:n.amountGreaterThanZeroError,onAmountChange:x=>l(d.id,{amount:x})})}),t.jsx(Wu,{isDisabled:s.length<=1,isPaid:dt(d.status),label:n.deleteInstallment,onRemove:()=>o(d.id)})]})},d.id)})})}const Hu=/^\d*(?:[.,]\d{0,2})?$/;function qu({amount:e,ariaLabel:s,isDisabled:a,isInvalid:n,errorMessage:r,onAmountChange:i}){const[l,o]=p.useState(null);return t.jsx(c.Input,{variant:"bordered","aria-label":s,type:"text",inputMode:"decimal",autoComplete:"off",isDisabled:a,isInvalid:n,errorMessage:n?r:void 0,value:l??(e?String(e):""),onChange:d=>{const u=d.target.value.trim();if(!Hu.test(u))return;o(u);const f=Number(u.replace(",","."));i(ns(Number.isFinite(f)?f:0))},onBlur:()=>o(null),startContent:t.jsx("span",{className:"text-zinc-900",children:"$"})})}function Wu({isDisabled:e,isPaid:s,label:a,onRemove:n}){const r=t.jsx(B,{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||s,onPress:n,"aria-label":a,children:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return s?t.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:t.jsx("span",{className:"inline-flex",children:r})}):r}function Yu({total:e,donationAmount:s,hasTotalMismatch:a,mode:n,installments:r,formatter:i,labels:l,className:o}){const d=r.length,u=r[0]?.amount??0,f=r[1]?.amount??u,m=d>1&&Math.round(u*100)!==Math.round(f*100),h=ns(s-e),x=Math.max(h,0),g=Math.max(-h,0),j=a?t.jsxs("span",{children:[l.totalError,". Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(s)}),"."]}):n==="automatic"?m?t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records:"," ",t.jsx("strong",{children:i.format(u)})," first charge and"," ",t.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records of"," ",t.jsx("strong",{children:i.format(u)})," each."]}):t.jsxs("span",{children:["Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(s)}),"."]}),b=n==="automatic"?`Total: ${i.format(e)}`:g>0?`Exceeds by: ${i.format(g)}`:`${l.remaining}: ${i.format(x)}`;return t.jsx(c.Alert,{isClosable:!1,color:a?"danger":"default",variant:"flat",radius:"full",className:o,endContent:t.jsx("span",{className:"whitespace-nowrap",children:b}),title:j})}function Gu(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[t.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),t.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),t.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,s)=>t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},s))})]})}const wn={paid:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",schedule:"bg-blue-50 text-blue-700",payment_due:"bg-amber-50 text-amber-700",overdue:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-700",refunded:"bg-zinc-100 text-zinc-600",partially_refunded:"bg-lime-50 text-lime-800",disputed:"bg-purple-50 text-purple-700",canceled:"bg-zinc-100 text-zinc-600",processing:"bg-sky-50 text-sky-700",pending_confirmation:"bg-indigo-50 text-indigo-700"},ti={paid:"Paid",scheduled:"Scheduled",schedule:"Scheduled",payment_due:"Payment Due",overdue:"Overdue",failed:"Failed",refunded:"Refunded",partially_refunded:"Partially refunded",disputed:"Disputed",canceled:"Canceled",processing:"Processing",pending_confirmation:"Pending Confirmation"},Ku={title:"Payments",saved:"Saved",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by name, ID, or date...",editInstallments:"Edit Payment",installmentId:"Payment",amount:"Amount",scheduledDate:"Scheduled Date",paidOn:"Paid on",partiallyRefunded:ti.partially_refunded,refundedAmount:"Refunded",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:t.jsxs(t.Fragment,{children:["Are you sure you want to delete this payment? ",t.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Qu={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Zu=[];function Xu({installments:e,currency:s,locale:a="en-US",showTitle:n=!0,showCard:r=!0,showEditPayment:i=!0,showDelete:l=!0,payNowHiddenStatuses:o=Zu,showSavedIndicator:d=!1,labels:u,isSaving:f=!1,onEditInstallments:m,onPayInstallment:h,onDeleteInstallment:x}){const[g,j]=p.useState(null),b={...Ku,...u},[w,N]=p.useState(""),D=new Intl.NumberFormat(a,{style:"currency",currency:s}),v=e.some(C=>si(C)!==null),S=e.some(C=>C.status==="partially_refunded"),M=n?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:b.title}),d?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:b.saved}):null]}):void 0,k=p.useMemo(()=>{const C=w.trim().toLowerCase();if(!C)return e;const _=new Intl.NumberFormat(a,{style:"currency",currency:s});return e.filter(E=>{const A=E.status??"scheduled";return[As(E),E.id,E.amount,E.dueDate,Qt(E.dueDate,a),Ds(E,b.paidOn,a),Es(E,b.refundedAmount,_),A,Fs(A,b.partiallyRefunded)].join(" ").toLowerCase().includes(C)})},[a,s,e,w,b.paidOn,b.refundedAmount,b.partiallyRefunded]),F=t.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[t.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[t.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:b.searchLabel}),t.jsx(c.Input,{variant:"bordered",size:"md",value:w,placeholder:b.searchPlaceholder,onChange:C=>N(C.target.value),startContent:t.jsx(P,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?t.jsx(B,{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:t.jsx(P,{icon:"solar:pen-outline",className:"size-4"}),isLoading:f,onPress:m,children:b.editInstallments}):null]}),t.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",k.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[k.map((C,_)=>{const E=C.status??"scheduled",A=As(C),R=Ds(C,b.paidOn,a),O=Es(C,b.refundedAmount,D);return t.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:t.jsxs(c.CardBody,{className:"gap-3 p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-xs text-default-500",children:["#",_+1]}),t.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:A||`PMT-${_+1}`})]}),t.jsx(Nn,{status:E,label:Fs(E,b.partiallyRefunded)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-default-500",children:b.amount}),t.jsx("p",{className:"font-medium text-foreground",children:D.format(C.amount)}),O?t.jsx("p",{className:"text-xs text-default-500",children:O}):null]}),t.jsxs("div",{className:"text-right",children:[t.jsx("p",{className:"text-xs text-default-500",children:b.scheduledDate}),t.jsx("p",{className:"font-medium text-foreground",children:Qt(C.dueDate,a)}),R?t.jsx("p",{className:"text-xs text-default-500",children:R}):null]})]}),t.jsx(Cn,{status:E,installment:C,labels:b,portalContainer:g??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:h,onDeleteInstallment:x})]})},C.id)}),k.length===0&&t.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:b.noInstallmentsFound})]})}),t.jsx("div",{className:c.cn("w-full overflow-x-hidden [@container(max-width:767px)]:hidden",k.length>5&&"max-h-[344px] overflow-y-auto pr-1"),children:t.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-12"}),t.jsx("col",{}),t.jsx("col",{className:v?"w-32":"w-24"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:S?"w-44":"w-36"}),t.jsx("col",{className:"w-44"})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[t.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.installmentId}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.amount}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.scheduledDate}),t.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:b.status}),t.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:b.actions})]})}),t.jsxs("tbody",{children:[k.map((C,_)=>{const E=C.status??"scheduled",A=As(C),R=Ds(C,b.paidOn,a),O=Es(C,b.refundedAmount,D);return t.jsxs("tr",{className:"text-zinc-500",children:[t.jsx("td",{className:"px-2 py-3",children:_+1}),t.jsx("td",{className:"overflow-hidden px-2 py-3",children:t.jsx("span",{className:"block w-full truncate",children:A||`PMT-${_+1}`})}),t.jsxs("td",{className:"px-2 py-3",children:[D.format(C.amount),O?t.jsx("span",{className:"block text-xs",children:O}):null]}),t.jsxs("td",{className:"px-2 py-3",children:[Qt(C.dueDate,a),R?t.jsx("span",{className:"block text-xs",children:R}):null]}),t.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:t.jsx(Nn,{status:E,label:Fs(E,b.partiallyRefunded)})}),t.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:t.jsx(Cn,{status:E,installment:C,labels:b,portalContainer:g??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:h,onDeleteInstallment:x})})]},C.id)}),k.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:b.noInstallmentsFound})})]})]})})]});return t.jsx("div",{ref:j,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:r?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"min-w-0 w-full gap-0 px-0",itemClasses:{base:"min-w-0 w-full overflow-x-hidden rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"w-full",content:"min-w-0 w-full overflow-x-hidden px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":b.title,title:M,children:F},"installment-table")}):F})}function As(e){return e.name?.trim()||e.id}function Ds(e,s,a){return!dt(e.status)||!e.fulfilledAt?null:`${s} ${Qt(e.fulfilledAt,a)}`}function si(e){const{refundedAmount:s}=e;return e.status!=="partially_refunded"||typeof s!="number"||!Number.isFinite(s)||s<=0?null:s}function Es(e,s,a){const n=si(e);return n===null?null:`${s} ${a.format(n)}`}function Fs(e,s){return e==="partially_refunded"?s:ti[e]??e}function Nn({status:e,label:s}){return t.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",wn[e]??wn.scheduled),startContent:t.jsx(em,{status:e}),children:s})}function Cn({status:e,installment:s,labels:a,portalContainer:n,showDelete:r,payNowHiddenStatuses:i,onPayInstallment:l,onDeleteInstallment:o}){const d=!i.includes(e),u=dt(e);return t.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[d?t.jsx(B,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:u,startContent:t.jsx(P,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>l?.(s),children:a.payNow}):null,t.jsx(Ju,{isFulfilled:u,showDelete:r,labels:a,portalContainer:n,onDelete:()=>o(s.id)})]})}function Ju({isFulfilled:e,showDelete:s,labels:a,portalContainer:n,onDelete:r}){const[i,l]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[t.jsx(c.DropdownTrigger,{children:t.jsx(B,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:t.jsx(P,{icon:"solar:menu-dots-bold",className:"size-4"})})}),t.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&s&&!e&&l(!0)},children:[t.jsx(c.DropdownSection,{title:"Actions",showDivider:s,children:t.jsx(c.DropdownItem,{textValue:a.sendLink,description:a.sendLinkDescription,startContent:t.jsx(P,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:a.sendLink},"send-link")}),s?t.jsx(c.DropdownSection,{title:a.dangerZone,children:t.jsx(c.DropdownItem,{textValue:a.deleteInstallment,className:"text-danger-600",color:"danger",description:a.deleteInstallmentDescription,startContent:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:a.deleteInstallment},"delete")}):null]})]}),s?t.jsx(va,{isOpen:i,labels:{title:a.deleteInstallmentConfirmationTitle,description:a.deleteInstallmentConfirmationDescription,cancel:a.deleteInstallmentConfirmationCancel,confirm:a.deleteInstallmentConfirmationConfirm},icon:t.jsx(P,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:n,shouldBlockScroll:!1,classNames:Qu,onClose:()=>l(!1),onConfirm:()=>{l(!1),r()}}):null]})}function em({status:e}){return e==="paid"?t.jsx(P,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?t.jsx(P,{icon:"solar:close-circle-bold",className:"size-3"}):e==="partially_refunded"?t.jsx(P,{icon:"solar:undo-left-round-bold",className:"size-3"}):e==="processing"?t.jsx(P,{icon:"solar:refresh-circle-bold",className:"size-3"}):e==="pending_confirmation"?t.jsx(P,{icon:"solar:clock-circle-bold",className:"size-3"}):t.jsx(P,{icon:"solar:calendar-outline",className:"size-3"})}const tm=/^\d{4}-\d{2}-\d{2}$/;function Qt(e,s){const a=tm.test(e)?new Date(`${e}T00:00:00`):new Date(e);return Number.isNaN(a.getTime())?e:new Intl.DateTimeFormat(s,{month:"short",day:"numeric",year:"numeric"}).format(a)}const sm={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},am=({cards:e,locale:s,currency:a,listHeightClassName:n="",labels:r,showRenewal:i=!0,defaultRenewalValue:l=!1,initialSelectedMembershipId:o=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:m=""})=>{const h=Array.isArray(e)?e:[],[x,g]=p.useState(o),[j,b]=p.useState(l),w={...sm,...r};p.useEffect(()=>{g(o)},[o]);const N=v=>{if(v===x){d&&f?.(v);return}g(v),f?.(v)},D=v=>{b(v),u?.(v)};return t.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",m),"data-testid":"membership-select-cards",children:[t.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:x??""}),t.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&t.jsx(li,{title:w.renewalTitle,description:w.renewalDescription,value:j,onValueChange:D}),t.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",n===""?"flex-1":c.cn("shrink-0",n)),"data-testid":"membership-select-cards-list",children:h.map(v=>t.jsx(ai,{itemKey:v.id,name:v.name,type:v.type,price:v.price,locale:s,currency:a,isSelected:x===v.id,onSelect:N},v.id))})]})},ai=({itemKey:e,name:s,type:a,price:n,locale:r="en-US",currency:i="USD",showPrice:l=!0,isSelected:o=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:m,statusLabel:h,statusTone:x="default",className:g=""})=>{const j=new Intl.NumberFormat(r,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(n),b=!!d&&!f,w=m||h,N=()=>{b&&d?.(e)};return t.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:N,className:c.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",g),"data-testid":"item-card","data-selected":o,isDisabled:f,children:t.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[t.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[t.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:s}),a&&t.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:t.jsx("p",{className:"text-center",children:a})}),w&&t.jsx(c.Chip,{"data-testid":"item-card-status",color:x,size:"sm",variant:"flat",className:"px-2",children:w})]}),l&&t.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:j})]})})},kn="w-full bg-gray-100",Sn={variant:"light",color:"default"},ni=({id:e,title:s,media:a,imageUrl:n,imageAlt:r,imageClassName:i="",imageAspect:l="aspect-[4/3]",meta:o=[],price:d,action:u,footer:f,onPress:m,isPressable:h=!1,isDisabled:x=!1,compact:g=!1,className:j="",bodyClassName:b="",footerClassName:w="",dataTestId:N})=>{const D=!!(d&&d.value),v=!!u?.label,S=h&&!!m&&!v,M=!S,k=v?{variant:u?.variant??Sn.variant,color:u?.color??Sn.color,size:u?.size??"sm",isDisabled:x||u?.isDisabled,startContent:u?.icon?t.jsx(P,{icon:u.icon,width:16}):void 0}:null,F=a??(n?t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,kn,i),children:t.jsx(c.Image,{removeWrapper:!0,src:n,alt:r||s,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,kn,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:t.jsx(P,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return t.jsxs(c.Card,{"data-testid":N||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",j),isPressable:S,onPress:m,isDisabled:x,shadow:"sm",radius:"lg",children:[t.jsx("div",{children:F}),t.jsxs(c.CardBody,{className:c.cn("gap-3",g?"p-3":"p-4",b),children:[t.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",g?"text-sm":""),children:s}),o.length>0?t.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((C,_)=>t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(P,{icon:C.icon,className:"size-4 text-gray-400",width:16}),t.jsx("span",{children:C.label})]},`${C.label}-${_}`))}):null,(D||v)&&t.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",g?"pt-0.5":"",w),children:[D?t.jsxs("span",{className:c.cn("mr-auto text-gray-500",g?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&t.jsxs("span",{children:[d.label," "]}),t.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):t.jsx("span",{className:"ml-auto","aria-hidden":!0}),v&&M?t.jsx(B,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:k?.variant,color:k?.color,size:k?.size,startContent:k?.startContent,isDisabled:k?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?t.jsx("div",{className:"pt-1",children:f}):null]})]})};ni.displayName="CatalogItemCard";const nm={open:"Open","selling-fast":"Selling fast","sold-out":"Sold out"};function ri({title:e,subtitle:s,price:a,imageUrl:n,status:r,isDisabled:i=!1,onPress:l,className:o}){return t.jsx(c.Card,{isPressable:!!l,isDisabled:i,onPress:l,shadow:"none",radius:"lg",className:c.cn("w-full border border-pos-hair",o),children:t.jsxs(c.CardBody,{className:"flex-row items-center gap-5 p-4",children:[t.jsx("div",{className:"grid size-[4.875rem] shrink-0 place-items-center overflow-hidden rounded-xl bg-default-100 text-default-500",children:n?t.jsx(c.Image,{removeWrapper:!0,src:n,alt:"",className:"size-full object-cover"}):t.jsx(P,{icon:"solar:ticket-outline",width:28})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h3",{className:"truncate text-lg font-semibold text-foreground",children:e}),t.jsx("p",{className:"mt-1 text-base text-default-500",children:s})]}),r?t.jsx("span",{"data-status":r,className:"rounded-full bg-default-100 px-3 py-1 text-sm font-medium text-default-600",children:nm[r]}):null,a?t.jsxs("strong",{className:"ml-5 whitespace-nowrap text-xl",children:["from ",a]}):null]})})}ri.displayName="ProgramListItem";const rm={card:"gap-3 rounded-xl border border-dashed px-6 py-12",panel:"px-6 py-[72px]"},im={card:"size-12 rounded-2xl",panel:"size-[76px] rounded-[20px] border mb-[18px]"},lm={card:"text-base font-medium text-default-900",panel:"text-[17px] font-semibold text-acct-ink"},om={card:"max-w-sm text-sm text-default-600",panel:"max-w-[380px] text-sm text-acct-sub mt-1.5"},cm={card:"mt-1",panel:"mt-[22px]"},dm="bg-acct-page border-acct-border text-acct-muted",um={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},mm={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"},xm={empty:"status",error:"alert",success:"status",loading:"status"},hm={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function pm(e,s,a,n){if(s===!1)return null;if(e==="loading"&&s===void 0)return t.jsx(c.Spinner,{size:"lg",color:"primary",className:n.spinner});if(p.isValidElement(s))return t.jsx(t.Fragment,{children:s});const r=typeof s=="string"?s:um[e];return r?t.jsx(P,{icon:r,width:a,height:a,"aria-hidden":"true",className:n.icon}):null}function vt({variant:e="empty",surface:s="card",title:a,titleAs:n="p",description:r,icon:i,actions:l,role:o=xm[e],ariaLive:d=hm[e],iconSize:u=24,className:f,classNames:m={},"data-testid":h="feedback-state"}){const x=pm(e,i,u,m);return t.jsxs("div",{role:o,"aria-live":d,"data-variant":e,"data-testid":h,"data-surface":s,className:c.cn("flex flex-col items-center justify-center text-center",rm[s],s==="card"?mm[e]:"bg-transparent",f,m.base),children:[x?t.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:c.cn("inline-flex items-center justify-center",im[s],e==="success"&&s==="card"&&"rounded-full",s==="panel"?dm:fm[e],m.iconWrapper),children:x}):null,t.jsxs("div",{className:c.cn("flex flex-col items-center",s==="card"&&"gap-1"),children:[t.jsx(n,{"data-testid":`${h}-title`,className:c.cn(lm[s],m.title),children:a}),r?t.jsx("p",{"data-testid":`${h}-description`,className:c.cn(om[s],m.description),children:r}):null]}),l?t.jsx("div",{"data-testid":`${h}-actions`,className:c.cn("flex flex-wrap items-center justify-center gap-2",cm[s],m.actions),children:l}):null]})}function ja(e){return t.jsx(vt,{...e,variant:"empty"})}function wa(e){return t.jsx(vt,{...e,variant:"error"})}function Na(e){return t.jsx(vt,{...e,variant:"loading"})}function ii(e){return t.jsx(vt,{...e,variant:"success"})}vt.displayName="FeedbackState";ja.displayName="EmptyState";wa.displayName="ErrorState";Na.displayName="LoadingState";ii.displayName="SuccessState";const li=({title:e,value:s,description:a,onValueChange:n,className:r=""})=>{const i=p.useId();return t.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||a?"justify-between gap-6":"justify-start",r),"data-testid":"toggle",children:[t.jsxs("div",{className:"flex flex-col items-start",children:[e&&t.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),a&&t.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:a})]}),t.jsx(c.Switch,{id:i,isSelected:s,onValueChange:n,"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"},bm=(e,s)=>new Intl.NumberFormat(e,{style:"currency",currency:s}),oi=e=>Object.values(e).reduce((s,a)=>s+Object.values(a).reduce((n,r)=>n+Object.values(r).reduce((i,l)=>i+l.selectedQuantity,0),0),0),ym=e=>e.reduce((s,a)=>s+a.dates.reduce((n,r)=>n+r.tickets.reduce((i,l)=>i+l.max,0),0),0),Ca=e=>e.flatMap(s=>s.dates.flatMap(a=>a.tickets.map(n=>({exhibition:s,dateGroup:a,ticket:n})))),$n=(e,s,a)=>{const n={};let r=a?s??ym(e):0;for(const{exhibition:i,dateGroup:l,ticket:o}of Ca(e)){n[i.id]??={},n[i.id][l.id]??={};const d=a?Math.min(o.max,r):0;n[i.id][l.id][o.id]={id:o.id,selectedQuantity:d,originalPrice:o.originalPrice,discountedPrice:o.price},r-=d}return n},An=(e,s,a)=>`${e}::${s}::${a}`,vm=(e,s,a)=>{const n=oi(s);for(const{exhibition:r,dateGroup:i,ticket:l}of Ca(e)){const o=s[r.id]?.[i.id]?.[l.id]?.selectedQuantity??0,d=a===void 0?l.max:Math.min(l.max,a-(n-o));if(d>0&&o<d)return!1}return!0},jm=({initialQuantity:e=1,minQuantity:s=1,maxQuantity:a=10,onChange:n,disabled:r=!1})=>{const i=Math.max(s,Math.min(a,e)),[l,o]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?l:String(i),m=()=>{r||i>=a||n?.(i+1)},h=()=>{r||i<=s||n?.(i-1)},x=v=>{if(r)return;o(v.target.value);const S=parseInt(v.target.value,10);isNaN(S)||n?.(Math.max(s,Math.min(a,S)))},g=v=>{const S=parseInt(v.target.value,10);if(u(!1),isNaN(S)){n?.(s);return}const M=Math.max(s,Math.min(a,S));M!==S?n?.(M):o(String(M))},j=i<=s,b=i>=a,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",N="bg-primary hover:bg-primary/80",D="bg-primary/40 cursor-not-allowed";return t.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[t.jsx("button",{type:"button",onClick:h,disabled:r||j,className:c.cn(w,r||j?D:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),t.jsx("input",{type:"number",value:f,onChange:x,onFocus:()=>u(!0),onBlur:g,disabled:r,min:s,max:a,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"}),t.jsx("button",{type:"button",onClick:m,disabled:r||b,className:c.cn(w,r||b?D:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},wm=({label:e,checked:s=!1,onChange:a,disabled:n=!1})=>{const r=()=>{n||a?.(!s)};return t.jsxs("button",{type:"button",onClick:r,disabled:n,role:"checkbox","aria-checked":s,"data-testid":"checkbox-button","data-checked":s,className:c.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",n&&"cursor-not-allowed opacity-60"),children:[t.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:()=>{},disabled:n,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),t.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",s?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:s&&t.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"})})]}),t.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},Nm=({item:e,quantity:s,onChange:a,getTotalSelectedTickets:n,userMaxLimit:r,settings:i,labels:l})=>{const o=()=>{if(!n||r===void 0)return e.max;const m=n();return Math.min(e.max,r-(m-s))},d=i?.locale??"en-US",u=i?.currency??"USD",f=bm(d,u);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[t.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?t.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.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)}),t.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?t.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:t.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,t.jsx("div",{className:"text-sm text-zinc-500",children:t.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[l.ticketsAllowedToRedeem," ",e.max]})})]}),t.jsx(jm,{initialQuantity:s,minQuantity:0,maxQuantity:o(),onChange:a})]}),e.membershipAlert?t.jsx(c.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:t.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]})},Cm=({exhibitionId:e,dateGroup:s,isLast:a=!1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d})=>t.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!a&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[t.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:s.date}),s.tickets.map((u,f)=>t.jsxs("div",{children:[t.jsx(Nm,{item:u,quantity:r(e,s.id,u.id),onChange:m=>n(e,s.id,u.id,m),getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d}),f<s.tickets.length-1?t.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),km=({title:e,exhibition:s,onQuantityChange:a,getTicketQuantity:n,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),m=s.dates.reduce((x,g)=>x+g.tickets.reduce((j,b)=>j+n(s.id,g.id,b.id),0),0),h=s.dates.some(x=>x.tickets.length>0);return t.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[t.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-${s.id}`,"data-testid":"upgrade-ticket-header-button",children:t.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[t.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[m," ",o.ticketsSelectedToRedeem]}),t.jsx("span",{className:c.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:t.jsx(P,{icon:"mdi:chevron-down"})})]})]})}),t.jsx("div",{id:`upgrade-items-${s.id}`,className:c.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&t.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:h?s.dates.map((x,g)=>t.jsx(Cm,{exhibitionId:s.id,dateGroup:x,isLast:g===s.dates.length-1,onQuantityChange:a,getTicketQuantity:n,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o},x.id)):t.jsx("div",{className:"px-5 py-10 text-center",children:t.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},Sm=({initialExpanded:e=!1,userMaxLimit:s,labels:a,settings:n,ticketSelectionData:r,className:i="",onSelectionChange:l})=>{const o=p.useMemo(()=>r??[],[r]),d={...gm,...a},[u,f]=p.useState(()=>$n(o,s,!0)),m=p.useRef(!1),h=p.useMemo(()=>{const N=Ca(o).map(({exhibition:D,dateGroup:v,ticket:S})=>[An(D.id,v.id,S.id),S]);return new Map(N)},[o]),x=vm(o,u,s),g=(N,D,v)=>u[N]?.[D]?.[v]?.selectedQuantity??0,j=()=>oi(u),b=(N,D,v,S)=>{const M=g(N,D,v),k=j()-M;if(s!==void 0&&k+S>s)return;const F=h.get(An(N,D,v));if(!F)return;const C={...u,[N]:{...u[N],[D]:{...u[N]?.[D],[v]:{id:v,selectedQuantity:S,originalPrice:F.originalPrice,discountedPrice:F.price}}}};f(C),l?.(C)},w=N=>{const D=$n(o,s,N);f(D),l?.(D)};return p.useEffect(()=>{!m.current&&x&&(l?.(u),m.current=!0)},[x,u,l]),t.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[t.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),t.jsx(wm,{label:d.selectAllButtonLabel,checked:x,onChange:w})]}),o.map(N=>t.jsx(km,{title:N.exhibitionName,exhibition:N,onQuantityChange:b,getTicketQuantity:g,getTotalSelectedTickets:j,userMaxLimit:s,settings:n,labels:d,initialExpanded:e},N.id))]})},Ls={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Ms=e=>{const s={};for(const a of e)a.type==="checkbox"?s[a.id]=[...a.selectedValues]:s[a.id]=a.selectedValue?[a.selectedValue]:[];return s},$m=(e,s)=>{const a={};for(const n of s){if(n.type==="checkbox"){a[n.id]=e[n.id]??[...n.selectedValues];continue}const r=e[n.id]??[];a[n.id]=r.length>0?r[0]:null}return a},Am=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,ci=({triggerLabel:e,triggerAriaLabel:s,triggerIcon:a="solar:tuning-square-outline",triggerVariant:n="bordered",triggerColor:r="default",triggerSize:i="sm",triggerClassName:l,popoverClassName:o,className:d,sections:u,onConfirm:f,onClear:m,appliedCount:h,countAriaLabel:x,countDisplay:g="badge",confirmLabel:j=Ls.confirm,clearLabel:b=Ls.clear,isOpen:w,defaultOpen:N=!1,onOpenChange:D,isDisabled:v=!1,closeOnConfirm:S=!0,keepOpenAfterClear:M=!1})=>{const[k,F]=p.useState(N),[C,_]=p.useState(()=>Ms(u)),E=w??k,A=h??u.filter(Y=>Am(Y)).length,R=Y=>{Y&&_(Ms(u)),w||F(Y),D?.(Y)},O=(Y,Z)=>{_(Q=>({...Q,[Y.id]:Z}))},V=(Y,Z)=>{_(Q=>({...Q,[Y.id]:Z?[Z]:[]}))},q=async()=>{_(Ms(u.map(Y=>Y.type==="checkbox"?{...Y,selectedValues:[]}:{...Y,selectedValue:null}))),await m(),M||R(!1)},I=async()=>{const Y=$m(C,u);await f(Y),S&&R(!1)},J=Y=>{if(Y.type==="checkbox")return t.jsx(c.CheckboxGroup,{label:Y.label,value:C[Y.id]??[],onValueChange:Q=>O(Y,Q),children:Y.options.map(Q=>t.jsx(c.Checkbox,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},Y.id);const Z=C[Y.id]?.[0]??"";return t.jsx(c.RadioGroup,{label:Y.label,value:Z,onValueChange:Q=>V(Y,Q||null),children:Y.options.map(Q=>t.jsx(c.Radio,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},Y.id)},W=p.useMemo(()=>A>0?x?.(A)||`${A} filters applied`:void 0,[x,A]),se=p.useMemo(()=>A===0?e||Ls.noLabel:x?x(A):`${e} (${A})`,[A,e,x]);return t.jsx("div",{className:d,children:t.jsxs(c.Popover,{isOpen:E,onOpenChange:R,placement:"bottom-end",children:[t.jsx(c.PopoverTrigger,{children:t.jsxs(B,{isDisabled:v,variant:n,color:r,size:i,className:l,"aria-label":s,"aria-haspopup":"dialog","aria-expanded":E,children:[t.jsx(P,{icon:a,width:16}),t.jsx("span",{children:e}),g==="badge"&&A>0?t.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":W,children:A}):g==="summary"&&se!==e?t.jsx("span",{className:"text-xs",children:se}):null]})}),t.jsx(c.PopoverContent,{className:o,children:t.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(Y=>J(Y)),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[t.jsx(B,{variant:"light",color:"default",size:"sm",onPress:q,children:b}),t.jsx(B,{color:"primary",size:"sm",onPress:I,children:j})]})]})})]})})};ci.displayName="FilterPopover";const Dm="No sessions available for this date",Em=e=>e==="sold-out"||e==="closed"?"danger":"success",Fm=e=>{const s=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof s=="number"?`${s} left`:"Limited":typeof s=="number"?`${s} seats available`:"Available"},Dn=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",Lm=(e,s)=>s&&e.some(a=>a.date===s)?s:e[0]?.date??null,di=({heading:e,subheading:s,days:a,selectedDate:n,onDateSelect:r,quickDates:i,selectedSessionId:l=null,onSessionSelect:o,emptyStateMessage:d=Dm,statusLabel:u,statusTone:f,sessionAriaLabel:m,dayButtonClassName:h,calendarSlot:x,dayGroupAriaLabel:g,sessionGridAriaLabel:j,className:b,headingClassName:w,subheadingClassName:N})=>{const D=Lm(a,n),v=a.find(C=>C.date===D),S=i??a.map(C=>({date:C.date,label:C.label})),M=v?.sessions??[],k=C=>C===D?"solid":"bordered",F=C=>{if(!Dn(C)){if(C.id===l){o(null);return}o(C.id)}};return t.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",b),"data-testid":"session-timeline-root",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),s?t.jsx("p",{className:c.cn("text-sm text-gray-700",N),children:s}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":g||"Session days",children:[S.map(C=>t.jsx(B,{size:"sm",variant:k(C.date),color:"default",className:c.cn("rounded-full",h),isDisabled:C.isDisabled,onPress:()=>{r(C.date)},children:t.jsx("span",{children:C.label})},C.date)),x?t.jsx("div",{children:x}):null]}),t.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":j||"Sessions",children:[M.length===0?t.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:d}):null,M.map(C=>{const _=Dn(C),E=C.id===l;return t.jsx("li",{className:"rounded-xl",children:t.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!_,onPress:()=>{F(C)},"aria-disabled":_,"aria-pressed":_?void 0:E,className:c.cn("w-full",_?"bg-gray-100 opacity-70":"",E?"w-full ring-2 ring-gray-900":""),"aria-label":m?m(C,{isSelected:E,isUnavailable:_}):_?`${C.startTime} ${C.endTime} sold out`:`${C.startTime} ${C.endTime} available`,children:t.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[t.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[C.startTime," – ",C.endTime]}),t.jsx(c.Chip,{size:"sm",color:f?f(C):Em(C.status),variant:"flat",children:u?u(C):Fm(C)})]})})},C.id)})]})]})};di.displayName="SessionTimeline";const Qs=16,Ze=e=>`${e/Qs}rem`;function Mm(){if(typeof document>"u"||typeof getComputedStyle!="function")return Qs;const e=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:Qs}const It=(e,s)=>e>=s*Mm(),_m=1120;function jt(){const e=p.useRef(null),[s,a]=p.useState(0),[,n]=p.useState("");return p.useLayoutEffect(()=>{const r=e.current;if(!r||typeof ResizeObserver>"u")return;const i=new ResizeObserver(l=>{const o=l[l.length-1];o&&a(o.borderBoxSize?.[0]?.inlineSize??o.contentRect.width)});return a(r.getBoundingClientRect().width),i.observe(r),()=>i.disconnect()},[]),p.useEffect(()=>{if(typeof MutationObserver>"u")return;const r=document.documentElement,i=new MutationObserver(()=>n(getComputedStyle(r).fontSize));return i.observe(r,{attributes:!0,attributeFilter:["style","class"]}),()=>i.disconnect()},[]),{ref:e,width:s}}const Rm=48,Oe={base:"flex items-start gap-4",baseWide:"mb-5 flex-nowrap",baseNarrow:"mb-[0.875rem] flex-wrap",identity:"flex min-w-0 items-center gap-4",text:"min-w-0",titleWide:"text-[1.6875rem] font-semibold leading-[1.5] tracking-[-.02em] text-default-900",titleNarrow:"text-[1.375rem] font-semibold leading-[1.5] tracking-[-.02em] text-default-900",subtitleWide:"mt-[0.4375rem] max-w-[47.5rem] text-[0.875rem] leading-[1.55] text-default-500",subtitleNarrow:"mt-[0.4375rem] max-w-[47.5rem] text-[0.84375rem] leading-[1.55] text-default-500",actionsWide:"ml-auto flex shrink-0 items-center gap-2.5",actionsNarrow:"flex shrink-0 items-center gap-2.5"},Tm=(e,s)=>typeof e=="string"?t.jsx(P,{icon:e,className:"size-5","aria-hidden":"true"}):e||s||null,ui=({title:e,subtitle:s,eyebrow:a,icon:n,initials:r,actions:i,titleAs:l="h1",className:o,classNames:d={},"data-testid":u="page-header",list:f,narrow:m,headerRef:h})=>{const x=Tm(n,r);return t.jsxs("header",{ref:h,"data-testid":u,"data-variant":f?"list":void 0,"data-size":f?m?"narrow":"wide":void 0,className:c.cn(f?c.cn(Oe.base,m?Oe.baseNarrow:Oe.baseWide):"flex flex-wrap items-start justify-between gap-4",o,d.base),children:[t.jsxs("div",{className:f?Oe.identity:"flex items-center gap-4",children:[x?t.jsx("div",{"aria-hidden":"true","data-testid":`${u}-icon`,className:c.cn("flex size-12 shrink-0 items-center justify-center rounded-xl bg-gray-900 text-sm font-semibold text-white",d.iconWrapper),children:x}):null,t.jsxs("div",{className:f?Oe.text:void 0,children:[a?t.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:a}):null,t.jsx(l,{"data-testid":`${u}-title`,className:c.cn(f?m?Oe.titleNarrow:Oe.titleWide:"text-3xl font-semibold text-gray-950",d.title),children:e}),s?t.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn(f?m?Oe.subtitleNarrow:Oe.subtitleWide:"mt-1 text-sm text-gray-600",d.subtitle),children:s}):null]})]}),i?t.jsx("div",{"data-testid":`${u}-actions`,className:c.cn(f?m?Oe.actionsNarrow:Oe.actionsWide:"flex flex-wrap items-center gap-2",d.actions),children:i}):null]})},Im=e=>{const{ref:s,width:a}=jt(),n=a>0&&!It(a,Rm);return t.jsx(ui,{...e,list:!0,narrow:n,headerRef:s})},mi=e=>e.variant==="list"?t.jsx(Im,{...e}):t.jsx(ui,{...e,list:!1,narrow:!1});mi.displayName="PageHeader";const qe={ok:{fg:je.ok,bg:je["ok-fill"]},warn:{fg:je.warn,bg:je["warn-fill"]},danger:{fg:je.danger,bg:je["danger-fill"]},info:{fg:je.info,bg:je["info-fill"]},violet:{fg:je.violet,bg:je["violet-fill"]},neutral:{fg:je.neutral,bg:je["neutral-fill"]}};function Pt(e){if(e==="positive")return{color:je.ok};if(e==="negative")return{color:je.danger}}const Pm={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default",info:"default",violet:"default"},Zs={active:{fg:"#057A54",bg:"#E6F4EF"},success:{fg:"#057A54",bg:"#E6F4EF"},draft:{fg:"#B7791F",bg:"#FBF0DD"},pending:{fg:"#B7791F",bg:"#FBF0DD"},warning:{fg:"#B7791F",bg:"#FBF0DD"},danger:{fg:"#B62214",bg:"#FBEAE8"},archived:{fg:"#9CA3AF",bg:"#F1F2F4"},inactive:{fg:"#9CA3AF",bg:"#F1F2F4"},neutral:{fg:"#9CA3AF",bg:"#F1F2F4"},info:qe.info,violet:qe.violet},Om={active:"ok",success:"ok",draft:"warn",pending:"warn",warning:"warn",danger:"danger",archived:"neutral",inactive:"neutral",neutral:"neutral",info:"info",violet:"violet"},zm={sm:"px-[0.5625rem] py-[0.1875rem] text-[0.75rem]",md:"px-3 py-[0.3125rem] text-[0.8125rem]",lg:"px-3 py-[0.3125rem] text-[0.8125rem]"},Bm={info:Zs.info,violet:Zs.violet},fi=({status:e,label:s,variant:a="flat",size:n="sm",color:r,startContent:i,className:l,"data-testid":o="status-chip"})=>{if(a==="plain"){const u=qe[Om[e]];return t.jsxs("span",{"data-testid":o,"data-status":e,"data-variant":"plain",className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full font-normal",zm[n],"leading-[1.35]",l),style:{color:u.fg,backgroundColor:u.bg},children:[i,s]})}if(a==="dot"){const u=Zs[e];return t.jsxs("span",{"data-testid":o,"data-status":e,className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 py-[3px] text-[12px] font-semibold leading-[1.4]",l),style:{color:u.fg,backgroundColor:u.bg},children:[t.jsx("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:"currentColor"}}),s]})}const d=r?void 0:Bm[e];return t.jsx(c.Chip,{color:r??Pm[e],variant:a,size:n,startContent:i,"data-testid":o,"data-status":e,className:c.cn("font-medium",l),style:d?{color:d.fg,backgroundColor:d.bg}:void 0,children:s})};fi.displayName="StatusChip";const Vm={sm:"gap-1 rounded-md px-2 py-0.5 text-[11.5px] leading-normal",md:"gap-1.5 rounded-lg px-2.5 py-1 text-xs leading-normal"},Ut={base:"inline-flex items-baseline gap-1 whitespace-nowrap rounded-[0.4375rem] border border-pos-hair bg-default-100",sm:"px-2 py-0.5 text-[0.75rem] leading-[1.5]",md:"px-2.5 py-1 text-[0.8125rem] leading-[1.5]",label:"font-normal text-default-600",value:"font-semibold text-default-900"},ka=({label:e,value:s,size:a="sm",variant:n="default",className:r,"data-testid":i="key-value-chip"})=>n==="record"?t.jsxs("span",{"data-testid":i,"data-variant":"record",className:c.cn(Ut.base,Ut[a],r),children:[t.jsx("span",{className:Ut.label,children:e}),t.jsx("span",{className:Ut.value,children:s})]}):t.jsxs("span",{"data-testid":i,className:c.cn("inline-flex items-baseline whitespace-nowrap border border-default-200 bg-default-100",Vm[a],r),children:[t.jsx("span",{className:"font-medium text-default-400",children:e}),t.jsx("span",{className:"font-semibold text-default-700",children:s})]});ka.displayName="KeyValueChip";const xi="(prefers-reduced-motion: reduce)",hi="data-pos-reduce-motion",Ot="motion-reduce:transition-none [html[data-pos-reduce-motion=true]_&]:transition-none",Um="motion-reduce:animate-none [html[data-pos-reduce-motion=true]_&]:animate-none",Zt=`rounded-[0.375rem] bg-[linear-gradient(90deg,#F0F0F1_0,#F9F9FA_12.5rem,#F0F0F1_25rem)] bg-[length:50rem_100%] animate-record-shimmer ${Um}`;function Hm(){return typeof document>"u"?!1:document.documentElement.getAttribute(hi)==="true"?!0:typeof window.matchMedia=="function"&&window.matchMedia(xi).matches}function qm(){const[e,s]=p.useState(!1);return p.useEffect(()=>{const a=()=>s(Hm()),n=typeof window.matchMedia=="function"?window.matchMedia(xi):null;n?.addEventListener?.("change",a);const r=typeof MutationObserver>"u"?null:new MutationObserver(a);return r?.observe(document.documentElement,{attributes:!0,attributeFilter:[hi]}),a(),()=>{n?.removeEventListener?.("change",a),r?.disconnect()}},[]),e}const pi=({columns:e,rows:s=6,label:a="Loading",barHeight:n=12,alignLastRight:r=!1,appearance:i="pulse",className:l,classNames:o={},"data-testid":d="table-skeleton"})=>t.jsxs("div",{role:"status","aria-busy":"true","data-testid":d,className:c.cn("w-full",l,o.base),children:[t.jsx("span",{className:"sr-only",children:a}),t.jsx("div",{"aria-hidden":"true",children:Array.from({length:s}).map((u,f)=>i==="shimmer"?t.jsx("div",{"data-testid":`${d}-row`,className:c.cn("flex items-center border-b border-pos-hair",o.row),children:e.map((m,h)=>{const x=h===e.length-1;return t.jsx("div",{className:c.cn("min-w-0 flex-1 px-4 py-5",r&&x&&"flex justify-end"),children:t.jsx("div",{className:c.cn(Zt,o.bar),style:{height:Ze(n),width:m==="fill"?"60%":Ze(m),maxWidth:"100%"}})},h)})},f):t.jsx("div",{"data-testid":`${d}-row`,className:c.cn("flex items-center gap-3 border-t border-default-100 px-5 py-4",o.row),children:e.map((m,h)=>{const x=h===e.length-1;return t.jsx("div",{className:c.cn(m==="fill"?"flex-1":"shrink-0",r&&x&&"flex justify-end"),style:m==="fill"?void 0:{width:m},children:t.jsx("div",{className:c.cn("animate-pulse rounded bg-default-200",o.bar),style:{height:n,width:m==="fill"?"60%":m}})},h)})},f))})]});pi.displayName="TableSkeleton";const gi="text-left text-[11px] font-semibold uppercase tracking-[.04em] text-acct-sub px-4 pt-4 pb-3 whitespace-nowrap bg-transparent",bi="px-4 text-[13.5px] text-acct-ink2 align-middle",yi="border-t border-acct-hair transition-colors duration-150 hover:bg-acct-page data-[hover=true]:bg-acct-page",vi="w-full",ji="border-t border-acct-border px-5 py-3.5",Ht={base:"overflow-x-auto",th:"h-auto whitespace-nowrap border-b border-pos-hair bg-transparent px-4 py-[0.875rem] text-left text-[0.6875rem] font-semibold uppercase leading-[1.5] tracking-[.055em] text-default-500 first:rounded-none last:rounded-none last:pr-3",tr:`border-t border-pos-hair transition-colors duration-[120ms] first:border-t-0 data-[focus-visible=true]:outline-offset-[-2px] [tbody>&]:hover:bg-default-50 [tbody>&]:data-[hover=true]:bg-default-50 ${Ot}`,td:"h-[3.875rem] px-4 data-[focus-visible=true]:outline-offset-[-2px] py-[0.625rem] align-middle text-[0.875rem] text-default-900 last:pr-3"},wi=({columns:e,children:s,emptyContent:a,footer:n,ariaLabel:r,variant:i="default",className:l,classNames:o={},"data-testid":d="admin-table"})=>{const u=i==="framed";return t.jsxs("div",{className:c.cn(u&&Ht.base,l,o.base),"data-testid":d,"data-variant":u?"framed":void 0,children:[t.jsxs(c.Table,{"aria-label":r,removeWrapper:!0,classNames:{table:c.cn(vi,o.table),th:c.cn(u?Ht.th:gi,o.th),tr:c.cn(u?Ht.tr:yi,o.tr),td:c.cn(u?Ht.td:bi,o.td)},children:[t.jsx(c.TableHeader,{columns:e,children:f=>t.jsx(c.TableColumn,{align:f.align==="right"?"end":"start",width:f.width,children:f.label},f.key)}),t.jsx(c.TableBody,{emptyContent:a,children:s})]}),n?t.jsx("div",{"data-testid":`${d}-footer`,className:c.cn(!u&&ji,o.footer),children:n}):null]})};wi.displayName="AdminTable";const Wm={md:"w-[280px]",lg:"w-[360px]"},Ym=48,ze={base:"flex flex-wrap items-center gap-2.5 border-b border-pos-hair px-4 py-[0.875rem]",narrow:"[&_[data-slot=filter-select]]:!max-w-none [&_[data-slot=filter-select]]:!min-w-[calc(50%-0.3125rem)] [&_[data-slot=filter-select]]:grow [&_[data-slot=filter-select]]:basis-[calc(50%-0.3125rem)]",searchWide:"ml-auto",searchNarrow:"basis-full",inputBaseMd:"w-[15.625rem]",inputBaseLg:"w-[22.5rem]",inputBaseNarrow:"w-full",inputWrapper:"h-[2.375rem] min-h-[2.375rem] !h-[2.375rem] rounded-[0.625rem] border border-pos-field bg-white pl-3 pr-3 shadow-none data-[hover=true]:border-pos-field group-data-[focus=true]:border-primary",innerWrapper:"gap-[0.4375rem]",input:"text-ellipsis text-[0.875rem] text-default-900 data-[has-start-content=true]:ps-0",icon:"flex text-default-400 [&_svg]:size-4"},Gm=({searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,children:i,trailing:l,searchWidth:o="md",className:d,"data-testid":u="admin-toolbar"})=>{const{ref:f,width:m}=jt(),h=m>0&&!It(m,Ym);return t.jsxs("div",{ref:f,role:"search","data-testid":u,"data-variant":"framed","data-size":h?"narrow":"wide",className:c.cn(ze.base,h&&ze.narrow,d),children:[i,t.jsx("div",{"data-testid":`${u}-search-slot`,className:h?ze.searchNarrow:ze.searchWide,children:t.jsx(c.Input,{type:"search","aria-label":a,placeholder:n??a,value:e,onValueChange:s,startContent:t.jsx("span",{"aria-hidden":"true","data-testid":`${u}-search-icon`,className:ze.icon,children:r??t.jsx(P,{icon:"lucide:search"})}),"data-testid":`${u}-search`,variant:"bordered",radius:"none",classNames:{base:h?ze.inputBaseNarrow:o==="lg"?ze.inputBaseLg:ze.inputBaseMd,inputWrapper:ze.inputWrapper,innerWrapper:ze.innerWrapper,input:ze.input}})}),l]})},Ni=({searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,children:i,trailing:l,searchWidth:o="md",variant:d="default",className:u,"data-testid":f="admin-toolbar"})=>d==="framed"?t.jsx(Gm,{searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,trailing:l,searchWidth:o,className:u,"data-testid":f,children:i}):t.jsxs("div",{role:"search","data-testid":f,className:c.cn("flex flex-wrap items-center gap-3 mb-4",u),children:[t.jsx(c.Input,{type:"search","aria-label":a,placeholder:n??a,value:e,onValueChange:s,startContent:r?t.jsx("span",{"aria-hidden":"true",className:"flex text-acct-muted",children:r}):void 0,"data-testid":`${f}-search`,variant:"bordered",radius:"none",classNames:{base:Wm[o],inputWrapper:["h-10 min-h-10 !h-10 rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),input:"text-[13.5px] text-acct-ink"}}),i,l?t.jsx("div",{className:"ml-auto",children:l}):null]});Ni.displayName="AdminToolbar";const Km="ml-0.5 inline-flex min-w-[18px] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",Qm="ml-0.5 inline-flex min-w-[1.125rem] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",Zm="h-9 gap-1.5 rounded-full border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 hover:bg-gray-50 data-[pressed=true]:bg-gray-50",Ci=p.forwardRef(function({icon:s,children:a,count:n,appearance:r="pill",className:i,testId:l,...o},d){return r==="outline"?t.jsxs(B,{ref:d,"data-testid":l,"data-appearance":"outline",color:"default",variant:"bordered",radius:"md",size:"md",className:c.cn("rounded-[0.75rem] font-normal",i),...o,children:[t.jsx(P,{icon:s,className:"size-4","aria-hidden":!0}),t.jsx("span",{children:a}),n!==void 0&&n>0&&t.jsx("span",{className:Qm,children:n})]}):t.jsxs(B,{ref:d,"data-testid":l,variant:"light",size:"sm",className:c.cn(Zm,i),...o,children:[t.jsx(P,{icon:s,className:"size-4 text-gray-500","aria-hidden":!0}),t.jsx("span",{children:a}),n!==void 0&&n>0&&t.jsx("span",{className:Km,children:n})]})});Ci.displayName="ToolbarButton";function ki({items:e,value:s,onChange:a,ariaLabel:n,className:r,"data-testid":i="underline-tabs"}){return t.jsx(c.Tabs,{"aria-label":n,variant:"underlined",selectedKey:s,onSelectionChange:l=>a(String(l)),"data-testid":i,classNames:{base:c.cn("w-full mb-6",r),tabList:"gap-7 w-full relative rounded-none p-0 border-b border-acct-border",cursor:"w-full bg-acct-rust",tab:"max-w-fit px-0.5 h-auto pb-3",tabContent:"text-[15px] font-medium text-acct-sub group-data-[selected=true]:font-semibold group-data-[selected=true]:text-acct-rust",panel:"p-0"},children:e.map(l=>t.jsx(c.Tab,{title:l.label,"data-testid":`${i}-${l.key}`,children:l.content},l.key))})}ki.displayName="UnderlineTabs";const Sa="text-[11px] font-semibold uppercase tracking-[.04em] text-acct-muted mb-1.5",$a="font-normal normal-case tracking-normal",Si=["h-[38px] min-h-[38px] !h-[38px] rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),$i="text-[13.5px] text-acct-ink",Ai="bg-acct-page text-acct-muted cursor-default",Di="mt-[5px] text-xs text-acct-sub",Ei="mt-[5px] text-xs text-acct-danger",Fi=({children:e,suffix:s,className:a,"data-testid":n="admin-field-label"})=>t.jsxs("div",{"data-testid":n,className:c.cn(Sa,a),children:[e,s?t.jsxs("span",{className:$a,children:[" ",s]}):null]});Fi.displayName="AdminFieldLabel";const Li=({label:e,labelSuffix:s,value:a,onChange:n,placeholder:r,disabled:i=!1,readOnly:l=!1,mono:o=!1,autoFocus:d=!1,hint:u,invalid:f=!1,className:m,"data-testid":h="admin-text-field"})=>t.jsx(c.Input,{labelPlacement:e?"outside":void 0,label:e&&s?t.jsxs(t.Fragment,{children:[e,t.jsxs("span",{className:$a,children:[" ",s]})]}):e,value:a,placeholder:r,isDisabled:i,isReadOnly:l,autoFocus:d,isInvalid:f,description:!f&&u?u:void 0,errorMessage:f?u:void 0,onValueChange:n,"data-testid":h,variant:"bordered",radius:"none",classNames:{base:c.cn("w-full",m),label:Sa,inputWrapper:Si,input:c.cn($i,(o||l)&&"font-mono",l&&Ai),description:Di,errorMessage:Ei}});Li.displayName="AdminTextField";const Xm={sm:"size-6 min-w-6",md:"size-[30px] min-w-[30px]"},Mi=({actions:e,size:s="md",className:a,"data-testid":n="row-actions"})=>t.jsx("div",{role:"presentation","data-testid":n,className:c.cn("inline-flex gap-0.5",a),onClick:r=>r.stopPropagation(),children:e.map(r=>t.jsx(B,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:r.onPress,isDisabled:r.disabled,"aria-label":r.label,title:r.label,"data-testid":`${n}-${r.key}`,className:c.cn("text-acct-sub data-[hover=true]:bg-acct-hair",Xm[s]),children:r.icon},r.key))});Mi.displayName="RowActions";const _i=({children:e,placeholder:s="Select…",onOpen:a,onClear:n,ariaLabel:r,icon:i,trailingIcon:l,clearIcon:o,disabled:d=!1,className:u,"data-testid":f="picker-row"})=>{const m=e!=null;return t.jsxs("div",{"data-testid":f,className:c.cn("flex w-full min-h-10 items-center rounded-[10px] border border-acct-border bg-acct-surface px-[11px] transition-colors duration-150",d?"opacity-60":"hover:border-acct-rust-border",u),children:[t.jsxs(B,{variant:"light",radius:"none",disableAnimation:!0,onPress:a,isDisabled:d,"aria-haspopup":"dialog","aria-label":r,"data-testid":`${f}-trigger`,className:"flex h-auto min-h-0 min-w-0 flex-1 items-center justify-start gap-2.5 bg-transparent px-0 py-2 text-left text-inherit data-[hover=true]:bg-transparent",children:[i?t.jsx("span",{className:"flex shrink-0 text-acct-muted",children:i}):null,m?t.jsx("span",{className:"flex min-w-0 items-center gap-2",children:e}):t.jsx("span",{className:"text-[13.5px] font-semibold text-acct-sub",children:s}),l?t.jsx("span",{className:"ml-auto flex shrink-0 text-acct-muted",children:l}):null]}),m&&n?t.jsx(B,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:n,isDisabled:d,"aria-label":`Clear ${r}`,title:"Clear","data-testid":`${f}-clear`,className:"ml-1.5 size-6 min-w-6 shrink-0 text-acct-muted data-[hover=true]:bg-acct-hair",children:o}):null]})};_i.displayName="PickerRow";function Ri(e,s,a){if(a<=0||s<=0||e<=0)return{from:0,to:0};const n=(e-1)*s+1;return n>a?{from:0,to:0}:{from:n,to:Math.min(a,e*s)}}const Ti=({page:e,pageSize:s,total:a,unit:n,announce:r=!0,className:i,classNames:l={},"data-testid":o="pagination-summary"})=>{const{from:d,to:u}=Ri(e,s,a),f=c.cn("font-semibold text-default-700",l.emphasis);return t.jsxs("p",{"data-testid":o,"aria-live":r?"polite":void 0,className:c.cn("text-sm text-default-500",i,l.base),children:["Showing"," ",t.jsx("span",{"data-testid":`${o}-range`,className:f,children:d===0?0:`${d}–${u}`})," ","of"," ",t.jsx("span",{"data-testid":`${o}-total`,className:f,children:a}),n?t.jsxs(t.Fragment,{children:[" ",n]}):null]})};Ti.displayName="PaginationSummary";const fs="shadow-[0_1px_4px_rgba(0,0,0,.06),0_4px_12px_rgba(0,0,0,.06)]",Qe={base:`overflow-hidden rounded-2xl border border-pos-line bg-white ${fs}`,title:"m-0 min-w-0 text-[0.90625rem] font-semibold text-default-900 [overflow-wrap:anywhere]",count:"rounded-full bg-default-100 px-2 py-px text-[0.75rem] font-semibold text-default-600",icon:"flex shrink-0 text-default-500 [&_svg]:size-[1.125rem]",action:"ml-auto",description:"m-0 text-[0.84375rem] leading-[1.55] text-default-500 [&_b]:font-bold [&_b]:tabular-nums [&_b]:text-default-900",footer:"flex flex-wrap gap-2",footerAfterContent:"mt-[0.875rem]",footerAfterDescription:"mt-3"},Jm={section:"flex flex-wrap items-center gap-2 px-5 pt-4",aside:"flex flex-wrap items-center gap-[0.5625rem] px-[1.125rem] pt-[0.9375rem]"},ef={section:{padded:"px-5 pb-[1.125rem] pt-[0.875rem]",rows:"px-5 pb-[1.125rem] pt-2.5",flush:"pt-3",none:""},aside:{padded:"px-[1.125rem] pb-[1.125rem] pt-3",rows:"px-[1.125rem] pb-[1.125rem] pt-3",flush:"pt-3",none:""}},Ii=({isLoading:e=!1,isError:s=!1,isEmpty:a=!1,loadingTitle:n="Loading…",loadingContent:r,errorTitle:i="Something went wrong",errorDescription:l,retryLabel:o="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:m="Nothing here yet",emptyDescription:h,emptyIcon:x,emptyActions:g,emptyContent:j,children:b,toolbar:w,variant:N="default",className:D,classNames:v={},"data-testid":S="list-panel"})=>{const M=N==="framed",k={base:c.cn("border-0 bg-transparent py-12",v.state)},F=M?{base:c.cn("px-6 py-[3.625rem]",v.state),iconWrapper:"mb-[1.125rem] size-[4.75rem] rounded-[1.25rem] border-0 bg-default-100 text-default-400",icon:"size-[2.875rem]",title:"text-[1.0625rem] font-semibold text-default-900",description:"mt-1.5 max-w-[26.25rem] text-[0.875rem] leading-[1.55] text-default-500",actions:"mt-[1.375rem] gap-2.5"}:k;let C;return e?C=r??t.jsx(Na,{title:n,classNames:k,"data-testid":`${S}-loading`}):s?C=f??t.jsx(wa,{title:i,description:l,classNames:k,"data-testid":`${S}-error`,actions:u??(d?t.jsx(B,{color:"primary",variant:"flat",onPress:d,children:o}):void 0)}):a?C=j??t.jsx(ja,{surface:M?"panel":void 0,title:m,description:h,icon:x,actions:g,classNames:F,"data-testid":`${S}-empty`}):C=b,t.jsxs("section",{"data-testid":S,"data-variant":M?"framed":void 0,className:c.cn(M?`overflow-hidden rounded-2xl border border-pos-line bg-white ${fs}`:"rounded-xl bg-white p-2 shadow-sm",D,v.base),children:[w,C]})};Ii.displayName="ListPanel";const Pi=(e,s)=>s<=0?/^\d*$/.test(e):new RegExp(`^\\d*(?:[.,]\\d{0,${s}})?$`).test(e),rs=e=>{const s=Number.parseFloat(e.replace(",","."));return Number.isFinite(s)?s:null},Oi=(e,s)=>{const[a,n]=p.useState(()=>s(e)),r=(rs(a)??0)===(e??0)?a:s(e),i=p.useCallback(()=>{n(l=>{const o=rs(l);return o===null?"":String(o)})},[]);return{draft:r,setDraft:n,normalize:i}},tf=350,sf={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}"},_s=(e,s)=>Object.entries(s).reduce((a,[n,r])=>a.replace(`{${n}}`,r),e),af=({dueAmount:e,received:s,defaultReceived:a=null,onChange:n,locale:r="en-US",labels:i,isDisabled:l=!1,maxAmount:o,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const m={...sf,...i},h=Rt(e.currency,r),x=s!==void 0,[g,j]=p.useState(a??null),b=x?s:g,{draft:w,setDraft:N,normalize:D}=Oi(b,V=>V==null?"":String(V)),v=p.useMemo(()=>{const V=typeof b=="number"&&Number.isFinite(b)?b:0,q=Hs(V,e.value,e.currency,r);return{received:V,change:q>0?q:0,isValid:V>=e.value&&V>0}},[b,e.value,e.currency,r]),S=p.useCallback(V=>{const q=V.currentTarget;requestAnimationFrame(()=>{q.isConnected&&q.select()})},[]),M=p.useCallback(V=>{if(l)return;const q=V.replace(/[^\d.,]/g,"");if(!Pi(q,h))return;const I=rs(q);if(I!==null&&o!==void 0&&I>o)return;N(q),x||j(I);const J=typeof I=="number"&&Number.isFinite(I)?I:0,W=Hs(J,e.value,e.currency,r);n?.({received:J,change:W>0?W:0,isValid:J>=e.value&&J>0})},[x,l,e.value,e.currency,r,n,o,N,h]),k=v.isValid&&v.change>0,F=!v.isValid&&v.received>0,C=ge(v.change,r,e.currency),_=ge(e.value,r,e.currency),[E,A]=p.useState(""),R=p.useRef(null);p.useEffect(()=>{R.current&&clearTimeout(R.current);const V=k?_s(m.changeMessageTemplate,{change:C}):"",q=k?tf:0;return R.current=setTimeout(()=>A(V),q),()=>{R.current&&clearTimeout(R.current)}},[k,C,m.changeMessageTemplate]);const O=`${f}-received`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[t.jsx(c.Input,{id:O,label:m.receivedLabel,labelPlacement:"outside",type:"text",inputMode:h===0?"numeric":"decimal",pattern:h===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:w,onChange:V=>M(V.target.value),onFocus:S,onBlur:D,placeholder:m.receivedPlaceholder,isDisabled:l,isInvalid:F,errorMessage:F?_s(m.insufficientMessageTemplate,{due:_}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),k&&t.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:m.changeLabel,description:_s(m.changeMessageTemplate,{change:C}),icon:t.jsx(P,{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"}}),t.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:E})]})},nf={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},En=()=>{const e=new Date,s=a=>String(a).padStart(2,"0");return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`},zi=({dueAmount:e,value:s,defaultValue:a,onChange:n,labels:r,hideDate:i=!1,hideBankName:l=!1,isDisabled:o=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:m,"data-testid":h="check-tender-form"})=>{const x={...nf,...r},g=s!==void 0,[j,b]=p.useState({checkNumber:a?.checkNumber??"",bankName:a?.bankName??"",date:a?.date??En()}),[w,N]=p.useState(!!a?.checkNumber),D=p.useMemo(()=>g?{checkNumber:s?.checkNumber??"",bankName:s?.bankName??"",date:s?.date??En()}:j,[g,s,j]),v=p.useCallback(E=>{g||b(E);const A=E.checkNumber.trim(),R={amount:e.value,checkNumber:A,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:A.length>0&&e.value>0};n?.(R)},[g,e.value,i,n]),S=p.useCallback(E=>A=>{o||(E==="checkNumber"&&A.length>0&&N(!0),v({...D,[E]:A}))},[D,v,o]),M=p.useCallback(()=>{o||N(!0)},[o]),k=w&&D.checkNumber.trim()==="",F=`${h}-check-number`,C=`${h}-bank-name`,_=`${h}-date`;return t.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",m),"data-testid":h,children:[t.jsx(c.Input,{id:F,label:x.checkNumberLabel,labelPlacement:"outside",type:"text",value:D.checkNumber,onChange:E=>S("checkNumber")(E.target.value),onBlur:M,placeholder:x.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:k,errorMessage:k?x.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${h}-check-number-input`}),!l&&t.jsx(c.Input,{id:C,label:x.bankNameLabel,labelPlacement:"outside",type:"text",value:D.bankName,onChange:E=>S("bankName")(E.target.value),placeholder:x.bankNamePlaceholder,maxLength:u,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${h}-bank-name-input`}),!i&&t.jsx(c.Input,{id:_,label:x.dateLabel,labelPlacement:"outside",type:"date",value:D.date,onChange:E=>S("date")(E.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${h}-date-input`,className:"sm:col-span-2"})]})};zi.displayName="CheckTenderForm";const rf={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},lf=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Bi=({dueAmount:e,methodOptions:s=lf,value:a,defaultValue:n,onChange:r,labels:i,showReference:l=!1,isDisabled:o=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...rf,...i},m=a!==void 0,[h,x]=p.useState({method:n?.method??"",reference:n?.reference??""}),g=p.useMemo(()=>m?{method:a?.method??"",reference:a?.reference??""}:h,[m,a,h]),j=p.useCallback(S=>s.find(M=>M.value===S)?.label??"",[s]),b=p.useCallback(S=>{m||x(S);const M=j(S.method),k={amount:e.value,method:S.method,description:M,reference:S.reference.trim()||void 0,isValid:S.method!==""};r?.(k)},[m,e.value,r,j]),w=p.useCallback(S=>{if(o)return;const M=typeof S=="string"?S:Array.from(S)[0]?.toString()??"";b({...g,method:M})},[g,b,o]),N=p.useCallback(S=>{o||b({...g,reference:S})},[g,b,o]),D=`${u}-method`,v=`${u}-reference`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[t.jsx(He,{id:D,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:g.method?[g.method]:[],onSelectionChange:w,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:s.map(S=>t.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${S.value}`,children:S.label},S.value))}),l&&t.jsx(c.Input,{id:v,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:g.reference,onChange:S=>N(S.target.value),placeholder:f.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};Bi.displayName="OtherTenderForm";const of={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},cf={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},df={pending:"warning",recorded:"success",failed:"danger"},uf=e=>e==="pending"||e==="recorded",mf=e=>`#${e+1}`,Vi=({total:e,tenders:s,onRemove:a,locale:n="en-US",labels:r,hideCollectedList:i=!1,variant:l="banner",className:o,"data-testid":d="split-payment-summary"})=>{const u={...of,...r},{collected:f,remaining:m,isComplete:h}=p.useMemo(()=>{const g=s.reduce((b,w)=>uf(w.status)?b+w.amount:b,0),j=Math.max(e.value-g,0);return{collected:g,remaining:j,isComplete:g>=e.value&&e.value>0}},[s,e.value]),x=g=>g==="pending"?u.statusPending:g==="recorded"?u.statusRecorded:u.statusFailed;return t.jsxs("div",{className:c.cn("flex flex-col gap-4",o),"data-testid":d,children:[l==="compact"?t.jsxs("div",{className:"flex items-baseline justify-between gap-3","data-testid":`${d}-remaining-banner`,children:[t.jsx("span",{className:"text-sm text-default-600",children:h?u.completeLabel:u.remainingLabel}),t.jsx("span",{className:"text-base font-semibold tracking-tight","data-testid":`${d}-remaining-amount`,children:ge(h?f:m,n,e.currency)})]}):t.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${d}-remaining-banner`,children:[t.jsx("div",{className:"text-sm text-default-600",children:h?u.completeLabel:u.remainingLabel}),t.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${d}-remaining-amount`,children:ge(h?f:m,n,e.currency)})]}),!i&&s.length>0&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${d}-collected-list`,children:[t.jsx("h3",{className:"text-base font-semibold",children:u.collectedHeading}),s.map((g,j)=>t.jsx(ff,{index:j,tender:g,locale:n,currency:e.currency,removable:!!a&&g.status!=="recorded",onRemove:a?()=>a(g.id):void 0,statusLabel:x(g.status),removeAriaLabel:u.removeAriaLabel,recordedTooltip:u.removeTooltipForRecorded,dataTestId:`${d}-row-${j}`},g.id))]})]})};Vi.displayName="SplitPaymentSummary";const ff=({index:e,tender:s,locale:a,currency:n,removable:r,onRemove:i,statusLabel:l,removeAriaLabel:o,recordedTooltip:d,dataTestId:u})=>{const f=i?t.jsx(B,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!r,"aria-label":o,"data-testid":`${u}-remove`,className:c.cn(r?"text-default-700 hover:bg-default-200":"text-default-300"),children:t.jsx(P,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return t.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:[t.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:mf(e)}),t.jsx(P,{icon:cf[s.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:s.label}),t.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:ge(s.amount,a,n)}),t.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:df[s.status],startContent:s.status==="recorded"?t.jsx(P,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):s.status==="failed"?t.jsx(P,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:l}),f&&(r?f:t.jsx(c.Tooltip,{content:d,placement:"left",children:t.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},xf=`
|
|
16
|
+
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),t.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:t.jsx(B,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:l,"aria-label":"Zoom in",children:t.jsx(K.ZoomIn,{size:16})})})]})}function cd({editor:e,isDisabled:s=!1}){const[a,n]=p.useState(!1),[r,i]=p.useState(""),[l,o]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),m=x=>{if(x){const{from:g,to:j}=e.state.selection,b=e.isActive("link");let w="";if(b){const D=e.schema.marks.link,v=e.state.doc.resolve(g),S=Pa.getMarkRange(v,D);S&&(w=e.state.doc.textBetween(S.from,S.to,""))}else w=e.state.doc.textBetween(g,j,"");const N=e.getAttributes("link").href||"";i(w),o(N),u(b)}n(x)},h=()=>{if(l.trim()){const{from:x,to:g}=e.state.selection,j=e.schema.marks.link,b=e.state.doc.resolve(x),w=Pa.getMarkRange(b,j),N=w?.from??x,D=w?.to??g,v=e.state.doc.textBetween(N,D,"");r.trim()&&r!==v?e.chain().focus().setTextSelection({from:N,to:D}).deleteSelection().insertContent(`<a href="${l.trim()}">${r.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:l.trim()}).run()}n(!1)};return t.jsxs(c.Popover,{isOpen:a,onOpenChange:m,placement:"bottom",children:[t.jsx(c.PopoverTrigger,{children:t.jsx(B,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":"Link",children:t.jsx(K.Link,{size:16})})}),t.jsx(c.PopoverContent,{children:t.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:r,onChange:x=>i(x.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:l,onChange:x=>o(x.target.value),onKeyDown:x=>x.key==="Enter"&&h(),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(B,{size:"sm",color:"primary",onPress:h,isDisabled:!l.trim(),children:d?"Update":"Apply"})]})})]})}function dd({children:e,id:s,label:a,className:n,useButtonGroup:r=!0}){return r?t.jsx(c.ButtonGroup,{size:"sm",id:s,"aria-label":a,className:n,children:e}):t.jsx("div",{id:s,role:"group","aria-label":a,className:`flex items-center gap-2 ${n||""}`,children:e})}function kr(e,s){const a=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(s.map(o=>_t(o)))).forEach(o=>{const d=Xe[o];if(d)try{const u=d.canExecute?.(e)??!0,f=d.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,s]),[n,r]=p.useState(a);return p.useEffect(()=>{if(!e)return;const i=()=>{const l={};Array.from(new Set(s.map(d=>_t(d)))).forEach(d=>{const u=Xe[d];if(u)try{const f=u.canExecute?.(e)??!0,m=u.isActive?.(e)??!1;l[d]={isActive:m,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),l[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),r(l)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,s,a]),n}function Sr(e,s){const a=p.useCallback((l,o)=>{if(!e)return;const d=Xe[l];if(d)try{d.execute({editor:e,config:o}),s?.({type:"toggle",modifier:l})}catch(u){console.warn(`Failed to execute command for modifier: ${l}`,u)}},[e,s]),n=p.useCallback(l=>{a(l)},[a]),r=p.useCallback((l,o)=>{if(!e)return!1;const d=Xe[l];try{return d?.canExecute?.(e,o)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${l}`,u),!1}},[e]),i=p.useCallback((l,o)=>{if(!e)return!1;const d=Xe[l];try{return d?.isActive?.(e,o)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${l}`,u),!1}},[e]);return{executeCommand:a,toggleModifier:n,canExecute:r,isActive:i}}function ud(e=Ce.default){const[s,a]=p.useState(e),n=p.useCallback((o=Ce.step)=>{a(d=>Math.min(Ce.max,d+o))},[]),r=p.useCallback((o=Ce.step)=>{a(d=>Math.max(Ce.min,d-o))},[]),i=p.useCallback(()=>{a(Ce.default)},[]),l=p.useCallback(o=>{const d=Math.max(Ce.min,Math.min(Ce.max,o));a(d)},[]);return{zoom:s,setZoom:l,zoomIn:n,zoomOut:r,resetZoom:i,isMinZoom:s<=Ce.min,isMaxZoom:s>=Ce.max,isDefaultZoom:s===Ce.default}}const md=["bold","italic","strike","underline","code"];function fd({editor:e,modifiers:s,onToolbarAction:a}){const n=kr(e,s),{toggleModifier:r}=Sr(e,a);if(!e)return null;const i=s.map(l=>_t(l)).filter(l=>md.includes(l));return i.length===0?null:t.jsx(dd,{id:"text-formatting",label:"Text formatting",children:i.map(l=>{const o=n[l],d=pt(l);return t.jsx(ot,{icon:d,label:l.charAt(0).toUpperCase()+l.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(l)},l)})})}function xd({editor:e,modifiers:s,zoom:a=100,onZoomChange:n,sticky:r=!0,className:i,onToolbarAction:l}){const o=kr(e,s),{toggleModifier:d,executeCommand:u}=Sr(e,l);if(!e)return null;const f=s.map(k=>_t(k)),m=f.some(k=>["bold","italic","strike","underline","code"].includes(k)),h=f.some(k=>["textColor","highlight"].includes(k)),x=f.includes("heading"),g=f.includes("textAlign"),j=f.some(k=>["bulletList","orderedList","taskList"].includes(k)),b=f.includes("blockquote"),w=f.includes("codeBlock"),N=f.includes("link"),D=f.includes("horizontalRule"),v=f.some(k=>["undo","redo"].includes(k)),S=a!==void 0&&n!==void 0,M=r?"sticky top-0 z-10":"";return t.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:t.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx(fd,{editor:e,modifiers:s,onToolbarAction:l}),(h||x||g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&t.jsx(rn,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),f.includes("highlight")&&t.jsx(rn,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(x||g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),x&&t.jsxs(t.Fragment,{children:[t.jsx(ed,{editor:e}),(g||j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(k=>{const F=id[k],C=e.isActive({textAlign:k});return t.jsx(ot,{icon:F,label:`Align ${k}`,isActive:C,onClick:()=>u("textAlign",{type:"textAlign",alignment:k})},k)})}),(j||b||w||N||D||v||S)&&t.jsx(lt,{})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(td,{editor:e,types:f.filter(k=>["bulletList","orderedList","taskList"].includes(k))}),(b||w||N||D||v||S)&&t.jsx(lt,{})]}),(b||w||N||D)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[b&&t.jsx(ot,{icon:pt("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&t.jsx(ot,{icon:pt("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),N&&t.jsx(cd,{editor:e,isDisabled:o.link?.isDisabled}),D&&t.jsx(ot,{icon:pt("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(v||S)&&t.jsx(lt,{})]}),v&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&t.jsx(ot,{icon:pt("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&t.jsx(ot,{icon:pt("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>d("redo")})]}),S&&t.jsx(lt,{})]}),S&&t.jsx(od,{zoom:a,onZoomChange:k=>{n?.(k),l?.({type:"zoom",modifier:`${k}%`})}})]})})}const Ct={bold:{category:"mark",extension:zl.Bold,priority:100},italic:{category:"mark",extension:Bl.Italic,priority:100},strike:{category:"mark",extension:Vl.Strike,priority:100},underline:{category:"mark",extension:Ul.Underline,priority:100},code:{category:"mark",extension:Hl.Code,priority:100},textColor:{category:"mark",extension:ql.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Wl.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Yl.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Kl.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Zl.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Xl.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Jl.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:so.CodeBlock,priority:100},blockquote:{category:"node",extension:ao.Blockquote,priority:100},horizontalRule:{category:"node",extension:no.HorizontalRule,priority:100},hardBreak:{category:"node",extension:ro.HardBreak,priority:100},undo:{category:"extension",extension:Oa.History,priority:50},redo:{category:"extension",extension:Oa.History,priority:50},textAlign:{category:"extension",extension:io.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}},hd=[lo.Document,oo.Text,Ql.Paragraph,Gl.TextStyle.configure({HTMLAttributes:{}}),to.ListItem.configure({HTMLAttributes:{}}),eo.TaskItem.configure({nested:!0}),co.Dropcursor,uo.Gapcursor];function pd(e){const s=[],a=new Set,n=new Set;hd.forEach(o=>{o&&(s.push(o),n.add(o.name))});const r=e.map(o=>_t(o)),i=new Set;return r.forEach(o=>{const d=Ct[o];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(o=>{if(a.has(o))return;const d=Ct[o];if(!d||d.extension===null)return;const u=d.extension.name;if(n.has(u)){a.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;s.push(f),a.add(o),n.add(u)}),r.forEach(o=>{if(a.has(o))return;const d=Ct[o];if(!d){console.warn(`Extension config not found for modifier: ${o}`);return}if(d.extension===null){a.add(o);return}const u=d.extension.name;if(n.has(u)){a.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;s.push(f),a.add(o),n.add(u)}),s.sort((o,d)=>{const u=Object.values(Ct).find(x=>x?.extension?.name===o.name),f=Object.values(Ct).find(x=>x?.extension?.name===d.name),m=u?.priority??100;return(f?.priority??100)-m})}const $r={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"]},gd={h1:`font-size: ${fe.fontSize["4xl"]}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h2:`font-size: ${fe.fontSize["2xl"]}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h3:`font-size: ${fe.fontSize.xl}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h4:`font-size: ${fe.fontSize.lg}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h5:`font-size: ${fe.fontSize.base}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,h6:`font-size: ${fe.fontSize.sm}; font-weight: ${fe.fontWeight.semibold}; line-height: ${fe.lineHeight.tight}; margin: ${ue.md} 0 ${ue.sm} 0;`,p:`min-height: ${fe.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ue.xl}; margin: ${ue.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ue.xl}; margin: ${ue.md} 0;`,li:`display: list-item; margin: ${ue.xs} 0;`,strong:`font-weight: ${fe.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${we.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${fe.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${fe.fontFamily.mono};`,pre:`background: ${we.neutral.gray[800]}; border-radius: ${ue.sm}; color: ${we.neutral.gray[100]}; font-family: ${fe.fontFamily.mono}; margin: ${ue.lg} 0; padding: 0.75rem ${ue.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${we.neutral.gray[300]}; margin: ${ue.lg} 0; padding-left: ${ue.md}; color: ${we.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${we.neutral.gray[200]}; margin: ${ue.xl} 0;`,a:`color: ${we.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${we.palettes.warning[200]}; border-radius: ${ue.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ue.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},bd={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 yd(e){if(!e)return e;let s=e;for(const[a,n]of Object.entries(bd)){const r=new RegExp(`(<(?:ul|li)[^>]*data-type="${a}"[^>]*)>`,"gi");s=s.replace(r,(i,l)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${n}"`):`${l} style="${n}">`)}for(const[a,n]of Object.entries(gd)){const r=new RegExp(`<${a}(\\s[^>]*)?>`,"gi");s=s.replace(r,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${n}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${n}'`);{const l=i.indexOf(">");return`${i.slice(0,l)} style="${n}"${i.slice(l)}`}})}return s}const vd=({modifiers:e,zoom:s,onZoomChange:a,onToolbarAction:n})=>{const{editor:r}=ta.useCurrentEditor();return t.jsx(xd,{editor:r,modifiers:e,zoom:s,onZoomChange:a,onToolbarAction:n})},jd=({showCharacterCount:e,showWordCount:s})=>{const{editor:a}=ta.useCurrentEditor();if(!a||!e&&!s)return null;const n=a.getText(),r=n.length,i=n.split(/\s+/).filter(l=>l.length>0).length;return t.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&t.jsxs("span",{children:[r," characters"]}),s&&t.jsxs("span",{children:[i," words"]})]})},qs=p.forwardRef((e,s)=>{const{minRows:a=10,maxRows:n=30,disableAutosize:r=!1,showCharacterCount:i=!1,showWordCount:l=!1,showToolbar:o=!0,modifiers:d=$r.full,variant:u="bordered",initialContent:f,content:m,onContentChange:h,onUpdate:x,onToolbarAction:g,isReadOnly:j=!1,isDisabled:b=!1,includeInlineStyles:w=!0,...N}=e,{zoom:D,setZoom:v}=ud(),S=nn.lineHeight,M=a*S,k=r?void 0:n*S,F=p.useMemo(()=>pd(d),[d]),{Component:C,label:_,shouldLabelBeOutside:E,getBaseProps:A,getLabelProps:R,getInputWrapperProps:O}=c.useInput({...N,variant:u,ref:s,isMultiline:!0}),V=_?t.jsx("label",{...R(),children:_}):null,q=p.useCallback(({editor:I})=>{const J=I.getHTML(),W=w?yd(J):J,se=I.getJSON(),Y=I.getText(),Z=Y.length,Q=Y.split(/\s+/).filter(ne=>ne.length>0).length,ee={html:W,json:se,text:Y,characters:Z,words:Q};if(h?.(ee),x?.(ee),"onChange"in N&&typeof N.onChange=="function"){const ne={target:{value:W},currentTarget:{value:W}};N.onChange(ne)}},[h,x,N,w]);return t.jsxs(C,{...A(),children:[E?V:null,t.jsx("div",{...O(),className:c.cn(O().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:k?`${k+nn.toolbarHeight}px`:void 0,overflow:k?"auto":void 0},children:t.jsx(ta.EditorProvider,{editable:!j&&!b,slotBefore:o?t.jsx(vd,{modifiers:d,zoom:D,onZoomChange:v,onToolbarAction:g}):void 0,slotAfter:t.jsx(jd,{showCharacterCount:i,showWordCount:l}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${D}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:F,content:m||f||e.defaultValue||"",onUpdate:q})})]})});qs.displayName="TipTapEditor";const Ar=p.forwardRef((e,s)=>{const{adapter:a="tiptap",variant:n="bordered",...r}=e;return a==="tiptap"?t.jsx(qs,{...r,variant:n,ref:s}):(console.warn(`Adapter "${a}" is not supported. Using TipTap.`),t.jsx(qs,{...r,variant:n,ref:s}))});Ar.displayName="RichTextArea";function wd(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}const ln=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Nd={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Dr=({presetAmounts:e=ln,selectedDonation:s,defaultSelectedDonation:a=null,onChange:n,onAddDonation:r,currency:i="USD",locale:l="en-US",showCustomAmount:o=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:m=2,desktopColumns:h=3,isDisabled:x=!1,buttonVariant:g="bordered",buttonColor:j="default",inputVariant:b="bordered",size:w="md",className:N="",showCard:D=!0})=>{const v={...Nd,...f},S=Array.isArray(e)?e:ln,M={2:"grid-cols-2",3:"grid-cols-3"},k={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},F=`${M[m]} ${k[h]}`,[C,_]=ds(s,a,n),[E,A]=p.useState(""),[R,O]=p.useState(!1),[V,q]=p.useState(0),I=p.useCallback(Z=>{if(x)return;const Q={amount:Z.amount,isCustom:!1,presetId:Z.id};_(Q),A(""),O(!1),q(ee=>ee+1),r?.(Q)},[x,_,r]),J=p.useCallback(Z=>{if(x)return;if(A(Z!==void 0?String(Z):""),r){_(null);return}if(Z===void 0||isNaN(Z)){_(null);return}_({amount:Z,isCustom:!0})},[x,_,r]),W=p.useCallback(()=>{if(x)return;const Z=E!==""?parseFloat(E):void 0;Z===void 0||isNaN(Z)||r?.({amount:Z,isCustom:!0})},[x,E,r]),se=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=t.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[v.title&&t.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:v.title}),S.length>0&&t.jsx("div",{className:c.cn("grid gap-3",F),"data-testid":"donation-amounts-presets",children:S.map(Z=>{const Q=C!==null&&!C.isCustom&&C.presetId===Z.id;return t.jsx(B,{color:Q?"primary":j,variant:Q?"solid":g,className:"w-full",onPress:()=>I(Z),isDisabled:x,"data-testid":`donation-amounts-preset-${Z.id}`,children:Z.label||wd(Z.amount,l,i)},Z.id)})}),o&&t.jsxs("div",{className:"flex gap-3 items-start",children:[t.jsx(c.NumberInput,{placeholder:v.customAmountPlaceholder,"aria-label":v.customAmountAriaLabel,onInput:r?()=>{_(null),O(!0)}:void 0,variant:b,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:se,value:E!==""?parseFloat(E):void 0,onValueChange:J,isDisabled:x,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},r?`custom-${V}`:C?.isCustom===!1?C.presetId:"custom"),r&&t.jsx(B,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:W,isDisabled:x||!R,"data-testid":"donation-amounts-add-button",children:v.addDonationButton})]})]});return D?t.jsx(c.Card,{className:c.cn("w-full",N),"data-testid":"donation-amounts-card",children:t.jsx(c.CardBody,{children:Y})}):t.jsx("div",{className:c.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};Dr.displayName="DonationAmounts";const Cd=e=>{const s=Math.max(0,e),a=Math.floor(s/60).toString().padStart(2,"0"),n=(s%60).toString().padStart(2,"0");return`${a}:${n} minutes`},kd=e=>{switch(e){case"warning":return K.Clock;case"error":return K.AlertCircle;case"success":return K.CheckCircle;default:return K.Clock}},Sd=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"}},Er=p.forwardRef(({timeLeft:e,defaultTimeLeft:s=1200,onTimeChange:a,onExpire:n,variant:r="info",color:i="primary",message:l="Your cart expires in:",showIcon:o=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:m=Cd,className:h,...x},g)=>{const[j,b]=ds(e!==void 0?Math.max(0,e):void 0,Math.max(0,s),a),w=p.useRef(null),N=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||j<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{b(M=>M<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,n?.()),0):M-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,j,b,n]),p.useEffect(()=>{j>0&&(N.current=!1)},[j]);const D=d||kd(r),v=Sd(i),S={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return t.jsx("div",{ref:g,role:"banner","aria-live":"polite","aria-label":`${l} ${m(j)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",v,S[u],h),...x,children:t.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[t.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&&t.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:t.jsx(D,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),t.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:l})]}),t.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:t.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${m(j)}`,"data-testid":"expire-cart-timer-value",children:m(j)})})]})})})});Er.displayName="ExpireCartTimer";const ft=({icon:e,children:s,testId:a})=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":a,children:[t.jsx(P,{icon:e,width:20,className:"text-default-500"}),t.jsx("span",{children:s})]}),$d=({classes:e="",name:s,imageUrl:a,eventDate:n,eventTime:r,location:i,description:l,showImage:o=!1,compact:d=!1,layout:u="stacked",imageLoading:f="eager",showMoreButtonClassName:m,labels:h})=>{const[x,g]=p.useState(!1),[j,b]=p.useState(!1),w=p.useRef(null);return p.useEffect(()=>{const N=()=>{if(w.current){const D=w.current.scrollHeight>w.current.clientHeight;b(D)}};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[l]),u==="horizontal"?t.jsx(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:t.jsx(c.CardBody,{className:"p-0","data-testid":"event-details-horizontal-layout",children:t.jsxs("div",{className:"flex flex-col items-start gap-5 sm:flex-row sm:gap-8",children:[o&&a&&t.jsx("div",{className:"w-full shrink-0 overflow-hidden rounded-xl aspect-[3/2] sm:w-[360px]","data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:f,alt:`Event image for ${s}`,className:"w-full h-full object-cover object-center",src:a,"data-testid":"event-details-image"})}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"font-semibold text-2xl text-gray-800","data-testid":"event-details-title",children:s}),t.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:h.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[n&&t.jsx(ft,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:n}),r&&t.jsx(ft,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(ft,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:w,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&j&&t.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"})]}),(j||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(B,{onPress:()=>g(!x),variant:"light",className:c.cn("text-primary",m),size:"md",startContent:t.jsx(P,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:x?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})})}):t.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[t.jsxs(c.CardHeader,{className:c.cn("pt-2 pb-0 flex-col items-start",d?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&a&&t.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:f,alt:`Event image for ${s}`,className:"w-full h-full object-cover object-center",src:a,"data-testid":"event-details-image"})}),t.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:s})]}),t.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[t.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[n&&t.jsx(ft,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:n}),r&&t.jsx(ft,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(ft,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:w,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&j&&t.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"})]}),(j||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(B,{onPress:()=>g(!x),variant:"light",className:c.cn("text-primary",m),size:d?"sm":"md",startContent:t.jsx(P,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:x?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function Ws(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}function Ad(e){const s=e.replace(/[^\d.,-]/g,""),a=s.match(/,\d{1,2}$/);let n;a?n=s.replace(/\./g,"").replace(",","."):n=s.replace(/,/g,"");const r=parseFloat(n);return isNaN(r)?null:r}const Dd={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"},xt=e=>typeof e=="number"&&!isNaN(e),es=({offer:e,quantity:s,defaultQuantity:a=0,onQuantityChange:n,currency:r="USD",locale:i="en-US",labels:l,slots:o,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:m=!0,showDescription:h=!0,showPeopleCount:x=!0,showPrice:g=!0,priceDisplay:j,classNames:b={},"data-testid":w,selectedColor:N="default",selectionMode:D="stepper",compact:v=!1,isSoldOut:S,isMaxReached:M,isRuleBlocked:k,statusTone:F="default",statusLabel:C,disabledReason:_,disabled:E})=>{const A=p.useMemo(()=>({...Dd,...l}),[l]),[R,O]=p.useState(a),V=s!==void 0?s:R,q=!!(d||E),I=v||!!e.compact,J=D==="press-to-add",W=p.useMemo(()=>typeof S=="boolean"?S:typeof e.isSoldOut=="boolean"?e.isSoldOut:!xt(e.totalTicketsSold)||!xt(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[S,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),se=p.useMemo(()=>typeof M=="boolean"?M:typeof e.isMaxReached=="boolean"?e.isMaxReached:W||!xt(e.ticketsAllowed)?!1:V>=e.ticketsAllowed-(e.totalTicketsSold??0),[M,e.isMaxReached,W,e.ticketsAllowed,e.totalTicketsSold,V]),Y=p.useMemo(()=>typeof k=="boolean"?k:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[k,e.isRuleBlocked]),Z=_||e.disabledReason,Q=q||W||Y,ee=le=>{if(Q||le>0&&se)return;const ye=Math.max(0,V+le);s===void 0&&O(ye),n?.(e.id,ye)},ne=p.useMemo(()=>{if(W)return"soldOut";if(Y)return"ruleBlocked";if(q)return"disabled"},[W,Y,q]),X=p.useMemo(()=>F||(W||Y?"danger":se?"warning":"default"),[F,W,Y,se]),de=p.useMemo(()=>{if(ne)return ne==="ruleBlocked"?C||Z||A.ruleBlocked:ne==="soldOut"?C||Z||A.soldOut:ne==="disabled"?C||Z||A.disabled:C||A.maxReached},[ne,C,Z,A]),ae={soldOut:"danger",ruleBlocked:X,disabled:"default",maxReached:"warning"},Ie={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},Ee=()=>o?.renderName?o.renderName(e.name,e):t.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",I&&"text-sm",b.name),children:e.name}),Le=()=>{if(!g)return null;const le=j?.price??e.price,ye=j?.originalPrice,Ye=Ws(le,i,r);if(o?.renderPrice)return o.renderPrice(le,Ye,e);if(xt(ye)&&xt(le)&&ye>le){const $=Ws(ye,i,r);return t.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",I&&"mt-0.5",b.price),children:[t.jsxs("span",{className:"sr-only",children:["Original price ",$,", discounted price ",Ye]}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",I&&"text-xs",b.originalPrice),children:$}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",I&&"text-sm",b.discountedPrice),children:Ye})]})}return t.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",I&&"text-sm mt-0.5",b.price),children:Ye})},mt=()=>!h||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):t.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",I&&"mb-2 text-xs text-gray-600",b.description),children:e.description}),Ge=()=>{if(!x||!xt(e.numberOfPeople)||e.numberOfPeople<=0)return null;const le=e.numberOfPeople===1?A.person:A.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,le,e):t.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",I&&"mt-1 text-xs",b.peopleCount),children:[t.jsx(P,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",le]})},We=()=>{const le=V===0||Q,ye=se||Q;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:V,onIncrement:()=>ee(1),onDecrement:()=>ee(-1),isDecrementDisabled:le,isIncrementDisabled:ye,isDisabled:Q}):t.jsxs("div",{className:c.cn("flex items-center gap-2",b.quantitySelector),children:[t.jsx(B,{"data-testid":"offer-card-decrement-button",onPress:()=>ee(-1),isDisabled:le,variant:u,color:V>0?N:f,radius:"full",isIconOnly:!0,size:I?"md":"sm","aria-label":"Decrease quantity",children:t.jsx(P,{icon:"gravity-ui:minus",width:16})}),t.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",I&&"text-sm"),children:V}),t.jsx(B,{"data-testid":"offer-card-increment-button",onPress:()=>ee(1),isDisabled:ye,variant:u,color:V>0?N:f,radius:"full",isIconOnly:!0,size:I?"md":"sm","aria-label":"Increase quantity",children:t.jsx(P,{icon:"gravity-ui:plus",width:16})})]})},rt=(le,ye)=>o?.renderDisabledState?o.renderDisabledState(le,ye):le==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(ye):le==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(ye):t.jsx(c.Chip,{"data-testid":Ie[le],color:ae[le],variant:le==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",le==="maxReached"?"h-8":"h-10",le==="soldOut"&&b.soldOut,le==="maxReached"&&b.maxReachedAlert,I&&"h-8"),startContent:t.jsx(P,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:t.jsx("span",{className:"font-medium text-sm",children:ye})}),Je=t.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",I?"gap-1":"gap-2"),children:[t.jsxs("div",{className:c.cn("h-full col-span-2",Q||se?"opacity-50 pointer-events-none select-none":""),children:[Ee(),Le(),t.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",I?"mb-1":"mb-2"),children:[Ge(),mt()]})]}),!J&&t.jsx("div",{className:c.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",I&&"space-x-1 pb-1 md:p-1",b.compactFooter),children:ne&&de?rt(ne,de):We()})]}),Pe=se&&!W&&!Y&&!q?t.jsx(De.motion.div,{className:c.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:rt("maxReached",de||A.maxReached)}):null;return m?t.jsxs(c.Card,{className:c.cn("w-full",J&&!Q&&!se&&"cursor-pointer",I&&b.compact,b.base),"data-testid":w||`offer-card-${e.id}`,isPressable:J&&!Q&&!se,onPress:J&&!Q&&!se?()=>ee(1):void 0,children:[t.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",I?"pb-0.5":"",b.body),children:Je}),t.jsx(De.AnimatePresence,{children:Pe&&t.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",I?"pt-1":"",b.footer),children:Pe})})]}):t.jsxs("div",{className:c.cn("w-full",I&&b.compact,b.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx("div",{className:c.cn("pt-1 pb-0",I?"pb-0.5":"",b.body),children:Je}),t.jsx(De.AnimatePresence,{children:Pe&&t.jsx("div",{className:c.cn("w-full mt-0 pt-0",I?"pt-1":"",b.footer),children:Pe})})]})};es.displayName="OfferCard";const Fr=({message:e="No offers available.",icon:s="solar:ticket-sale-outline",iconSize:a=48,showCard:n=!0,classNames:r={},renderEmpty:i})=>{if(i){const o=i();return n?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:o})}const l=t.jsxs("div",{"data-testid":"offer-card-empty-content",className:c.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",r.content),children:[t.jsx(P,{"data-testid":"offer-card-empty-icon",icon:s,width:a,className:c.cn("mb-4",r.icon)}),t.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",r.message),children:e})]});return n?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:l})};Fr.displayName="OfferCardEmpty";const Ed={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},Lr=({error:e,labels:s,showCard:a=!0,color:n="danger",classNames:r={}})=>{const i={...Ed,...s},l=t.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:n,title:i.title,description:e||i.description,className:r.alert});return a?t.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:l})};Lr.displayName="OfferCardError";const Fd={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Mr=({quantity:e=2,gap:s=4,classNames:a={}})=>{const n=Fd[s];return t.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(n,a.base),children:Array.from({length:e}).map((r,i)=>t.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",a.card),children:[t.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:t.jsxs("div",{className:"space-y-2 w-full",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),t.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[t.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),t.jsx("div",{className:"flex items-start justify-end",children:t.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Mr.displayName="OfferCardSkeleton";const _r={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},Rr={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"}}},Ld={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},Tr=({offers:e=[],mapOffer:s,selection:a,defaultSelection:n={},onSelectionChange:r,onQuantityChange:i,currency:l="USD",locale:o="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:m="bordered",buttonColor:h="default",showCard:x=!0,animated:g=!0,gap:j=2,compact:b=!1,classNames:w={}})=>{const[N,D]=p.useState(n),v=a!==void 0?a:N,S=p.useCallback((E,A)=>{const R={...v,[E]:Math.max(0,A)};a===void 0&&D(R),r?.(R),i?.(E,R[E])},[v,a,r,i]),M=[...e].sort((E,A)=>(E.position??0)-(A.position??0)),k=E=>{const A=s?s(E):E,R=(v??{})[A.id]||0;return{offer:A,quantity:R,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:h,showCard:x,compact:b}},F=Ld[j],C=c.cn("grid mx-auto pt-2",F,w.base),_=E=>{const A=k(E);return t.jsx(es,{offer:A.offer,quantity:A.quantity,onQuantityChange:A.onQuantityChange,currency:A.currency,locale:A.locale,labels:A.labels,slots:A.slots,isDisabled:A.isDisabled,buttonVariant:A.buttonVariant,buttonColor:A.buttonColor,showCard:A.showCard,compact:A.compact,classNames:w.card},A.offer.id)};return g?t.jsx(De.motion.div,{"data-testid":"offer-card-list",className:C,variants:_r,initial:"hidden",animate:"show",children:t.jsx(De.AnimatePresence,{children:M.map(E=>{const A=k(E);return t.jsx(De.motion.div,{"data-testid":`offer-card-list-item-${A.offer.id}`,className:w.cardWrapper,variants:Rr,exit:{opacity:0,y:-20},transition:{duration:.3},children:t.jsx(es,{offer:A.offer,quantity:A.quantity,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:h,showCard:x,compact:b||A.offer.compact,classNames:w.card})},A.offer.id)})})}):t.jsx("div",{"data-testid":"offer-card-list",className:C,children:M.map(_)})};Tr.displayName="OfferCardList";var Tt=e=>e.type==="checkbox",ct=e=>e instanceof Date,Fe=e=>e==null;const Ir=e=>typeof e=="object";var be=e=>!Fe(e)&&!Array.isArray(e)&&Ir(e)&&!ct(e),Pr=e=>be(e)&&e.target?Tt(e.target)?e.target.checked:e.target.value:e,Md=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Or=(e,s)=>e.has(Md(s)),_d=e=>{const s=e.constructor&&e.constructor.prototype;return be(s)&&s.hasOwnProperty("isPrototypeOf")},ma=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function he(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(ma&&(e instanceof Blob||s))return e;const a=Array.isArray(e);if(!a&&!(be(e)&&_d(e)))return e;const n=a?[]:Object.create(Object.getPrototypeOf(e));for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=he(e[r]));return n}var us=e=>/^\w*$/.test(e),me=e=>e===void 0,fa=e=>Array.isArray(e)?e.filter(Boolean):[],xa=e=>fa(e.replace(/["|']|\]/g,"").split(/\.|\[/)),H=(e,s,a)=>{if(!s||!be(e))return a;const n=(us(s)?[s]:xa(s)).reduce((r,i)=>Fe(r)?r:r[i],e);return me(n)||n===e?me(e[s])?a:e[s]:n},Re=e=>typeof e=="boolean",Ae=e=>typeof e=="function",ce=(e,s,a)=>{let n=-1;const r=us(s)?[s]:xa(s),i=r.length,l=i-1;for(;++n<i;){const o=r[n];let d=a;if(n!==l){const u=e[o];d=be(u)||Array.isArray(u)?u:isNaN(+r[n+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=d,e=e[o]}};const ts={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ve={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ke={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},zr=p.createContext(null);zr.displayName="HookFormControlContext";const ha=()=>p.useContext(zr);var Br=(e,s,a,n=!0)=>{const r={defaultValues:s._defaultValues};for(const i in e)Object.defineProperty(r,i,{get:()=>{const l=i;return s._proxyFormState[l]!==Ve.all&&(s._proxyFormState[l]=!n||Ve.all),a&&(a[l]=!0),e[l]}});return r};const pa=typeof window<"u"?p.useLayoutEffect:p.useEffect;function Rd(e){const s=ha(),{control:a=s,disabled:n,name:r,exact:i}=e||{},[l,o]=p.useState(a._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return pa(()=>a._subscribe({name:r,formState:d.current,exact:i,callback:u=>{!n&&o({...a._formState,...u})}}),[r,n,i]),p.useEffect(()=>{d.current.isValid&&a._setValid(!0)},[a]),p.useMemo(()=>Br(l,a,d.current,!1),[l,a])}var Te=e=>typeof e=="string",Ys=(e,s,a,n,r)=>Te(e)?(n&&s.watch.add(e),H(a,e,r)):Array.isArray(e)?e.map(i=>(n&&s.watch.add(i),H(a,i))):(n&&(s.watchAll=!0),a),Gs=e=>Fe(e)||!Ir(e);function Ue(e,s,a=new WeakSet){if(Gs(e)||Gs(s))return Object.is(e,s);if(ct(e)&&ct(s))return Object.is(e.getTime(),s.getTime());const n=Object.keys(e),r=Object.keys(s);if(n.length!==r.length)return!1;if(a.has(e)||a.has(s))return!0;a.add(e),a.add(s);for(const i of n){const l=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=s[i];if(ct(l)&&ct(o)||be(l)&&be(o)||Array.isArray(l)&&Array.isArray(o)?!Ue(l,o,a):!Object.is(l,o))return!1}}return!0}function Td(e){const s=ha(),{control:a=s,name:n,defaultValue:r,disabled:i,exact:l,compute:o}=e||{},d=p.useRef(r),u=p.useRef(o),f=p.useRef(void 0),m=p.useRef(a),h=p.useRef(n);u.current=o;const[x,g]=p.useState(()=>{const v=a._getWatch(n,d.current);return u.current?u.current(v):v}),j=p.useCallback(v=>{const S=Ys(n,a._names,v||a._formValues,!1,d.current);return u.current?u.current(S):S},[a._formValues,a._names,n]),b=p.useCallback(v=>{if(!i){const S=Ys(n,a._names,v||a._formValues,!1,d.current);if(u.current){const M=u.current(S);Ue(M,f.current)||(g(M),f.current=M)}else g(S)}},[a._formValues,a._names,i,n]);pa(()=>((m.current!==a||!Ue(h.current,n))&&(m.current=a,h.current=n,b()),a._subscribe({name:n,formState:{values:!0},exact:l,callback:v=>{b(v.values)}})),[a,l,n,b]),p.useEffect(()=>a._removeUnmounted());const w=m.current!==a,N=h.current,D=p.useMemo(()=>{if(i)return null;const v=!w&&!Ue(N,n);return w||v?j():null},[i,w,n,N,j]);return D!==null?D:x}function Id(e){const s=ha(),{name:a,disabled:n,control:r=s,shouldUnregister:i,defaultValue:l,exact:o=!0}=e,d=Or(r._names.array,a),u=p.useMemo(()=>H(r._formValues,a,H(r._defaultValues,a,l)),[r,a,l]),f=Td({control:r,name:a,defaultValue:u,exact:o}),m=Rd({control:r,name:a,exact:o}),h=p.useRef(e),x=p.useRef(void 0),g=p.useRef(r.register(a,{...e.rules,value:f,...Re(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const j=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!H(m.errors,a)},isDirty:{enumerable:!0,get:()=>!!H(m.dirtyFields,a)},isTouched:{enumerable:!0,get:()=>!!H(m.touchedFields,a)},isValidating:{enumerable:!0,get:()=>!!H(m.validatingFields,a)},error:{enumerable:!0,get:()=>H(m.errors,a)}}),[m,a]),b=p.useCallback(v=>g.current.onChange({target:{value:Pr(v),name:a},type:ts.CHANGE}),[a]),w=p.useCallback(()=>g.current.onBlur({target:{value:H(r._formValues,a),name:a},type:ts.BLUR}),[a,r._formValues]),N=p.useCallback(v=>{const S=H(r._fields,a);S&&S._f&&v&&(S._f.ref={focus:()=>Ae(v.focus)&&v.focus(),select:()=>Ae(v.select)&&v.select(),setCustomValidity:M=>Ae(v.setCustomValidity)&&v.setCustomValidity(M),reportValidity:()=>Ae(v.reportValidity)&&v.reportValidity()})},[r._fields,a]),D=p.useMemo(()=>({name:a,value:f,...Re(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:b,onBlur:w,ref:N}),[a,n,m.disabled,b,w,N,f]);return p.useEffect(()=>{const v=r._options.shouldUnregister||i,S=x.current;S&&S!==a&&!d&&r.unregister(S),r.register(a,{...h.current.rules,...Re(h.current.disabled)?{disabled:h.current.disabled}:{}});const M=(k,F)=>{const C=H(r._fields,k);C&&C._f&&(C._f.mount=F)};if(M(a,!0),v){const k=he(H(r._options.defaultValues,a,h.current.defaultValue));ce(r._defaultValues,a,k),me(H(r._formValues,a))&&ce(r._formValues,a,k)}return!d&&r.register(a),x.current=a,()=>{(d?v&&!r._state.action:v)?r.unregister(a):M(a,!1)}},[a,r,d,i]),p.useEffect(()=>{r._setDisabledField({disabled:n,name:a})},[n,a,r]),p.useMemo(()=>({field:D,formState:m,fieldState:j}),[D,m,j])}const Pd=p.createContext(null);Pd.displayName="HookFormContext";var Od=(e,s,a,n,r)=>s?{...a[e],types:{...a[e]&&a[e].types?a[e].types:{},[n]:r||!0}}:{},Et=e=>Array.isArray(e)?e:[e],on=()=>{let e=[];return{get observers(){return e},next:r=>{for(const i of e)i.next&&i.next(r)},subscribe:r=>(e.push(r),{unsubscribe:()=>{e=e.filter(i=>i!==r)}}),unsubscribe:()=>{e=[]}}};function Vr(e,s){const a={};for(const n in e)if(e.hasOwnProperty(n)){const r=e[n],i=s[n];if(r&&be(r)&&i){const l=Vr(r,i);be(l)&&(a[n]=l)}else e[n]&&(a[n]=i)}return a}var Se=e=>be(e)&&!Object.keys(e).length,ga=e=>e.type==="file",ss=e=>{if(!ma)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},Ur=e=>e.type==="select-multiple",ba=e=>e.type==="radio",zd=e=>ba(e)||Tt(e),ks=e=>ss(e)&&e.isConnected;function Bd(e,s){const a=s.slice(0,-1).length;let n=0;for(;n<a;)e=me(e)?n++:e[s[n++]];return e}function Vd(e){for(const s in e)if(e.hasOwnProperty(s)&&!me(e[s]))return!1;return!0}function pe(e,s){const a=Array.isArray(s)?s:us(s)?[s]:xa(s),n=a.length===1?e:Bd(e,a),r=a.length-1,i=a[r];return n&&delete n[i],r!==0&&(be(n)&&Se(n)||Array.isArray(n)&&Vd(n))&&pe(e,a.slice(0,-1)),e}var Ud=e=>{for(const s in e)if(Ae(e[s]))return!0;return!1};function Hr(e){return Array.isArray(e)||be(e)&&!Ud(e)}function Ks(e,s={}){for(const a in e){const n=e[a];Hr(n)?(s[a]=Array.isArray(n)?[]:{},Ks(n,s[a])):me(n)||(s[a]=!0)}return s}function gt(e,s,a){a||(a=Ks(s));for(const n in e){const r=e[n];if(Hr(r))me(s)||Gs(a[n])?a[n]=Ks(r,Array.isArray(r)?[]:{}):gt(r,Fe(s)?{}:s[n],a[n]);else{const i=s[n];a[n]=!Ue(r,i)}}return a}const cn={value:!1,isValid:!1},dn={value:!0,isValid:!0};var qr=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(a=>a&&a.checked&&!a.disabled).map(a=>a.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!me(e[0].attributes.value)?me(e[0].value)||e[0].value===""?dn:{value:e[0].value,isValid:!0}:dn:cn}return cn},Wr=(e,{valueAsNumber:s,valueAsDate:a,setValueAs:n})=>me(e)?e:s?e===""?NaN:e&&+e:a&&Te(e)?new Date(e):n?n(e):e;const un={isValid:!1,value:null};var Yr=e=>Array.isArray(e)?e.reduce((s,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:s,un):un;function mn(e){const s=e.ref;return ga(s)?s.files:ba(s)?Yr(e.refs).value:Ur(s)?[...s.selectedOptions].map(({value:a})=>a):Tt(s)?qr(e.refs).value:Wr(me(s.value)?e.ref.value:s.value,e)}var Hd=(e,s,a,n)=>{const r={};for(const i of e){const l=H(s,i);l&&ce(r,i,l._f)}return{criteriaMode:a,names:[...e],fields:r,shouldUseNativeValidation:n}},as=e=>e instanceof RegExp,kt=e=>me(e)?e:as(e)?e.source:be(e)?as(e.value)?e.value.source:e.value:e,fn=e=>({isOnSubmit:!e||e===Ve.onSubmit,isOnBlur:e===Ve.onBlur,isOnChange:e===Ve.onChange,isOnAll:e===Ve.all,isOnTouch:e===Ve.onTouched});const xn="AsyncFunction";var qd=e=>!!e&&!!e.validate&&!!(Ae(e.validate)&&e.validate.constructor.name===xn||be(e.validate)&&Object.values(e.validate).find(s=>s.constructor.name===xn)),Wd=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),hn=(e,s,a)=>!a&&(s.watchAll||s.watch.has(e)||[...s.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Ft=(e,s,a,n)=>{for(const r of a||Object.keys(e)){const i=H(e,r);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&s(l.refs[0],r)&&!n)return!0;if(l.ref&&s(l.ref,l.name)&&!n)return!0;if(Ft(o,s))break}else if(be(o)&&Ft(o,s))break}}};function pn(e,s,a){const n=H(e,a);if(n||us(a))return{error:n,name:a};const r=a.split(".");for(;r.length;){const i=r.join("."),l=H(s,i),o=H(e,i);if(l&&!Array.isArray(l)&&a!==i)return{name:a};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};r.pop()}return{name:a}}var Yd=(e,s,a,n)=>{a(e);const{name:r,...i}=e;return Se(i)||Object.keys(i).length>=Object.keys(s).length||Object.keys(i).find(l=>s[l]===(!n||Ve.all))},Gd=(e,s,a)=>!e||!s||e===s||Et(e).some(n=>n&&(a?n===s:n.startsWith(s)||s.startsWith(n))),Kd=(e,s,a,n,r)=>r.isOnAll?!1:!a&&r.isOnTouch?!(s||e):(a?n.isOnBlur:r.isOnBlur)?!e:(a?n.isOnChange:r.isOnChange)?e:!0,Qd=(e,s)=>!fa(H(e,s)).length&&pe(e,s),Zd=(e,s,a)=>{const n=Et(H(e,a));return ce(n,"root",s[a]),ce(e,a,n),e};function gn(e,s,a="validate"){if(Te(e)||Array.isArray(e)&&e.every(Te)||Re(e)&&!e)return{type:a,message:Te(e)?e:"",ref:s}}var ht=e=>be(e)&&!as(e)?e:{value:e,message:""},bn=async(e,s,a,n,r,i)=>{const{ref:l,refs:o,required:d,maxLength:u,minLength:f,min:m,max:h,pattern:x,validate:g,name:j,valueAsNumber:b,mount:w}=e._f,N=H(a,j);if(!w||s.has(j))return{};const D=o?o[0]:l,v=A=>{r&&D.reportValidity&&(D.setCustomValidity(Re(A)?"":A||""),D.reportValidity())},S={},M=ba(l),k=Tt(l),F=M||k,C=(b||ga(l))&&me(l.value)&&me(N)||ss(l)&&l.value===""||N===""||Array.isArray(N)&&!N.length,_=Od.bind(null,j,n,S),E=(A,R,O,V=Ke.maxLength,q=Ke.minLength)=>{const I=A?R:O;S[j]={type:A?V:q,message:I,ref:l,..._(A?V:q,I)}};if(i?!Array.isArray(N)||!N.length:d&&(!F&&(C||Fe(N))||Re(N)&&!N||k&&!qr(o).isValid||M&&!Yr(o).isValid)){const{value:A,message:R}=Te(d)?{value:!!d,message:d}:ht(d);if(A&&(S[j]={type:Ke.required,message:R,ref:D,..._(Ke.required,R)},!n))return v(R),S}if(!C&&(!Fe(m)||!Fe(h))){let A,R;const O=ht(h),V=ht(m);if(!Fe(N)&&!isNaN(N)){const q=l.valueAsNumber||N&&+N;Fe(O.value)||(A=q>O.value),Fe(V.value)||(R=q<V.value)}else{const q=l.valueAsDate||new Date(N),I=se=>new Date(new Date().toDateString()+" "+se),J=l.type=="time",W=l.type=="week";Te(O.value)&&N&&(A=J?I(N)>I(O.value):W?N>O.value:q>new Date(O.value)),Te(V.value)&&N&&(R=J?I(N)<I(V.value):W?N<V.value:q<new Date(V.value))}if((A||R)&&(E(!!A,O.message,V.message,Ke.max,Ke.min),!n))return v(S[j].message),S}if((u||f)&&!C&&(Te(N)||i&&Array.isArray(N))){const A=ht(u),R=ht(f),O=!Fe(A.value)&&N.length>+A.value,V=!Fe(R.value)&&N.length<+R.value;if((O||V)&&(E(O,A.message,R.message),!n))return v(S[j].message),S}if(x&&!C&&Te(N)){const{value:A,message:R}=ht(x);if(as(A)&&!N.match(A)&&(S[j]={type:Ke.pattern,message:R,ref:l,..._(Ke.pattern,R)},!n))return v(R),S}if(g){if(Ae(g)){const A=await g(N,a),R=gn(A,D);if(R&&(S[j]={...R,..._(Ke.validate,R.message)},!n))return v(R.message),S}else if(be(g)){let A={};for(const R in g){if(!Se(A)&&!n)break;const O=gn(await g[R](N,a),D,R);O&&(A={...O,..._(R,O.message)},v(O.message),n&&(S[j]=A))}if(!Se(A)&&(S[j]={ref:D,...A},!n))return S}}return v(!0),S};const Xd={mode:Ve.onSubmit,reValidateMode:Ve.onChange,shouldFocusError:!0};function Jd(e={}){let s={...Xd,...e},a={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ae(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},r=be(s.defaultValues)||be(s.values)?he(s.defaultValues||s.values)||{}:{},i=s.shouldUnregister?{}:he(r),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},d,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...f};let h={...m};const x={array:on(),state:on()},g=s.criteriaMode===Ve.all,j=y=>$=>{clearTimeout(u),u=setTimeout(y,$)},b=async y=>{if(!l.keepIsValid&&!s.disabled&&(m.isValid||h.isValid||y)){let $;s.resolver?($=Se((await F()).errors),w()):$=await _(n,!0),$!==a.isValid&&x.state.next({isValid:$})}},w=(y,$)=>{!s.disabled&&(m.isValidating||m.validatingFields||h.isValidating||h.validatingFields)&&((y||Array.from(o.mount)).forEach(L=>{L&&($?ce(a.validatingFields,L,$):pe(a.validatingFields,L))}),x.state.next({validatingFields:a.validatingFields,isValidating:!Se(a.validatingFields)}))},N=(y,$=[],L,U,z=!0,T=!0)=>{if(U&&L&&!s.disabled){if(l.action=!0,T&&Array.isArray(H(n,y))){const G=L(H(n,y),U.argA,U.argB);z&&ce(n,y,G)}if(T&&Array.isArray(H(a.errors,y))){const G=L(H(a.errors,y),U.argA,U.argB);z&&ce(a.errors,y,G),Qd(a.errors,y)}if((m.touchedFields||h.touchedFields)&&T&&Array.isArray(H(a.touchedFields,y))){const G=L(H(a.touchedFields,y),U.argA,U.argB);z&&ce(a.touchedFields,y,G)}(m.dirtyFields||h.dirtyFields)&&(a.dirtyFields=gt(r,i)),x.state.next({name:y,isDirty:A(y,$),dirtyFields:a.dirtyFields,errors:a.errors,isValid:a.isValid})}else ce(i,y,$)},D=(y,$)=>{ce(a.errors,y,$),x.state.next({errors:a.errors})},v=y=>{a.errors=y,x.state.next({errors:a.errors,isValid:!1})},S=(y,$,L,U)=>{const z=H(n,y);if(z){const T=H(i,y,me(L)?H(r,y):L);me(T)||U&&U.defaultChecked||$?ce(i,y,$?T:mn(z._f)):V(y,T),l.mount&&!l.action&&b()}},M=(y,$,L,U,z)=>{let T=!1,G=!1;const re={name:y};if(!s.disabled){if(!L||U){(m.isDirty||h.isDirty)&&(G=a.isDirty,a.isDirty=re.isDirty=A(),T=G!==re.isDirty);const ie=Ue(H(r,y),$);G=!!H(a.dirtyFields,y),ie?pe(a.dirtyFields,y):ce(a.dirtyFields,y,!0),re.dirtyFields=a.dirtyFields,T=T||(m.dirtyFields||h.dirtyFields)&&G!==!ie}if(L){const ie=H(a.touchedFields,y);ie||(ce(a.touchedFields,y,L),re.touchedFields=a.touchedFields,T=T||(m.touchedFields||h.touchedFields)&&ie!==L)}T&&z&&x.state.next(re)}return T?re:{}},k=(y,$,L,U)=>{const z=H(a.errors,y),T=(m.isValid||h.isValid)&&Re($)&&a.isValid!==$;if(s.delayError&&L?(d=j(()=>D(y,L)),d(s.delayError)):(clearTimeout(u),d=null,L?ce(a.errors,y,L):pe(a.errors,y)),(L?!Ue(z,L):z)||!Se(U)||T){const G={...U,...T&&Re($)?{isValid:$}:{},errors:a.errors,name:y};a={...a,...G},x.state.next(G)}},F=async y=>(w(y,!0),await s.resolver(i,s.context,Hd(y||o.mount,n,s.criteriaMode,s.shouldUseNativeValidation))),C=async y=>{const{errors:$}=await F(y);if(w(y),y)for(const L of y){const U=H($,L);U?ce(a.errors,L,U):pe(a.errors,L)}else a.errors=$;return $},_=async(y,$,L={valid:!0})=>{for(const U in y){const z=y[U];if(z){const{_f:T,...G}=z;if(T){const re=o.array.has(T.name),ie=z._f&&qd(z._f);ie&&m.validatingFields&&w([T.name],!0);const ke=await bn(z,o.disabled,i,g,s.shouldUseNativeValidation&&!$,re);if(ie&&m.validatingFields&&w([T.name]),ke[T.name]&&(L.valid=!1,$||e.shouldUseNativeValidation))break;!$&&(H(ke,T.name)?re?Zd(a.errors,ke,T.name):ce(a.errors,T.name,ke[T.name]):pe(a.errors,T.name))}!Se(G)&&await _(G,$,L)}}return L.valid},E=()=>{for(const y of o.unMount){const $=H(n,y);$&&($._f.refs?$._f.refs.every(L=>!ks(L)):!ks($._f.ref))&&ae(y)}o.unMount=new Set},A=(y,$)=>!s.disabled&&(y&&$&&ce(i,y,$),!Ue(Y(),r)),R=(y,$,L)=>Ys(y,o,{...l.mount?i:me($)?r:Te(y)?{[y]:$}:$},L,$),O=y=>fa(H(l.mount?i:r,y,s.shouldUnregister?H(r,y,[]):[])),V=(y,$,L={})=>{const U=H(n,y);let z=$;if(U){const T=U._f;T&&(!T.disabled&&ce(i,y,Wr($,T)),z=ss(T.ref)&&Fe($)?"":$,Ur(T.ref)?[...T.ref.options].forEach(G=>G.selected=z.includes(G.value)):T.refs?Tt(T.ref)?T.refs.forEach(G=>{(!G.defaultChecked||!G.disabled)&&(Array.isArray(z)?G.checked=!!z.find(re=>re===G.value):G.checked=z===G.value||!!z)}):T.refs.forEach(G=>G.checked=G.value===z):ga(T.ref)?T.ref.value="":(T.ref.value=z,T.ref.type||x.state.next({name:y,values:he(i)})))}(L.shouldDirty||L.shouldTouch)&&M(y,z,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&se(y)},q=(y,$,L)=>{for(const U in $){if(!$.hasOwnProperty(U))return;const z=$[U],T=y+"."+U,G=H(n,T);(o.array.has(y)||be(z)||G&&!G._f)&&!ct(z)?q(T,z,L):V(T,z,L)}},I=(y,$,L={})=>{const U=H(n,y),z=o.array.has(y),T=he($);ce(i,y,T),z?(x.array.next({name:y,values:he(i)}),(m.isDirty||m.dirtyFields||h.isDirty||h.dirtyFields)&&L.shouldDirty&&x.state.next({name:y,dirtyFields:gt(r,i),isDirty:A(y,T)})):U&&!U._f&&!Fe(T)?q(y,T,L):V(y,T,L),hn(y,o)?x.state.next({...a,name:y,values:he(i)}):x.state.next({name:l.mount?y:void 0,values:he(i)})},J=async y=>{l.mount=!0;const $=y.target;let L=$.name,U=!0;const z=H(n,L),T=ie=>{U=Number.isNaN(ie)||ct(ie)&&isNaN(ie.getTime())||Ue(ie,H(i,L,ie))},G=fn(s.mode),re=fn(s.reValidateMode);if(z){let ie,ke;const it=$.type?mn(z._f):Pr(y),et=y.type===ts.BLUR||y.type===ts.FOCUS_OUT,Il=!Wd(z._f)&&!s.resolver&&!H(a.errors,L)&&!z._f.deps||Kd(et,H(a.touchedFields,L),a.isSubmitted,re,G),xs=hn(L,o,et);ce(i,L,it),et?(!$||!$.readOnly)&&(z._f.onBlur&&z._f.onBlur(y),d&&d(0)):z._f.onChange&&z._f.onChange(y);const hs=M(L,it,et),Pl=!Se(hs)||xs;if(!et&&x.state.next({name:L,type:y.type,values:he(i)}),Il)return(m.isValid||h.isValid)&&(s.mode==="onBlur"?et&&b():et||b()),Pl&&x.state.next({name:L,...xs?{}:hs});if(!et&&xs&&x.state.next({...a}),s.resolver){const{errors:Ta}=await F([L]);if(w([L]),T(it),U){const Ol=pn(a.errors,n,L),Ia=pn(Ta,n,Ol.name||L);ie=Ia.error,L=Ia.name,ke=Se(Ta)}}else w([L],!0),ie=(await bn(z,o.disabled,i,g,s.shouldUseNativeValidation))[L],w([L]),T(it),U&&(ie?ke=!1:(m.isValid||h.isValid)&&(ke=await _(n,!0)));U&&(z._f.deps&&(!Array.isArray(z._f.deps)||z._f.deps.length>0)&&se(z._f.deps),k(L,ke,ie,hs))}},W=(y,$)=>{if(H(a.errors,$)&&y.focus)return y.focus(),1},se=async(y,$={})=>{let L,U;const z=Et(y);if(s.resolver){const T=await C(me(y)?y:z);L=Se(T),U=y?!z.some(G=>H(T,G)):L}else y?(U=(await Promise.all(z.map(async T=>{const G=H(n,T);return await _(G&&G._f?{[T]:G}:G)}))).every(Boolean),!(!U&&!a.isValid)&&b()):U=L=await _(n);return x.state.next({...!Te(y)||(m.isValid||h.isValid)&&L!==a.isValid?{}:{name:y},...s.resolver||!y?{isValid:L}:{},errors:a.errors}),$.shouldFocus&&!U&&Ft(n,W,y?z:o.mount),U},Y=(y,$)=>{let L={...l.mount?i:r};return $&&(L=Vr($.dirtyFields?a.dirtyFields:a.touchedFields,L)),me(y)?L:Te(y)?H(L,y):y.map(U=>H(L,U))},Z=(y,$)=>({invalid:!!H(($||a).errors,y),isDirty:!!H(($||a).dirtyFields,y),error:H(($||a).errors,y),isValidating:!!H(a.validatingFields,y),isTouched:!!H(($||a).touchedFields,y)}),Q=y=>{y&&Et(y).forEach($=>pe(a.errors,$)),x.state.next({errors:y?a.errors:{}})},ee=(y,$,L)=>{const U=(H(n,y,{_f:{}})._f||{}).ref,z=H(a.errors,y)||{},{ref:T,message:G,type:re,...ie}=z;ce(a.errors,y,{...ie,...$,ref:U}),x.state.next({name:y,errors:a.errors,isValid:!1}),L&&L.shouldFocus&&U&&U.focus&&U.focus()},ne=(y,$)=>Ae(y)?x.state.subscribe({next:L=>"values"in L&&y(R(void 0,$),L)}):R(y,$,!0),X=y=>x.state.subscribe({next:$=>{Gd(y.name,$.name,y.exact)&&Yd($,y.formState||m,le,y.reRenderRoot)&&y.callback({values:{...i},...a,...$,defaultValues:r})}}).unsubscribe,de=y=>(l.mount=!0,h={...h,...y.formState},X({...y,formState:{...f,...y.formState}})),ae=(y,$={})=>{for(const L of y?Et(y):o.mount)o.mount.delete(L),o.array.delete(L),$.keepValue||(pe(n,L),pe(i,L)),!$.keepError&&pe(a.errors,L),!$.keepDirty&&pe(a.dirtyFields,L),!$.keepTouched&&pe(a.touchedFields,L),!$.keepIsValidating&&pe(a.validatingFields,L),!s.shouldUnregister&&!$.keepDefaultValue&&pe(r,L);x.state.next({values:he(i)}),x.state.next({...a,...$.keepDirty?{isDirty:A()}:{}}),!$.keepIsValid&&b()},Ie=({disabled:y,name:$})=>{if(Re(y)&&l.mount||y||o.disabled.has($)){const z=o.disabled.has($)!==!!y;y?o.disabled.add($):o.disabled.delete($),z&&l.mount&&!l.action&&b()}},Ee=(y,$={})=>{let L=H(n,y);const U=Re($.disabled)||Re(s.disabled);return ce(n,y,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:y}},name:y,mount:!0,...$}}),o.mount.add(y),L?Ie({disabled:Re($.disabled)?$.disabled:s.disabled,name:y}):S(y,!0,$.value),{...U?{disabled:$.disabled||s.disabled}:{},...s.progressive?{required:!!$.required,min:kt($.min),max:kt($.max),minLength:kt($.minLength),maxLength:kt($.maxLength),pattern:kt($.pattern)}:{},name:y,onChange:J,onBlur:J,ref:z=>{if(z){Ee(y,$),L=H(n,y);const T=me(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,G=zd(T),re=L._f.refs||[];if(G?re.find(ie=>ie===T):T===L._f.ref)return;ce(n,y,{_f:{...L._f,...G?{refs:[...re.filter(ks),T,...Array.isArray(H(r,y))?[{}]:[]],ref:{type:T.type,name:y}}:{ref:T}}}),S(y,!1,void 0,T)}else L=H(n,y,{}),L._f&&(L._f.mount=!1),(s.shouldUnregister||$.shouldUnregister)&&!(Or(o.array,y)&&l.action)&&o.unMount.add(y)}}},Le=()=>s.shouldFocusError&&Ft(n,W,o.mount),mt=y=>{Re(y)&&(x.state.next({disabled:y}),Ft(n,($,L)=>{const U=H(n,L);U&&($.disabled=U._f.disabled||y,Array.isArray(U._f.refs)&&U._f.refs.forEach(z=>{z.disabled=U._f.disabled||y}))},0,!1))},Ge=(y,$)=>async L=>{let U;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let z=he(i);if(x.state.next({isSubmitting:!0}),s.resolver){const{errors:T,values:G}=await F();w(),a.errors=T,z=he(G)}else await _(n);if(o.disabled.size)for(const T of o.disabled)pe(z,T);if(pe(a.errors,"root"),Se(a.errors)){x.state.next({errors:{}});try{await y(z,L)}catch(T){U=T}}else $&&await $({...a.errors},L),Le(),setTimeout(Le);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(a.errors)&&!U,submitCount:a.submitCount+1,errors:a.errors}),U)throw U},We=(y,$={})=>{H(n,y)&&(me($.defaultValue)?I(y,he(H(r,y))):(I(y,$.defaultValue),ce(r,y,he($.defaultValue))),$.keepTouched||pe(a.touchedFields,y),$.keepDirty||(pe(a.dirtyFields,y),a.isDirty=$.defaultValue?A(y,he(H(r,y))):A()),$.keepError||(pe(a.errors,y),m.isValid&&b()),x.state.next({...a}))},rt=(y,$={})=>{const L=y?he(y):r,U=he(L),z=Se(y),T=z?r:U;if($.keepDefaultValues||(r=L),!$.keepValues){if($.keepDirtyValues){const G=new Set([...o.mount,...Object.keys(gt(r,i))]);for(const re of Array.from(G)){const ie=H(a.dirtyFields,re),ke=H(i,re),it=H(T,re);ie&&!me(ke)?ce(T,re,ke):!ie&&!me(it)&&I(re,it)}}else{if(ma&&me(y))for(const G of o.mount){const re=H(n,G);if(re&&re._f){const ie=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(ss(ie)){const ke=ie.closest("form");if(ke){ke.reset();break}}}}if($.keepFieldsRef)for(const G of o.mount)I(G,H(T,G));else n={}}i=s.shouldUnregister?$.keepDefaultValues?he(r):{}:he(T),x.array.next({values:{...T}}),x.state.next({values:{...T}})}o={mount:$.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!$.keepIsValid||!!$.keepDirtyValues||!s.shouldUnregister&&!Se(T),l.watch=!!s.shouldUnregister,l.keepIsValid=!!$.keepIsValid,l.action=!1,$.keepErrors||(a.errors={}),x.state.next({submitCount:$.keepSubmitCount?a.submitCount:0,isDirty:z?!1:$.keepDirty?a.isDirty:!!($.keepDefaultValues&&!Ue(y,r)),isSubmitted:$.keepIsSubmitted?a.isSubmitted:!1,dirtyFields:z?{}:$.keepDirtyValues?$.keepDefaultValues&&i?gt(r,i):a.dirtyFields:$.keepDefaultValues&&y?gt(r,y):$.keepDirty?a.dirtyFields:{},touchedFields:$.keepTouched?a.touchedFields:{},errors:$.keepErrors?a.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?a.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},Je=(y,$)=>rt(Ae(y)?y(i):y,{...s.resetOptions,...$}),Pe=(y,$={})=>{const L=H(n,y),U=L&&L._f;if(U){const z=U.refs?U.refs[0]:U.ref;z.focus&&setTimeout(()=>{z.focus(),$.shouldSelect&&Ae(z.select)&&z.select()})}},le=y=>{a={...a,...y}},Ye={control:{register:Ee,unregister:ae,getFieldState:Z,handleSubmit:Ge,setError:ee,_subscribe:X,_runSchema:F,_updateIsValidating:w,_focusError:Le,_getWatch:R,_getDirty:A,_setValid:b,_setFieldArray:N,_setDisabledField:Ie,_setErrors:v,_getFieldArray:O,_reset:rt,_resetDefaultValues:()=>Ae(s.defaultValues)&&s.defaultValues().then(y=>{Je(y,s.resetOptions),x.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:mt,_subjects:x,_proxyFormState:m,get _fields(){return n},get _formValues(){return i},get _state(){return l},set _state(y){l=y},get _defaultValues(){return r},get _names(){return o},set _names(y){o=y},get _formState(){return a},get _options(){return s},set _options(y){s={...s,...y}}},subscribe:de,trigger:se,register:Ee,handleSubmit:Ge,watch:ne,setValue:I,getValues:Y,reset:Je,resetField:We,clearErrors:Q,unregister:ae,setError:ee,setFocus:Pe,getFieldState:Z};return{...Ye,formControl:Ye}}function eu(e={}){const s=p.useRef(void 0),a=p.useRef(void 0),[n,r]=p.useState({isDirty:!1,isValidating:!1,isLoading:Ae(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:Ae(e.defaultValues)?void 0:e.defaultValues});if(!s.current)if(e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!Ae(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Jd(e);s.current={...o,formState:n}}const i=s.current.control;return i._options=e,pa(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>r({...i._formState}),reRenderRoot:!0});return r(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[i]),p.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),p.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),p.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),p.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),p.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==n.isDirty&&i._subjects.state.next({isDirty:l})}},[i,n.isDirty]),p.useEffect(()=>{var l;e.values&&!Ue(e.values,a.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),a.current=e.values,r(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),p.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()}),s.current.formState=p.useMemo(()=>Br(n,i),[i,n]),s.current}function tu(e,s=3){return e%1===0?e.toString():e.toFixed(s).replace(/\.?0+$/,"")}function su(e,s="en-US",a="USD"){try{return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(n){return console.warn(`Invalid currency formatting: ${n}`),`${a} ${e.toFixed(2)}`}}function au(e="USD",s="en-US"){try{return new Intl.NumberFormat(s,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function nu(e){const s=e.replace(/[^\d.,-]/g,""),a=s.match(/,\d{1,2}$/);let n;a?n=s.replace(/\./g,"").replace(",","."):n=s.replace(/,/g,"");const r=parseFloat(n);return isNaN(r)?null:r}function ru(e,s,a=.001){const n=e-s,r=Math.abs(n)<=a;return{difference:n,isBalanced:r,isUnderAllocated:!r&&n>0,isOverAllocated:!r&&n<0}}function ya(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}ya();const iu={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:"$"},Ss=()=>({id:ya(),amount:0,glAccount:null,isTaxDeductible:!1}),Gr=({distribution:e,defaultDistribution:s,glAccounts:a=[],isLoadingGlAccounts:n=!1,onSearchGlAccounts:r,onDistributionChange:i,onAmountChange:l,onGlAccountChange:o,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:m=!0,isDisabled:h=!1,labels:x,classNames:g={},"data-testid":j,control:b,name:w,rules:N})=>{const D={...iu,...x},v=b!==void 0&&w!==void 0,S=eu({defaultValues:{_internal:s||Ss()}}),M=Id({control:v?b:S.control,name:v?w:"_internal",rules:v?N:void 0}),[k,F]=p.useState(s||Ss()),C=v?M.field.value??Ss():e??k,_=v&&!!M.fieldState?.error,E=v&&(M.fieldState?.isTouched??!1),A=_||E,R=A&&(!C.amount||C.amount<=0),O=A&&!C.glAccount,[V,q]=p.useState(C.glAccount?.name||""),I=p.useCallback(ee=>{const ne={...C,...ee};v&&M.field.onChange(ne),!v&&e===void 0&&F(ne),i?.(ne)},[C,e,i,v,M]),J=p.useCallback(ee=>{const ne=ee||0;I({amount:ne}),l?.(ne)},[I,l]),W=p.useCallback(ee=>{q(ee),r?.(ee)},[r]),se=p.useCallback(ee=>{if(ee===null){I({glAccount:null}),o?.(null);return}const X=a.find(de=>String(de.id)===String(ee))||null;I({glAccount:X}),o?.(X)},[a,I,o]),Y=p.useCallback(()=>{q(""),I({glAccount:null}),o?.(null)},[I,o]),Z=p.useCallback(ee=>{I({isTaxDeductible:ee}),d?.(ee)},[I,d]),Q=p.useCallback(()=>{u?.()},[u]);return t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":j||"revenue-distribution-card",className:c.cn(g.base),children:t.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",g.body),children:[t.jsx("div",{className:c.cn("shrink-0",g.amountContainer),children:t.jsx(c.NumberInput,{"data-testid":`${j||"revenue-distribution-card"}-amount-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[D.amount,t.jsx(c.Tooltip,{content:D.amountTooltip,children:t.jsx(P,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:C.amount||void 0,onValueChange:J,labelPlacement:"outside",placeholder:D.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:h,isInvalid:R,errorMessage:R?"Amount is required":void 0,minValue:0,step:.01,className:g.amountInput,startContent:t.jsx("div",{className:"pointer-events-none flex items-center",children:t.jsx("span",{className:"text-default-400 text-small",children:D.currencySymbol})})})}),t.jsx("div",{className:c.cn("grow",g.glAccountContainer),children:t.jsx(c.Autocomplete,{"data-testid":`${j||"revenue-distribution-card"}-gl-account-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[D.glAccount,t.jsx(c.Tooltip,{content:D.glAccountTooltip,children:t.jsx(P,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:n,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:a,menuTrigger:"input",inputValue:C.glAccount?.name??V,selectedKey:C.glAccount?.id??null,isDisabled:h,isInvalid:O,errorMessage:O?"GL Account is required":void 0,listboxProps:{emptyContent:n?D.searching:D.noGlAccountsFound},placeholder:D.glAccountPlaceholder,onInputChange:W,onSelectionChange:se,onClear:Y,className:g.glAccountInput,children:ee=>t.jsx(c.AutocompleteItem,{textValue:ee.name,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:ee.name}),ee.code&&t.jsx("span",{className:"text-xs text-default-400",children:ee.code})]})},ee.id)})}),t.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",g.taxDeductibleContainer),children:t.jsx(c.Checkbox,{radius:"full","data-testid":`${j||"revenue-distribution-card"}-tax-deductible`,isSelected:C.isTaxDeductible,onValueChange:Z,isDisabled:h||!m,className:g.taxDeductibleCheckbox,children:D.taxDeductible})}),t.jsx("div",{className:c.cn("shrink-0 pt-6",g.deleteContainer),children:t.jsx(B,{"data-testid":`${j||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:h||!f,onPress:Q,startContent:t.jsx(P,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",g.deleteButton),children:D.deleteButton})})]})})};Gr.displayName="RevenueDistributionCard";const Kr=({message:e="No distributions configured",icon:s="solar:document-text-outline",iconSize:a=48,showCard:n=!0,classNames:r={},renderEmpty:i})=>{if(i)return t.jsx(t.Fragment,{children:i()});const l=t.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",r.content),children:[t.jsx(P,{icon:s,width:a,className:c.cn("text-default-300 mb-4",r.icon)}),t.jsx("p",{className:c.cn("text-default-500 text-sm text-center",r.message),children:e})]});return n?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:l})};Kr.displayName="RevenueDistributionEmpty";const lu={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Qr=({error:e,labels:s,showCard:a=!0,color:n="danger",classNames:r={}})=>{const i={...lu,...s},l=t.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:n,title:i.title,description:e||i.description,className:r.alert});return a?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:l})};Qr.displayName="RevenueDistributionError";const Zr=({rows:e=1,showCard:s=!0,classNames:a={}})=>{const n=Array.from({length:e},(i,l)=>l),r=i=>t.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",a.row),children:[t.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),t.jsxs("div",{className:"grow flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),t.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[t.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),t.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),t.jsx("div",{className:"shrink-0 pb-2",children:t.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return s?t.jsx("div",{className:c.cn("flex flex-col gap-3",a.base),children:n.map(i=>t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:t.jsx(c.CardBody,{children:r(i)})},i))}):t.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",a.base),children:n.map(i=>r(i))})};Zr.displayName="RevenueDistributionSkeleton";function va({isOpen:e,labels:s,icon:a,isConfirming:n=!1,confirmColor:r="danger",iconTone:i="danger",portalContainer:l,shouldBlockScroll:o,classNames:d,onClose:u,onConfirm:f}){return t.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:l,shouldBlockScroll:o,classNames:{...d,base:c.cn("max-w-[440px] rounded-3xl",d?.base),closeButton:c.cn("right-5 top-5 text-zinc-500",d?.closeButton)},onOpenChange:m=>!m&&u(),children:t.jsxs(c.ModalContent,{children:[t.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[a&&t.jsx("span",{className:c.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:a}),t.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:s.title})]}),t.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:t.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:s.description})}),t.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[t.jsx(B,{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:s.cancel}),t.jsx(B,{type:"button",size:"md",color:r,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",r==="danger"?"bg-danger-600":"bg-brand"),isLoading:n,onPress:f,children:s.confirm})]})]})})}const ou=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function yn(e){return!e.fund&&Number(e.percentage||0)<=0}function cu({mode:e,assignments:s}){const a=s.filter(i=>i.fund),n=a.reduce((i,l)=>i+Number(l.percentage||0),0),r=s.some(i=>!i.fund||Number(i.percentage||0)<=0);return a.length>=1&&!r&&Math.round(n*100)/100===100}const du={title:"Payment assignment",saved:"Saved",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"},Xr={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"},St={...Xr,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},uu={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"},mu={wrapper:"!absolute !inset-0 !z-50 !h-auto !w-auto !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 !h-auto !w-auto rounded-2xl"};function fu(){return t.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[t.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const xu=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,hu=e=>e.fund!==null;function pu({assignments:e,funds:s,labels:a,classNames:n,isSaving:r=!1,hasSavedAssignments:i=!1,showSavedIndicator:l=!1,isCollapsed:o,isFundPickerOpen:d=!1,activeAssignmentId:u=null,modalPortalContainer:f,footer:m,onAssignmentsChange:h,onOpenFundPicker:x,onCloseFundPicker:g,onCollapseChange:j,onSave:b}){const[w,N]=p.useState(null),D=f??w??void 0,v={...du,...a},S=e.filter(X=>!yn(X)),k=S.filter(hu).length>0,F=p.useMemo(()=>e.filter(X=>!yn(X)).reduce((X,de)=>X+Number(de.percentage||0),0),[e]),C=Math.round(F*100)/100,_=S.some(X=>!X.fund||Number(X.percentage||0)<=0),E=k&&(C!==100||_),A=`${v.totalError} (${v.total} ${Number(F.toFixed(2))}%)`,R=cu({mode:"split",assignments:e}),O=k&&C>=100,[V,q]=p.useState(!1),[I,J]=p.useState(!1),W=t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(fu,{}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:v.title}),l?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:v.saved}):null]}),se=(X,de)=>{h(e.map(ae=>ae.id===X?{...ae,...de}:ae))},Y=()=>{O||h([...e,ou()])},Z=X=>{e.length<=1||h(e.filter(de=>de.id!==X))},Q=()=>{if(!r){if(!R){J(!0);return}if(!i){b();return}q(!0)}},ee=()=>{q(!1),b()},ne=X=>{const de=u??e.find(ae=>!ae.fund)?.id??e[0]?.id;de&&(h(e.map(ae=>ae.id===de?{...ae,fund:X}:ae)),g())};return t.jsxs("div",{ref:N,className:c.cn("vvt-pa relative min-w-0 w-full font-sans text-zinc-900 [container-type:inline-size]",d&&!f&&"min-h-[560px]",n?.root),children:[t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:o===void 0?["installment-fund-assignment"]:void 0,selectedKeys:o===void 0?void 0:new Set(o?[]:["installment-fund-assignment"]),className:c.cn("w-full gap-0 px-0",n?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",n?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:X=>j?.(!(X==="all"||Array.from(X).length>0)),children:t.jsx(c.AccordionItem,{"aria-label":v.title,title:W,children:t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",n?.content),children:[t.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!k&&t.jsx(c.Alert,{icon:t.jsx(P,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Xr,color:"default",variant:"flat",title:v.emptySplit}),k&&t.jsx(gu,{assignments:e,labels:v,total:F,hasTotalError:I&&!R||E,validationMessage:A,onSelectFund:X=>x(X),onRemoveFund:Z,onPercentageChange:(X,de)=>se(X,{percentage:xu(de)})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx(B,{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 [@container(max-width:479px)]:w-full",startContent:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:O,onPress:()=>k?Y():x(),children:v.assignSpecificFund}),t.jsx(B,{type:"button","data-testid":"installment-fund-assignment-save-button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-40 px-4 text-sm font-medium [@container(max-width:479px)]:w-full",startContent:r?void 0:t.jsx(P,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:r,isDisabled:!R||r,onPress:Q,children:v.saveAssignment})]})]}),m]})},"installment-fund-assignment")}),d&&t.jsx(bu,{funds:s,labels:v,selectedFundIds:e.map(X=>X.fund?.id).filter(Boolean),portalContainer:D,onSelect:ne,onClose:g}),t.jsx(va,{isOpen:V,labels:{title:v.modifyAssignedFundsTitle,description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:v.modifyAssignedFundsDescription}),t.jsx("p",{className:"mt-3",children:v.modifyAssignedFundsWarning})]}),cancel:v.modifyAssignedFundsCancel,confirm:v.modifyAssignedFundsConfirm},icon:t.jsx(P,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:D,shouldBlockScroll:!1,classNames:mu,onClose:()=>q(!1),onConfirm:ee})]})}function gu({assignments:e,labels:s,total:a,hasTotalError:n,validationMessage:r,onSelectFund:i,onRemoveFund:l,onPercentageChange:o}){return t.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>t.jsxs("div",{"data-testid":"installment-fund-assignment-row",className:"flex min-h-15 w-full flex-wrap items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[t.jsx("div",{className:c.cn("flex min-h-11 min-w-0 basis-full items-center gap-2","[@container(min-width:560px)]:basis-0 [@container(min-width:560px)]:flex-1 [@container(min-width:560px)]:gap-4"),children:d.fund?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"min-w-0 break-words rounded-2xl bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[d.fund.glCode," - ",d.fund.accountName]}),t.jsx(B,{type:"button",variant:"light",color:"primary",radius:"full",className:"flex-none px-2 text-sm font-normal",onPress:()=>i(d.id),children:"Replace"})]}):t.jsx(B,{type:"button",size:"lg",variant:"light",radius:"full",className:"max-w-full justify-start px-4 text-lg font-normal text-zinc-900",startContent:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:s.assignSpecificFund})}),t.jsx("label",{className:"flex min-w-0 flex-1 items-center [@container(min-width:560px)]:w-48 [@container(min-width:560px)]:flex-none",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>o(d.id,Number(f.target.value)),endContent:t.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:uu})}),e.length>1&&t.jsx(B,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:c.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(d.id),"aria-label":s.removeFund,children:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),t.jsx(c.Alert,{icon:t.jsx(P,{icon:n?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:n?"warning":"success",variant:"flat",classNames:{...St,base:c.cn(St.base,n?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(St.iconWrapper,n?"text-warning-700":"text-success-700"),alertIcon:c.cn(St.alertIcon,n?"text-warning-700":"text-success-700"),title:c.cn(St.title,n?"text-warning-700":"text-success-700")},title:n?r:`${s.total} ${Number(a.toFixed(2))}%`})]})}function bu({funds:e,labels:s,selectedFundIds:a,portalContainer:n,onSelect:r,onClose:i}){const[l,o]=p.useState(""),d=e.filter(u=>{if(a.includes(u.id))return!1;const f=l.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return t.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:n,classNames:{wrapper:"!absolute !inset-0 !z-50 !h-auto !w-auto !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 !h-auto !w-auto rounded-2xl",base:"max-h-[calc(100%-2rem)] w-full max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:u=>!u&&i(),children:t.jsxs(c.ModalContent,{className:"max-h-full",children:[t.jsx(c.ModalHeader,{className:"px-6 pr-12 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:s.modalTitle}),t.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[t.jsx(c.Input,{variant:"bordered","aria-label":s.searchPlaceholder,value:l,placeholder:s.searchPlaceholder,onChange:u=>o(u.target.value),startContent:t.jsx(P,{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"}}),t.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto [container-type:inline-size]",children:[t.jsxs("div",{className:"hidden 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 [@container(min-width:520px)]:grid",children:[t.jsx("span",{children:s.glCode}),t.jsx("span",{children:s.accountName}),t.jsx("span",{children:s.actions})]}),d.length===0&&t.jsx("div",{className:"p-4 text-sm text-zinc-500",children:s.noFunds}),d.map(u=>t.jsxs("div",{"data-testid":"installment-fund-picker-row",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 border-b border-zinc-100 px-3 py-2.5 text-sm leading-5 text-zinc-900 last:border-b-0 [@container(min-width:520px)]:grid-cols-[1fr_1.3fr_0.6fr] [@container(min-width:520px)]:gap-5 [@container(min-width:520px)]:border-b-0",children:[t.jsx("span",{className:"col-start-1 row-start-1 font-medium [@container(min-width:520px)]:font-normal",children:u.glCode}),t.jsx("span",{className:"col-start-1 row-start-2 min-w-0 break-words text-zinc-600 [@container(min-width:520px)]:col-start-2 [@container(min-width:520px)]:row-start-1 [@container(min-width:520px)]:text-zinc-900",children:u.accountName}),t.jsx(B,{type:"button",size:"sm",variant:"bordered",radius:"full",className:"col-start-2 row-span-2 row-start-1 h-9 min-w-20 border-zinc-200 bg-white text-sm font-medium text-zinc-900 [@container(min-width:520px)]:col-start-3 [@container(min-width:520px)]:row-span-1 [@container(min-width:520px)]:min-w-24",onPress:()=>r(u),children:s.select})]},u.id))]})]})]})})}function yu(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const vu={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function ju({totalAmount:e,remainingBalance:s,amountReceived:a,currency:n="USD",locale:r="en-US",labels:i,className:l}){const o={...vu,...i},d=new Intl.NumberFormat(r,{style:"currency",currency:n});return t.jsx("div",{className:c.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",l),children:t.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[t.jsx($s,{label:o.totalAmount,value:d.format(e)}),t.jsx($s,{label:o.remainingBalance,value:d.format(s)}),t.jsx($s,{label:o.amountReceived,value:d.format(a)})]})})}function $s({label:e,value:s}){return t.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[t.jsx("span",{className:"font-medium text-zinc-700",children:e}),t.jsx("span",{className:"font-normal text-zinc-950",children:s})]})}const wu={monthly:1,quarterly:3,annual:12},Jr=e=>{const[s,a,n]=e.split("-").map(Number);return{year:s,month:a,day:n}},Nu=(e,s)=>new Date(e,s+1,0).getDate(),Cu=e=>{const s=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${s}-${a}-${n}`},ku=(e,s)=>{const{year:a,month:n,day:r}=Jr(e),i=n-1+s,l=a+Math.floor(i/12),o=(i%12+12)%12,d=Math.min(r,Nu(l,o));return new Date(l,o,d)},Su=(e,s)=>{const{year:a,month:n,day:r}=Jr(e),i=new Date(a,n-1,r);return i.setDate(i.getDate()+s),i};function ei(e,s){const a=Math.max(1,Math.floor(s.numberOfInstallments||1)),n=Math.round(e*100),r=Math.floor(n/a),i=n-r*a,l=wu[s.frequency];return Array.from({length:a},(o,d)=>{const u=s.frequency==="weekly"?Su(s.firstInstallmentDate,d*7):ku(s.firstInstallmentDate,d*(l??1));return{id:crypto.randomUUID(),dueDate:Cu(u),amount:(r+(d===0?i:0))/100}})}function $u(e){return new Set(e.map((s,a)=>{const n=e[a+1]?.dueDate;return s.dueDate&&n&&s.dueDate>n?s.id:null}).filter(s=>!!s))}function Au(e){return{missingDateRows:new Set(e.filter(s=>!s.dueDate).map(s=>s.id)),invalidDateRows:$u(e),invalidAmountRows:new Set(e.filter(s=>Number(s.amount||0)<=0).map(s=>s.id))}}function Du(e){return e.missingDateRows.size>0||e.invalidDateRows.size>0||e.invalidAmountRows.size>0}function Eu(e,s){const a=e[0];return!a||!s||a.dueDate===s?e:[{...a,dueDate:s},...e.slice(1)]}const Fu=new Set(["paid","partially_refunded","refunded"]);function dt(e){return e!==void 0&&Fu.has(e)}const Lu={title:"Payments",saved:"Saved",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",cancelEdit:"Cancel",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",dayOfMonth:"Day of month",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",weekly:"Weekly",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal the total 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.",dueDateRequiredError:"Payment date is required.",amountGreaterThanZeroError:"Payment amount must be greater than 0."},Mu=["weekly","monthly","quarterly","annual"],_u=Array.from({length:31},(e,s)=>s+1),Ru=["numberOfInstallments","frequency","firstInstallmentDate"],vn=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),ns=e=>Math.round(e*100)/100,Tu=(e,s)=>{const a=new Date(`${e}T00:00:00`);return Number.isNaN(a.getTime())?e:new Intl.DateTimeFormat(s,{month:"short",day:"numeric",year:"numeric"}).format(a)},ms=e=>{if(!e)return null;try{return Ac(e)}catch{return null}},Iu=e=>ms(e)?.day??1,Pu=(e,s)=>new Date(e,s,0).getDate(),Ou=(e,s)=>{const a=ms(e);if(!a)return e;const n=Math.min(s,Pu(a.year,a.month));return a.set({day:n}).toString()},jn=e=>{const s=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${s}`};function zu({mode:e,donationAmount:s,currency:a="USD",locale:n="en-US",installments:r,automaticSettings:i,defaultTab:l="automatic",showTitle:o=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:m=Ru,startDate:h,firstInstallmentDateOverride:x,labels:g,classNames:j,isSaving:b=!1,showSavedIndicator:w=!1,isModeSwitchDisabled:N=!1,onModeChange:D,onAutomaticSettingsChange:v,onInstallmentsChange:S,onSave:M,onCancel:k}){const[F,C]=p.useState(l),_={...Lu,...g},E=e??F,A=p.useMemo(()=>new Intl.NumberFormat(n,{style:"currency",currency:a}),[a,n]),R=p.useMemo(()=>({...i,firstInstallmentDate:m.includes("firstInstallmentDate")?i.firstInstallmentDate:m.includes("dayOfMonth")?i.firstInstallmentDate||h||"":h||i.firstInstallmentDate}),[i,m,h]),O=E==="automatic"?Eu(ei(s,R),m.includes("firstInstallmentDate")?void 0:x):r,V=p.useMemo(()=>ns(O.reduce((ae,Ie)=>ae+Number(Ie.amount||0),0)),[O]),q=Math.abs(V-s)>.009,I=ns(s-V)<=0,J=p.useMemo(()=>Au(r),[r]),W=E==="manual"&&Du(J),se=q||W,Y=o?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:_.title}),w?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:_.saved}):null]}):void 0,Z=ae=>{ae!==E&&(e||C(ae),D?.(ae),ae==="manual"&&r.length===0&&S([vn()]))},Q=(ae,Ie)=>{const Ee=r.find(Le=>Le.id===ae);dt(Ee?.status)||S(r.map(Le=>Le.id===ae?{...Le,...Ie}:Le))},ee=()=>{S([...r,vn()])},ne=ae=>{const Ie=r.find(Ee=>Ee.id===ae);dt(Ie?.status)||S(r.filter(Ee=>Ee.id!==ae))},X=()=>{b||se||M?.()},de=t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.content),children:[f||u||k?t.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?t.jsx(Bu,{mode:E,labels:_,onModeChange:Z,isDisabled:N,className:j?.tabs}):null,t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[k?t.jsx(B,{type:"button","data-testid":"installment-schedule-cancel-button",size:"md",variant:"bordered",radius:"full",className:"min-w-28",isDisabled:b,onPress:k,children:_.cancelEdit}):null,u?t.jsx(B,{type:"button","data-testid":"installment-schedule-save-button",size:"md",color:"primary",radius:"full",className:"min-w-36",startContent:b?void 0:t.jsx(P,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:b,isDisabled:b||se,onPress:X,children:_.saveInstallments}):null]})]}):null,t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.preview),children:[E==="automatic"&&t.jsx(Vu,{settings:R,inputs:m,labels:_,className:j?.controls,onSettingsChange:v}),O.length===0&&t.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:E==="automatic"?_.emptyAutomatic:_.emptyManual}),O.length>0&&t.jsx(Uu,{mode:E,installments:O,rowErrors:J,labels:_,formatter:A,locale:n,onUpdateInstallment:Q,onRemoveInstallment:ne}),E==="manual"&&t.jsx("div",{className:"flex flex-wrap gap-3",children:t.jsx(B,{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:t.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:I,onPress:ee,children:_.addInstallment})}),t.jsx(Yu,{total:V,donationAmount:s,hasTotalMismatch:q,mode:E,installments:O,formatter:A,labels:_,className:j?.summary})]})]});return t.jsx("div",{className:c.cn("vvt-ps relative font-sans text-zinc-900",j?.root),children:d?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",j?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",j?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":_.title,title:Y,children:de},"installment-schedule")}):de})}function Bu({mode:e,labels:s,className:a,isDisabled:n=!1,onModeChange:r}){return t.jsxs(c.Tabs,{"aria-label":s.title,selectedKey:e,isDisabled:n,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",a),onSelectionChange:i=>r(i),children:[t.jsx(c.Tab,{title:s.automaticMode},"automatic"),t.jsx(c.Tab,{title:s.manualMode},"manual")]})}function Vu({settings:e,inputs:s,labels:a,className:n,onSettingsChange:r}){const i=l=>{if(l==="numberOfInstallments")return t.jsx("div",{className:"min-w-0",children:t.jsx(c.Input,{variant:"bordered",label:a.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:o=>o.currentTarget.blur(),onChange:o=>{const d=o.target.value;r({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},l);if(l==="frequency")return t.jsx("div",{className:"min-w-0",children:t.jsx(He,{variant:"bordered",label:a.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:o=>{const d=Array.from(o)[0];typeof d=="string"&&r({...e,frequency:d})},children:Mu.map(o=>t.jsx(c.SelectItem,{textValue:a[o],children:a[o]},o))})},l);if(l==="dayOfMonth"){const o=String(Iu(e.firstInstallmentDate));return t.jsx("div",{className:"min-w-0",children:t.jsx(He,{variant:"bordered",label:a.dayOfMonth,labelPlacement:"outside",selectedKeys:[o],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&r({...e,firstInstallmentDate:Ou(e.firstInstallmentDate,u)})},children:_u.map(d=>t.jsx(c.SelectItem,{textValue:jn(d),children:jn(d)},String(d)))})},l)}return t.jsx("div",{className:"min-w-0",children:t.jsx(ua,{variant:"bordered",label:a.firstInstallmentDate,labelPlacement:"outside",value:ms(e.firstInstallmentDate),onChange:o=>r({...e,firstInstallmentDate:o?o.toString():""}),startContent:t.jsx(P,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},l)};return s.length===0?null:t.jsx("div",{className:c.cn("grid gap-4",n),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:s.map(i)})}function Uu({mode:e,installments:s,rowErrors:a,labels:n,formatter:r,locale:i,onUpdateInstallment:l,onRemoveInstallment:o}){return e==="automatic"?t.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:t.jsx("div",{className:c.cn("flex flex-col gap-3",s.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:s.map((d,u)=>t.jsxs("div",{className:c.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",u===0&&"border border-primary/25 bg-primary/5 text-primary"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["#",u+1]}),t.jsx("span",{children:"▪"}),t.jsx("span",{children:Tu(d.dueDate,i)}),u===0&&s.length>1&&t.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),t.jsx("span",{className:"text-zinc-950",children:r.format(d.amount)})]},d.id))})}):t.jsx("div",{className:"flex flex-col gap-2",children:s.map((d,u)=>{const f=a.missingDateRows.has(d.id),m=a.invalidDateRows.has(d.id),h=a.invalidAmountRows.has(d.id);return t.jsx("div",{className:"flex w-full flex-col gap-1",children:t.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[t.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:u+1}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(ua,{variant:"bordered","aria-label":`${n.dueDate} ${u+1}`,isDisabled:dt(d.status),isInvalid:f||m,errorMessage:f?n.dueDateRequiredError:m?n.dateOrderError:void 0,value:ms(d.dueDate),onChange:x=>l(d.id,{dueDate:x?x.toString():""})})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(qu,{amount:d.amount,ariaLabel:`${n.amount} ${u+1}`,isDisabled:dt(d.status),isInvalid:h,errorMessage:n.amountGreaterThanZeroError,onAmountChange:x=>l(d.id,{amount:x})})}),t.jsx(Wu,{isDisabled:s.length<=1,isPaid:dt(d.status),label:n.deleteInstallment,onRemove:()=>o(d.id)})]})},d.id)})})}const Hu=/^\d*(?:[.,]\d{0,2})?$/;function qu({amount:e,ariaLabel:s,isDisabled:a,isInvalid:n,errorMessage:r,onAmountChange:i}){const[l,o]=p.useState(null);return t.jsx(c.Input,{variant:"bordered","aria-label":s,type:"text",inputMode:"decimal",autoComplete:"off",isDisabled:a,isInvalid:n,errorMessage:n?r:void 0,value:l??(e?String(e):""),onChange:d=>{const u=d.target.value.trim();if(!Hu.test(u))return;o(u);const f=Number(u.replace(",","."));i(ns(Number.isFinite(f)?f:0))},onBlur:()=>o(null),startContent:t.jsx("span",{className:"text-zinc-900",children:"$"})})}function Wu({isDisabled:e,isPaid:s,label:a,onRemove:n}){const r=t.jsx(B,{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||s,onPress:n,"aria-label":a,children:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return s?t.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:t.jsx("span",{className:"inline-flex",children:r})}):r}function Yu({total:e,donationAmount:s,hasTotalMismatch:a,mode:n,installments:r,formatter:i,labels:l,className:o}){const d=r.length,u=r[0]?.amount??0,f=r[1]?.amount??u,m=d>1&&Math.round(u*100)!==Math.round(f*100),h=ns(s-e),x=Math.max(h,0),g=Math.max(-h,0),j=a?t.jsxs("span",{children:[l.totalError,". Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(s)}),"."]}):n==="automatic"?m?t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records:"," ",t.jsx("strong",{children:i.format(u)})," first charge and"," ",t.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records of"," ",t.jsx("strong",{children:i.format(u)})," each."]}):t.jsxs("span",{children:["Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(s)}),"."]}),b=n==="automatic"?`Total: ${i.format(e)}`:g>0?`Exceeds by: ${i.format(g)}`:`${l.remaining}: ${i.format(x)}`;return t.jsx(c.Alert,{isClosable:!1,color:a?"danger":"default",variant:"flat",radius:"full",className:o,endContent:t.jsx("span",{className:"whitespace-nowrap",children:b}),title:j})}function Gu(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[t.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),t.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),t.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,s)=>t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},s))})]})}const wn={paid:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",schedule:"bg-blue-50 text-blue-700",payment_due:"bg-amber-50 text-amber-700",overdue:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-700",refunded:"bg-zinc-100 text-zinc-600",partially_refunded:"bg-lime-50 text-lime-800",disputed:"bg-purple-50 text-purple-700",canceled:"bg-zinc-100 text-zinc-600",processing:"bg-sky-50 text-sky-700",pending_confirmation:"bg-indigo-50 text-indigo-700"},ti={paid:"Paid",scheduled:"Scheduled",schedule:"Scheduled",payment_due:"Payment Due",overdue:"Overdue",failed:"Failed",refunded:"Refunded",partially_refunded:"Partially refunded",disputed:"Disputed",canceled:"Canceled",processing:"Processing",pending_confirmation:"Pending Confirmation"},Ku={title:"Payments",saved:"Saved",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by name, ID, or date...",editInstallments:"Edit Payment",installmentId:"Payment",amount:"Amount",scheduledDate:"Scheduled Date",paidOn:"Paid on",partiallyRefunded:ti.partially_refunded,refundedAmount:"Refunded",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:t.jsxs(t.Fragment,{children:["Are you sure you want to delete this payment? ",t.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Qu={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Zu=[];function Xu({installments:e,currency:s,locale:a="en-US",showTitle:n=!0,showCard:r=!0,showEditPayment:i=!0,showDelete:l=!0,payNowHiddenStatuses:o=Zu,showSavedIndicator:d=!1,labels:u,isSaving:f=!1,onEditInstallments:m,onPayInstallment:h,onDeleteInstallment:x}){const[g,j]=p.useState(null),b={...Ku,...u},[w,N]=p.useState(""),D=new Intl.NumberFormat(a,{style:"currency",currency:s}),v=e.some(C=>si(C)!==null),S=e.some(C=>C.status==="partially_refunded"),M=n?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:b.title}),d?t.jsx(c.Chip,{size:"sm",radius:"full",color:"success",variant:"flat",children:b.saved}):null]}):void 0,k=p.useMemo(()=>{const C=w.trim().toLowerCase();if(!C)return e;const _=new Intl.NumberFormat(a,{style:"currency",currency:s});return e.filter(E=>{const A=E.status??"scheduled";return[As(E),E.id,E.amount,E.dueDate,Qt(E.dueDate,a),Ds(E,b.paidOn,a),Es(E,b.refundedAmount,_),A,Fs(A,b.partiallyRefunded)].join(" ").toLowerCase().includes(C)})},[a,s,e,w,b.paidOn,b.refundedAmount,b.partiallyRefunded]),F=t.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[t.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[t.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:b.searchLabel}),t.jsx(c.Input,{variant:"bordered",size:"md",value:w,placeholder:b.searchPlaceholder,onChange:C=>N(C.target.value),startContent:t.jsx(P,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?t.jsx(B,{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:t.jsx(P,{icon:"solar:pen-outline",className:"size-4"}),isLoading:f,onPress:m,children:b.editInstallments}):null]}),t.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",k.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[k.map((C,_)=>{const E=C.status??"scheduled",A=As(C),R=Ds(C,b.paidOn,a),O=Es(C,b.refundedAmount,D);return t.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:t.jsxs(c.CardBody,{className:"gap-3 p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-xs text-default-500",children:["#",_+1]}),t.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:A||`PMT-${_+1}`})]}),t.jsx(Nn,{status:E,label:Fs(E,b.partiallyRefunded)})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-default-500",children:b.amount}),t.jsx("p",{className:"font-medium text-foreground",children:D.format(C.amount)}),O?t.jsx("p",{className:"text-xs text-default-500",children:O}):null]}),t.jsxs("div",{className:"text-right",children:[t.jsx("p",{className:"text-xs text-default-500",children:b.scheduledDate}),t.jsx("p",{className:"font-medium text-foreground",children:Qt(C.dueDate,a)}),R?t.jsx("p",{className:"text-xs text-default-500",children:R}):null]})]}),t.jsx(Cn,{status:E,installment:C,labels:b,portalContainer:g??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:h,onDeleteInstallment:x})]})},C.id)}),k.length===0&&t.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:b.noInstallmentsFound})]})}),t.jsx("div",{className:c.cn("w-full overflow-x-hidden [@container(max-width:767px)]:hidden",k.length>5&&"max-h-[344px] overflow-y-auto pr-1"),children:t.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-12"}),t.jsx("col",{}),t.jsx("col",{className:v?"w-32":"w-24"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:S?"w-44":"w-36"}),t.jsx("col",{className:"w-44"})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[t.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.installmentId}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.amount}),t.jsx("th",{className:"px-2 py-3 font-medium",children:b.scheduledDate}),t.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:b.status}),t.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:b.actions})]})}),t.jsxs("tbody",{children:[k.map((C,_)=>{const E=C.status??"scheduled",A=As(C),R=Ds(C,b.paidOn,a),O=Es(C,b.refundedAmount,D);return t.jsxs("tr",{className:"text-zinc-500",children:[t.jsx("td",{className:"px-2 py-3",children:_+1}),t.jsx("td",{className:"overflow-hidden px-2 py-3",children:t.jsx("span",{className:"block w-full truncate",children:A||`PMT-${_+1}`})}),t.jsxs("td",{className:"px-2 py-3",children:[D.format(C.amount),O?t.jsx("span",{className:"block text-xs",children:O}):null]}),t.jsxs("td",{className:"px-2 py-3",children:[Qt(C.dueDate,a),R?t.jsx("span",{className:"block text-xs",children:R}):null]}),t.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:t.jsx(Nn,{status:E,label:Fs(E,b.partiallyRefunded)})}),t.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:t.jsx(Cn,{status:E,installment:C,labels:b,portalContainer:g??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:h,onDeleteInstallment:x})})]},C.id)}),k.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:b.noInstallmentsFound})})]})]})})]});return t.jsx("div",{ref:j,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:r?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"min-w-0 w-full gap-0 px-0",itemClasses:{base:"min-w-0 w-full overflow-x-hidden rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"w-full",content:"min-w-0 w-full overflow-x-hidden px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":b.title,title:M,children:F},"installment-table")}):F})}function As(e){return e.name?.trim()||e.id}function Ds(e,s,a){return!dt(e.status)||!e.fulfilledAt?null:`${s} ${Qt(e.fulfilledAt,a)}`}function si(e){const{refundedAmount:s}=e;return e.status!=="partially_refunded"||typeof s!="number"||!Number.isFinite(s)||s<=0?null:s}function Es(e,s,a){const n=si(e);return n===null?null:`${s} ${a.format(n)}`}function Fs(e,s){return e==="partially_refunded"?s:ti[e]??e}function Nn({status:e,label:s}){return t.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",wn[e]??wn.scheduled),startContent:t.jsx(em,{status:e}),children:s})}function Cn({status:e,installment:s,labels:a,portalContainer:n,showDelete:r,payNowHiddenStatuses:i,onPayInstallment:l,onDeleteInstallment:o}){const d=!i.includes(e),u=dt(e);return t.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[d?t.jsx(B,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:u,startContent:t.jsx(P,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>l?.(s),children:a.payNow}):null,t.jsx(Ju,{isFulfilled:u,showDelete:r,labels:a,portalContainer:n,onDelete:()=>o(s.id)})]})}function Ju({isFulfilled:e,showDelete:s,labels:a,portalContainer:n,onDelete:r}){const[i,l]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[t.jsx(c.DropdownTrigger,{children:t.jsx(B,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:t.jsx(P,{icon:"solar:menu-dots-bold",className:"size-4"})})}),t.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&s&&!e&&l(!0)},children:[t.jsx(c.DropdownSection,{title:"Actions",showDivider:s,children:t.jsx(c.DropdownItem,{textValue:a.sendLink,description:a.sendLinkDescription,startContent:t.jsx(P,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:a.sendLink},"send-link")}),s?t.jsx(c.DropdownSection,{title:a.dangerZone,children:t.jsx(c.DropdownItem,{textValue:a.deleteInstallment,className:"text-danger-600",color:"danger",description:a.deleteInstallmentDescription,startContent:t.jsx(P,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:a.deleteInstallment},"delete")}):null]})]}),s?t.jsx(va,{isOpen:i,labels:{title:a.deleteInstallmentConfirmationTitle,description:a.deleteInstallmentConfirmationDescription,cancel:a.deleteInstallmentConfirmationCancel,confirm:a.deleteInstallmentConfirmationConfirm},icon:t.jsx(P,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:n,shouldBlockScroll:!1,classNames:Qu,onClose:()=>l(!1),onConfirm:()=>{l(!1),r()}}):null]})}function em({status:e}){return e==="paid"?t.jsx(P,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?t.jsx(P,{icon:"solar:close-circle-bold",className:"size-3"}):e==="partially_refunded"?t.jsx(P,{icon:"solar:undo-left-round-bold",className:"size-3"}):e==="processing"?t.jsx(P,{icon:"solar:refresh-circle-bold",className:"size-3"}):e==="pending_confirmation"?t.jsx(P,{icon:"solar:clock-circle-bold",className:"size-3"}):t.jsx(P,{icon:"solar:calendar-outline",className:"size-3"})}const tm=/^\d{4}-\d{2}-\d{2}$/;function Qt(e,s){const a=tm.test(e)?new Date(`${e}T00:00:00`):new Date(e);return Number.isNaN(a.getTime())?e:new Intl.DateTimeFormat(s,{month:"short",day:"numeric",year:"numeric"}).format(a)}const sm={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},am=({cards:e,locale:s,currency:a,listHeightClassName:n="",labels:r,showRenewal:i=!0,defaultRenewalValue:l=!1,initialSelectedMembershipId:o=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:m=""})=>{const h=Array.isArray(e)?e:[],[x,g]=p.useState(o),[j,b]=p.useState(l),w={...sm,...r};p.useEffect(()=>{g(o)},[o]);const N=v=>{if(v===x){d&&f?.(v);return}g(v),f?.(v)},D=v=>{b(v),u?.(v)};return t.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",m),"data-testid":"membership-select-cards",children:[t.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:x??""}),t.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&t.jsx(li,{title:w.renewalTitle,description:w.renewalDescription,value:j,onValueChange:D}),t.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",n===""?"flex-1":c.cn("shrink-0",n)),"data-testid":"membership-select-cards-list",children:h.map(v=>t.jsx(ai,{itemKey:v.id,name:v.name,type:v.type,price:v.price,locale:s,currency:a,isSelected:x===v.id,onSelect:N},v.id))})]})},ai=({itemKey:e,name:s,type:a,price:n,locale:r="en-US",currency:i="USD",showPrice:l=!0,isSelected:o=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:m,statusLabel:h,statusTone:x="default",className:g=""})=>{const j=new Intl.NumberFormat(r,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(n),b=!!d&&!f,w=m||h,N=()=>{b&&d?.(e)};return t.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:N,className:c.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",g),"data-testid":"item-card","data-selected":o,isDisabled:f,children:t.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[t.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[t.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:s}),a&&t.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:t.jsx("p",{className:"text-center",children:a})}),w&&t.jsx(c.Chip,{"data-testid":"item-card-status",color:x,size:"sm",variant:"flat",className:"px-2",children:w})]}),l&&t.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:j})]})})},kn="w-full bg-gray-100",Sn={variant:"light",color:"default"},ni=({id:e,title:s,media:a,imageUrl:n,imageAlt:r,imageClassName:i="",imageAspect:l="aspect-[4/3]",meta:o=[],price:d,action:u,footer:f,onPress:m,isPressable:h=!1,isDisabled:x=!1,compact:g=!1,className:j="",bodyClassName:b="",footerClassName:w="",dataTestId:N})=>{const D=!!(d&&d.value),v=!!u?.label,S=h&&!!m&&!v,M=!S,k=v?{variant:u?.variant??Sn.variant,color:u?.color??Sn.color,size:u?.size??"sm",isDisabled:x||u?.isDisabled,startContent:u?.icon?t.jsx(P,{icon:u.icon,width:16}):void 0}:null,F=a??(n?t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,kn,i),children:t.jsx(c.Image,{removeWrapper:!0,src:n,alt:r||s,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,kn,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:t.jsx(P,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return t.jsxs(c.Card,{"data-testid":N||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",j),isPressable:S,onPress:m,isDisabled:x,shadow:"sm",radius:"lg",children:[t.jsx("div",{children:F}),t.jsxs(c.CardBody,{className:c.cn("gap-3",g?"p-3":"p-4",b),children:[t.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",g?"text-sm":""),children:s}),o.length>0?t.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((C,_)=>t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(P,{icon:C.icon,className:"size-4 text-gray-400",width:16}),t.jsx("span",{children:C.label})]},`${C.label}-${_}`))}):null,(D||v)&&t.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",g?"pt-0.5":"",w),children:[D?t.jsxs("span",{className:c.cn("mr-auto text-gray-500",g?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&t.jsxs("span",{children:[d.label," "]}),t.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):t.jsx("span",{className:"ml-auto","aria-hidden":!0}),v&&M?t.jsx(B,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:k?.variant,color:k?.color,size:k?.size,startContent:k?.startContent,isDisabled:k?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?t.jsx("div",{className:"pt-1",children:f}):null]})]})};ni.displayName="CatalogItemCard";const nm={open:"Open","selling-fast":"Selling fast","sold-out":"Sold out"};function ri({title:e,subtitle:s,price:a,imageUrl:n,status:r,isDisabled:i=!1,onPress:l,className:o}){return t.jsx(c.Card,{isPressable:!!l,isDisabled:i,onPress:l,shadow:"none",radius:"lg",className:c.cn("w-full border border-pos-hair",o),children:t.jsxs(c.CardBody,{className:"flex-row items-center gap-5 p-4",children:[t.jsx("div",{className:"grid size-[4.875rem] shrink-0 place-items-center overflow-hidden rounded-xl bg-default-100 text-default-500",children:n?t.jsx(c.Image,{removeWrapper:!0,src:n,alt:"",className:"size-full object-cover"}):t.jsx(P,{icon:"solar:ticket-outline",width:28})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h3",{className:"truncate text-lg font-semibold text-foreground",children:e}),t.jsx("p",{className:"mt-1 text-base text-default-500",children:s})]}),r?t.jsx("span",{"data-status":r,className:"rounded-full bg-default-100 px-3 py-1 text-sm font-medium text-default-600",children:nm[r]}):null,a?t.jsxs("strong",{className:"ml-5 whitespace-nowrap text-xl",children:["from ",a]}):null]})})}ri.displayName="ProgramListItem";const rm={card:"gap-3 rounded-xl border border-dashed px-6 py-12",panel:"px-6 py-[72px]"},im={card:"size-12 rounded-2xl",panel:"size-[76px] rounded-[20px] border mb-[18px]"},lm={card:"text-base font-medium text-default-900",panel:"text-[17px] font-semibold text-acct-ink"},om={card:"max-w-sm text-sm text-default-600",panel:"max-w-[380px] text-sm text-acct-sub mt-1.5"},cm={card:"mt-1",panel:"mt-[22px]"},dm="bg-acct-page border-acct-border text-acct-muted",um={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},mm={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"},xm={empty:"status",error:"alert",success:"status",loading:"status"},hm={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function pm(e,s,a,n){if(s===!1)return null;if(e==="loading"&&s===void 0)return t.jsx(c.Spinner,{size:"lg",color:"primary",className:n.spinner});if(p.isValidElement(s))return t.jsx(t.Fragment,{children:s});const r=typeof s=="string"?s:um[e];return r?t.jsx(P,{icon:r,width:a,height:a,"aria-hidden":"true",className:n.icon}):null}function vt({variant:e="empty",surface:s="card",title:a,titleAs:n="p",description:r,icon:i,actions:l,role:o=xm[e],ariaLive:d=hm[e],iconSize:u=24,className:f,classNames:m={},"data-testid":h="feedback-state"}){const x=pm(e,i,u,m);return t.jsxs("div",{role:o,"aria-live":d,"data-variant":e,"data-testid":h,"data-surface":s,className:c.cn("flex flex-col items-center justify-center text-center",rm[s],s==="card"?mm[e]:"bg-transparent",f,m.base),children:[x?t.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:c.cn("inline-flex items-center justify-center",im[s],e==="success"&&s==="card"&&"rounded-full",s==="panel"?dm:fm[e],m.iconWrapper),children:x}):null,t.jsxs("div",{className:c.cn("flex flex-col items-center",s==="card"&&"gap-1"),children:[t.jsx(n,{"data-testid":`${h}-title`,className:c.cn(lm[s],m.title),children:a}),r?t.jsx("p",{"data-testid":`${h}-description`,className:c.cn(om[s],m.description),children:r}):null]}),l?t.jsx("div",{"data-testid":`${h}-actions`,className:c.cn("flex flex-wrap items-center justify-center gap-2",cm[s],m.actions),children:l}):null]})}function ja(e){return t.jsx(vt,{...e,variant:"empty"})}function wa(e){return t.jsx(vt,{...e,variant:"error"})}function Na(e){return t.jsx(vt,{...e,variant:"loading"})}function ii(e){return t.jsx(vt,{...e,variant:"success"})}vt.displayName="FeedbackState";ja.displayName="EmptyState";wa.displayName="ErrorState";Na.displayName="LoadingState";ii.displayName="SuccessState";const li=({title:e,value:s,description:a,onValueChange:n,className:r=""})=>{const i=p.useId();return t.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||a?"justify-between gap-6":"justify-start",r),"data-testid":"toggle",children:[t.jsxs("div",{className:"flex flex-col items-start",children:[e&&t.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),a&&t.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:a})]}),t.jsx(c.Switch,{id:i,isSelected:s,onValueChange:n,"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"},bm=(e,s)=>new Intl.NumberFormat(e,{style:"currency",currency:s}),oi=e=>Object.values(e).reduce((s,a)=>s+Object.values(a).reduce((n,r)=>n+Object.values(r).reduce((i,l)=>i+l.selectedQuantity,0),0),0),ym=e=>e.reduce((s,a)=>s+a.dates.reduce((n,r)=>n+r.tickets.reduce((i,l)=>i+l.max,0),0),0),Ca=e=>e.flatMap(s=>s.dates.flatMap(a=>a.tickets.map(n=>({exhibition:s,dateGroup:a,ticket:n})))),$n=(e,s,a)=>{const n={};let r=a?s??ym(e):0;for(const{exhibition:i,dateGroup:l,ticket:o}of Ca(e)){n[i.id]??={},n[i.id][l.id]??={};const d=a?Math.min(o.max,r):0;n[i.id][l.id][o.id]={id:o.id,selectedQuantity:d,originalPrice:o.originalPrice,discountedPrice:o.price},r-=d}return n},An=(e,s,a)=>`${e}::${s}::${a}`,vm=(e,s,a)=>{const n=oi(s);for(const{exhibition:r,dateGroup:i,ticket:l}of Ca(e)){const o=s[r.id]?.[i.id]?.[l.id]?.selectedQuantity??0,d=a===void 0?l.max:Math.min(l.max,a-(n-o));if(d>0&&o<d)return!1}return!0},jm=({initialQuantity:e=1,minQuantity:s=1,maxQuantity:a=10,onChange:n,disabled:r=!1})=>{const i=Math.max(s,Math.min(a,e)),[l,o]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?l:String(i),m=()=>{r||i>=a||n?.(i+1)},h=()=>{r||i<=s||n?.(i-1)},x=v=>{if(r)return;o(v.target.value);const S=parseInt(v.target.value,10);isNaN(S)||n?.(Math.max(s,Math.min(a,S)))},g=v=>{const S=parseInt(v.target.value,10);if(u(!1),isNaN(S)){n?.(s);return}const M=Math.max(s,Math.min(a,S));M!==S?n?.(M):o(String(M))},j=i<=s,b=i>=a,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",N="bg-primary hover:bg-primary/80",D="bg-primary/40 cursor-not-allowed";return t.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[t.jsx("button",{type:"button",onClick:h,disabled:r||j,className:c.cn(w,r||j?D:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),t.jsx("input",{type:"number",value:f,onChange:x,onFocus:()=>u(!0),onBlur:g,disabled:r,min:s,max:a,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"}),t.jsx("button",{type:"button",onClick:m,disabled:r||b,className:c.cn(w,r||b?D:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},wm=({label:e,checked:s=!1,onChange:a,disabled:n=!1})=>{const r=()=>{n||a?.(!s)};return t.jsxs("button",{type:"button",onClick:r,disabled:n,role:"checkbox","aria-checked":s,"data-testid":"checkbox-button","data-checked":s,className:c.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",n&&"cursor-not-allowed opacity-60"),children:[t.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:()=>{},disabled:n,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),t.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",s?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:s&&t.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"})})]}),t.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},Nm=({item:e,quantity:s,onChange:a,getTotalSelectedTickets:n,userMaxLimit:r,settings:i,labels:l})=>{const o=()=>{if(!n||r===void 0)return e.max;const m=n();return Math.min(e.max,r-(m-s))},d=i?.locale??"en-US",u=i?.currency??"USD",f=bm(d,u);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[t.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?t.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.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)}),t.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?t.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:t.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,t.jsx("div",{className:"text-sm text-zinc-500",children:t.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[l.ticketsAllowedToRedeem," ",e.max]})})]}),t.jsx(jm,{initialQuantity:s,minQuantity:0,maxQuantity:o(),onChange:a})]}),e.membershipAlert?t.jsx(c.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:t.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]})},Cm=({exhibitionId:e,dateGroup:s,isLast:a=!1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d})=>t.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!a&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[t.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:s.date}),s.tickets.map((u,f)=>t.jsxs("div",{children:[t.jsx(Nm,{item:u,quantity:r(e,s.id,u.id),onChange:m=>n(e,s.id,u.id,m),getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d}),f<s.tickets.length-1?t.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),km=({title:e,exhibition:s,onQuantityChange:a,getTicketQuantity:n,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),m=s.dates.reduce((x,g)=>x+g.tickets.reduce((j,b)=>j+n(s.id,g.id,b.id),0),0),h=s.dates.some(x=>x.tickets.length>0);return t.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[t.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-${s.id}`,"data-testid":"upgrade-ticket-header-button",children:t.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[t.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[m," ",o.ticketsSelectedToRedeem]}),t.jsx("span",{className:c.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:t.jsx(P,{icon:"mdi:chevron-down"})})]})]})}),t.jsx("div",{id:`upgrade-items-${s.id}`,className:c.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&t.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:h?s.dates.map((x,g)=>t.jsx(Cm,{exhibitionId:s.id,dateGroup:x,isLast:g===s.dates.length-1,onQuantityChange:a,getTicketQuantity:n,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o},x.id)):t.jsx("div",{className:"px-5 py-10 text-center",children:t.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},Sm=({initialExpanded:e=!1,userMaxLimit:s,labels:a,settings:n,ticketSelectionData:r,className:i="",onSelectionChange:l})=>{const o=p.useMemo(()=>r??[],[r]),d={...gm,...a},[u,f]=p.useState(()=>$n(o,s,!0)),m=p.useRef(!1),h=p.useMemo(()=>{const N=Ca(o).map(({exhibition:D,dateGroup:v,ticket:S})=>[An(D.id,v.id,S.id),S]);return new Map(N)},[o]),x=vm(o,u,s),g=(N,D,v)=>u[N]?.[D]?.[v]?.selectedQuantity??0,j=()=>oi(u),b=(N,D,v,S)=>{const M=g(N,D,v),k=j()-M;if(s!==void 0&&k+S>s)return;const F=h.get(An(N,D,v));if(!F)return;const C={...u,[N]:{...u[N],[D]:{...u[N]?.[D],[v]:{id:v,selectedQuantity:S,originalPrice:F.originalPrice,discountedPrice:F.price}}}};f(C),l?.(C)},w=N=>{const D=$n(o,s,N);f(D),l?.(D)};return p.useEffect(()=>{!m.current&&x&&(l?.(u),m.current=!0)},[x,u,l]),t.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[t.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),t.jsx(wm,{label:d.selectAllButtonLabel,checked:x,onChange:w})]}),o.map(N=>t.jsx(km,{title:N.exhibitionName,exhibition:N,onQuantityChange:b,getTicketQuantity:g,getTotalSelectedTickets:j,userMaxLimit:s,settings:n,labels:d,initialExpanded:e},N.id))]})},Ls={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Ms=e=>{const s={};for(const a of e)a.type==="checkbox"?s[a.id]=[...a.selectedValues]:s[a.id]=a.selectedValue?[a.selectedValue]:[];return s},$m=(e,s)=>{const a={};for(const n of s){if(n.type==="checkbox"){a[n.id]=e[n.id]??[...n.selectedValues];continue}const r=e[n.id]??[];a[n.id]=r.length>0?r[0]:null}return a},Am=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,ci=({triggerLabel:e,triggerAriaLabel:s,triggerIcon:a="solar:tuning-square-outline",triggerVariant:n="bordered",triggerColor:r="default",triggerSize:i="sm",triggerClassName:l,popoverClassName:o,className:d,sections:u,onConfirm:f,onClear:m,appliedCount:h,countAriaLabel:x,countDisplay:g="badge",confirmLabel:j=Ls.confirm,clearLabel:b=Ls.clear,isOpen:w,defaultOpen:N=!1,onOpenChange:D,isDisabled:v=!1,closeOnConfirm:S=!0,keepOpenAfterClear:M=!1})=>{const[k,F]=p.useState(N),[C,_]=p.useState(()=>Ms(u)),E=w??k,A=h??u.filter(Y=>Am(Y)).length,R=Y=>{Y&&_(Ms(u)),w||F(Y),D?.(Y)},O=(Y,Z)=>{_(Q=>({...Q,[Y.id]:Z}))},V=(Y,Z)=>{_(Q=>({...Q,[Y.id]:Z?[Z]:[]}))},q=async()=>{_(Ms(u.map(Y=>Y.type==="checkbox"?{...Y,selectedValues:[]}:{...Y,selectedValue:null}))),await m(),M||R(!1)},I=async()=>{const Y=$m(C,u);await f(Y),S&&R(!1)},J=Y=>{if(Y.type==="checkbox")return t.jsx(c.CheckboxGroup,{label:Y.label,value:C[Y.id]??[],onValueChange:Q=>O(Y,Q),children:Y.options.map(Q=>t.jsx(c.Checkbox,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},Y.id);const Z=C[Y.id]?.[0]??"";return t.jsx(c.RadioGroup,{label:Y.label,value:Z,onValueChange:Q=>V(Y,Q||null),children:Y.options.map(Q=>t.jsx(c.Radio,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},Y.id)},W=p.useMemo(()=>A>0?x?.(A)||`${A} filters applied`:void 0,[x,A]),se=p.useMemo(()=>A===0?e||Ls.noLabel:x?x(A):`${e} (${A})`,[A,e,x]);return t.jsx("div",{className:d,children:t.jsxs(c.Popover,{isOpen:E,onOpenChange:R,placement:"bottom-end",children:[t.jsx(c.PopoverTrigger,{children:t.jsxs(B,{isDisabled:v,variant:n,color:r,size:i,className:l,"aria-label":s,"aria-haspopup":"dialog","aria-expanded":E,children:[t.jsx(P,{icon:a,width:16}),t.jsx("span",{children:e}),g==="badge"&&A>0?t.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":W,children:A}):g==="summary"&&se!==e?t.jsx("span",{className:"text-xs",children:se}):null]})}),t.jsx(c.PopoverContent,{className:o,children:t.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(Y=>J(Y)),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[t.jsx(B,{variant:"light",color:"default",size:"sm",onPress:q,children:b}),t.jsx(B,{color:"primary",size:"sm",onPress:I,children:j})]})]})})]})})};ci.displayName="FilterPopover";const Dm="No sessions available for this date",Em=e=>e==="sold-out"||e==="closed"?"danger":"success",Fm=e=>{const s=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof s=="number"?`${s} left`:"Limited":typeof s=="number"?`${s} seats available`:"Available"},Dn=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",Lm=(e,s)=>s&&e.some(a=>a.date===s)?s:e[0]?.date??null,di=({heading:e,subheading:s,days:a,selectedDate:n,onDateSelect:r,quickDates:i,selectedSessionId:l=null,onSessionSelect:o,emptyStateMessage:d=Dm,statusLabel:u,statusTone:f,sessionAriaLabel:m,dayButtonClassName:h,calendarSlot:x,dayGroupAriaLabel:g,sessionGridAriaLabel:j,className:b,headingClassName:w,subheadingClassName:N})=>{const D=Lm(a,n),v=a.find(C=>C.date===D),S=i??a.map(C=>({date:C.date,label:C.label})),M=v?.sessions??[],k=C=>C===D?"solid":"bordered",F=C=>{if(!Dn(C)){if(C.id===l){o(null);return}o(C.id)}};return t.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",b),"data-testid":"session-timeline-root",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),s?t.jsx("p",{className:c.cn("text-sm text-gray-700",N),children:s}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":g||"Session days",children:[S.map(C=>t.jsx(B,{size:"sm",variant:k(C.date),color:"default",className:c.cn("rounded-full",h),isDisabled:C.isDisabled,onPress:()=>{r(C.date)},children:t.jsx("span",{children:C.label})},C.date)),x?t.jsx("div",{children:x}):null]}),t.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":j||"Sessions",children:[M.length===0?t.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:d}):null,M.map(C=>{const _=Dn(C),E=C.id===l;return t.jsx("li",{className:"rounded-xl",children:t.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!_,onPress:()=>{F(C)},"aria-disabled":_,"aria-pressed":_?void 0:E,className:c.cn("w-full",_?"bg-gray-100 opacity-70":"",E?"w-full ring-2 ring-gray-900":""),"aria-label":m?m(C,{isSelected:E,isUnavailable:_}):_?`${C.startTime} ${C.endTime} sold out`:`${C.startTime} ${C.endTime} available`,children:t.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[t.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[C.startTime," – ",C.endTime]}),t.jsx(c.Chip,{size:"sm",color:f?f(C):Em(C.status),variant:"flat",children:u?u(C):Fm(C)})]})})},C.id)})]})]})};di.displayName="SessionTimeline";const Qs=16,Ze=e=>`${e/Qs}rem`;function Mm(){if(typeof document>"u"||typeof getComputedStyle!="function")return Qs;const e=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:Qs}const It=(e,s)=>e>=s*Mm(),_m=1120;function jt(){const e=p.useRef(null),[s,a]=p.useState(0),[,n]=p.useState("");return p.useLayoutEffect(()=>{const r=e.current;if(!r||typeof ResizeObserver>"u")return;const i=new ResizeObserver(l=>{const o=l[l.length-1];o&&a(o.borderBoxSize?.[0]?.inlineSize??o.contentRect.width)});return a(r.getBoundingClientRect().width),i.observe(r),()=>i.disconnect()},[]),p.useEffect(()=>{if(typeof MutationObserver>"u")return;const r=document.documentElement,i=new MutationObserver(()=>n(getComputedStyle(r).fontSize));return i.observe(r,{attributes:!0,attributeFilter:["style","class"]}),()=>i.disconnect()},[]),{ref:e,width:s}}const Rm=48,Oe={base:"flex items-start gap-4",baseWide:"mb-5 flex-nowrap",baseNarrow:"mb-[0.875rem] flex-wrap",identity:"flex min-w-0 items-center gap-4",text:"min-w-0",titleWide:"text-[1.6875rem] font-semibold leading-[1.5] tracking-[-.02em] text-default-900",titleNarrow:"text-[1.375rem] font-semibold leading-[1.5] tracking-[-.02em] text-default-900",subtitleWide:"mt-[0.4375rem] max-w-[47.5rem] text-[0.875rem] leading-[1.55] text-default-500",subtitleNarrow:"mt-[0.4375rem] max-w-[47.5rem] text-[0.84375rem] leading-[1.55] text-default-500",actionsWide:"ml-auto flex shrink-0 items-center gap-2.5",actionsNarrow:"flex shrink-0 items-center gap-2.5"},Tm=(e,s)=>typeof e=="string"?t.jsx(P,{icon:e,className:"size-5","aria-hidden":"true"}):e||s||null,ui=({title:e,subtitle:s,eyebrow:a,icon:n,initials:r,actions:i,titleAs:l="h1",className:o,classNames:d={},"data-testid":u="page-header",list:f,narrow:m,headerRef:h})=>{const x=Tm(n,r);return t.jsxs("header",{ref:h,"data-testid":u,"data-variant":f?"list":void 0,"data-size":f?m?"narrow":"wide":void 0,className:c.cn(f?c.cn(Oe.base,m?Oe.baseNarrow:Oe.baseWide):"flex flex-wrap items-start justify-between gap-4",o,d.base),children:[t.jsxs("div",{className:f?Oe.identity:"flex items-center gap-4",children:[x?t.jsx("div",{"aria-hidden":"true","data-testid":`${u}-icon`,className:c.cn("flex size-12 shrink-0 items-center justify-center rounded-xl bg-gray-900 text-sm font-semibold text-white",d.iconWrapper),children:x}):null,t.jsxs("div",{className:f?Oe.text:void 0,children:[a?t.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:a}):null,t.jsx(l,{"data-testid":`${u}-title`,className:c.cn(f?m?Oe.titleNarrow:Oe.titleWide:"text-3xl font-semibold text-gray-950",d.title),children:e}),s?t.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn(f?m?Oe.subtitleNarrow:Oe.subtitleWide:"mt-1 text-sm text-gray-600",d.subtitle),children:s}):null]})]}),i?t.jsx("div",{"data-testid":`${u}-actions`,className:c.cn(f?m?Oe.actionsNarrow:Oe.actionsWide:"flex flex-wrap items-center gap-2",d.actions),children:i}):null]})},Im=e=>{const{ref:s,width:a}=jt(),n=a>0&&!It(a,Rm);return t.jsx(ui,{...e,list:!0,narrow:n,headerRef:s})},mi=e=>e.variant==="list"?t.jsx(Im,{...e}):t.jsx(ui,{...e,list:!1,narrow:!1});mi.displayName="PageHeader";const qe={ok:{fg:je.ok,bg:je["ok-fill"]},warn:{fg:je.warn,bg:je["warn-fill"]},danger:{fg:je.danger,bg:je["danger-fill"]},info:{fg:je.info,bg:je["info-fill"]},violet:{fg:je.violet,bg:je["violet-fill"]},neutral:{fg:je.neutral,bg:je["neutral-fill"]}};function Pt(e){if(e==="positive")return{color:je.ok};if(e==="negative")return{color:je.danger}}const Pm={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default",info:"default",violet:"default"},Zs={active:{fg:"#057A54",bg:"#E6F4EF"},success:{fg:"#057A54",bg:"#E6F4EF"},draft:{fg:"#B7791F",bg:"#FBF0DD"},pending:{fg:"#B7791F",bg:"#FBF0DD"},warning:{fg:"#B7791F",bg:"#FBF0DD"},danger:{fg:"#B62214",bg:"#FBEAE8"},archived:{fg:"#9CA3AF",bg:"#F1F2F4"},inactive:{fg:"#9CA3AF",bg:"#F1F2F4"},neutral:{fg:"#9CA3AF",bg:"#F1F2F4"},info:qe.info,violet:qe.violet},Om={active:"ok",success:"ok",draft:"warn",pending:"warn",warning:"warn",danger:"danger",archived:"neutral",inactive:"neutral",neutral:"neutral",info:"info",violet:"violet"},zm={sm:"px-[0.5625rem] py-[0.1875rem] text-[0.75rem]",md:"px-3 py-[0.3125rem] text-[0.8125rem]",lg:"px-3 py-[0.3125rem] text-[0.8125rem]"},Bm={info:Zs.info,violet:Zs.violet},fi=({status:e,label:s,variant:a="flat",size:n="sm",color:r,startContent:i,className:l,"data-testid":o="status-chip"})=>{if(a==="plain"){const u=qe[Om[e]];return t.jsxs("span",{"data-testid":o,"data-status":e,"data-variant":"plain",className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full font-normal",zm[n],"leading-[1.35]",l),style:{color:u.fg,backgroundColor:u.bg},children:[i,s]})}if(a==="dot"){const u=Zs[e];return t.jsxs("span",{"data-testid":o,"data-status":e,className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 py-[3px] text-[12px] font-semibold leading-[1.4]",l),style:{color:u.fg,backgroundColor:u.bg},children:[t.jsx("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:"currentColor"}}),s]})}const d=r?void 0:Bm[e];return t.jsx(c.Chip,{color:r??Pm[e],variant:a,size:n,startContent:i,"data-testid":o,"data-status":e,className:c.cn("font-medium",l),style:d?{color:d.fg,backgroundColor:d.bg}:void 0,children:s})};fi.displayName="StatusChip";const Vm={sm:"gap-1 rounded-md px-2 py-0.5 text-[11.5px] leading-normal",md:"gap-1.5 rounded-lg px-2.5 py-1 text-xs leading-normal"},Ut={base:"inline-flex items-baseline gap-1 whitespace-nowrap rounded-[0.4375rem] border border-pos-hair bg-default-100",sm:"px-2 py-0.5 text-[0.75rem] leading-[1.5]",md:"px-2.5 py-1 text-[0.8125rem] leading-[1.5]",label:"font-normal text-default-600",value:"font-semibold text-default-900"},ka=({label:e,value:s,size:a="sm",variant:n="default",className:r,"data-testid":i="key-value-chip"})=>n==="record"?t.jsxs("span",{"data-testid":i,"data-variant":"record",className:c.cn(Ut.base,Ut[a],r),children:[t.jsx("span",{className:Ut.label,children:e}),t.jsx("span",{className:Ut.value,children:s})]}):t.jsxs("span",{"data-testid":i,className:c.cn("inline-flex items-baseline whitespace-nowrap border border-default-200 bg-default-100",Vm[a],r),children:[t.jsx("span",{className:"font-medium text-default-400",children:e}),t.jsx("span",{className:"font-semibold text-default-700",children:s})]});ka.displayName="KeyValueChip";const xi="(prefers-reduced-motion: reduce)",hi="data-pos-reduce-motion",Ot="motion-reduce:transition-none [html[data-pos-reduce-motion=true]_&]:transition-none",Um="motion-reduce:animate-none [html[data-pos-reduce-motion=true]_&]:animate-none",Zt=`rounded-[0.375rem] bg-[linear-gradient(90deg,#F0F0F1_0,#F9F9FA_12.5rem,#F0F0F1_25rem)] bg-[length:50rem_100%] animate-record-shimmer ${Um}`;function Hm(){return typeof document>"u"?!1:document.documentElement.getAttribute(hi)==="true"?!0:typeof window.matchMedia=="function"&&window.matchMedia(xi).matches}function qm(){const[e,s]=p.useState(!1);return p.useEffect(()=>{const a=()=>s(Hm()),n=typeof window.matchMedia=="function"?window.matchMedia(xi):null;n?.addEventListener?.("change",a);const r=typeof MutationObserver>"u"?null:new MutationObserver(a);return r?.observe(document.documentElement,{attributes:!0,attributeFilter:[hi]}),a(),()=>{n?.removeEventListener?.("change",a),r?.disconnect()}},[]),e}const pi=({columns:e,rows:s=6,label:a="Loading",barHeight:n=12,alignLastRight:r=!1,appearance:i="pulse",className:l,classNames:o={},"data-testid":d="table-skeleton"})=>t.jsxs("div",{role:"status","aria-busy":"true","data-testid":d,className:c.cn("w-full",l,o.base),children:[t.jsx("span",{className:"sr-only",children:a}),t.jsx("div",{"aria-hidden":"true",children:Array.from({length:s}).map((u,f)=>i==="shimmer"?t.jsx("div",{"data-testid":`${d}-row`,className:c.cn("flex items-center border-b border-pos-hair",o.row),children:e.map((m,h)=>{const x=h===e.length-1;return t.jsx("div",{className:c.cn("min-w-0 flex-1 px-4 py-5",r&&x&&"flex justify-end"),children:t.jsx("div",{className:c.cn(Zt,o.bar),style:{height:Ze(n),width:m==="fill"?"60%":Ze(m),maxWidth:"100%"}})},h)})},f):t.jsx("div",{"data-testid":`${d}-row`,className:c.cn("flex items-center gap-3 border-t border-default-100 px-5 py-4",o.row),children:e.map((m,h)=>{const x=h===e.length-1;return t.jsx("div",{className:c.cn(m==="fill"?"flex-1":"shrink-0",r&&x&&"flex justify-end"),style:m==="fill"?void 0:{width:m},children:t.jsx("div",{className:c.cn("animate-pulse rounded bg-default-200",o.bar),style:{height:n,width:m==="fill"?"60%":m}})},h)})},f))})]});pi.displayName="TableSkeleton";const gi="text-left text-[11px] font-semibold uppercase tracking-[.04em] text-acct-sub px-4 pt-4 pb-3 whitespace-nowrap bg-transparent",bi="px-4 text-[13.5px] text-acct-ink2 align-middle",yi="border-t border-acct-hair transition-colors duration-150 hover:bg-acct-page data-[hover=true]:bg-acct-page",vi="w-full",ji="border-t border-acct-border px-5 py-3.5",Ht={base:"overflow-x-auto",th:"h-auto whitespace-nowrap border-b border-pos-hair bg-transparent px-4 py-[0.875rem] text-left text-[0.6875rem] font-semibold uppercase leading-[1.5] tracking-[.055em] text-default-500 first:rounded-none last:rounded-none last:pr-3",tr:`border-t border-pos-hair transition-colors duration-[120ms] first:border-t-0 data-[focus-visible=true]:outline-offset-[-2px] [tbody>&]:hover:bg-default-50 [tbody>&]:data-[hover=true]:bg-default-50 ${Ot}`,td:"h-[3.875rem] px-4 data-[focus-visible=true]:outline-offset-[-2px] py-[0.625rem] align-middle text-[0.875rem] text-default-900 last:pr-3"},wi=({columns:e,children:s,emptyContent:a,footer:n,ariaLabel:r,variant:i="default",className:l,classNames:o={},"data-testid":d="admin-table"})=>{const u=i==="framed";return t.jsxs("div",{className:c.cn(u&&Ht.base,l,o.base),"data-testid":d,"data-variant":u?"framed":void 0,children:[t.jsxs(c.Table,{"aria-label":r,removeWrapper:!0,classNames:{table:c.cn(vi,o.table),th:c.cn(u?Ht.th:gi,o.th),tr:c.cn(u?Ht.tr:yi,o.tr),td:c.cn(u?Ht.td:bi,o.td)},children:[t.jsx(c.TableHeader,{columns:e,children:f=>t.jsx(c.TableColumn,{align:f.align==="right"?"end":"start",width:f.width,children:f.label},f.key)}),t.jsx(c.TableBody,{emptyContent:a,children:s})]}),n?t.jsx("div",{"data-testid":`${d}-footer`,className:c.cn(!u&&ji,o.footer),children:n}):null]})};wi.displayName="AdminTable";const Wm={md:"w-[280px]",lg:"w-[360px]"},Ym=48,ze={base:"flex flex-wrap items-center gap-2.5 border-b border-pos-hair px-4 py-[0.875rem]",narrow:"[&_[data-slot=filter-select]]:!max-w-none [&_[data-slot=filter-select]]:!min-w-[calc(50%-0.3125rem)] [&_[data-slot=filter-select]]:grow [&_[data-slot=filter-select]]:basis-[calc(50%-0.3125rem)]",searchWide:"ml-auto",searchNarrow:"basis-full",inputBaseMd:"w-[15.625rem]",inputBaseLg:"w-[22.5rem]",inputBaseNarrow:"w-full",inputWrapper:"h-[2.375rem] min-h-[2.375rem] !h-[2.375rem] rounded-[0.625rem] border border-pos-field bg-white pl-3 pr-3 shadow-none data-[hover=true]:border-pos-field group-data-[focus=true]:border-primary",innerWrapper:"gap-[0.4375rem]",input:"text-ellipsis text-[0.875rem] text-default-900 data-[has-start-content=true]:ps-0",icon:"flex text-default-400 [&_svg]:size-4"},Gm=({searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,searchClearable:i=!1,children:l,trailing:o,searchWidth:d="md",className:u,"data-testid":f="admin-toolbar"})=>{const{ref:m,width:h}=jt(),x=h>0&&!It(h,Ym);return t.jsxs("div",{ref:m,role:"search","data-testid":f,"data-variant":"framed","data-size":x?"narrow":"wide",className:c.cn(ze.base,x&&ze.narrow,u),children:[l,t.jsx("div",{"data-testid":`${f}-search-slot`,className:x?ze.searchNarrow:ze.searchWide,children:t.jsx(c.Input,{type:"search","aria-label":a,placeholder:n??a,value:e,onValueChange:s,isClearable:i,onClear:i?()=>s(""):void 0,startContent:t.jsx("span",{"aria-hidden":"true","data-testid":`${f}-search-icon`,className:ze.icon,children:r??t.jsx(P,{icon:"lucide:search"})}),"data-testid":`${f}-search`,variant:"bordered",radius:"none",classNames:{base:x?ze.inputBaseNarrow:d==="lg"?ze.inputBaseLg:ze.inputBaseMd,inputWrapper:ze.inputWrapper,innerWrapper:ze.innerWrapper,input:ze.input}})}),o]})},Ni=({searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,searchClearable:i=!1,children:l,trailing:o,searchWidth:d="md",variant:u="default",className:f,"data-testid":m="admin-toolbar"})=>u==="framed"?t.jsx(Gm,{searchValue:e,onSearchChange:s,searchLabel:a,searchPlaceholder:n,searchIcon:r,searchClearable:i,trailing:o,searchWidth:d,className:f,"data-testid":m,children:l}):t.jsxs("div",{role:"search","data-testid":m,className:c.cn("flex flex-wrap items-center gap-3 mb-4",f),children:[t.jsx(c.Input,{type:"search","aria-label":a,placeholder:n??a,value:e,onValueChange:s,isClearable:i,onClear:i?()=>s(""):void 0,startContent:r?t.jsx("span",{"aria-hidden":"true",className:"flex text-acct-muted",children:r}):void 0,"data-testid":`${m}-search`,variant:"bordered",radius:"none",classNames:{base:Wm[d],inputWrapper:["h-10 min-h-10 !h-10 rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),input:"text-[13.5px] text-acct-ink"}}),l,o?t.jsx("div",{className:"ml-auto",children:o}):null]});Ni.displayName="AdminToolbar";const Km="ml-0.5 inline-flex min-w-[18px] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",Qm="ml-0.5 inline-flex min-w-[1.125rem] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",Zm="h-9 gap-1.5 rounded-full border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 hover:bg-gray-50 data-[pressed=true]:bg-gray-50",Ci=p.forwardRef(function({icon:s,children:a,count:n,appearance:r="pill",className:i,testId:l,...o},d){return r==="outline"?t.jsxs(B,{ref:d,"data-testid":l,"data-appearance":"outline",color:"default",variant:"bordered",radius:"md",size:"md",className:c.cn("rounded-[0.75rem] font-normal",i),...o,children:[t.jsx(P,{icon:s,className:"size-4","aria-hidden":!0}),t.jsx("span",{children:a}),n!==void 0&&n>0&&t.jsx("span",{className:Qm,children:n})]}):t.jsxs(B,{ref:d,"data-testid":l,variant:"light",size:"sm",className:c.cn(Zm,i),...o,children:[t.jsx(P,{icon:s,className:"size-4 text-gray-500","aria-hidden":!0}),t.jsx("span",{children:a}),n!==void 0&&n>0&&t.jsx("span",{className:Km,children:n})]})});Ci.displayName="ToolbarButton";function ki({items:e,value:s,onChange:a,ariaLabel:n,className:r,"data-testid":i="underline-tabs"}){return t.jsx(c.Tabs,{"aria-label":n,variant:"underlined",selectedKey:s,onSelectionChange:l=>a(String(l)),"data-testid":i,classNames:{base:c.cn("w-full mb-6",r),tabList:"gap-7 w-full relative rounded-none p-0 border-b border-acct-border",cursor:"w-full bg-acct-rust",tab:"max-w-fit px-0.5 h-auto pb-3",tabContent:"text-[15px] font-medium text-acct-sub group-data-[selected=true]:font-semibold group-data-[selected=true]:text-acct-rust",panel:"p-0"},children:e.map(l=>t.jsx(c.Tab,{title:l.label,"data-testid":`${i}-${l.key}`,children:l.content},l.key))})}ki.displayName="UnderlineTabs";const Sa="text-[11px] font-semibold uppercase tracking-[.04em] text-acct-muted mb-1.5",$a="font-normal normal-case tracking-normal",Si=["h-[38px] min-h-[38px] !h-[38px] rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),$i="text-[13.5px] text-acct-ink",Ai="bg-acct-page text-acct-muted cursor-default",Di="mt-[5px] text-xs text-acct-sub",Ei="mt-[5px] text-xs text-acct-danger",Fi=({children:e,suffix:s,className:a,"data-testid":n="admin-field-label"})=>t.jsxs("div",{"data-testid":n,className:c.cn(Sa,a),children:[e,s?t.jsxs("span",{className:$a,children:[" ",s]}):null]});Fi.displayName="AdminFieldLabel";const Li=({label:e,labelSuffix:s,value:a,onChange:n,placeholder:r,disabled:i=!1,readOnly:l=!1,mono:o=!1,autoFocus:d=!1,hint:u,invalid:f=!1,className:m,"data-testid":h="admin-text-field"})=>t.jsx(c.Input,{labelPlacement:e?"outside":void 0,label:e&&s?t.jsxs(t.Fragment,{children:[e,t.jsxs("span",{className:$a,children:[" ",s]})]}):e,value:a,placeholder:r,isDisabled:i,isReadOnly:l,autoFocus:d,isInvalid:f,description:!f&&u?u:void 0,errorMessage:f?u:void 0,onValueChange:n,"data-testid":h,variant:"bordered",radius:"none",classNames:{base:c.cn("w-full",m),label:Sa,inputWrapper:Si,input:c.cn($i,(o||l)&&"font-mono",l&&Ai),description:Di,errorMessage:Ei}});Li.displayName="AdminTextField";const Xm={sm:"size-6 min-w-6",md:"size-[30px] min-w-[30px]"},Mi=({actions:e,size:s="md",className:a,"data-testid":n="row-actions"})=>t.jsx("div",{role:"presentation","data-testid":n,className:c.cn("inline-flex gap-0.5",a),onClick:r=>r.stopPropagation(),children:e.map(r=>t.jsx(B,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:r.onPress,isDisabled:r.disabled,"aria-label":r.label,title:r.label,"data-testid":`${n}-${r.key}`,className:c.cn("text-acct-sub data-[hover=true]:bg-acct-hair",Xm[s]),children:r.icon},r.key))});Mi.displayName="RowActions";const _i=({children:e,placeholder:s="Select…",onOpen:a,onClear:n,ariaLabel:r,icon:i,trailingIcon:l,clearIcon:o,disabled:d=!1,className:u,"data-testid":f="picker-row"})=>{const m=e!=null;return t.jsxs("div",{"data-testid":f,className:c.cn("flex w-full min-h-10 items-center rounded-[10px] border border-acct-border bg-acct-surface px-[11px] transition-colors duration-150",d?"opacity-60":"hover:border-acct-rust-border",u),children:[t.jsxs(B,{variant:"light",radius:"none",disableAnimation:!0,onPress:a,isDisabled:d,"aria-haspopup":"dialog","aria-label":r,"data-testid":`${f}-trigger`,className:"flex h-auto min-h-0 min-w-0 flex-1 items-center justify-start gap-2.5 bg-transparent px-0 py-2 text-left text-inherit data-[hover=true]:bg-transparent",children:[i?t.jsx("span",{className:"flex shrink-0 text-acct-muted",children:i}):null,m?t.jsx("span",{className:"flex min-w-0 items-center gap-2",children:e}):t.jsx("span",{className:"text-[13.5px] font-semibold text-acct-sub",children:s}),l?t.jsx("span",{className:"ml-auto flex shrink-0 text-acct-muted",children:l}):null]}),m&&n?t.jsx(B,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:n,isDisabled:d,"aria-label":`Clear ${r}`,title:"Clear","data-testid":`${f}-clear`,className:"ml-1.5 size-6 min-w-6 shrink-0 text-acct-muted data-[hover=true]:bg-acct-hair",children:o}):null]})};_i.displayName="PickerRow";function Ri(e,s,a){if(a<=0||s<=0||e<=0)return{from:0,to:0};const n=(e-1)*s+1;return n>a?{from:0,to:0}:{from:n,to:Math.min(a,e*s)}}const Ti=({page:e,pageSize:s,total:a,unit:n,announce:r=!0,className:i,classNames:l={},"data-testid":o="pagination-summary"})=>{const{from:d,to:u}=Ri(e,s,a),f=c.cn("font-semibold text-default-700",l.emphasis);return t.jsxs("p",{"data-testid":o,"aria-live":r?"polite":void 0,className:c.cn("text-sm text-default-500",i,l.base),children:["Showing"," ",t.jsx("span",{"data-testid":`${o}-range`,className:f,children:d===0?0:`${d}–${u}`})," ","of"," ",t.jsx("span",{"data-testid":`${o}-total`,className:f,children:a}),n?t.jsxs(t.Fragment,{children:[" ",n]}):null]})};Ti.displayName="PaginationSummary";const fs="shadow-[0_1px_4px_rgba(0,0,0,.06),0_4px_12px_rgba(0,0,0,.06)]",Qe={base:`overflow-hidden rounded-2xl border border-pos-line bg-white ${fs}`,title:"m-0 min-w-0 text-[0.90625rem] font-semibold text-default-900 [overflow-wrap:anywhere]",count:"rounded-full bg-default-100 px-2 py-px text-[0.75rem] font-semibold text-default-600",icon:"flex shrink-0 text-default-500 [&_svg]:size-[1.125rem]",action:"ml-auto",description:"m-0 text-[0.84375rem] leading-[1.55] text-default-500 [&_b]:font-bold [&_b]:tabular-nums [&_b]:text-default-900",footer:"flex flex-wrap gap-2",footerAfterContent:"mt-[0.875rem]",footerAfterDescription:"mt-3"},Jm={section:"flex flex-wrap items-center gap-2 px-5 pt-4",aside:"flex flex-wrap items-center gap-[0.5625rem] px-[1.125rem] pt-[0.9375rem]"},ef={section:{padded:"px-5 pb-[1.125rem] pt-[0.875rem]",rows:"px-5 pb-[1.125rem] pt-2.5",flush:"pt-3",none:""},aside:{padded:"px-[1.125rem] pb-[1.125rem] pt-3",rows:"px-[1.125rem] pb-[1.125rem] pt-3",flush:"pt-3",none:""}},Ii=({isLoading:e=!1,isError:s=!1,isEmpty:a=!1,loadingTitle:n="Loading…",loadingContent:r,errorTitle:i="Something went wrong",errorDescription:l,retryLabel:o="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:m="Nothing here yet",emptyDescription:h,emptyIcon:x,emptyActions:g,emptyContent:j,children:b,toolbar:w,variant:N="default",className:D,classNames:v={},"data-testid":S="list-panel"})=>{const M=N==="framed",k={base:c.cn("border-0 bg-transparent py-12",v.state)},F=M?{base:c.cn("px-6 py-[3.625rem]",v.state),iconWrapper:"mb-[1.125rem] size-[4.75rem] rounded-[1.25rem] border-0 bg-default-100 text-default-400",icon:"size-[2.875rem]",title:"text-[1.0625rem] font-semibold text-default-900",description:"mt-1.5 max-w-[26.25rem] text-[0.875rem] leading-[1.55] text-default-500",actions:"mt-[1.375rem] gap-2.5"}:k;let C;return e?C=r??t.jsx(Na,{title:n,classNames:k,"data-testid":`${S}-loading`}):s?C=f??t.jsx(wa,{title:i,description:l,classNames:k,"data-testid":`${S}-error`,actions:u??(d?t.jsx(B,{color:"primary",variant:"flat",onPress:d,children:o}):void 0)}):a?C=j??t.jsx(ja,{surface:M?"panel":void 0,title:m,description:h,icon:x,actions:g,classNames:F,"data-testid":`${S}-empty`}):C=b,t.jsxs("section",{"data-testid":S,"data-variant":M?"framed":void 0,className:c.cn(M?`overflow-hidden rounded-2xl border border-pos-line bg-white ${fs}`:"rounded-xl bg-white p-2 shadow-sm",D,v.base),children:[w,C]})};Ii.displayName="ListPanel";const Pi=(e,s)=>s<=0?/^\d*$/.test(e):new RegExp(`^\\d*(?:[.,]\\d{0,${s}})?$`).test(e),rs=e=>{const s=Number.parseFloat(e.replace(",","."));return Number.isFinite(s)?s:null},Oi=(e,s)=>{const[a,n]=p.useState(()=>s(e)),r=(rs(a)??0)===(e??0)?a:s(e),i=p.useCallback(()=>{n(l=>{const o=rs(l);return o===null?"":String(o)})},[]);return{draft:r,setDraft:n,normalize:i}},tf=350,sf={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}"},_s=(e,s)=>Object.entries(s).reduce((a,[n,r])=>a.replace(`{${n}}`,r),e),af=({dueAmount:e,received:s,defaultReceived:a=null,onChange:n,locale:r="en-US",labels:i,isDisabled:l=!1,maxAmount:o,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const m={...sf,...i},h=Rt(e.currency,r),x=s!==void 0,[g,j]=p.useState(a??null),b=x?s:g,{draft:w,setDraft:N,normalize:D}=Oi(b,V=>V==null?"":String(V)),v=p.useMemo(()=>{const V=typeof b=="number"&&Number.isFinite(b)?b:0,q=Hs(V,e.value,e.currency,r);return{received:V,change:q>0?q:0,isValid:V>=e.value&&V>0}},[b,e.value,e.currency,r]),S=p.useCallback(V=>{const q=V.currentTarget;requestAnimationFrame(()=>{q.isConnected&&q.select()})},[]),M=p.useCallback(V=>{if(l)return;const q=V.replace(/[^\d.,]/g,"");if(!Pi(q,h))return;const I=rs(q);if(I!==null&&o!==void 0&&I>o)return;N(q),x||j(I);const J=typeof I=="number"&&Number.isFinite(I)?I:0,W=Hs(J,e.value,e.currency,r);n?.({received:J,change:W>0?W:0,isValid:J>=e.value&&J>0})},[x,l,e.value,e.currency,r,n,o,N,h]),k=v.isValid&&v.change>0,F=!v.isValid&&v.received>0,C=ge(v.change,r,e.currency),_=ge(e.value,r,e.currency),[E,A]=p.useState(""),R=p.useRef(null);p.useEffect(()=>{R.current&&clearTimeout(R.current);const V=k?_s(m.changeMessageTemplate,{change:C}):"",q=k?tf:0;return R.current=setTimeout(()=>A(V),q),()=>{R.current&&clearTimeout(R.current)}},[k,C,m.changeMessageTemplate]);const O=`${f}-received`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[t.jsx(c.Input,{id:O,label:m.receivedLabel,labelPlacement:"outside",type:"text",inputMode:h===0?"numeric":"decimal",pattern:h===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:w,onChange:V=>M(V.target.value),onFocus:S,onBlur:D,placeholder:m.receivedPlaceholder,isDisabled:l,isInvalid:F,errorMessage:F?_s(m.insufficientMessageTemplate,{due:_}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),k&&t.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:m.changeLabel,description:_s(m.changeMessageTemplate,{change:C}),icon:t.jsx(P,{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"}}),t.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:E})]})},nf={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},En=()=>{const e=new Date,s=a=>String(a).padStart(2,"0");return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`},zi=({dueAmount:e,value:s,defaultValue:a,onChange:n,labels:r,hideDate:i=!1,hideBankName:l=!1,isDisabled:o=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:m,"data-testid":h="check-tender-form"})=>{const x={...nf,...r},g=s!==void 0,[j,b]=p.useState({checkNumber:a?.checkNumber??"",bankName:a?.bankName??"",date:a?.date??En()}),[w,N]=p.useState(!!a?.checkNumber),D=p.useMemo(()=>g?{checkNumber:s?.checkNumber??"",bankName:s?.bankName??"",date:s?.date??En()}:j,[g,s,j]),v=p.useCallback(E=>{g||b(E);const A=E.checkNumber.trim(),R={amount:e.value,checkNumber:A,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:A.length>0&&e.value>0};n?.(R)},[g,e.value,i,n]),S=p.useCallback(E=>A=>{o||(E==="checkNumber"&&A.length>0&&N(!0),v({...D,[E]:A}))},[D,v,o]),M=p.useCallback(()=>{o||N(!0)},[o]),k=w&&D.checkNumber.trim()==="",F=`${h}-check-number`,C=`${h}-bank-name`,_=`${h}-date`;return t.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",m),"data-testid":h,children:[t.jsx(c.Input,{id:F,label:x.checkNumberLabel,labelPlacement:"outside",type:"text",value:D.checkNumber,onChange:E=>S("checkNumber")(E.target.value),onBlur:M,placeholder:x.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:k,errorMessage:k?x.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${h}-check-number-input`}),!l&&t.jsx(c.Input,{id:C,label:x.bankNameLabel,labelPlacement:"outside",type:"text",value:D.bankName,onChange:E=>S("bankName")(E.target.value),placeholder:x.bankNamePlaceholder,maxLength:u,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${h}-bank-name-input`}),!i&&t.jsx(c.Input,{id:_,label:x.dateLabel,labelPlacement:"outside",type:"date",value:D.date,onChange:E=>S("date")(E.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${h}-date-input`,className:"sm:col-span-2"})]})};zi.displayName="CheckTenderForm";const rf={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},lf=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Bi=({dueAmount:e,methodOptions:s=lf,value:a,defaultValue:n,onChange:r,labels:i,showReference:l=!1,isDisabled:o=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...rf,...i},m=a!==void 0,[h,x]=p.useState({method:n?.method??"",reference:n?.reference??""}),g=p.useMemo(()=>m?{method:a?.method??"",reference:a?.reference??""}:h,[m,a,h]),j=p.useCallback(S=>s.find(M=>M.value===S)?.label??"",[s]),b=p.useCallback(S=>{m||x(S);const M=j(S.method),k={amount:e.value,method:S.method,description:M,reference:S.reference.trim()||void 0,isValid:S.method!==""};r?.(k)},[m,e.value,r,j]),w=p.useCallback(S=>{if(o)return;const M=typeof S=="string"?S:Array.from(S)[0]?.toString()??"";b({...g,method:M})},[g,b,o]),N=p.useCallback(S=>{o||b({...g,reference:S})},[g,b,o]),D=`${u}-method`,v=`${u}-reference`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[t.jsx(He,{id:D,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:g.method?[g.method]:[],onSelectionChange:w,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:s.map(S=>t.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${S.value}`,children:S.label},S.value))}),l&&t.jsx(c.Input,{id:v,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:g.reference,onChange:S=>N(S.target.value),placeholder:f.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};Bi.displayName="OtherTenderForm";const of={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},cf={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},df={pending:"warning",recorded:"success",failed:"danger"},uf=e=>e==="pending"||e==="recorded",mf=e=>`#${e+1}`,Vi=({total:e,tenders:s,onRemove:a,locale:n="en-US",labels:r,hideCollectedList:i=!1,variant:l="banner",className:o,"data-testid":d="split-payment-summary"})=>{const u={...of,...r},{collected:f,remaining:m,isComplete:h}=p.useMemo(()=>{const g=s.reduce((b,w)=>uf(w.status)?b+w.amount:b,0),j=Math.max(e.value-g,0);return{collected:g,remaining:j,isComplete:g>=e.value&&e.value>0}},[s,e.value]),x=g=>g==="pending"?u.statusPending:g==="recorded"?u.statusRecorded:u.statusFailed;return t.jsxs("div",{className:c.cn("flex flex-col gap-4",o),"data-testid":d,children:[l==="compact"?t.jsxs("div",{className:"flex items-baseline justify-between gap-3","data-testid":`${d}-remaining-banner`,children:[t.jsx("span",{className:"text-sm text-default-600",children:h?u.completeLabel:u.remainingLabel}),t.jsx("span",{className:"text-base font-semibold tracking-tight","data-testid":`${d}-remaining-amount`,children:ge(h?f:m,n,e.currency)})]}):t.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${d}-remaining-banner`,children:[t.jsx("div",{className:"text-sm text-default-600",children:h?u.completeLabel:u.remainingLabel}),t.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${d}-remaining-amount`,children:ge(h?f:m,n,e.currency)})]}),!i&&s.length>0&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${d}-collected-list`,children:[t.jsx("h3",{className:"text-base font-semibold",children:u.collectedHeading}),s.map((g,j)=>t.jsx(ff,{index:j,tender:g,locale:n,currency:e.currency,removable:!!a&&g.status!=="recorded",onRemove:a?()=>a(g.id):void 0,statusLabel:x(g.status),removeAriaLabel:u.removeAriaLabel,recordedTooltip:u.removeTooltipForRecorded,dataTestId:`${d}-row-${j}`},g.id))]})]})};Vi.displayName="SplitPaymentSummary";const ff=({index:e,tender:s,locale:a,currency:n,removable:r,onRemove:i,statusLabel:l,removeAriaLabel:o,recordedTooltip:d,dataTestId:u})=>{const f=i?t.jsx(B,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!r,"aria-label":o,"data-testid":`${u}-remove`,className:c.cn(r?"text-default-700 hover:bg-default-200":"text-default-300"),children:t.jsx(P,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return t.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:[t.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:mf(e)}),t.jsx(P,{icon:cf[s.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:s.label}),t.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:ge(s.amount,a,n)}),t.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:df[s.status],startContent:s.status==="recorded"?t.jsx(P,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):s.status==="failed"?t.jsx(P,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:l}),f&&(r?f:t.jsx(c.Tooltip,{content:d,placement:"left",children:t.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},xf=`
|
|
17
17
|
@keyframes pp-modal-in {
|
|
18
18
|
from { opacity: 0; transform: scale(0.96); }
|
|
19
19
|
to { opacity: 1; transform: scale(1); }
|
package/dist/index.js
CHANGED
|
@@ -10434,29 +10434,30 @@ const $f = {
|
|
|
10434
10434
|
searchLabel: a,
|
|
10435
10435
|
searchPlaceholder: r,
|
|
10436
10436
|
searchIcon: i,
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10437
|
+
searchClearable: s = !1,
|
|
10438
|
+
children: l,
|
|
10439
|
+
trailing: o,
|
|
10440
|
+
searchWidth: c = "md",
|
|
10441
|
+
className: d,
|
|
10442
|
+
"data-testid": f = "admin-toolbar"
|
|
10442
10443
|
}) => {
|
|
10443
|
-
const { ref:
|
|
10444
|
+
const { ref: m, width: g } = Ot(), h = g > 0 && !Xt(g, Sf);
|
|
10444
10445
|
return /* @__PURE__ */ u(
|
|
10445
10446
|
"div",
|
|
10446
10447
|
{
|
|
10447
|
-
ref:
|
|
10448
|
+
ref: m,
|
|
10448
10449
|
role: "search",
|
|
10449
|
-
"data-testid":
|
|
10450
|
+
"data-testid": f,
|
|
10450
10451
|
"data-variant": "framed",
|
|
10451
|
-
"data-size":
|
|
10452
|
-
className: p(Ke.base,
|
|
10452
|
+
"data-size": h ? "narrow" : "wide",
|
|
10453
|
+
className: p(Ke.base, h && Ke.narrow, d),
|
|
10453
10454
|
children: [
|
|
10454
|
-
|
|
10455
|
+
l,
|
|
10455
10456
|
/* @__PURE__ */ n(
|
|
10456
10457
|
"div",
|
|
10457
10458
|
{
|
|
10458
|
-
"data-testid": `${
|
|
10459
|
-
className:
|
|
10459
|
+
"data-testid": `${f}-search-slot`,
|
|
10460
|
+
className: h ? Ke.searchNarrow : Ke.searchWide,
|
|
10460
10461
|
children: /* @__PURE__ */ n(
|
|
10461
10462
|
Ce,
|
|
10462
10463
|
{
|
|
@@ -10465,20 +10466,22 @@ const $f = {
|
|
|
10465
10466
|
placeholder: r ?? a,
|
|
10466
10467
|
value: e,
|
|
10467
10468
|
onValueChange: t,
|
|
10469
|
+
isClearable: s,
|
|
10470
|
+
onClear: s ? () => t("") : void 0,
|
|
10468
10471
|
startContent: /* @__PURE__ */ n(
|
|
10469
10472
|
"span",
|
|
10470
10473
|
{
|
|
10471
10474
|
"aria-hidden": "true",
|
|
10472
|
-
"data-testid": `${
|
|
10475
|
+
"data-testid": `${f}-search-icon`,
|
|
10473
10476
|
className: Ke.icon,
|
|
10474
10477
|
children: i ?? /* @__PURE__ */ n(T, { icon: "lucide:search" })
|
|
10475
10478
|
}
|
|
10476
10479
|
),
|
|
10477
|
-
"data-testid": `${
|
|
10480
|
+
"data-testid": `${f}-search`,
|
|
10478
10481
|
variant: "bordered",
|
|
10479
10482
|
radius: "none",
|
|
10480
10483
|
classNames: {
|
|
10481
|
-
base:
|
|
10484
|
+
base: h ? Ke.inputBaseNarrow : c === "lg" ? Ke.inputBaseLg : Ke.inputBaseMd,
|
|
10482
10485
|
inputWrapper: Ke.inputWrapper,
|
|
10483
10486
|
innerWrapper: Ke.innerWrapper,
|
|
10484
10487
|
input: Ke.input
|
|
@@ -10487,7 +10490,7 @@ const $f = {
|
|
|
10487
10490
|
)
|
|
10488
10491
|
}
|
|
10489
10492
|
),
|
|
10490
|
-
|
|
10493
|
+
o
|
|
10491
10494
|
]
|
|
10492
10495
|
}
|
|
10493
10496
|
);
|
|
@@ -10497,13 +10500,14 @@ const $f = {
|
|
|
10497
10500
|
searchLabel: a,
|
|
10498
10501
|
searchPlaceholder: r,
|
|
10499
10502
|
searchIcon: i,
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10503
|
+
searchClearable: s = !1,
|
|
10504
|
+
children: l,
|
|
10505
|
+
trailing: o,
|
|
10506
|
+
searchWidth: c = "md",
|
|
10507
|
+
variant: d = "default",
|
|
10508
|
+
className: f,
|
|
10509
|
+
"data-testid": m = "admin-toolbar"
|
|
10510
|
+
}) => d === "framed" ? /* @__PURE__ */ n(
|
|
10507
10511
|
Af,
|
|
10508
10512
|
{
|
|
10509
10513
|
searchValue: e,
|
|
@@ -10511,13 +10515,14 @@ const $f = {
|
|
|
10511
10515
|
searchLabel: a,
|
|
10512
10516
|
searchPlaceholder: r,
|
|
10513
10517
|
searchIcon: i,
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10518
|
+
searchClearable: s,
|
|
10519
|
+
trailing: o,
|
|
10520
|
+
searchWidth: c,
|
|
10521
|
+
className: f,
|
|
10522
|
+
"data-testid": m,
|
|
10523
|
+
children: l
|
|
10524
|
+
}
|
|
10525
|
+
) : /* @__PURE__ */ u("div", { role: "search", "data-testid": m, className: p("flex flex-wrap items-center gap-3 mb-4", f), children: [
|
|
10521
10526
|
/* @__PURE__ */ n(
|
|
10522
10527
|
Ce,
|
|
10523
10528
|
{
|
|
@@ -10526,12 +10531,14 @@ const $f = {
|
|
|
10526
10531
|
placeholder: r ?? a,
|
|
10527
10532
|
value: e,
|
|
10528
10533
|
onValueChange: t,
|
|
10534
|
+
isClearable: s,
|
|
10535
|
+
onClear: s ? () => t("") : void 0,
|
|
10529
10536
|
startContent: i ? /* @__PURE__ */ n("span", { "aria-hidden": "true", className: "flex text-acct-muted", children: i }) : void 0,
|
|
10530
|
-
"data-testid": `${
|
|
10537
|
+
"data-testid": `${m}-search`,
|
|
10531
10538
|
variant: "bordered",
|
|
10532
10539
|
radius: "none",
|
|
10533
10540
|
classNames: {
|
|
10534
|
-
base: $f[
|
|
10541
|
+
base: $f[c],
|
|
10535
10542
|
inputWrapper: [
|
|
10536
10543
|
"h-10 min-h-10 !h-10 rounded-[11px] border border-acct-border bg-acct-surface px-3",
|
|
10537
10544
|
"data-[hover=true]:border-acct-rust-border",
|
|
@@ -10541,8 +10548,8 @@ const $f = {
|
|
|
10541
10548
|
}
|
|
10542
10549
|
}
|
|
10543
10550
|
),
|
|
10544
|
-
|
|
10545
|
-
|
|
10551
|
+
l,
|
|
10552
|
+
o ? /* @__PURE__ */ n("div", { className: "ml-auto", children: o }) : null
|
|
10546
10553
|
] });
|
|
10547
10554
|
Df.displayName = "AdminToolbar";
|
|
10548
10555
|
const Ef = "ml-0.5 inline-flex min-w-[18px] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground", Ff = "ml-0.5 inline-flex min-w-[1.125rem] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground", Lf = "h-9 gap-1.5 rounded-full border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 hover:bg-gray-50 data-[pressed=true]:bg-gray-50", _f = W.forwardRef(
|
|
@@ -8,6 +8,8 @@ export interface AdminToolbarProps {
|
|
|
8
8
|
searchPlaceholder?: string;
|
|
9
9
|
/** Leading glyph inside the search box. */
|
|
10
10
|
searchIcon?: React.ReactNode;
|
|
11
|
+
/** Shows a clear button inside the search box while it holds text. Off by default. */
|
|
12
|
+
searchClearable?: boolean;
|
|
11
13
|
/** Filters, sort pickers, a toggle — laid out after the search box. */
|
|
12
14
|
children?: React.ReactNode;
|
|
13
15
|
/** Pushed to the far right, for a primary action. */
|