@moondreamsdev/dreamer-ui 1.7.6-test.0 → 1.7.6

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("react"),y=require("./utils.cjs.js"),E=require("./QuestionMarkCircled-o1tqa8ZJ.cjs"),$=require("./styles-BqvnMUW1.cjs"),K=require("react-dom");function S({id:n,title:s,content:e,children:o,className:t="",disabled:r=!1,isOpen:a=!1,onToggle:d,triggerClassName:c="",bodyClassName:f=""}){const m=u.useId(),l=n||`accordion-item-${m}`,p=`${l}-header`,h=`${l}-panel`,b=()=>{!r&&d&&d()},v=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),b())};return i.jsxs("div",{className:y.join("border-b border-gray-200",r&&"opacity-60 cursor-not-allowed",t),children:[i.jsxs("button",{id:p,type:"button",className:y.join("w-full text-left py-3 px-4 flex justify-between items-center focus:outline focus:outline-secondary",r?"cursor-not-allowed":"hover:bg-gray-50/10 cursor-pointer",c),"aria-expanded":a,"aria-controls":h,disabled:r,onClick:b,onKeyDown:v,children:[i.jsx("span",{children:s}),i.jsx("span",{className:y.join("transform transition-transform duration-300 ease-linear",a?"rotate-180":"rotate-0"),"aria-hidden":"true",children:i.jsx(E.ChevronDown,{size:18})})]}),i.jsx("div",{id:h,role:"region","aria-labelledby":p,className:y.join("transition-all duration-300 ease-linear px-4",a?"max-h-96 opacity-100 overflow-auto py-3":"max-h-0 opacity-0 overflow-hidden",f),children:a&&(o||e)})]})}function Q({id:n,items:s=[],children:e,className:o="",itemClassName:t="",allowMultiple:r=!1,defaultOpenItems:a=[],triggersClassName:d="",bodiesClassName:c=""}){const f=u.useId(),m=n||`accordion-group-${f}`,[l,p]=u.useState(new Set(a)),h=x=>{p(w=>{const g=new Set(w);return g.has(x)?g.delete(x):(r||g.clear(),g.add(x)),g})},b=x=>`${f}-item-${x}`,v=x=>l.has(x);return i.jsxs("div",{id:m,className:o,children:[s.length>0&&s.map((x,w)=>{const g=x.id||b(w);return i.jsx(S,{id:g,title:x.title,content:x.content,disabled:x.disabled,isOpen:v(g),onToggle:()=>h(g),className:t,triggerClassName:d,bodyClassName:c},g)}),s.length===0&&e&&u.Children.map(e,(x,w)=>{if(u.isValidElement(x)&&x.type===S){const g=x.props.id||b(w);return u.createElement(S,{...x.props,key:g,id:g,className:y.join(t,x.props.className),isOpen:v(g),onToggle:()=>h(g),triggerClassName:y.join(d,x.props.triggerClassName),bodyClassName:y.join(c,x.props.bodyClassName)})}return null})]})}function V(){const[n,s]=u.useState(0);return u.useEffect(()=>{const e=setInterval(()=>{s(o=>(o+1)%3)},500);return()=>clearInterval(e)},[]),i.jsx("div",{className:"absolute inset-0 inline-flex items-center justify-center gap-x-2 align-middle",children:[0,1,2].map(e=>i.jsx("div",{className:y.join("rounded-full transition-all duration-500 ease-in-out size-[0.35em] bg-current",n===e&&"transform -translate-y-1")},e))})}const _={base:"",primary:"bg-primary text-primary-foreground hover:bg-primary/85 disabled:bg-muted disabled:text-muted-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/85 disabled:bg-muted/80 disabled:text-muted-foreground/80",tertiary:"text-primary hover:text-primary-foreground disabled:text-muted",outline:"border border-primary text-primary hover:border-primary-foreground hover:text-primary-foreground disabled:border-muted disabled:text-muted",link:"underline-offset-4 hover:underline disabled:underline disabled:text-muted",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/85 disabled:bg-muted disabled:text-muted-foreground"},X={stripped:"",fitted:"size-fit",sm:"px-2 py-1 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg",icon:"p-1 w-fit aspect-square",full:"p-2 w-full"},Z={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"},B={variant:"primary",size:"md",rounded:"md"};function M({variant:n=B.variant,size:s,rounded:e=B.rounded,loading:o,linkTo:t,linkProps:r,type:a="button",className:d,...c}){let f;n==="link"&&!s?f="fitted":f=s||B.size;const l=y.join("appearance-none focus:outline-none focus:ring not-disabled:hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed transition-all",_[n],X[f],Z[e],o&&"relative pointer-events-none",t&&"relative",d);return i.jsxs("button",{...c,role:t?"link":c.role,"aria-label":c["aria-label"]||(r==null?void 0:r["aria-label"]),"aria-description":c["aria-description"]||(r==null?void 0:r["aria-description"]),"aria-disabled":c.disabled||o,"aria-busy":o,type:a,className:l,children:[o&&i.jsx(V,{}),i.jsx("span",{className:y.join(o&&"invisible"),children:c.children}),t&&!c.disabled&&i.jsx("a",{...r,"aria-hidden":!0,href:t,rel:(r==null?void 0:r.rel)||"noreferrer",className:"absolute inset-0"})]})}function J(n){const[s,e]=u.useState(""),o=u.useCallback(t=>{let r=t,a="";for(;r&&!a;){const d=window.getComputedStyle(r).backgroundColor;d&&d!=="transparent"&&d!=="rgba(0, 0, 0, 0)"&&(a=d),r=r.parentElement}return a||"transparent"},[]);return u.useEffect(()=>{const t=document.getElementById(n);if(t){const r=o(t.parentElement);e(r)}},[n,o]),s}function Y({ref:n,id:s,size:e=20,color:o,filled:t=!1,rounded:r=!0,checked:a=!1,onCheckedChange:d,disabled:c,className:f="",...m}){const l=u.useId(),p=u.useMemo(()=>s||`checkbox-${l}`,[s,l]),h=J(p),[b,v]=u.useState(a);u.useEffect(()=>{v(a)},[a]);const x=()=>{c||(v(!b),d==null||d(!b))},w=j=>{j.key===" "&&(j.preventDefault(),x())},g=y.join("flex items-center justify-center border outline outline-transparent focus:outline-current focus:outline-offset-2",r&&"rounded",c&&"opacity-40 cursor-not-allowed",!c&&"cursor-pointer",f);return i.jsx("button",{id:p,type:"button",ref:n,tabIndex:0,role:"checkbox",onClick:x,"aria-checked":b,"aria-disabled":c,onKeyDownCapture:w,style:{width:e,height:e,color:o,backgroundColor:b&&t?"currentcolor":"transparent"},className:g,...m,children:b&&i.jsx(E.Check,{size:e,color:t?h:void 0})})}function O({children:n,className:s,linkTo:e,linkProps:o,onButtonClick:t,buttonProps:r,...a}){return e&&t&&console.warn('Clickable: Both "linkTo" and "onButtonClick" props are provided. Only "linkTo" will be used.'),i.jsxs("div",{className:y.join("relative w-fit",s),...a,children:[n,e&&i.jsx("a",{...o,rel:(o==null?void 0:o.rel)||"noreferrer",href:e,className:y.join("absolute inset-0",o==null?void 0:o.className)}),!e&&t&&i.jsx("button",{...r,type:"button",onClick:t,className:y.join("absolute inset-0 cursor-pointer",r==null?void 0:r.className)})]})}function R({elementId:n,type:s,message:e}){return u.useEffect(()=>{const o=document.getElementById(n);if(o){if(!e&&s==="error"){o.removeAttribute("data-error");return}if(!e&&s==="success"){o.removeAttribute("data-success");return}return o.setAttribute("aria-describedby",`${n}-${s}-message`),o.setAttribute("aria-invalid",s==="error"?"true":"false"),s==="error"&&o.setAttribute("data-error","true"),s==="success"&&o.setAttribute("data-success","true"),()=>{o.removeAttribute("aria-describedby"),o.removeAttribute("aria-invalid"),o.removeAttribute("data-error"),o.removeAttribute("data-success")}}},[n,s,e]),e?i.jsxs("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-start",s==="error"&&"text-destructive",s==="success"&&"text-success"),role:"status",children:[s==="error"?i.jsx(E.ExclamationTriangle,{}):i.jsx(E.CheckCircled,{}),i.jsx("span",{id:`${n}-${s}-message`,children:e})]}):null}const P={base:"",default:"ring ring-transparent focus:ring-primary-foreground not-disabled:data-error:ring-destructive not-disabled:data-success:ring-success",underline:"border-b border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},ee={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},H={variant:"default",rounded:"none"};function te({variant:n=H.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:o,successMessage:t,type:r="text",className:a,...d}){const c=u.useId(),[f,m]=u.useState(!1);let l=s;n==="outline"&&!s&&(l="md"),l=l||H.rounded;const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all","file:mr-2 file:border-0 file:rounded-md file:px-1.5 file:py-1 file:bg-primary hover:file:bg-primary/85 file:text-sm file:font-medium file:text-foreground file:transition-colors",!e&&P[n],!e&&ee[l],r==="password"&&"pr-10",!e&&"px-2 py-1",e&&"pointer-events-none",a);return i.jsxs("div",{className:y.join(e&&"cursor-text"),style:{height:d.height,width:d.width},children:[i.jsxs("div",{className:y.join(r==="password"&&"relative"),children:[i.jsx("input",{...d,id:c,type:r==="password"&&f?"text":r,"aria-disabled":d.disabled,readOnly:e,"aria-readonly":e||d["aria-readonly"],"data-error":o?!0:void 0,"data-success":t?!0:void 0,className:b}),r==="password"&&i.jsx("button",{onClick:()=>m(!f),className:"absolute inset-y-0 right-0 px-2 hover:cursor-pointer","aria-label":"Toggle password visibility","data-state":f?"visible":"hidden",children:f?i.jsx(E.EyeClosed$1,{size:20}):i.jsx(E.EyeClosed,{size:20})})]}),!e&&i.jsx(R,{elementId:c,type:"error",message:o}),!e&&i.jsx(R,{elementId:c,type:"success",message:t})]})}function re({display:n="inline",width:s="fit-content",className:e="",required:o,helpMessage:t,suffix:r,htmlFor:a,children:d,...c}){const f=u.useId(),m=y.join("font-medium",n,e),l=t?`${a??f}-help`:void 0;return i.jsxs("div",{style:{display:n==="inline"?"inline-flex":"flex",width:s},className:"relative",children:[i.jsxs("label",{className:m,htmlFor:a,...c,children:[d,o&&i.jsx("span",{className:"text-red-500 font-medium ml-1","aria-label":"required",children:"*"})]}),t&&i.jsx("span",{className:"text-gray-500 ml-1 size-fit -translate-y-1/3","aria-describedby":l,"aria-label":"Help information",title:t,children:i.jsx(E.QuestionMarkCircled,{})}),t&&i.jsx("div",{id:l,className:"sr-only",children:t}),r&&i.jsx("span",{className:"ml-1",children:r})]})}function oe(n){const[s,e]=u.useState(!1),[o,t]=u.useState(!1);return u.useEffect(()=>{n?(t(!0),setTimeout(()=>e(!0),10)):(e(!1),setTimeout(()=>t(!1),150))},[n]),{show:s,shouldRender:o}}function ne(n,s){u.useEffect(()=>{const e=o=>{o.key==="Escape"&&n&&s()};return document.addEventListener("keydown",e),n&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow="auto"}},[n,s])}function se(n,s){const e=u.useRef(null),o=u.useCallback(()=>{const t=document.getElementById(n);if(!t)return;const r=t.querySelectorAll('[data-modal-action="true"]');if(r.length>0){r[0].focus();return}const a=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(a.length>0){const d=Array.from(a).filter(c=>!(c instanceof HTMLButtonElement&&c.getAttribute("data-modal-close-button")==="true"));if(d.length>0){d[0].focus();return}a[0].focus();return}t.focus()},[n]);u.useEffect(()=>(s&&(e.current=document.activeElement,o()),()=>{document.body.style.overflow="auto",e.current instanceof HTMLElement&&e.current.focus()}),[s,o])}function ae({id:n,isOpen:s,onClose:e,title:o,children:t,contentOnly:r=!1,className:a,overlayClassName:d,hideCloseButton:c=!1,actions:f=[],disableCloseOnOverlayClick:m=!1,ariaLabelledBy:l,ariaDescribedBy:p}){const h=u.useId(),b=n||`modal-${h}`,v=n?`${n}-title`:`modal-title-${h}`,{show:x,shouldRender:w}=oe(s);if(se(b,w),ne(w,e),!w)return null;const g=()=>o?u.isValidElement(o)?i.jsx("div",{className:"mb-4",children:o}):i.jsx("h2",{className:"mb-4 text-xl font-semibold",id:v,children:o}):null,j=()=>f.length===0?null:i.jsx("div",{className:"mt-6 not-sm:grid gap-y-2 sm:flex sm:justify-start sm:flex-row-reverse sm:gap-x-3",children:f.map((N,D)=>{const{label:L,className:I,...A}=N;return i.jsx(M,{className:I,type:"button",...A,"data-modal-action":"true",children:L},D)})});return i.jsx(i.Fragment,{children:K.createPortal(i.jsx("div",{"aria-labelledby":l??o?v:void 0,"aria-describedby":p,role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] overflow-y-auto",children:i.jsxs("div",{className:"flex min-h-screen items-center justify-center p-4",children:[i.jsx("div",{className:$.n("fixed inset-0 bg-black/20 transition-all",d),onClick:()=>{m||e()}}),r&&i.jsx("div",{className:$.n("relative w-fit",a),children:t}),!r&&i.jsxs("div",{id:b,tabIndex:-1,className:$.n("relative w-full max-w-xl transform rounded-lg shadow-xl transition-all p-6 bg-inherit focus:ring ease-in duration-75",x?"opacity-100 scale-100":"opacity-0 scale-90",a),children:[!c&&i.jsx("button",{type:"button",onClick:e,"data-modal-close-button":"true",className:"rounded-md p-0.5 top-2.5 right-2.5 absolute opacity-80 hover:opacity-100 transition-opacity focus:outline-none focus:ring-2 focus:ring-gray-500 leading-0",children:i.jsx(E.X,{size:18})}),g(),t,j()]})]})}),document.body)})}function U({itemId:n,checked:s,onChange:e,name:o,disabled:t=!1,className:r=""}){const a="relative inline-flex items-center justify-center rounded-full",d=()=>{t||e()},c=y.join(a,!s&&"hover:border-current/60",!t&&"border-current cursor-pointer",t&&"border-muted/60 cursor-not-allowed",r);return i.jsx("div",{id:n,role:"radio",tabIndex:-1,"aria-checked":s,"aria-disabled":t,"aria-description":`Radio button for ${o}`,"aria-labelledby":`${n}-label`,onClick:d,className:c,style:{width:"1em",height:"1em",padding:"0.1em",borderWidth:"0.06em"},children:s&&i.jsx("div",{className:y.join("size-full aspect-square rounded-full",t&&"bg-muted/60",!t&&"bg-current")})})}function T({value:n,children:s,className:e="",isSelected:o=!1,onChange:t,disabled:r=!1,hideInput:a=!1,description:d,name:c}){const m=`radio-${u.useId()}-${n}`,l=()=>{r||t==null||t(n)};return i.jsxs("div",{title:d,className:y.join("relative flex items-center",e,a&&`p-2 border-2 focus-within:border-dashed focus-within:${r?"border-current/50":"border-current/80"}`,a&&!o&&`border-transparent ${r?"":"not-focus-within:hover:border-border/60"}`,a&&o&&"border-border",r&&"opacity-60 cursor-not-allowed"),style:{gap:"0.5em"},children:[!a&&i.jsx(U,{itemId:m,name:c||"",checked:o,onChange:l,disabled:r,className:y.join(a&&"")}),i.jsx("div",{id:a?m:void 0,tabIndex:a?-1:void 0,role:a?"radio":void 0,onClick:a?l:void 0,"aria-checked":a?o?"true":"false":void 0,"aria-disabled":a?r:void 0,"aria-description":a?d||`Radio button for ${c}`:void 0,"aria-labelledby":a?`${m}-label`:void 0,className:y.join(a&&"size-full",typeof s=="object"&&"grow focus:outline-none"),children:i.jsx("label",{id:`${m}-label`,onClick:a?void 0:l,className:y.join(r&&"cursor-not-allowed",!r&&"cursor-pointer"),children:s})})]})}function ie(n,s){const[e,o]=u.useState(s),[t,r]=u.useState(-1),[a,d]=u.useState(!1),c=u.useCallback((h,b)=>{var w;const v=h[b];v.hasAttribute("disabled")||v.getAttribute("aria-disabled")==="true"||((w=h[b])==null||w.click(),r(b))},[]),f=u.useCallback((h,b)=>{var x;if(h.preventDefault(),a||!b.length)return;const v=s!==-1?s:0;(x=b[v])==null||x.focus(),o(v),s!==-1&&c(b,v)},[s,a,c]),m=u.useCallback(h=>{var w;if(!h.shiftKey)return;h.preventDefault();const b=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(g=>!g.hasAttribute("disabled")&&g.tabIndex>=0),v=b.findIndex(g=>g.id===n),x=v>0?v-1:b.length-1;(w=b[x])==null||w.focus()},[n]),l=u.useCallback((h,b)=>{var j;if(!b.length)return;const v=h.target;if(!b.some(N=>N.id===v.id))return;const w=e!==-1?e:0;let g=w;switch(h.key){case"ArrowUp":case"ArrowLeft":h.preventDefault(),g=w>0?w-1:b.length-1;break;case"ArrowDown":case"ArrowRight":h.preventDefault(),g=(w+1)%b.length;break;case" ":h.preventDefault(),c(b,w);return;case"Tab":m(h);return;default:return}(j=b[g])==null||j.focus(),o(g),t!==-1&&c(b,g)},[e,t,m,c]),p=u.useCallback(()=>{const h=document.querySelector(`[id="${n}"][role="radiogroup"]`);return h?Array.from(h.querySelectorAll('[role="radio"]')):[]},[n]);u.useEffect(()=>{const h=document.querySelector(`[id="${n}"][role="radiogroup"]`);if(!h)return;const b=p(),v=j=>f(j,b),x=j=>l(j,b),w=()=>d(!0),g=()=>d(!1);return document.addEventListener("keydown",x),h.addEventListener("focus",v),h.addEventListener("mousedown",w),document.addEventListener("mouseup",g),()=>{document.removeEventListener("keydown",x),h.removeEventListener("focus",v),h.removeEventListener("mousedown",w),document.removeEventListener("mouseup",g)}},[n,p,f,l])}function ue({options:n=[],value:s,onChange:e,id:o,children:t,className:r="",childrenClassName:a="",hideInputs:d=!1}){const c=u.useId(),f=o||`radio-group-${c}`;ie(f,n.findIndex(l=>l===s));const m=u.useMemo(()=>n.reduce((l,p)=>(typeof p=="string"?l.some(h=>h.value===p)||l.push({label:p,value:p}):l.push(p),l),[]),[n]);return i.jsxs("div",{id:f,role:"radiogroup",tabIndex:0,className:y.join(r,"focus:outline-none"),children:[m.length>0&&m.map((l,p)=>i.jsx(T,{value:l.value,isSelected:s===l.value,onChange:e,name:f,disabled:l.disabled,description:l.description,hideInput:d,className:a,children:l.label},`${l.value}-${p}`)),m.length===0&&t&&u.Children.map(t,l=>u.isValidElement(l)&&l.type===T?i.jsx(T,{...l.props,className:y.join(a,l.props.className),hideInput:l.props.hideInput||d,isSelected:s===l.props.value,onChange:e,name:f,children:l.props.children}):null)]})}function le({children:n,ref:s,...e}){if(u.isValidElement(n)){let o={...e};return n.props&&(o={...o,...n.props}),u.cloneElement(n,{...o,ref:t=>{typeof s=="function"?s(t):s&&(s.current=t)}})}return u.createElement("div",{...e,ref:s},n)}function de({elementId:n,maxLength:s}){const[e,o]=u.useState(0);return u.useEffect(()=>{const t=document.getElementById(n);if(!t)return;const r=()=>{const a=t.value.length;o(a);const d=a>=s;t.setAttribute("aria-describedby",`${n}-character-count`),t.setAttribute("aria-invalid",d?"true":"false"),d?t.setAttribute("data-error","true"):t.removeAttribute("data-error")};return r(),t.addEventListener("input",r),t.setAttribute("maxlength",String(s)),()=>{t.removeEventListener("input",r),t.removeAttribute("maxlength"),t.removeAttribute("aria-describedby"),t.removeAttribute("aria-invalid"),t.removeAttribute("data-error")}},[n,s]),i.jsx("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-end",e>=s&&"text-destructive",e<s&&"text-current"),role:"status",children:i.jsxs("span",{id:`${n}-character-count`,children:[e," / ",s," characters"]})})}function ce(n,s){u.useEffect(()=>{const e=document.getElementById(n);if(!e)return;if(!s){e.style.height="auto";return}const o=()=>{e.style.height="auto",e.style.height=`${e.scrollHeight}px`};return o(),e.addEventListener("input",o),e.addEventListener("resize",o),window.addEventListener("resize",o),()=>{e.removeEventListener("input",o),e.removeEventListener("resize",o),window.removeEventListener("resize",o)}},[n,s])}const fe={base:"","left-line":"border-l border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},me={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},G={variant:"outline",rounded:"none"};function be({variant:n=G.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:o,successMessage:t,hideResizeHandle:r=!1,autoExpand:a=!1,characterLimit:d=0,className:c,...f}){const m=u.useId();ce(m,a||e);let l=s;n==="outline"&&!s&&(l="md"),l=l||G.rounded;let p=r;(e||n==="left-line"&&!r)&&(p=!0);const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",!e&&fe[n],!e&&me[l],!e&&"px-2 py-1",e&&"pointer-events-none",p&&"no-resize-handle",c);return i.jsxs("div",{className:y.join("-space-y-1.5",e&&"cursor-text"),children:[i.jsx("textarea",{...f,id:m,"aria-disabled":f.disabled,readOnly:e,"aria-readonly":e||f["aria-readonly"],style:{resize:a?"none":void 0},className:b}),d>0&&i.jsx(de,{elementId:m,maxLength:d}),!e&&i.jsx(R,{elementId:m,type:"error",message:o}),!e&&i.jsx(R,{elementId:m,type:"success",message:t})]})}function he(n){return{calculatePosition:u.useCallback((e,o)=>{const t=e.getBoundingClientRect(),r=o.getBoundingClientRect(),a={width:window.innerWidth,height:window.innerHeight},d=(p,h,b,v)=>p<0||h<0||p+b>a.width||h+v>a.height,c={top:{x:t.left+t.width/2-r.width/2,y:t.top-r.height-k,arrow:{x:r.width/2-C,y:r.height}},bottom:{x:t.left+t.width/2-r.width/2,y:t.bottom+k,arrow:{x:r.width/2-C,y:-6}},left:{x:t.left-r.width-k,y:t.top+t.height/2-r.height/2,arrow:{x:r.width,y:r.height/2-C}},right:{x:t.right+k,y:t.top+t.height/2-r.height/2,arrow:{x:-6,y:r.height/2-C}}};let f=n,m=c[n];if(d(m.x,m.y,r.width,r.height)){const p={top:"bottom",bottom:"top",left:"right",right:"left"},h=c[p[n]];if(!d(h.x,h.y,r.width,r.height))f=p[n],m=h;else{const b=["top","bottom","left","right"].filter(v=>v!==n&&v!==p[n]);for(const v of b){const x=c[v];if(!d(x.x,x.y,r.width,r.height)){f=v,m=x;break}}}}m.x=Math.max(8,Math.min(m.x,a.width-r.width-8)),m.y=Math.max(8,Math.min(m.y,a.height-r.height-8));const l={x:t.left+t.width/2,y:t.top+t.height/2};return f==="top"||f==="bottom"?m.arrow.x=Math.max(C,Math.min(l.x-m.x-C,r.width-C*2)):m.arrow.y=Math.max(C,Math.min(l.y-m.y-C,r.height-C*2)),{...m,placement:f}},[n])}}function xe(n,s,e){const o=u.useRef(null),t=u.useRef(null),r=u.useCallback(()=>{if(!o.current||!t.current)return;const a=n(o.current,t.current);e(a)},[n,e]);return u.useEffect(()=>{if(!s)return;const a=()=>r();return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,r]),{triggerRef:o,tooltipRef:t,updatePosition:r}}function ge(n,s,e,o,t,r,a,d,c){const f=u.useRef(null),m=u.useCallback(()=>{n||(f.current&&clearTimeout(f.current),f.current=window.setTimeout(()=>{e(!0),requestAnimationFrame(()=>{t(),o(!0)})},s))},[n,s,e,t,o]),l=u.useCallback((p=!1)=>{if(f.current&&clearTimeout(f.current),p){o(!1),setTimeout(()=>e(!1),150);return}f.current=window.setTimeout(()=>{o(!1),setTimeout(()=>e(!1),150)},100)},[o,e]);return u.useEffect(()=>{!r&&!a&&!d&&c&&l()},[r,a,d,c,l]),u.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{showTooltip:m,hideTooltip:l,timeoutRef:f}}const k=4,C=6;function pe({id:n,children:s,message:e,placement:o="top",disabled:t=!1,delay:r=200,className:a}){const[d,c]=u.useState(!1),[f,m]=u.useState(!1),[l,p]=u.useState(null),[h,b]=u.useState(!1),[v,x]=u.useState(!1),[w,g]=u.useState(!1),{calculatePosition:j}=he(o),{triggerRef:N,tooltipRef:D,updatePosition:L}=xe(j,f,p),{showTooltip:I,hideTooltip:A,timeoutRef:q}=ge(t,r,m,c,L,h,v,w,d),W=u.useId(),F=n??W;return i.jsxs(i.Fragment,{children:[u.cloneElement(s,{ref:z=>{N.current=z},onMouseEnter:()=>{b(!0),I()},onMouseLeave:()=>{b(!1)},onFocus:()=>{g(!0),I()},onBlur:()=>{g(!1),A(!0)},onKeyDown:z=>{z.key==="Escape"&&A(!0)},"aria-describedby":t?void 0:F}),f&&K.createPortal(i.jsx("div",{ref:D,id:F,role:"tooltip",className:y.join("fixed z-50 px-2 py-1 text-sm rounded shadow-lg pointer-events-auto transition-all duration-150 ease-out",d?"opacity-100":"opacity-0",a),style:l?{left:l.x,top:l.y}:{opacity:0},onMouseEnter:()=>{x(!0),q.current&&clearTimeout(q.current)},onMouseLeave:()=>{x(!1)},children:e}),document.body)]})}exports.ActionModal=$.ActionModal;exports.Accordion=Q;exports.AccordionItem=S;exports.Button=M;exports.ButtonLoadingDots=V;exports.Checkbox=Y;exports.Clickable=O;exports.Input=te;exports.Label=re;exports.Modal=ae;exports.RadioGroup=ue;exports.RadioGroupItem=T;exports.RadioInput=U;exports.Slot=le;exports.Textarea=be;exports.Tooltip=pe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("react"),y=require("./utils.cjs.js"),E=require("./QuestionMarkCircled-o1tqa8ZJ.cjs"),S=require("./styles-Bxzm1DQb.cjs"),K=require("react-dom");function T({id:n,title:s,content:e,children:o,className:t="",disabled:r=!1,isOpen:a=!1,onToggle:d,triggerClassName:c="",bodyClassName:f=""}){const m=u.useId(),l=n||`accordion-item-${m}`,p=`${l}-header`,h=`${l}-panel`,b=()=>{!r&&d&&d()},v=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),b())};return i.jsxs("div",{className:y.join("border-b border-gray-200",r&&"opacity-60 cursor-not-allowed",t),children:[i.jsxs("button",{id:p,type:"button",className:y.join("w-full text-left py-3 px-4 flex justify-between items-center focus:outline focus:outline-secondary",r?"cursor-not-allowed":"hover:bg-gray-50/10 cursor-pointer",c),"aria-expanded":a,"aria-controls":h,disabled:r,onClick:b,onKeyDown:v,children:[i.jsx("span",{children:s}),i.jsx("span",{className:y.join("transform transition-transform duration-300 ease-linear",a?"rotate-180":"rotate-0"),"aria-hidden":"true",children:i.jsx(E.ChevronDown,{size:18})})]}),i.jsx("div",{id:h,role:"region","aria-labelledby":p,className:y.join("transition-all duration-300 ease-linear px-4",a?"max-h-96 opacity-100 overflow-auto py-3":"max-h-0 opacity-0 overflow-hidden",f),children:a&&(o||e)})]})}function Q({id:n,items:s=[],children:e,className:o="",itemClassName:t="",allowMultiple:r=!1,defaultOpenItems:a=[],triggersClassName:d="",bodiesClassName:c=""}){const f=u.useId(),m=n||`accordion-group-${f}`,[l,p]=u.useState(new Set(a)),h=x=>{p(w=>{const g=new Set(w);return g.has(x)?g.delete(x):(r||g.clear(),g.add(x)),g})},b=x=>`${f}-item-${x}`,v=x=>l.has(x);return i.jsxs("div",{id:m,className:o,children:[s.length>0&&s.map((x,w)=>{const g=x.id||b(w);return i.jsx(T,{id:g,title:x.title,content:x.content,disabled:x.disabled,isOpen:v(g),onToggle:()=>h(g),className:t,triggerClassName:d,bodyClassName:c},g)}),s.length===0&&e&&u.Children.map(e,(x,w)=>{if(u.isValidElement(x)&&x.type===T){const g=x.props.id||b(w);return u.createElement(T,{...x.props,key:g,id:g,className:y.join(t,x.props.className),isOpen:v(g),onToggle:()=>h(g),triggerClassName:y.join(d,x.props.triggerClassName),bodyClassName:y.join(c,x.props.bodyClassName)})}return null})]})}function M(){const[n,s]=u.useState(0);return u.useEffect(()=>{const e=setInterval(()=>{s(o=>(o+1)%3)},500);return()=>clearInterval(e)},[]),i.jsx("div",{className:"absolute inset-0 inline-flex items-center justify-center gap-x-2 align-middle",children:[0,1,2].map(e=>i.jsx("div",{className:y.join("rounded-full transition-all duration-500 ease-in-out size-[0.35em] bg-current",n===e&&"transform -translate-y-1")},e))})}const X={base:"",primary:"bg-primary text-primary-foreground hover:bg-primary/85 disabled:bg-muted disabled:text-muted-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/85 disabled:bg-muted/80 disabled:text-muted-foreground/80",tertiary:"text-primary hover:text-primary-foreground disabled:text-muted",outline:"border border-primary text-primary hover:border-primary-foreground hover:text-primary-foreground disabled:border-muted disabled:text-muted",link:"underline-offset-4 hover:underline disabled:underline disabled:text-muted",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/85 disabled:bg-muted disabled:text-muted-foreground"},Z={stripped:"",fitted:"size-fit",sm:"px-2 py-1 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg",icon:"p-1 w-fit aspect-square",full:"p-2 w-full"},J={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"},q={variant:"primary",size:"md",rounded:"md"};function W({variant:n=q.variant,size:s,rounded:e=q.rounded,loading:o,linkTo:t,linkProps:r,type:a="button",className:d,...c}){let f;n==="link"&&!s?f="fitted":f=s||q.size;const l=y.join("appearance-none focus:outline-none focus:ring not-disabled:hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed transition-all",X[n],Z[f],J[e],o&&"relative pointer-events-none",t&&"relative",d);return i.jsxs("button",{...c,role:t?"link":c.role,"aria-label":c["aria-label"]||(r==null?void 0:r["aria-label"]),"aria-description":c["aria-description"]||(r==null?void 0:r["aria-description"]),"aria-disabled":c.disabled||o,"aria-busy":o,type:a,className:l,children:[o&&i.jsx(M,{}),i.jsx("span",{className:y.join(o&&"invisible"),children:c.children}),t&&!c.disabled&&i.jsx("a",{...r,"aria-hidden":!0,href:t,rel:(r==null?void 0:r.rel)||"noreferrer",className:"absolute inset-0"})]})}function Y(n){const[s,e]=u.useState(""),o=u.useCallback(t=>{let r=t,a="";for(;r&&!a;){const d=window.getComputedStyle(r).backgroundColor;d&&d!=="transparent"&&d!=="rgba(0, 0, 0, 0)"&&(a=d),r=r.parentElement}return a||"transparent"},[]);return u.useEffect(()=>{const t=document.getElementById(n);if(t){const r=o(t.parentElement);e(r)}},[n,o]),s}function O({ref:n,id:s,size:e=20,color:o,filled:t=!1,rounded:r=!0,checked:a=!1,onCheckedChange:d,disabled:c,className:f="",...m}){const l=u.useId(),p=u.useMemo(()=>s||`checkbox-${l}`,[s,l]),h=Y(p),[b,v]=u.useState(a);u.useEffect(()=>{v(a)},[a]);const x=()=>{c||(v(!b),d==null||d(!b))},w=j=>{j.key===" "&&(j.preventDefault(),x())},g=y.join("flex items-center justify-center border outline outline-transparent focus:outline-current focus:outline-offset-2",r&&"rounded",c&&"opacity-40 cursor-not-allowed",!c&&"cursor-pointer",f);return i.jsx("button",{id:p,type:"button",ref:n,tabIndex:0,role:"checkbox",onClick:x,"aria-checked":b,"aria-disabled":c,onKeyDownCapture:w,style:{width:e,height:e,color:o,backgroundColor:b&&t?"currentcolor":"transparent"},className:g,...m,children:b&&i.jsx(E.Check,{size:e,color:t?h:void 0})})}function P({children:n,className:s,linkTo:e,linkProps:o,onButtonClick:t,buttonProps:r,...a}){return e&&t&&console.warn('Clickable: Both "linkTo" and "onButtonClick" props are provided. Only "linkTo" will be used.'),i.jsxs("div",{className:y.join("relative w-fit",s),...a,children:[n,e&&i.jsx("a",{...o,rel:(o==null?void 0:o.rel)||"noreferrer",href:e,className:y.join("absolute inset-0",o==null?void 0:o.className)}),!e&&t&&i.jsx("button",{...r,type:"button",onClick:t,className:y.join("absolute inset-0 cursor-pointer",r==null?void 0:r.className)})]})}function D({elementId:n,type:s,message:e}){return u.useEffect(()=>{const o=document.getElementById(n);if(o){if(!e&&s==="error"){o.removeAttribute("data-error");return}if(!e&&s==="success"){o.removeAttribute("data-success");return}return o.setAttribute("aria-describedby",`${n}-${s}-message`),o.setAttribute("aria-invalid",s==="error"?"true":"false"),s==="error"&&o.setAttribute("data-error","true"),s==="success"&&o.setAttribute("data-success","true"),()=>{o.removeAttribute("aria-describedby"),o.removeAttribute("aria-invalid"),o.removeAttribute("data-error"),o.removeAttribute("data-success")}}},[n,s,e]),e?i.jsxs("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-start",s==="error"&&"text-destructive",s==="success"&&"text-success"),role:"status",children:[s==="error"?i.jsx(E.ExclamationTriangle,{}):i.jsx(E.CheckCircled,{}),i.jsx("span",{id:`${n}-${s}-message`,children:e})]}):null}const ee={base:"",default:"ring ring-transparent focus:ring-primary-foreground not-disabled:data-error:ring-destructive not-disabled:data-success:ring-success",underline:"border-b border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},te={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},G={variant:"default",rounded:"none"};function re({variant:n=G.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:o,successMessage:t,type:r="text",className:a,...d}){const c=u.useId(),[f,m]=u.useState(!1);let l=s;n==="outline"&&!s&&(l="md"),l=l||G.rounded;const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all","file:mr-2 file:border-0 file:rounded-md file:px-1.5 file:py-1 file:bg-primary hover:file:bg-primary/85 file:text-sm file:font-medium file:text-foreground file:transition-colors",!e&&ee[n],!e&&te[l],r==="password"&&"pr-10",!e&&"px-2 py-1",e&&"pointer-events-none",a);return i.jsxs("div",{className:y.join(e&&"cursor-text"),style:{height:d.height,width:d.width},children:[i.jsxs("div",{className:y.join(r==="password"&&"relative"),children:[i.jsx("input",{...d,id:c,type:r==="password"&&f?"text":r,"aria-disabled":d.disabled,readOnly:e,"aria-readonly":e||d["aria-readonly"],"data-error":o?!0:void 0,"data-success":t?!0:void 0,className:b}),r==="password"&&i.jsx("button",{onClick:()=>m(!f),className:"absolute inset-y-0 right-0 px-2 hover:cursor-pointer","aria-label":"Toggle password visibility","data-state":f?"visible":"hidden",children:f?i.jsx(E.EyeClosed$1,{size:20}):i.jsx(E.EyeClosed,{size:20})})]}),!e&&i.jsx(D,{elementId:c,type:"error",message:o}),!e&&i.jsx(D,{elementId:c,type:"success",message:t})]})}function oe({display:n="inline",width:s="fit-content",className:e="",required:o,helpMessage:t,suffix:r,htmlFor:a,children:d,...c}){const f=u.useId(),m=y.join("font-medium",n,e),l=t?`${a??f}-help`:void 0;return i.jsxs("div",{style:{display:n==="inline"?"inline-flex":"flex",width:s},className:"relative",children:[i.jsxs("label",{className:m,htmlFor:a,...c,children:[d,o&&i.jsx("span",{className:"text-red-500 font-medium ml-1","aria-label":"required",children:"*"})]}),t&&i.jsx("span",{className:"text-gray-500 ml-1 size-fit -translate-y-1/3","aria-describedby":l,"aria-label":"Help information",title:t,children:i.jsx(E.QuestionMarkCircled,{})}),t&&i.jsx("div",{id:l,className:"sr-only",children:t}),r&&i.jsx("span",{className:"ml-1",children:r})]})}function ne(n){const[s,e]=u.useState(!1),[o,t]=u.useState(!1);return u.useEffect(()=>{n?(t(!0),setTimeout(()=>e(!0),10)):(e(!1),setTimeout(()=>t(!1),150))},[n]),{show:s,shouldRender:o}}function se(n,s){u.useEffect(()=>{const e=o=>{o.key==="Escape"&&n&&s()};return document.addEventListener("keydown",e),n&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow="auto"}},[n,s])}function ae(n,s){const e=u.useRef(null),o=u.useCallback(()=>{const t=document.getElementById(n);if(!t)return;const r=t.querySelectorAll('[data-modal-action="true"]');if(r.length>0){r[0].focus();return}const a=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(a.length>0){const d=Array.from(a).filter(c=>!(c instanceof HTMLButtonElement&&c.getAttribute("data-modal-close-button")==="true"));if(d.length>0){d[0].focus();return}a[0].focus();return}t.focus()},[n]);u.useEffect(()=>(s&&(e.current=document.activeElement,o()),()=>{document.body.style.overflow="auto",e.current instanceof HTMLElement&&e.current.focus()}),[s,o])}function ie({id:n,isOpen:s,onClose:e,title:o,children:t,contentOnly:r=!1,className:a,overlayClassName:d,hideCloseButton:c=!1,actions:f=[],disableCloseOnOverlayClick:m=!1,ariaLabelledBy:l,ariaDescribedBy:p}){const h=u.useId(),b=n||`modal-${h}`,v=n?`${n}-title`:`modal-title-${h}`,{show:x,shouldRender:w}=ne(s);if(ae(b,w),se(w,e),!w)return null;const g=()=>o?u.isValidElement(o)?i.jsx("div",{className:"mb-4",children:o}):i.jsx("h2",{className:"mb-4 text-xl font-semibold",id:v,children:o}):null,j=()=>f.length===0?null:i.jsx("div",{className:"mt-6 not-sm:grid gap-y-2 sm:flex sm:justify-start sm:flex-row-reverse sm:gap-x-3",children:f.map((N,L)=>{const{label:z,className:I,...A}=N;return i.jsx(W,{className:I,type:"button",...A,"data-modal-action":"true",children:z},L)})});return i.jsx(i.Fragment,{children:K.createPortal(i.jsx("div",{"aria-labelledby":l??o?v:void 0,"aria-describedby":p,role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] overflow-y-auto",children:i.jsxs("div",{className:"flex min-h-screen items-center justify-center p-4",children:[i.jsx("div",{className:S.n("fixed inset-0 bg-black/20 transition-all",d),onClick:()=>{m||e()}}),r&&i.jsx("div",{className:S.n("relative w-fit",a),children:t}),!r&&i.jsxs("div",{id:b,tabIndex:-1,className:S.n("relative w-full max-w-xl transform rounded-lg shadow-xl transition-all p-6 bg-inherit focus:ring ease-in duration-75",x?"opacity-100 scale-100":"opacity-0 scale-90",a),children:[!c&&i.jsx("button",{type:"button",onClick:e,"data-modal-close-button":"true",className:"rounded-md p-0.5 top-2.5 right-2.5 absolute opacity-80 hover:opacity-100 transition-opacity focus:outline-none focus:ring-2 focus:ring-gray-500 leading-0",children:i.jsx(E.X,{size:18})}),g(),t,j()]})]})}),document.body)})}function U({itemId:n,checked:s,onChange:e,name:o,disabled:t=!1,className:r=""}){const a="relative inline-flex items-center justify-center rounded-full",d=()=>{t||e()},c=y.join(a,!s&&"hover:border-current/60",!t&&"border-current cursor-pointer",t&&"border-muted/60 cursor-not-allowed",r);return i.jsx("div",{id:n,role:"radio",tabIndex:-1,"aria-checked":s,"aria-disabled":t,"aria-description":`Radio button for ${o}`,"aria-labelledby":`${n}-label`,onClick:d,className:c,style:{width:"1em",height:"1em",padding:"0.1em",borderWidth:"0.06em"},children:s&&i.jsx("div",{className:y.join("size-full aspect-square rounded-full",t&&"bg-muted/60",!t&&"bg-current")})})}function R({value:n,children:s,className:e="",isSelected:o=!1,onChange:t,disabled:r=!1,hideInput:a=!1,description:d,name:c}){const m=`radio-${u.useId()}-${n}`,l=()=>{r||t==null||t(n)};return i.jsxs("div",{title:d,className:y.join("relative flex items-center",e,a&&`p-2 border-2 focus-within:border-dashed focus-within:${r?"border-current/50":"border-current/80"}`,a&&!o&&`border-transparent ${r?"":"not-focus-within:hover:border-border/60"}`,a&&o&&"border-border",r&&"opacity-60 cursor-not-allowed"),style:{gap:"0.5em"},children:[!a&&i.jsx(U,{itemId:m,name:c||"",checked:o,onChange:l,disabled:r,className:y.join(a&&"")}),i.jsx("div",{id:a?m:void 0,tabIndex:a?-1:void 0,role:a?"radio":void 0,onClick:a?l:void 0,"aria-checked":a?o?"true":"false":void 0,"aria-disabled":a?r:void 0,"aria-description":a?d||`Radio button for ${c}`:void 0,"aria-labelledby":a?`${m}-label`:void 0,className:y.join(a&&"size-full",typeof s=="object"&&"grow focus:outline-none"),children:i.jsx("label",{id:`${m}-label`,onClick:a?void 0:l,className:y.join(r&&"cursor-not-allowed",!r&&"cursor-pointer"),children:s})})]})}function ue(n,s){const[e,o]=u.useState(s),[t,r]=u.useState(-1),[a,d]=u.useState(!1),c=u.useCallback((h,b)=>{var w;const v=h[b];v.hasAttribute("disabled")||v.getAttribute("aria-disabled")==="true"||((w=h[b])==null||w.click(),r(b))},[]),f=u.useCallback((h,b)=>{var x;if(h.preventDefault(),a||!b.length)return;const v=s!==-1?s:0;(x=b[v])==null||x.focus(),o(v),s!==-1&&c(b,v)},[s,a,c]),m=u.useCallback(h=>{var w;if(!h.shiftKey)return;h.preventDefault();const b=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(g=>!g.hasAttribute("disabled")&&g.tabIndex>=0),v=b.findIndex(g=>g.id===n),x=v>0?v-1:b.length-1;(w=b[x])==null||w.focus()},[n]),l=u.useCallback((h,b)=>{var j;if(!b.length)return;const v=h.target;if(!b.some(N=>N.id===v.id))return;const w=e!==-1?e:0;let g=w;switch(h.key){case"ArrowUp":case"ArrowLeft":h.preventDefault(),g=w>0?w-1:b.length-1;break;case"ArrowDown":case"ArrowRight":h.preventDefault(),g=(w+1)%b.length;break;case" ":h.preventDefault(),c(b,w);return;case"Tab":m(h);return;default:return}(j=b[g])==null||j.focus(),o(g),t!==-1&&c(b,g)},[e,t,m,c]),p=u.useCallback(()=>{const h=document.querySelector(`[id="${n}"][role="radiogroup"]`);return h?Array.from(h.querySelectorAll('[role="radio"]')):[]},[n]);u.useEffect(()=>{const h=document.querySelector(`[id="${n}"][role="radiogroup"]`);if(!h)return;const b=p(),v=j=>f(j,b),x=j=>l(j,b),w=()=>d(!0),g=()=>d(!1);return document.addEventListener("keydown",x),h.addEventListener("focus",v),h.addEventListener("mousedown",w),document.addEventListener("mouseup",g),()=>{document.removeEventListener("keydown",x),h.removeEventListener("focus",v),h.removeEventListener("mousedown",w),document.removeEventListener("mouseup",g)}},[n,p,f,l])}function le({options:n=[],value:s,onChange:e,id:o,children:t,className:r="",childrenClassName:a="",hideInputs:d=!1}){const c=u.useId(),f=o||`radio-group-${c}`;ue(f,n.findIndex(l=>l===s));const m=u.useMemo(()=>n.reduce((l,p)=>(typeof p=="string"?l.some(h=>h.value===p)||l.push({label:p,value:p}):l.push(p),l),[]),[n]);return i.jsxs("div",{id:f,role:"radiogroup",tabIndex:0,className:y.join(r,"focus:outline-none"),children:[m.length>0&&m.map((l,p)=>i.jsx(R,{value:l.value,isSelected:s===l.value,onChange:e,name:f,disabled:l.disabled,description:l.description,hideInput:d,className:a,children:l.label},`${l.value}-${p}`)),m.length===0&&t&&u.Children.map(t,l=>u.isValidElement(l)&&l.type===R?i.jsx(R,{...l.props,className:y.join(a,l.props.className),hideInput:l.props.hideInput||d,isSelected:s===l.props.value,onChange:e,name:f,children:l.props.children}):null)]})}function de({children:n,ref:s,...e}){if(u.isValidElement(n)){let o={...e};return n.props&&(o={...o,...n.props}),u.cloneElement(n,{...o,ref:t=>{typeof s=="function"?s(t):s&&(s.current=t)}})}return u.createElement("div",{...e,ref:s},n)}function ce({elementId:n,maxLength:s}){const[e,o]=u.useState(0);return u.useEffect(()=>{const t=document.getElementById(n);if(!t)return;const r=()=>{const a=t.value.length;o(a);const d=a>=s;t.setAttribute("aria-describedby",`${n}-character-count`),t.setAttribute("aria-invalid",d?"true":"false"),d?t.setAttribute("data-error","true"):t.removeAttribute("data-error")};return r(),t.addEventListener("input",r),t.setAttribute("maxlength",String(s)),()=>{t.removeEventListener("input",r),t.removeAttribute("maxlength"),t.removeAttribute("aria-describedby"),t.removeAttribute("aria-invalid"),t.removeAttribute("data-error")}},[n,s]),i.jsx("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-end",e>=s&&"text-destructive",e<s&&"text-current"),role:"status",children:i.jsxs("span",{id:`${n}-character-count`,children:[e," / ",s," characters"]})})}function fe(n,s){u.useEffect(()=>{const e=document.getElementById(n);if(!e)return;if(!s){e.style.height="auto";return}const o=()=>{e.style.height="auto",e.style.height=`${e.scrollHeight}px`};return o(),e.addEventListener("input",o),e.addEventListener("resize",o),window.addEventListener("resize",o),()=>{e.removeEventListener("input",o),e.removeEventListener("resize",o),window.removeEventListener("resize",o)}},[n,s])}const me={base:"","left-line":"border-l border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},be={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},V={variant:"outline",rounded:"none"};function he({variant:n=V.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:o,successMessage:t,hideResizeHandle:r=!1,autoExpand:a=!1,characterLimit:d=0,className:c,...f}){const m=u.useId();fe(m,a||e);let l=s;n==="outline"&&!s&&(l="md"),l=l||V.rounded;let p=r;(e||n==="left-line"&&!r)&&(p=!0);const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",!e&&me[n],!e&&be[l],!e&&"px-2 py-1",e&&"pointer-events-none",p&&"no-resize-handle",c);return i.jsxs("div",{className:y.join("-space-y-1.5",e&&"cursor-text"),children:[i.jsx("textarea",{...f,id:m,"aria-disabled":f.disabled,readOnly:e,"aria-readonly":e||f["aria-readonly"],style:{resize:a?"none":void 0},className:b}),d>0&&i.jsx(ce,{elementId:m,maxLength:d}),!e&&i.jsx(D,{elementId:m,type:"error",message:o}),!e&&i.jsx(D,{elementId:m,type:"success",message:t})]})}const k=8,$=4,C=6;function xe(n){return{calculatePosition:u.useCallback((e,o)=>{const t=e.getBoundingClientRect(),r=o.getBoundingClientRect(),a={width:window.innerWidth,height:window.innerHeight},d=(p,h,b,v)=>p<0||h<0||p+b>a.width||h+v>a.height,c={top:{x:t.left+t.width/2-r.width/2,y:t.top-r.height-$,arrow:{x:r.width/2-C,y:r.height}},bottom:{x:t.left+t.width/2-r.width/2,y:t.bottom+$,arrow:{x:r.width/2-C,y:-6}},left:{x:t.left-r.width-$,y:t.top+t.height/2-r.height/2,arrow:{x:r.width,y:r.height/2-C}},right:{x:t.right+$,y:t.top+t.height/2-r.height/2,arrow:{x:-6,y:r.height/2-C}}};let f=n,m=c[n];if(d(m.x,m.y,r.width,r.height)){const p={top:"bottom",bottom:"top",left:"right",right:"left"},h=c[p[n]];if(!d(h.x,h.y,r.width,r.height))f=p[n],m=h;else{const b=["top","bottom","left","right"].filter(v=>v!==n&&v!==p[n]);for(const v of b){const x=c[v];if(!d(x.x,x.y,r.width,r.height)){f=v,m=x;break}}}}m.x=Math.max(k,Math.min(m.x,a.width-r.width-k)),m.y=Math.max(k,Math.min(m.y,a.height-r.height-k));const l={x:t.left+t.width/2,y:t.top+t.height/2};return f==="top"||f==="bottom"?m.arrow.x=Math.max(C,Math.min(l.x-m.x-C,r.width-C*2)):m.arrow.y=Math.max(C,Math.min(l.y-m.y-C,r.height-C*2)),{...m,placement:f}},[n])}}function ge(n,s,e){const o=u.useRef(null),t=u.useRef(null),r=u.useCallback(()=>{if(!o.current||!t.current)return;const a=n(o.current,t.current);e(a)},[n,e]);return u.useEffect(()=>{if(!s)return;const a=()=>r();return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,r]),{triggerRef:o,tooltipRef:t,updatePosition:r}}function pe(n,s,e,o,t,r,a,d,c){const f=u.useRef(null),m=u.useCallback(()=>{n||(f.current&&clearTimeout(f.current),f.current=window.setTimeout(()=>{e(!0),requestAnimationFrame(()=>{t(),o(!0)})},s))},[n,s,e,t,o]),l=u.useCallback((p=!1)=>{if(f.current&&clearTimeout(f.current),p){o(!1),setTimeout(()=>e(!1),150);return}f.current=window.setTimeout(()=>{o(!1),setTimeout(()=>e(!1),150)},100)},[o,e]);return u.useEffect(()=>{!r&&!a&&!d&&c&&l()},[r,a,d,c,l]),u.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{showTooltip:m,hideTooltip:l,timeoutRef:f}}function ve({id:n,children:s,message:e,placement:o="top",disabled:t=!1,delay:r=200,className:a}){const[d,c]=u.useState(!1),[f,m]=u.useState(!1),[l,p]=u.useState(null),[h,b]=u.useState(!1),[v,x]=u.useState(!1),[w,g]=u.useState(!1),{calculatePosition:j}=xe(o),{triggerRef:N,tooltipRef:L,updatePosition:z}=ge(j,f,p),{showTooltip:I,hideTooltip:A,timeoutRef:F}=pe(t,r,m,c,z,h,v,w,d),_=u.useId(),H=n??_;return i.jsxs(i.Fragment,{children:[u.cloneElement(s,{ref:B=>{N.current=B},onMouseEnter:()=>{b(!0),I()},onMouseLeave:()=>{b(!1)},onFocus:()=>{g(!0),I()},onBlur:()=>{g(!1),A(!0)},onKeyDown:B=>{B.key==="Escape"&&A(!0)},"aria-describedby":t?void 0:H}),f&&K.createPortal(i.jsx("div",{ref:L,id:H,role:"tooltip",className:y.join("fixed z-50 px-2 py-1 text-sm rounded shadow-lg pointer-events-auto transition-all duration-150 ease-out",d?"opacity-100":"opacity-0",a),style:l?{left:l.x,top:l.y}:{opacity:0},onMouseEnter:()=>{x(!0),F.current&&clearTimeout(F.current)},onMouseLeave:()=>{x(!1)},children:e}),document.body)]})}exports.ActionModal=S.ActionModal;exports.Accordion=Q;exports.AccordionItem=T;exports.Button=W;exports.ButtonLoadingDots=M;exports.Checkbox=O;exports.Clickable=P;exports.Input=re;exports.Label=oe;exports.Modal=ie;exports.RadioGroup=le;exports.RadioGroupItem=R;exports.RadioInput=U;exports.Slot=de;exports.Textarea=he;exports.Tooltip=ve;
2
2
  //# sourceMappingURL=components.cjs.js.map