dccxx-s3-explorer 1.0.27 → 1.0.28
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/s3-explorer.umd.cjs
CHANGED
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
|
|
139
139
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
140
140
|
|
|
141
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},xm="DialogDescriptionWarning",Cm=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${kl(xm).contentName}}.`;return d.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Sm=Cl,Em=El,Nm=Tl,Ll=Pl,Rl=Al,Vl=Fl,Bl=Dl,Tm=Il;const Ut=Sm,vr=Em,Pm=Nm,zl=d.forwardRef(({className:e,...t},n)=>l.jsx(Ll,{ref:n,className:Q("s3-explr-ui-dialog-overlay fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));zl.displayName=Ll.displayName;const Ft=d.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Pm,{children:[l.jsx(zl,{}),l.jsxs(Rl,{ref:r,className:Q("s3-explr-ui-dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,l.jsxs(Tm,{className:Q("s3-explr-ui-dialog-close absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[l.jsx($o,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),l.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Ft.displayName=Rl.displayName;const Ot=({className:e,...t})=>l.jsx("div",{className:Q("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ot.displayName="DialogHeader";const Tn=({className:e,...t})=>l.jsx("div",{className:Q("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Tn.displayName="DialogFooter";const Dt=d.forwardRef(({className:e,...t},n)=>l.jsx(Vl,{ref:n,className:Q("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",e),...t}));Dt.displayName=Vl.displayName;const yr=d.forwardRef(({className:e,...t},n)=>l.jsx(Bl,{ref:n,className:Q("s3-explr-ui-dialog-description text-sm text-muted-foreground",e),...t}));yr.displayName=Bl.displayName;const Mt=d.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:Q("s3-explr-ui-input","flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Mt.displayName="Input";var Am="Label",Hl=d.forwardRef((e,t)=>l.jsx(be.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Hl.displayName=Am;var Ul=Hl;const _m=Uo("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 s3-explr-ui-label",{variants:{variant:{default:"s3-explr-ui-label-default",required:"s3-explr-ui-label-required",disabled:"s3-explr-ui-label-disabled"},size:{default:"s3-explr-ui-label-size-default",sm:"s3-explr-ui-label-size-sm",lg:"s3-explr-ui-label-size-lg"}},defaultVariants:{variant:"default",size:"default"}}),jt=d.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Ul,{ref:o,className:Q(_m({variant:t,size:n}),e),...r}));jt.displayName=Ul.displayName;const wr=d.forwardRef(({className:e,...t},n)=>l.jsx("div",{className:Q("relative w-full overflow-auto","s3-explr-ui-table-container"),children:l.jsx("table",{ref:n,className:Q("w-full caption-bottom text-sm","s3-explr-ui-table",e),...t})}));wr.displayName="Table";const br=d.forwardRef(({className:e,...t},n)=>l.jsx("thead",{ref:n,className:Q("[&_tr]:border-b","s3-explr-ui-table-header",e),...t}));br.displayName="TableHeader";const xr=d.forwardRef(({className:e,...t},n)=>l.jsx("tbody",{ref:n,className:Q("[&_tr:last-child]:border-0","s3-explr-ui-table-body",e),...t}));xr.displayName="TableBody";const Fm=d.forwardRef(({className:e,...t},n)=>l.jsx("tfoot",{ref:n,className:Q("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",e),...t}));Fm.displayName="TableFooter";const Ye=d.forwardRef(({className:e,...t},n)=>l.jsx("tr",{ref:n,className:Q("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",e),...t}));Ye.displayName="TableRow";const st=d.forwardRef(({className:e,...t},n)=>l.jsx("th",{ref:n,className:Q("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-head",e),...t}));st.displayName="TableHead";const Oe=d.forwardRef(({className:e,...t},n)=>l.jsx("td",{ref:n,className:Q("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",e),...t}));Oe.displayName="TableCell";const Om=d.forwardRef(({className:e,...t},n)=>l.jsx("caption",{ref:n,className:Q("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",e),...t}));Om.displayName="TableCaption";function cs(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function an(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function jl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function us(...e){return t=>{let n=!1;const r=e.map(o=>{const s=jl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():jl(e[o],null)}}}}function ds(...e){return d.useCallback(us(...e),e)}var fs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Mm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(ps,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(ps,{...r,ref:t,children:n})});fs.displayName="Slot";var ps=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=$m(n);return d.cloneElement(n,{...Im(r,n.props),ref:t?us(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});ps.displayName="SlotClone";var Dm=({children:e})=>l.jsx(l.Fragment,{children:e});function Mm(e){return d.isValidElement(e)&&e.type===Dm}function Im(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $m(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function km(e){const t=e+"CollectionProvider",[n,r]=Pt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:h}=p,y=D.useRef(null),w=D.useRef(new Map).current;return l.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:h})};i.displayName=t;const a=e+"CollectionSlot",u=D.forwardRef((p,v)=>{const{scope:h,children:y}=p,w=s(a,h),b=ds(v,w.collectionRef);return l.jsx(fs,{ref:b,children:y})});u.displayName=a;const c=e+"CollectionItemSlot",f="data-radix-collection-item",g=D.forwardRef((p,v)=>{const{scope:h,children:y,...w}=p,b=D.useRef(null),S=ds(v,b),E=s(c,h);return D.useEffect(()=>(E.itemMap.set(b,{ref:b,...w}),()=>void E.itemMap.delete(b))),l.jsx(fs,{[f]:"",ref:S,children:y})});g.displayName=c;function m(p){const v=s(e+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((E,C)=>w.indexOf(E.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,r]}var Wl=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Rm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(gs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(gs,{...r,ref:t,children:n})});Wl.displayName="Slot";var gs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=Bm(n);return d.cloneElement(n,{...Vm(r,n.props),ref:t?us(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});gs.displayName="SlotClone";var Lm=({children:e})=>l.jsx(l.Fragment,{children:e});function Rm(e){return d.isValidElement(e)&&e.type===Lm}function Vm(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Bm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Gl=zm.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Wl:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Hm=d.createContext(void 0);function ql(e){const t=d.useContext(Hm);return e||t||"ltr"}var hs="rovingFocusGroup.onEntryFocus",Um={bubbles:!1,cancelable:!0},Cr="RovingFocusGroup",[ms,Kl,jm]=km(Cr),[Wm,Xl]=Pt(Cr,[jm]),[Gm,qm]=Wm(Cr),Jl=d.forwardRef((e,t)=>l.jsx(ms.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ms.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Km,{...e,ref:t})})}));Jl.displayName=Cr;var Km=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...g}=e,m=d.useRef(null),p=ds(t,m),v=ql(s),[h=null,y]=Qt({prop:i,defaultProp:a,onChange:u}),[w,b]=d.useState(!1),S=Pe(c),E=Kl(n),C=d.useRef(!1),[P,_]=d.useState(0);return d.useEffect(()=>{const O=m.current;if(O)return O.addEventListener(hs,S),()=>O.removeEventListener(hs,S)},[S]),l.jsx(Gm,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:h,onItemFocus:d.useCallback(O=>y(O),[y]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>_(O=>O+1),[]),onFocusableItemRemove:d.useCallback(()=>_(O=>O-1),[]),children:l.jsx(Gl.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...g,ref:p,style:{outline:"none",...e.style},onMouseDown:an(e.onMouseDown,()=>{C.current=!0}),onFocus:an(e.onFocus,O=>{const $=!C.current;if(O.target===O.currentTarget&&$&&!w){const F=new CustomEvent(hs,Um);if(O.currentTarget.dispatchEvent(F),!F.defaultPrevented){const G=E().filter(U=>U.focusable),k=G.find(U=>U.active),R=G.find(U=>U.id===h),q=[k,R,...G].filter(Boolean).map(U=>U.ref.current);Ql(q,f)}}C.current=!1}),onBlur:an(e.onBlur,()=>b(!1))})})}),Yl="RovingFocusGroupItem",Zl=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=tn(),u=s||a,c=qm(Yl,n),f=c.currentTabStopId===u,g=Kl(n),{onFocusableItemAdd:m,onFocusableItemRemove:p}=c;return d.useEffect(()=>{if(r)return m(),()=>p()},[r,m,p]),l.jsx(ms.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Gl.span,{tabIndex:f?0:-1,"data-orientation":c.orientation,...i,ref:t,onMouseDown:an(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:an(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:an(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=Ym(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=g().filter(b=>b.focusable).map(b=>b.ref.current);if(h==="last")w.reverse();else if(h==="prev"||h==="next"){h==="prev"&&w.reverse();const b=w.indexOf(v.currentTarget);w=c.loop?Zm(w,b+1):w.slice(b+1)}setTimeout(()=>Ql(w))}})})})});Zl.displayName=Yl;var Xm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ym(e,t,n){const r=Jm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Xm[r]}function Ql(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Zm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Qm=Jl,ev=Zl;function ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function tv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ec(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ec(e[o],null)}}}}function nv(...e){return d.useCallback(tv(...e),e)}function rv(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var tc=e=>{const{present:t,children:n}=e,r=ov(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=nv(r.ref,sv(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};tc.displayName="Presence";function ov(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=rv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const c=Sr(r.current);s.current=a==="mounted"?c:"none"},[a]),Ve(()=>{const c=r.current,f=o.current;if(f!==e){const m=s.current,p=Sr(c);e?u("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ve(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,g=p=>{const h=Sr(r.current).includes(p.animationName);if(p.target===t&&h&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},m=p=>{p.target===t&&(s.current=Sr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Sr(e){return(e==null?void 0:e.animationName)||"none"}function sv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function nc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function iv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=nc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():nc(e[o],null)}}}}var rc=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(lv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(vs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(vs,{...r,ref:t,children:n})});rc.displayName="Slot";var vs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=uv(n);return d.cloneElement(n,{...cv(r,n.props),ref:t?iv(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});vs.displayName="SlotClone";var av=({children:e})=>l.jsx(l.Fragment,{children:e});function lv(e){return d.isValidElement(e)&&e.type===av}function cv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function uv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var dv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Er=dv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?rc:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),ys="Tabs",[fv,iC]=Pt(ys,[Xl]),oc=Xl(),[pv,ws]=fv(ys),sc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:u="automatic",...c}=e,f=ql(a),[g,m]=Qt({prop:r,onChange:o,defaultProp:s});return l.jsx(pv,{scope:n,baseId:tn(),value:g,onValueChange:m,orientation:i,dir:f,activationMode:u,children:l.jsx(Er.div,{dir:f,"data-orientation":i,...c,ref:t})})});sc.displayName=ys;var ic="TabsList",ac=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=ws(ic,n),i=oc(n);return l.jsx(Qm,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:l.jsx(Er.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});ac.displayName=ic;var lc="TabsTrigger",cc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=ws(lc,n),a=oc(n),u=fc(i.baseId,r),c=pc(i.baseId,r),f=r===i.value;return l.jsx(ev,{asChild:!0,...a,focusable:!o,active:f,children:l.jsx(Er.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":c,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...s,ref:t,onMouseDown:cs(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?i.onValueChange(r):g.preventDefault()}),onKeyDown:cs(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&i.onValueChange(r)}),onFocus:cs(e.onFocus,()=>{const g=i.activationMode!=="manual";!f&&!o&&g&&i.onValueChange(r)})})})});cc.displayName=lc;var uc="TabsContent",dc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,a=ws(uc,n),u=fc(a.baseId,r),c=pc(a.baseId,r),f=r===a.value,g=d.useRef(f);return d.useEffect(()=>{const m=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(m)},[]),l.jsx(tc,{present:o||f,children:({present:m})=>l.jsx(Er.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:c,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:m&&s})})});dc.displayName=uc;function fc(e,t){return`${e}-trigger-${t}`}function pc(e,t){return`${e}-content-${t}`}var gv=sc,gc=ac,hc=cc,mc=dc;const hv=gv,vc=d.forwardRef(({className:e,...t},n)=>l.jsx(gc,{ref:n,className:Q("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));vc.displayName=gc.displayName;const Nr=d.forwardRef(({className:e,...t},n)=>l.jsx(hc,{ref:n,className:Q("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Nr.displayName=hc.displayName;const Tr=d.forwardRef(({className:e,...t},n)=>l.jsx(mc,{ref:n,className:Q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Tr.displayName=mc.displayName;const Pn=d.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:Q("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Pn.displayName="Textarea";function mv(e,t=[]){let n=[];function r(s,i){const a=d.createContext(i),u=n.length;n=[...n,i];function c(g){const{scope:m,children:p,...v}=g,h=(m==null?void 0:m[e][u])||a,y=d.useMemo(()=>v,Object.values(v));return l.jsx(h.Provider,{value:y,children:p})}function f(g,m){const p=(m==null?void 0:m[e][u])||a,v=d.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${g}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,f]}const o=()=>{const s=n.map(i=>d.createContext(i));return function(a){const u=(a==null?void 0:a[e])||s;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return o.scopeName=e,[r,vv(o,...t)]}function vv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:u,scopeName:c})=>{const g=u(s)[`__scope${c}`];return{...a,...g}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var bs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(wv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(xs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(xs,{...r,ref:t,children:n})});bs.displayName="Slot";var xs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=xv(n);return d.cloneElement(n,{...bv(r,n.props),ref:t?ar(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});xs.displayName="SlotClone";var yv=({children:e})=>l.jsx(l.Fragment,{children:e});function wv(e){return d.isValidElement(e)&&e.type===yv}function bv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function xv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Cv(e){const t=e+"CollectionProvider",[n,r]=mv(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:h}=p,y=D.useRef(null),w=D.useRef(new Map).current;return l.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:h})};i.displayName=t;const a=e+"CollectionSlot",u=D.forwardRef((p,v)=>{const{scope:h,children:y}=p,w=s(a,h),b=He(v,w.collectionRef);return l.jsx(bs,{ref:b,children:y})});u.displayName=a;const c=e+"CollectionItemSlot",f="data-radix-collection-item",g=D.forwardRef((p,v)=>{const{scope:h,children:y,...w}=p,b=D.useRef(null),S=He(v,b),E=s(c,h);return D.useEffect(()=>(E.itemMap.set(b,{ref:b,...w}),()=>void E.itemMap.delete(b))),l.jsx(bs,{[f]:"",ref:S,children:y})});g.displayName=c;function m(p){const v=s(e+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((E,C)=>w.indexOf(E.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,r]}var Sv="VisuallyHidden",Cs=d.forwardRef((e,t)=>l.jsx(be.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Cs.displayName=Sv;var Ss="ToastProvider",[Es,Ev,Nv]=Cv("Toast"),[yc,aC]=Pt("Toast",[Nv]),[Tv,Pr]=yc(Ss),wc=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,u]=d.useState(null),[c,f]=d.useState(0),g=d.useRef(!1),m=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ss}\`. Expected non-empty \`string\`.`),l.jsx(Es.Provider,{scope:t,children:l.jsx(Tv,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:u,onToastAdd:d.useCallback(()=>f(p=>p+1),[]),onToastRemove:d.useCallback(()=>f(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:m,children:i})})};wc.displayName=Ss;var bc="ToastViewport",Pv=["F8"],Ns="toast.viewportPause",Ts="toast.viewportResume",xc=d.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Pv,label:o="Notifications ({hotkey})",...s}=e,i=Pr(bc,n),a=Ev(n),u=d.useRef(null),c=d.useRef(null),f=d.useRef(null),g=d.useRef(null),m=He(t,g,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;d.useEffect(()=>{const y=w=>{var S;r.length!==0&&r.every(E=>w[E]||w.code===E)&&((S=g.current)==null||S.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),d.useEffect(()=>{const y=u.current,w=g.current;if(v&&y&&w){const b=()=>{if(!i.isClosePausedRef.current){const P=new CustomEvent(Ns);w.dispatchEvent(P),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const P=new CustomEvent(Ts);w.dispatchEvent(P),i.isClosePausedRef.current=!1}},E=P=>{!y.contains(P.relatedTarget)&&S()},C=()=>{y.contains(document.activeElement)||S()};return y.addEventListener("focusin",b),y.addEventListener("focusout",E),y.addEventListener("pointermove",b),y.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{y.removeEventListener("focusin",b),y.removeEventListener("focusout",E),y.removeEventListener("pointermove",b),y.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const h=d.useCallback(({tabbingDirection:y})=>{const b=a().map(S=>{const E=S.ref.current,C=[E,...Bv(E)];return y==="forwards"?C:C.reverse()});return(y==="forwards"?b.reverse():b).flat()},[a]);return d.useEffect(()=>{const y=g.current;if(y){const w=b=>{var C,P,_;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const O=document.activeElement,$=b.shiftKey;if(b.target===y&&$){(C=c.current)==null||C.focus();return}const k=h({tabbingDirection:$?"backwards":"forwards"}),R=k.findIndex(I=>I===O);_s(k.slice(R+1))?b.preventDefault():$?(P=c.current)==null||P.focus():(_=f.current)==null||_.focus()}};return y.addEventListener("keydown",w),()=>y.removeEventListener("keydown",w)}},[a,h]),l.jsxs(mh,{ref:u,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&l.jsx(Ps,{ref:c,onFocusFromOutsideViewport:()=>{const y=h({tabbingDirection:"forwards"});_s(y)}}),l.jsx(Es.Slot,{scope:n,children:l.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&l.jsx(Ps,{ref:f,onFocusFromOutsideViewport:()=>{const y=h({tabbingDirection:"backwards"});_s(y)}})]})});xc.displayName=bc;var Cc="ToastFocusProxy",Ps=d.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=Pr(Cc,n);return l.jsx(Cs,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ps.displayName=Cc;var Ar="Toast",Av="toast.swipeStart",_v="toast.swipeMove",Fv="toast.swipeCancel",Ov="toast.swipeEnd",Sc=d.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,u]=Qt({prop:r,defaultProp:o,onChange:s});return l.jsx(en,{present:n||a,children:l.jsx(Iv,{open:a,...i,ref:t,onClose:()=>u(!1),onPause:Pe(e.onPause),onResume:Pe(e.onResume),onSwipeStart:ye(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ye(e.onSwipeMove,c=>{const{x:f,y:g}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:ye(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ye(e.onSwipeEnd,c=>{const{x:f,y:g}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});Sc.displayName=Ar;var[Dv,Mv]=yc(Ar,{onClose(){}}),Iv=d.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:u,onResume:c,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:m,onSwipeEnd:p,...v}=e,h=Pr(Ar,n),[y,w]=d.useState(null),b=He(t,I=>w(I)),S=d.useRef(null),E=d.useRef(null),C=o||h.duration,P=d.useRef(0),_=d.useRef(C),O=d.useRef(0),{onToastAdd:$,onToastRemove:F}=h,G=Pe(()=>{var q;(y==null?void 0:y.contains(document.activeElement))&&((q=h.viewport)==null||q.focus()),i()}),k=d.useCallback(I=>{!I||I===1/0||(window.clearTimeout(O.current),P.current=new Date().getTime(),O.current=window.setTimeout(G,I))},[G]);d.useEffect(()=>{const I=h.viewport;if(I){const q=()=>{k(_.current),c==null||c()},U=()=>{const J=new Date().getTime()-P.current;_.current=_.current-J,window.clearTimeout(O.current),u==null||u()};return I.addEventListener(Ns,U),I.addEventListener(Ts,q),()=>{I.removeEventListener(Ns,U),I.removeEventListener(Ts,q)}}},[h.viewport,C,u,c,k]),d.useEffect(()=>{s&&!h.isClosePausedRef.current&&k(C)},[s,C,h.isClosePausedRef,k]),d.useEffect(()=>($(),()=>F()),[$,F]);const R=d.useMemo(()=>y?Fc(y):null,[y]);return h.viewport?l.jsxs(l.Fragment,{children:[R&&l.jsx($v,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:R}),l.jsx(Dv,{scope:n,onClose:G,children:jn.createPortal(l.jsx(Es.ItemSlot,{scope:n,children:l.jsx(hh,{asChild:!0,onEscapeKeyDown:ye(a,()=>{h.isFocusedToastEscapeKeyDownRef.current||G(),h.isFocusedToastEscapeKeyDownRef.current=!1}),children:l.jsx(be.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":h.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ye(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(h.isFocusedToastEscapeKeyDownRef.current=!0,G()))}),onPointerDown:ye(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ye(e.onPointerMove,I=>{if(!S.current)return;const q=I.clientX-S.current.x,U=I.clientY-S.current.y,J=!!E.current,K=["left","right"].includes(h.swipeDirection),ee=["left","up"].includes(h.swipeDirection)?Math.min:Math.max,ce=K?ee(0,q):0,fe=K?0:ee(0,U),Ce=I.pointerType==="touch"?10:2,Ie={x:ce,y:fe},je={originalEvent:I,delta:Ie};J?(E.current=Ie,_r(_v,g,je,{discrete:!1})):Oc(Ie,h.swipeDirection,Ce)?(E.current=Ie,_r(Av,f,je,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(q)>Ce||Math.abs(U)>Ce)&&(S.current=null)}),onPointerUp:ye(e.onPointerUp,I=>{const q=E.current,U=I.target;if(U.hasPointerCapture(I.pointerId)&&U.releasePointerCapture(I.pointerId),E.current=null,S.current=null,q){const J=I.currentTarget,K={originalEvent:I,delta:q};Oc(q,h.swipeDirection,h.swipeThreshold)?_r(Ov,p,K,{discrete:!0}):_r(Fv,m,K,{discrete:!0}),J.addEventListener("click",ee=>ee.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null}),$v=e=>{const{__scopeToast:t,children:n,...r}=e,o=Pr(Ar,t),[s,i]=d.useState(!1),[a,u]=d.useState(!1);return Rv(()=>i(!0)),d.useEffect(()=>{const c=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:l.jsx(Yo,{asChild:!0,children:l.jsx(Cs,{...r,children:s&&l.jsxs(l.Fragment,{children:[o.label," ",n]})})})},kv="ToastTitle",Ec=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return l.jsx(be.div,{...r,ref:t})});Ec.displayName=kv;var Lv="ToastDescription",Nc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return l.jsx(be.div,{...r,ref:t})});Nc.displayName=Lv;var Tc="ToastAction",Pc=d.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?l.jsx(_c,{altText:n,asChild:!0,children:l.jsx(As,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Tc}\`. Expected non-empty \`string\`.`),null)});Pc.displayName=Tc;var Ac="ToastClose",As=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Mv(Ac,n);return l.jsx(_c,{asChild:!0,children:l.jsx(be.button,{type:"button",...r,ref:t,onClick:ye(e.onClick,o.onClose)})})});As.displayName=Ac;var _c=d.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return l.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Fc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Vv(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Fc(r))}}),t}function _r(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Va(o,s):o.dispatchEvent(s)}var Oc=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function Rv(e=()=>{}){const t=Pe(e);Ve(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Vv(e){return e.nodeType===e.ELEMENT_NODE}function Bv(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function _s(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var zv=wc,Dc=xc,Mc=Sc,Ic=Ec,$c=Nc,kc=Pc,Lc=As;const Hv=zv,Rc=d.forwardRef(({className:e,...t},n)=>l.jsx(Dc,{ref:n,className:Q("s3-explr-ui-toast-viewport fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Rc.displayName=Dc.displayName;const Uv=Uo("s3-explr-ui-toast group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"s3-explr-ui-toast-default border bg-background text-foreground",destructive:"s3-explr-ui-toast-destructive destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Vc=d.forwardRef(({className:e,variant:t,...n},r)=>l.jsx(Mc,{ref:r,className:Q(Uv({variant:t}),e),...n}));Vc.displayName=Mc.displayName;const jv=d.forwardRef(({className:e,...t},n)=>l.jsx(kc,{ref:n,className:Q("s3-explr-ui-toast-action inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));jv.displayName=kc.displayName;const Bc=d.forwardRef(({className:e,...t},n)=>l.jsx(Lc,{ref:n,className:Q("s3-explr-ui-toast-close absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:l.jsx($o,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));Bc.displayName=Lc.displayName;const zc=d.forwardRef(({className:e,...t},n)=>l.jsx(Ic,{ref:n,className:Q("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",e),...t}));zc.displayName=Ic.displayName;const Hc=d.forwardRef(({className:e,...t},n)=>l.jsx($c,{ref:n,className:Q("s3-explr-ui-toast-description text-sm opacity-90",e),...t}));Hc.displayName=$c.displayName;const Wv=1,Gv=1e6;let Fs=0;function qv(){return Fs=(Fs+1)%Number.MAX_SAFE_INTEGER,Fs.toString()}const Os=new Map,Uc=e=>{if(Os.has(e))return;const t=setTimeout(()=>{Os.delete(e),An({type:"REMOVE_TOAST",toastId:e})},Gv);Os.set(e,t)},Kv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Wv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Uc(n):e.toasts.forEach(r=>{Uc(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Fr=[];let Or={toasts:[]};function An(e){Or=Kv(Or,e),Fr.forEach(t=>{t(Or)})}function Xv({...e}){const t=qv(),n=o=>An({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>An({type:"DISMISS_TOAST",toastId:t});return An({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ds(){const[e,t]=d.useState(Or);return d.useEffect(()=>(Fr.push(t),()=>{const n=Fr.indexOf(t);n>-1&&Fr.splice(n,1)}),[e]),{...e,toast:Xv,dismiss:n=>An({type:"DISMISS_TOAST",toastId:n})}}function jc(){const{toasts:e}=Ds();return l.jsxs(Hv,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return l.jsxs(Vc,{...s,className:`s3-explr-ui-toast ${s.className||""}`,children:[l.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&l.jsx(zc,{className:"s3-explr-ui-toast-title",children:n}),r&&l.jsx(Hc,{className:"s3-explr-ui-toast-description",children:r})]}),o&&l.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),l.jsx(Bc,{className:"s3-explr-ui-toast-close"})]},t)}),l.jsx(Rc,{className:"s3-explr-ui-toast-viewport"})]})}function vt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Wc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Wc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Wc(e[o],null)}}}}function _n(...e){return d.useCallback(Jv(...e),e)}var Yv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Fn=Yv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Zv(e,t){e&&jn.flushSync(()=>e.dispatchEvent(t))}var Qv="DismissableLayer",Ms="dismissableLayer.update",ey="dismissableLayer.pointerDownOutside",ty="dismissableLayer.focusOutside",Gc,qc=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kc=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...u}=e,c=d.useContext(qc),[f,g]=d.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),v=_n(t,_=>g(_)),h=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),b=f?h.indexOf(f):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,E=b>=w,C=oy(_=>{const O=_.target,$=[...c.branches].some(F=>F.contains(O));!E||$||(o==null||o(_),i==null||i(_),_.defaultPrevented||a==null||a())},m),P=sy(_=>{const O=_.target;[...c.branches].some(F=>F.contains(O))||(s==null||s(_),i==null||i(_),_.defaultPrevented||a==null||a())},m);return Wa(_=>{b===c.layers.size-1&&(r==null||r(_),!_.defaultPrevented&&a&&(_.preventDefault(),a()))},m),d.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Gc=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),Xc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Gc)}},[f,m,n,c]),d.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),Xc())},[f,c]),d.useEffect(()=>{const _=()=>p({});return document.addEventListener(Ms,_),()=>document.removeEventListener(Ms,_)},[]),l.jsx(Fn.div,{...u,ref:v,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:vt(e.onFocusCapture,P.onFocusCapture),onBlurCapture:vt(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:vt(e.onPointerDownCapture,C.onPointerDownCapture)})});Kc.displayName=Qv;var ny="DismissableLayerBranch",ry=d.forwardRef((e,t)=>{const n=d.useContext(qc),r=d.useRef(null),o=_n(t,r);return d.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Fn.div,{...e,ref:o})});ry.displayName=ny;function oy(e,t=globalThis==null?void 0:globalThis.document){const n=Pe(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){Jc(ey,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function sy(e,t=globalThis==null?void 0:globalThis.document){const n=Pe(e),r=d.useRef(!1);return d.useEffect(()=>{const o=s=>{s.target&&!r.current&&Jc(ty,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Xc(){const e=new CustomEvent(Ms);document.dispatchEvent(e)}function Jc(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Zv(o,s):o.dispatchEvent(s)}const iy=["top","right","bottom","left"],It=Math.min,Be=Math.max,Dr=Math.round,Mr=Math.floor,it=e=>({x:e,y:e}),ay={left:"right",right:"left",bottom:"top",top:"bottom"},ly={start:"end",end:"start"};function Is(e,t,n){return Be(e,It(t,n))}function yt(e,t){return typeof e=="function"?e(t):e}function wt(e){return e.split("-")[0]}function ln(e){return e.split("-")[1]}function $s(e){return e==="x"?"y":"x"}function ks(e){return e==="y"?"height":"width"}function $t(e){return["top","bottom"].includes(wt(e))?"y":"x"}function Ls(e){return $s($t(e))}function cy(e,t,n){n===void 0&&(n=!1);const r=ln(e),o=Ls(e),s=ks(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ir(i)),[i,Ir(i)]}function uy(e){const t=Ir(e);return[Rs(e),t,Rs(t)]}function Rs(e){return e.replace(/start|end/g,t=>ly[t])}function dy(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function fy(e,t,n,r){const o=ln(e);let s=dy(wt(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Rs)))),s}function Ir(e){return e.replace(/left|right|bottom|top/g,t=>ay[t])}function py(e){return{top:0,right:0,bottom:0,left:0,...e}}function Yc(e){return typeof e!="number"?py(e):{top:e,right:e,bottom:e,left:e}}function $r(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Zc(e,t,n){let{reference:r,floating:o}=e;const s=$t(t),i=Ls(t),a=ks(i),u=wt(t),c=s==="y",f=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(u){case"top":p={x:f,y:r.y-o.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:g};break;case"left":p={x:r.x-o.width,y:g};break;default:p={x:r.x,y:r.y}}switch(ln(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const gy=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:g}=Zc(c,r,u),m=r,p={},v=0;for(let h=0;h<a.length;h++){const{name:y,fn:w}=a[h],{x:b,y:S,data:E,reset:C}=await w({x:f,y:g,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});f=b??f,g=S??g,p={...p,[y]:{...p[y],...E}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:f,y:g}=Zc(c,m,u)),h=-1)}return{x:f,y:g,placement:m,strategy:o,middlewareData:p}};async function On(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:u}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:m=!1,padding:p=0}=yt(t,e),v=Yc(p),y=a[m?g==="floating"?"reference":"floating":g],w=$r(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:u})),b=g==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=$r(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:u}):b);return{top:(w.top-C.top+v.top)/E.y,bottom:(C.bottom-w.bottom+v.bottom)/E.y,left:(w.left-C.left+v.left)/E.x,right:(C.right-w.right+v.right)/E.x}}const hy=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:u}=t,{element:c,padding:f=0}=yt(e,t)||{};if(c==null)return{};const g=Yc(f),m={x:n,y:r},p=Ls(o),v=ks(p),h=await i.getDimensions(c),y=p==="y",w=y?"top":"left",b=y?"bottom":"right",S=y?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],C=m[p]-s.reference[p],P=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let _=P?P[S]:0;(!_||!await(i.isElement==null?void 0:i.isElement(P)))&&(_=a.floating[S]||s.floating[v]);const O=E/2-C/2,$=_/2-h[v]/2-1,F=It(g[w],$),G=It(g[b],$),k=F,R=_-h[v]-G,I=_/2-h[v]/2+O,q=Is(k,I,R),U=!u.arrow&&ln(o)!=null&&I!==q&&s.reference[v]/2-(I<k?F:G)-h[v]/2<0,J=U?I<k?I-k:I-R:0;return{[p]:m[p]+J,data:{[p]:q,centerOffset:I-q-J,...U&&{alignmentOffset:J}},reset:U}}}),my=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:u,elements:c}=t,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:h=!0,...y}=yt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=wt(o),b=$t(a),S=wt(a)===a,E=await(u.isRTL==null?void 0:u.isRTL(c.floating)),C=m||(S||!h?[Ir(a)]:uy(a)),P=v!=="none";!m&&P&&C.push(...fy(a,h,v,E));const _=[a,...C],O=await On(t,y),$=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&$.push(O[w]),g){const I=cy(o,i,E);$.push(O[I[0]],O[I[1]])}if(F=[...F,{placement:o,overflows:$}],!$.every(I=>I<=0)){var G,k;const I=(((G=s.flip)==null?void 0:G.index)||0)+1,q=_[I];if(q)return{data:{index:I,overflows:F},reset:{placement:q}};let U=(k=F.filter(J=>J.overflows[0]<=0).sort((J,K)=>J.overflows[1]-K.overflows[1])[0])==null?void 0:k.placement;if(!U)switch(p){case"bestFit":{var R;const J=(R=F.filter(K=>{if(P){const ee=$t(K.placement);return ee===b||ee==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(ee=>ee>0).reduce((ee,ce)=>ee+ce,0)]).sort((K,ee)=>K[1]-ee[1])[0])==null?void 0:R[0];J&&(U=J);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function Qc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function eu(e){return iy.some(t=>e[t]>=0)}const vy=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=yt(e,t);switch(r){case"referenceHidden":{const s=await On(t,{...o,elementContext:"reference"}),i=Qc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:eu(i)}}}case"escaped":{const s=await On(t,{...o,altBoundary:!0}),i=Qc(s,n.floating);return{data:{escapedOffsets:i,escaped:eu(i)}}}default:return{}}}}};async function yy(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=wt(n),a=ln(n),u=$t(n)==="y",c=["left","top"].includes(i)?-1:1,f=s&&u?-1:1,g=yt(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),u?{x:p*f,y:m*c}:{x:m*c,y:p*f}}const wy=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,u=await yy(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:s+u.y,data:{...u,placement:i}}}}},by=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...u}=yt(e,t),c={x:n,y:r},f=await On(t,u),g=$t(wt(o)),m=$s(g);let p=c[m],v=c[g];if(s){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",b=p+f[y],S=p-f[w];p=Is(b,p,S)}if(i){const y=g==="y"?"top":"left",w=g==="y"?"bottom":"right",b=v+f[y],S=v-f[w];v=Is(b,v,S)}const h=a.fn({...t,[m]:p,[g]:v});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[g]:i}}}}}},xy=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:u=!0,crossAxis:c=!0}=yt(e,t),f={x:n,y:r},g=$t(o),m=$s(g);let p=f[m],v=f[g];const h=yt(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(u){const S=m==="y"?"height":"width",E=s.reference[m]-s.floating[S]+y.mainAxis,C=s.reference[m]+s.reference[S]-y.mainAxis;p<E?p=E:p>C&&(p=C)}if(c){var w,b;const S=m==="y"?"width":"height",E=["top","left"].includes(wt(o)),C=s.reference[g]-s.floating[S]+(E&&((w=i.offset)==null?void 0:w[g])||0)+(E?0:y.crossAxis),P=s.reference[g]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[g])||0)-(E?y.crossAxis:0);v<C?v=C:v>P&&(v=P)}return{[m]:p,[g]:v}}}},Cy=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:u=()=>{},...c}=yt(e,t),f=await On(t,c),g=wt(o),m=ln(o),p=$t(o)==="y",{width:v,height:h}=s.floating;let y,w;g==="top"||g==="bottom"?(y=g,w=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=g,y=m==="end"?"top":"bottom");const b=h-f.top-f.bottom,S=v-f.left-f.right,E=It(h-f[y],b),C=It(v-f[w],S),P=!t.middlewareData.shift;let _=E,O=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=b),P&&!m){const F=Be(f.left,0),G=Be(f.right,0),k=Be(f.top,0),R=Be(f.bottom,0);p?O=v-2*(F!==0||G!==0?F+G:Be(f.left,f.right)):_=h-2*(k!==0||R!==0?k+R:Be(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:_});const $=await i.getDimensions(a.floating);return v!==$.width||h!==$.height?{reset:{rects:!0}}:{}}}};function kr(){return typeof window<"u"}function cn(e){return tu(e)?(e.nodeName||"").toLowerCase():"#document"}function ze(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){var t;return(t=(tu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function tu(e){return kr()?e instanceof Node||e instanceof ze(e).Node:!1}function Ze(e){return kr()?e instanceof Element||e instanceof ze(e).Element:!1}function lt(e){return kr()?e instanceof HTMLElement||e instanceof ze(e).HTMLElement:!1}function nu(e){return!kr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ze(e).ShadowRoot}function Dn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Qe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Sy(e){return["table","td","th"].includes(cn(e))}function Lr(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Vs(e){const t=Bs(),n=Ze(e)?Qe(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Ey(e){let t=kt(e);for(;lt(t)&&!un(t);){if(Vs(t))return t;if(Lr(t))return null;t=kt(t)}return null}function Bs(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function un(e){return["html","body","#document"].includes(cn(e))}function Qe(e){return ze(e).getComputedStyle(e)}function Rr(e){return Ze(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kt(e){if(cn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||nu(e)&&e.host||at(e);return nu(t)?t.host:t}function ru(e){const t=kt(e);return un(t)?e.ownerDocument?e.ownerDocument.body:e.body:lt(t)&&Dn(t)?t:ru(t)}function Mn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ru(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ze(o);if(s){const a=zs(i);return t.concat(i,i.visualViewport||[],Dn(o)?o:[],a&&n?Mn(a):[])}return t.concat(o,Mn(o,[],n))}function zs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ou(e){const t=Qe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=lt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Dr(n)!==s||Dr(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Hs(e){return Ze(e)?e:e.contextElement}function dn(e){const t=Hs(e);if(!lt(t))return it(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ou(t);let i=(s?Dr(n.width):n.width)/r,a=(s?Dr(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Ny=it(0);function su(e){const t=ze(e);return!Bs()||!t.visualViewport?Ny:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ze(e)?!1:t}function Wt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Hs(e);let i=it(1);t&&(r?Ze(r)&&(i=dn(r)):i=dn(e));const a=Ty(s,n,r)?su(s):it(0);let u=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,f=o.width/i.x,g=o.height/i.y;if(s){const m=ze(s),p=r&&Ze(r)?ze(r):r;let v=m,h=zs(v);for(;h&&r&&p!==v;){const y=dn(h),w=h.getBoundingClientRect(),b=Qe(h),S=w.left+(h.clientLeft+parseFloat(b.paddingLeft))*y.x,E=w.top+(h.clientTop+parseFloat(b.paddingTop))*y.y;u*=y.x,c*=y.y,f*=y.x,g*=y.y,u+=S,c+=E,v=ze(h),h=zs(v)}}return $r({width:f,height:g,x:u,y:c})}function Us(e,t){const n=Rr(e).scrollLeft;return t?t.left+n:Wt(at(e)).left+n}function iu(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Us(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Py(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=at(r),a=t?Lr(t.floating):!1;if(r===i||a&&s)return n;let u={scrollLeft:0,scrollTop:0},c=it(1);const f=it(0),g=lt(r);if((g||!g&&!s)&&((cn(r)!=="body"||Dn(i))&&(u=Rr(r)),lt(r))){const p=Wt(r);c=dn(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const m=i&&!g&&!s?iu(i,u,!0):it(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-u.scrollLeft*c.x+f.x+m.x,y:n.y*c.y-u.scrollTop*c.y+f.y+m.y}}function Ay(e){return Array.from(e.getClientRects())}function _y(e){const t=at(e),n=Rr(e),r=e.ownerDocument.body,o=Be(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Be(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return Qe(r).direction==="rtl"&&(i+=Be(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Fy(e,t){const n=ze(e),r=at(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,u=0;if(o){s=o.width,i=o.height;const c=Bs();(!c||c&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:s,height:i,x:a,y:u}}function Oy(e,t){const n=Wt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=lt(e)?dn(e):it(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,u=o*s.x,c=r*s.y;return{width:i,height:a,x:u,y:c}}function au(e,t,n){let r;if(t==="viewport")r=Fy(e,n);else if(t==="document")r=_y(at(e));else if(Ze(t))r=Oy(t,n);else{const o=su(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $r(r)}function lu(e,t){const n=kt(e);return n===t||!Ze(n)||un(n)?!1:Qe(n).position==="fixed"||lu(n,t)}function Dy(e,t){const n=t.get(e);if(n)return n;let r=Mn(e,[],!1).filter(a=>Ze(a)&&cn(a)!=="body"),o=null;const s=Qe(e).position==="fixed";let i=s?kt(e):e;for(;Ze(i)&&!un(i);){const a=Qe(i),u=Vs(i);!u&&a.position==="fixed"&&(o=null),(s?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Dn(i)&&!u&&lu(e,i))?r=r.filter(f=>f!==i):o=a,i=kt(i)}return t.set(e,r),r}function My(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Lr(t)?[]:Dy(t,this._c):[].concat(n),r],a=i[0],u=i.reduce((c,f)=>{const g=au(t,f,o);return c.top=Be(g.top,c.top),c.right=It(g.right,c.right),c.bottom=It(g.bottom,c.bottom),c.left=Be(g.left,c.left),c},au(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Iy(e){const{width:t,height:n}=ou(e);return{width:t,height:n}}function $y(e,t,n){const r=lt(t),o=at(t),s=n==="fixed",i=Wt(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const u=it(0);if(r||!r&&!s)if((cn(t)!=="body"||Dn(o))&&(a=Rr(t)),r){const m=Wt(t,!0,s,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}else o&&(u.x=Us(o));const c=o&&!r&&!s?iu(o,a):it(0),f=i.left+a.scrollLeft-u.x-c.x,g=i.top+a.scrollTop-u.y-c.y;return{x:f,y:g,width:i.width,height:i.height}}function js(e){return Qe(e).position==="static"}function cu(e,t){if(!lt(e)||Qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return at(e)===n&&(n=n.ownerDocument.body),n}function uu(e,t){const n=ze(e);if(Lr(e))return n;if(!lt(e)){let o=kt(e);for(;o&&!un(o);){if(Ze(o)&&!js(o))return o;o=kt(o)}return n}let r=cu(e,t);for(;r&&Sy(r)&&js(r);)r=cu(r,t);return r&&un(r)&&js(r)&&!Vs(r)?n:r||Ey(e)||n}const ky=async function(e){const t=this.getOffsetParent||uu,n=this.getDimensions,r=await n(e.floating);return{reference:$y(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ly(e){return Qe(e).direction==="rtl"}const Ry={convertOffsetParentRelativeRectToViewportRelativeRect:Py,getDocumentElement:at,getClippingRect:My,getOffsetParent:uu,getElementRects:ky,getClientRects:Ay,getDimensions:Iy,getScale:dn,isElement:Ze,isRTL:Ly};function Vy(e,t){let n=null,r;const o=at(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const{left:c,top:f,width:g,height:m}=e.getBoundingClientRect();if(a||t(),!g||!m)return;const p=Mr(f),v=Mr(o.clientWidth-(c+g)),h=Mr(o.clientHeight-(f+m)),y=Mr(c),b={rootMargin:-p+"px "+-v+"px "+-h+"px "+-y+"px",threshold:Be(0,It(1,u))||1};let S=!0;function E(C){const P=C[0].intersectionRatio;if(P!==u){if(!S)return i();P?i(!1,P):r=setTimeout(()=>{i(!1,1e-7)},1e3)}S=!1}try{n=new IntersectionObserver(E,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,b)}n.observe(e)}return i(!0),s}function By(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=Hs(e),f=o||s?[...c?Mn(c):[],...Mn(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const g=c&&a?Vy(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(w=>{let[b]=w;b&&b.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!u&&p.observe(c),p.observe(t));let v,h=u?Wt(e):null;u&&y();function y(){const w=Wt(e);h&&(w.x!==h.x||w.y!==h.y||w.width!==h.width||w.height!==h.height)&&n(),h=w,v=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),g==null||g(),(w=p)==null||w.disconnect(),p=null,u&&cancelAnimationFrame(v)}}const zy=wy,Hy=by,Uy=my,jy=Cy,Wy=vy,du=hy,Gy=xy,qy=(e,t,n)=>{const r=new Map,o={platform:Ry,...n},s={...o.platform,_c:r};return gy(e,t,{...o,platform:s})};var Vr=typeof document<"u"?D.useLayoutEffect:D.useEffect;function Br(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Br(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pu(e,t){const n=fu(e);return Math.round(t*n)/n}function Ws(e){const t=d.useRef(e);return Vr(()=>{t.current=e}),t}function Ky(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:u,open:c}=e,[f,g]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=d.useState(r);Br(m,r)||p(r);const[v,h]=d.useState(null),[y,w]=d.useState(null),b=d.useCallback(K=>{K!==P.current&&(P.current=K,h(K))},[]),S=d.useCallback(K=>{K!==_.current&&(_.current=K,w(K))},[]),E=s||v,C=i||y,P=d.useRef(null),_=d.useRef(null),O=d.useRef(f),$=u!=null,F=Ws(u),G=Ws(o),k=Ws(c),R=d.useCallback(()=>{if(!P.current||!_.current)return;const K={placement:t,strategy:n,middleware:m};G.current&&(K.platform=G.current),qy(P.current,_.current,K).then(ee=>{const ce={...ee,isPositioned:k.current!==!1};I.current&&!Br(O.current,ce)&&(O.current=ce,jn.flushSync(()=>{g(ce)}))})},[m,t,n,G,k]);Vr(()=>{c===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,g(K=>({...K,isPositioned:!1})))},[c]);const I=d.useRef(!1);Vr(()=>(I.current=!0,()=>{I.current=!1}),[]),Vr(()=>{if(E&&(P.current=E),C&&(_.current=C),E&&C){if(F.current)return F.current(E,C,R);R()}},[E,C,R,F,$]);const q=d.useMemo(()=>({reference:P,floating:_,setReference:b,setFloating:S}),[b,S]),U=d.useMemo(()=>({reference:E,floating:C}),[E,C]),J=d.useMemo(()=>{const K={position:n,left:0,top:0};if(!U.floating)return K;const ee=pu(U.floating,f.x),ce=pu(U.floating,f.y);return a?{...K,transform:"translate("+ee+"px, "+ce+"px)",...fu(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ee,top:ce}},[n,a,U.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:R,refs:q,elements:U,floatingStyles:J}),[f,R,q,U,J])}const Xy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?du({element:r.current,padding:o}).fn(n):{}:r?du({element:r,padding:o}).fn(n):{}}}},Jy=(e,t)=>({...zy(e),options:[e,t]}),Yy=(e,t)=>({...Hy(e),options:[e,t]}),Zy=(e,t)=>({...Gy(e),options:[e,t]}),Qy=(e,t)=>({...Uy(e),options:[e,t]}),ew=(e,t)=>({...jy(e),options:[e,t]}),tw=(e,t)=>({...Wy(e),options:[e,t]}),nw=(e,t)=>({...Xy(e),options:[e,t]});var rw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ow=rw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),sw="Arrow",gu=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ow.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});gu.displayName=sw;var iw=gu;function hu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function aw(...e){return t=>{let n=!1;const r=e.map(o=>{const s=hu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():hu(e[o],null)}}}}function mu(...e){return d.useCallback(aw(...e),e)}var lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],vu=lw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Gs="Popper",[yu,wu]=Pt(Gs),[cw,bu]=yu(Gs),xu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return l.jsx(cw,{scope:t,anchor:r,onAnchorChange:o,children:n})};xu.displayName=Gs;var Cu="PopperAnchor",Su=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bu(Cu,n),i=d.useRef(null),a=mu(t,i);return d.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:l.jsx(vu.div,{...o,ref:a})});Su.displayName=Cu;var qs="PopperContent",[uw,dw]=yu(qs),Eu=d.forwardRef((e,t)=>{var Ne,Te,$e,Rt,tt,hn;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...h}=e,y=bu(qs,n),[w,b]=d.useState(null),S=mu(t,Ge=>b(Ge)),[E,C]=d.useState(null),P=La(E),_=(P==null?void 0:P.width)??0,O=(P==null?void 0:P.height)??0,$=r+(s!=="center"?"-"+s:""),F=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},G=Array.isArray(c)?c:[c],k=G.length>0,R={padding:F,boundary:G.filter(pw),altBoundary:k},{refs:I,floatingStyles:q,placement:U,isPositioned:J,middlewareData:K}=Ky({strategy:"fixed",placement:$,whileElementsMounted:(...Ge)=>By(...Ge,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Jy({mainAxis:o+O,alignmentAxis:i}),u&&Yy({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Zy():void 0,...R}),u&&Qy({...R}),ew({...R,apply:({elements:Ge,rects:ft,availableWidth:mn,availableHeight:Hn})=>{const{width:vn,height:x}=ft.reference,N=Ge.floating.style;N.setProperty("--radix-popper-available-width",`${mn}px`),N.setProperty("--radix-popper-available-height",`${Hn}px`),N.setProperty("--radix-popper-anchor-width",`${vn}px`),N.setProperty("--radix-popper-anchor-height",`${x}px`)}}),E&&nw({element:E,padding:a}),gw({arrowWidth:_,arrowHeight:O}),m&&tw({strategy:"referenceHidden",...R})]}),[ee,ce]=Pu(U),fe=Pe(v);Ve(()=>{J&&(fe==null||fe())},[J,fe]);const Ce=(Ne=K.arrow)==null?void 0:Ne.x,Ie=(Te=K.arrow)==null?void 0:Te.y,je=(($e=K.arrow)==null?void 0:$e.centerOffset)!==0,[We,we]=d.useState();return Ve(()=>{w&&we(window.getComputedStyle(w).zIndex)},[w]),l.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:J?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:We,"--radix-popper-transform-origin":[(Rt=K.transformOrigin)==null?void 0:Rt.x,(tt=K.transformOrigin)==null?void 0:tt.y].join(" "),...((hn=K.hide)==null?void 0:hn.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(uw,{scope:n,placedSide:ee,onArrowChange:C,arrowX:Ce,arrowY:Ie,shouldHideArrow:je,children:l.jsx(vu.div,{"data-side":ee,"data-align":ce,...h,ref:S,style:{...h.style,animation:J?void 0:"none"}})})})});Eu.displayName=qs;var Nu="PopperArrow",fw={top:"bottom",right:"left",bottom:"top",left:"right"},Tu=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=dw(Nu,r),i=fw[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(iw,{...o,ref:n,style:{...o.style,display:"block"}})})});Tu.displayName=Nu;function pw(e){return e!==null}var gw=e=>({name:"transformOrigin",options:e,fn(t){var y,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[c,f]=Pu(n),g={start:"0%",center:"50%",end:"100%"}[f],m=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+u/2;let v="",h="";return c==="bottom"?(v=i?g:`${m}px`,h=`${-u}px`):c==="top"?(v=i?g:`${m}px`,h=`${r.floating.height+u}px`):c==="right"?(v=`${-u}px`,h=i?g:`${p}px`):c==="left"&&(v=`${r.floating.width+u}px`,h=i?g:`${p}px`),{data:{x:v,y:h}}}});function Pu(e){const[t,n="center"]=e.split("-");return[t,n]}var hw=xu,mw=Su,vw=Eu,yw=Tu,ww="Portal",Au=d.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=d.useState(!1);Ve(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?no.createPortal(l.jsx(Fn.div,{...r,ref:t}),i):null});Au.displayName=ww;function bw(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Ks=e=>{const{present:t,children:n}=e,r=xw(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=_n(r.ref,Cw(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Ks.displayName="Presence";function xw(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=bw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const c=zr(r.current);s.current=a==="mounted"?c:"none"},[a]),Ve(()=>{const c=r.current,f=o.current;if(f!==e){const m=s.current,p=zr(c);e?u("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ve(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,g=p=>{const h=zr(r.current).includes(p.animationName);if(p.target===t&&h&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},m=p=>{p.target===t&&(s.current=zr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function zr(e){return(e==null?void 0:e.animationName)||"none"}function Cw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Sw="VisuallyHidden",_u=d.forwardRef((e,t)=>l.jsx(Fn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));_u.displayName=Sw;var Ew=_u,[Hr,lC]=Pt("Tooltip",[wu]),Ur=wu(),Fu="TooltipProvider",Nw=700,Xs="tooltip.open",[Tw,Js]=Hr(Fu),Ou=e=>{const{__scopeTooltip:t,delayDuration:n=Nw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,[i,a]=d.useState(!0),u=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const f=c.current;return()=>window.clearTimeout(f)},[]),l.jsx(Tw,{scope:t,isOpenDelayed:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:d.useCallback(f=>{u.current=f},[]),disableHoverableContent:o,children:s})};Ou.displayName=Fu;var jr="Tooltip",[Pw,In]=Hr(jr),Du=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,u=Js(jr,e.__scopeTooltip),c=Ur(t),[f,g]=d.useState(null),m=tn(),p=d.useRef(0),v=i??u.disableHoverableContent,h=a??u.delayDuration,y=d.useRef(!1),[w=!1,b]=Qt({prop:r,defaultProp:o,onChange:_=>{_?(u.onOpen(),document.dispatchEvent(new CustomEvent(Xs))):u.onClose(),s==null||s(_)}}),S=d.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),E=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,b(!0)},[b]),C=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),P=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,b(!0),p.current=0},h)},[h,b]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),l.jsx(hw,{...c,children:l.jsx(Pw,{scope:t,contentId:m,open:w,stateAttribute:S,trigger:f,onTriggerChange:g,onTriggerEnter:d.useCallback(()=>{u.isOpenDelayed?P():E()},[u.isOpenDelayed,P,E]),onTriggerLeave:d.useCallback(()=>{v?C():(window.clearTimeout(p.current),p.current=0)},[C,v]),onOpen:E,onClose:C,disableHoverableContent:v,children:n})})};Du.displayName=jr;var Ys="TooltipTrigger",Mu=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=In(Ys,n),s=Js(Ys,n),i=Ur(n),a=d.useRef(null),u=_n(t,a,o.onTriggerChange),c=d.useRef(!1),f=d.useRef(!1),g=d.useCallback(()=>c.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),l.jsx(mw,{asChild:!0,...i,children:l.jsx(Fn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:vt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:vt(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:vt(e.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:vt(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:vt(e.onBlur,o.onClose),onClick:vt(e.onClick,o.onClose)})})});Mu.displayName=Ys;var Zs="TooltipPortal",[Aw,_w]=Hr(Zs,{forceMount:void 0}),Iu=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=In(Zs,t);return l.jsx(Aw,{scope:t,forceMount:n,children:l.jsx(Ks,{present:n||s.open,children:l.jsx(Au,{asChild:!0,container:o,children:r})})})};Iu.displayName=Zs;var fn="TooltipContent",$u=d.forwardRef((e,t)=>{const n=_w(fn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=In(fn,e.__scopeTooltip);return l.jsx(Ks,{present:r||i.open,children:i.disableHoverableContent?l.jsx(ku,{side:o,...s,ref:t}):l.jsx(Fw,{side:o,...s,ref:t})})}),Fw=d.forwardRef((e,t)=>{const n=In(fn,e.__scopeTooltip),r=Js(fn,e.__scopeTooltip),o=d.useRef(null),s=_n(t,o),[i,a]=d.useState(null),{trigger:u,onClose:c}=n,f=o.current,{onPointerInTransitChange:g}=r,m=d.useCallback(()=>{a(null),g(!1)},[g]),p=d.useCallback((v,h)=>{const y=v.currentTarget,w={x:v.clientX,y:v.clientY},b=Iw(w,y.getBoundingClientRect()),S=$w(w,b),E=kw(h.getBoundingClientRect()),C=Rw([...S,...E]);a(C),g(!0)},[g]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(u&&f){const v=y=>p(y,f),h=y=>p(y,u);return u.addEventListener("pointerleave",v),f.addEventListener("pointerleave",h),()=>{u.removeEventListener("pointerleave",v),f.removeEventListener("pointerleave",h)}}},[u,f,p,m]),d.useEffect(()=>{if(i){const v=h=>{const y=h.target,w={x:h.clientX,y:h.clientY},b=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),S=!Lw(w,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,f,i,c,m]),l.jsx(ku,{...e,ref:s})}),[Ow,Dw]=Hr(jr,{isInside:!1}),ku=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,u=In(fn,n),c=Ur(n),{onClose:f}=u;return d.useEffect(()=>(document.addEventListener(Xs,f),()=>document.removeEventListener(Xs,f)),[f]),d.useEffect(()=>{if(u.trigger){const g=m=>{const p=m.target;p!=null&&p.contains(u.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,f]),l.jsx(Kc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:l.jsxs(vw,{"data-state":u.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(xa,{children:r}),l.jsx(Ow,{scope:n,isInside:!0,children:l.jsx(Ew,{id:u.contentId,role:"tooltip",children:o||r})})]})})});$u.displayName=fn;var Lu="TooltipArrow",Mw=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ur(n);return Dw(Lu,n).isInside?null:l.jsx(yw,{...o,...r,ref:t})});Mw.displayName=Lu;function Iw(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function $w(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function kw(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function Lw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,u=t[s].y,c=t[i].x,f=t[i].y;u>r!=f>r&&n<(c-a)*(r-u)/(f-u)+a&&(o=!o)}return o}function Rw(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Vw(t)}function Vw(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Bw=Ou,zw=Du,Hw=Mu,Uw=Iu,Ru=$u;const Vu=Bw,Bu=zw,zu=Hw,Qs=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(Uw,{children:l.jsx(Ru,{ref:r,sideOffset:t,className:Q("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Qs.displayName=Ru.displayName;function jw({title:e,titleId:t,...n},r){return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?d.createElement("title",{id:t},e):null,d.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ww=d.forwardRef(jw);var Gw=function(e){return function(t,n){var r=D.useRef(!1);e(function(){return function(){r.current=!1}},[]),e(function(){if(!r.current)r.current=!0;else return t()},n)}},Hu=function(e){return typeof e=="function"},Uu=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const qw=Gw(D.useEffect);function ju(e){var t=D.useRef(e);return t.current=e,t}var Kw=function(e){Uu&&(Hu(e)||console.error("useUnmount expected parameter is a function, got ".concat(typeof e)));var t=ju(e);D.useEffect(function(){return function(){t.current()}},[])},Wr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Jw(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Wu=Jw,Yw=typeof Wr=="object"&&Wr&&Wr.Object===Object&&Wr,Zw=Yw,Qw=Zw,eb=typeof self=="object"&&self&&self.Object===Object&&self,tb=Qw||eb||Function("return this")(),Gu=tb,nb=Gu,rb=function(){return nb.Date.now()},ob=rb,sb=/\s/;function ib(e){for(var t=e.length;t--&&sb.test(e.charAt(t)););return t}var ab=ib,lb=ab,cb=/^\s+/;function ub(e){return e&&e.slice(0,lb(e)+1).replace(cb,"")}var db=ub,fb=Gu,pb=fb.Symbol,qu=pb,Ku=qu,Xu=Object.prototype,gb=Xu.hasOwnProperty,hb=Xu.toString,$n=Ku?Ku.toStringTag:void 0;function mb(e){var t=gb.call(e,$n),n=e[$n];try{e[$n]=void 0;var r=!0}catch{}var o=hb.call(e);return r&&(t?e[$n]=n:delete e[$n]),o}var vb=mb,yb=Object.prototype,wb=yb.toString;function bb(e){return wb.call(e)}var xb=bb,Ju=qu,Cb=vb,Sb=xb,Eb="[object Null]",Nb="[object Undefined]",Yu=Ju?Ju.toStringTag:void 0;function Tb(e){return e==null?e===void 0?Nb:Eb:Yu&&Yu in Object(e)?Cb(e):Sb(e)}var Pb=Tb;function Ab(e){return e!=null&&typeof e=="object"}var _b=Ab,Fb=Pb,Ob=_b,Db="[object Symbol]";function Mb(e){return typeof e=="symbol"||Ob(e)&&Fb(e)==Db}var Ib=Mb,$b=db,Zu=Wu,kb=Ib,Qu=NaN,Lb=/^[-+]0x[0-9a-f]+$/i,Rb=/^0b[01]+$/i,Vb=/^0o[0-7]+$/i,Bb=parseInt;function zb(e){if(typeof e=="number")return e;if(kb(e))return Qu;if(Zu(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Zu(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$b(e);var n=Rb.test(e);return n||Vb.test(e)?Bb(e.slice(2),n?2:8):Lb.test(e)?Qu:+e}var Hb=zb,Ub=Wu,ei=ob,ed=Hb,jb="Expected a function",Wb=Math.max,Gb=Math.min;function qb(e,t,n){var r,o,s,i,a,u,c=0,f=!1,g=!1,m=!0;if(typeof e!="function")throw new TypeError(jb);t=ed(t)||0,Ub(n)&&(f=!!n.leading,g="maxWait"in n,s=g?Wb(ed(n.maxWait)||0,t):s,m="trailing"in n?!!n.trailing:m);function p(P){var _=r,O=o;return r=o=void 0,c=P,i=e.apply(O,_),i}function v(P){return c=P,a=setTimeout(w,t),f?p(P):i}function h(P){var _=P-u,O=P-c,$=t-_;return g?Gb($,s-O):$}function y(P){var _=P-u,O=P-c;return u===void 0||_>=t||_<0||g&&O>=s}function w(){var P=ei();if(y(P))return b(P);a=setTimeout(w,h(P))}function b(P){return a=void 0,m&&r?p(P):(r=o=void 0,i)}function S(){a!==void 0&&clearTimeout(a),c=0,r=u=o=a=void 0}function E(){return a===void 0?i:b(ei())}function C(){var P=ei(),_=y(P);if(r=arguments,o=this,u=P,_){if(a===void 0)return v(u);if(g)return clearTimeout(a),a=setTimeout(w,t),p(u)}return a===void 0&&(a=setTimeout(w,t)),i}return C.cancel=S,C.flush=E,C}var Kb=qb;const Xb=Xw(Kb);function Jb(){var e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}Jb()||(global.Date=Date);function Yb(e,t){var n;Uu&&(Hu(e)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof e)));var r=ju(e),o=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=D.useMemo(function(){return Xb(function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return r.current.apply(r,il([],sl(i),!1))},o,t)},[]);return Kw(function(){s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function Zb(e,t,n){var r=sl(D.useState({}),2),o=r[0],s=r[1],i=Yb(function(){s({})},n).run;D.useEffect(function(){return i()},t),qw(e,[o])}const Qb=D.forwardRef(({onChange:e},t)=>{const n=D.useRef(null),[r,o]=D.useState("");return D.useImperativeHandle(t,()=>({setValue:s=>{var i;o(s),(i=n.current)==null||i.focus()}})),Zb(()=>{e==null||e(r)},[r],{wait:300}),l.jsxs(l.Fragment,{children:[l.jsx(Mt,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:s=>o(s.target.value),className:"pr-8"}),r&&l.jsx("button",{onClick:()=>{var s;o(""),(s=n.current)==null||s.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:l.jsx(Ww,{className:"h-5 w-5"})})]})}),De={current:!1},td="crawl:jobs",pn="crawl:current_job",ex=e=>{const[t,n]=D.useState(null),[r,o]=D.useState(0);return D.useEffect(()=>{const s=localStorage.getItem(pn);if(s){const i=JSON.parse(s);n(i),i!=null&&i.startTime&&o(Math.floor((Date.now()-i.startTime)/1e3))}},[]),D.useEffect(()=>{if(!(t!=null&&t.startTime))return;const s=setInterval(()=>{o(Math.floor((Date.now()-t.startTime)/1e3))},1e3);return()=>clearInterval(s)},[t==null?void 0:t.startTime]),D.useEffect(()=>{if(!(t!=null&&t.id))return;const s=async()=>{try{const u=(await ie.get(`${e}/api/crawl/${t.id}?taskId=${t.taskId}`)).data;n(c=>{if(!c)return null;const f={...c,status:u};return localStorage.setItem(pn,JSON.stringify(f)),(u.status==="completed"||u.status==="failed")&&setTimeout(()=>{n(null),localStorage.removeItem(pn)},100),f})}catch(a){console.error("Error polling job status:",a)}},i=setInterval(s,3e3);return s(),()=>clearInterval(i)},[t==null?void 0:t.id,e]),{currentJob:t,elapsedTime:r,setCurrentJob:s=>{s&&!s.startTime&&(s.startTime=Date.now()),n(s),s?localStorage.setItem(pn,JSON.stringify(s)):localStorage.removeItem(pn)}}},tx=(e,t,n)=>{const r=[],o=s=>{(e[s]||[]).forEach(a=>{a.name.toLowerCase().includes(t.toLowerCase())&&r.push(a),a.isFolder&&a.key.startsWith(n)&&o(a.key)})};return o(n),r},Gr=(e,t)=>{const n=[],r=o=>{(e[o]||[]).forEach(i=>{n.push(i.key),i.isFolder&&r(i.key)})};return r(t),n},nx=(e,t)=>{const n=[];return(e[t]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Gr(e,o.key))}),n},rx=(e,t,n=[])=>{const[r,o]=D.useState({}),[s,i]=D.useState(!1),[a,u]=D.useState(null),c=D.useRef(t);D.useEffect(()=>{c.current=t},[t]);const f=async()=>{i(!0);try{const g=!De.current;De.current&&(De.current=!1);const m=await ie.get(`${e}/api/files`,{params:{cache:g,displayPrefixes:JSON.stringify(n),prefix:c.current},timeout:3e5});o(m.data),u(null)}catch(g){u(g instanceof Error?g:new Error("Failed to fetch files"))}finally{i(!1)}};return D.useEffect(()=>{f()},[]),{data:r,isLoading:s,error:a,refetch:f}},kn=e=>{var r,o,s;const t=((s=(o=(r=e==null?void 0:e.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:s.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(t||"")},ox=D.memo(({homeLabel:e="Kho tài liệu",apiBaseUrl:t="http://localhost:3002",rootPrefix:n="",asSelector:r=!1,onSelected:o=i=>console.log("Đã chọn:",i),displayPrefixes:s})=>{var Td;const[i,a]=D.useState(""),[u,c]=D.useState(new Set),[f,g]=D.useState(n),[m,p]=D.useState(null),[v,h]=D.useState(!1),[y,w]=D.useState(""),[b,S]=D.useState(!1),[E,C]=D.useState(null),[P,_]=D.useState(!1),[O,$]=D.useState(!1),[F,G]=D.useState(null),k=D.useRef(null),{toast:R}=Ds(),[I,q]=D.useState(null),[U,J]=D.useState(null),[K,ee]=D.useState(""),[ce,fe]=D.useState(!1),[Ce,Ie]=D.useState(new Set),[je,We]=D.useState(""),[we,Ne]=D.useState(!1),[Te,$e]=D.useState(!1),[Rt,tt]=D.useState("rename"),[hn,Ge]=D.useState(!1),[ft,mn]=D.useState(""),[Hn,vn]=D.useState("1"),[x,N]=D.useState(!1),[A,z]=D.useState(!1),[B,V]=D.useState(!1),[X,oe]=D.useState(!1),{currentJob:te,elapsedTime:pe,setCurrentJob:pt}=ex(t),gi=m||n,{data:_e,isLoading:qt,error:hi,refetch:ke}=rx(t,gi,s);D.useEffect(()=>{te!=null&&te.status&&(te.status.status==="completed"?(R({title:"Thu thập website hoàn tất",description:`Đã thu thập thành công ${te.url} với ${te.status.completed} trang`}),De.current=!0,ke()):te.status.status==="failed"&&R({title:"Thu thập website thất bại",description:`Không thể thu thập ${te.url}. Vui lòng thử lại.`,variant:"destructive"}))},[(Td=te==null?void 0:te.status)==null?void 0:Td.status]);const Qr=D.useMemo(()=>_e[f]||[],[_e,f]),gt=D.useMemo(()=>i?tx(_e,i,f):Qr,[Qr,i,f,_e]),Un=D.useMemo(()=>{const M={};return gt.forEach((L,H)=>{u.has(L.key)&&(M[H]=!0)}),M},[u,gt]),_x=M=>{const L=Gr(_e,M);if(L.length===0)return u.has(M)?"all":"none";const H=L.filter(W=>u.has(W)).length;return H===0?"none":H===L.length?"all":"partial"},eo=M=>{oe(!0),p(M),g(M)};D.useEffect(()=>{X&&(De.current=!0,ke().finally(()=>oe(!1)))},[X]);const Fx=async(M,L)=>{S(!0);try{const H=`${L}${M}/`;if((await ie.post(`${t}/api/create-folder`,{prefix:H})).status!==200){R({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"});return}De.current=!0,await ke(),R({title:"Đã tạo thư mục",description:`Đã tạo thành công thư mục "${M}"`}),w(""),h(!1)}catch(H){console.error("Error creating folder:",H),R({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"})}finally{S(!1)}},Cd=async(M,L,H)=>{G(H),z(!0);try{if(sg(M,R))return;let W=localStorage.getItem("dataLogin"),se;try{W&&(W=JSON.parse(W),se=W.user)}catch{W=null}const ae=new FormData;ae.append("prefix",L),Array.from(M).forEach(he=>ae.append("files",he)),se!=null&&se.id&&(console.log("🚀 ~ uploadFiles ~ user:",se),ae.append("metadata",JSON.stringify({creator:se.username,creatorId:se.id,DataSource:"Tệp tải lên"}))),await ie.post(`${t}/api/upload`,ae,{headers:{"Content-Type":"multipart/form-data"}}),p(L),De.current=!0,await ke()}catch(W){console.error("Lỗi tải lên:",W)}finally{G(null),z(!1)}},Ox=async M=>{var L;V(!0);try{await ie.delete(`${t}/api/files`,{data:{paths:[M.key]}});const H=((L=M.key)==null?void 0:L.replace(/^(.*?)(\/.*)?$/,(W,se,ae)=>!ae||ae==="/"?"":se+"/"))||"";p(H),De.current=!0,R({title:"Đã xóa tập tin",description:`Đã xóa thành công "${M.name}"`}),C(null)}catch(H){console.error("Error deleting file:",H),R({title:"Lỗi",description:"Không thể xóa tập tin",variant:"destructive"})}finally{V(!1),await ke()}},to=M=>{const L=new Set(u),H=typeof M=="function"?M(Un):M;new Set(Object.keys(Un).map(Number)).forEach(se=>{const ae=gt[se];ae&&(H[se]||(L.delete(ae.key),ae.isFolder&&Gr(_e,ae.key).forEach(he=>L.delete(he))))}),Object.entries(H).forEach(([se,ae])=>{const he=parseInt(se),Ct=gt[he];Ct&&ae&&(L.add(Ct.key),Ct.isFolder&&Gr(_e,Ct.key).forEach(vi=>L.add(vi)))}),c(L)},Dx=async()=>{var M;_(!0);try{const L=Array.from(u),H=L.map(se=>Object.values(_e).flat().find(ae=>ae.key===se)).filter(se=>se!==void 0);if(H.length===0){R({title:"Lỗi",description:"Không có tập tin nào được chọn để xóa",variant:"destructive"});return}await ie.delete(`${t}/api/files`,{data:{paths:L}});const W=((M=H[0])==null?void 0:M.key.replace(/^(.*?)(\/.*)?$/,(se,ae,he)=>!he||he==="/"?"":ae+"/"))||"";p(W),De.current=!0,ke(),R({title:"Đã xóa tập tin",description:`Đã xóa thành công ${H.length} mục`}),$(!1),c(new Set)}catch(L){console.error("Error deleting files:",L),R({title:"Lỗi",description:"Không thể xóa các tập tin đã chọn",variant:"destructive"})}finally{_(!1)}},Mx=async(M,L)=>{fe(!0);try{const H=M.key;let W;M.isFolder?W=H.split("/").slice(0,-2).join("/")+"/":W=H.substring(0,H.lastIndexOf("/")+1);const se=W+L+(M.isFolder?"/":"");await ie.post(`${t}/api/rename`,{oldPath:H,newPath:se}),De.current=!0,await ke(),R({title:"Đã đổi tên",description:`Đã đổi tên thành công "${M.name}" thành "${L}"`}),q(null),ee(""),J(null)}catch(H){console.error("Error renaming item:",H),R({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{fe(!1)}},Sd=async M=>{Ie(L=>new Set([...L,...M]));try{const L=await ie.post(`${t}/api/download`,{paths:M},{responseType:"blob"}),H=window.URL.createObjectURL(L.data),W=document.createElement("a");W.href=H;const se=L.headers["Content-Disposition"]||L.headers["content-disposition"],ae=se==null?void 0:se.match(/filename="(.+)"/),he=ae?decodeURIComponent(ae[1]):"download.zip";W.setAttribute("download",he),document.body.appendChild(W),W.click(),document.body.removeChild(W),window.URL.revokeObjectURL(H),R({title:"Bắt đầu tải xuống",description:`Đã bắt đầu tải xuống ${M.length} mục${M.length>1,""}`})}catch(L){console.error("Error downloading files:",L),R({title:"Lỗi",description:"Không thể tải xuống tập tin",variant:"destructive"})}finally{Ie(L=>{const H=new Set(L);return M.forEach(W=>H.delete(W)),H})}},Ed=f?f.replace(n,"").split("/").filter(Boolean):[],Ix=()=>Array.from(u).map(M=>{var L;for(const H in _e){const W=(L=_e[H])==null?void 0:L.find(se=>se.key===M);if(W)return W}return null}).filter(M=>M!==null),Nd=D.useMemo(()=>{const M=[{id:"select",header:()=>{const L=nx(_e,f),H=L.length>0&&L.every(se=>u.has(se)),W=L.some(se=>u.has(se));return l.jsx(Go,{checked:H?!0:W?"indeterminate":!1,onCheckedChange:se=>{if(se){const ae=gt.reduce((he,Ct,vi)=>(he[vi]=!0,he),{});to(ae)}else to({})},"aria-label":"Chọn tất cả"})},cell:({row:L})=>{const H=L.original,se=H.isFolder?_x(H.key):u.has(H.key)?"all":"none";return l.jsx("div",{className:"flex items-center",children:l.jsx(Go,{checked:se==="partial"?"indeterminate":se==="all",onCheckedChange:ae=>{const he={...Un};ae?he[L.index]=!0:delete he[L.index],to(he)},"aria-label":"Chọn dòng"})})},enableSorting:!1},{id:"fileName",header:"Tên tập tin",accessorKey:"name",cell:({row:L})=>{const H=L.original,W=H.key.substring(0,H.key.lastIndexOf("/"))||"/",se=i.trim()!==""&&W!==f,ae=W.split("/").filter(Boolean);return l.jsxs("div",{className:"flex flex-col",children:[l.jsxs("div",{className:`flex items-center gap-2 ${H.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{H.isFolder&&eo(H.key)},children:[H.isFolder?l.jsx(ro,{className:"h-5 w-5 text-blue-500"}):null,H.name]}),se&&l.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[l.jsx(ro,{className:"h-4 w-4 text-gray-500 my-auto"}),l.jsxs("span",{className:"flex items-center ml-1",children:[l.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{eo("")},children:"/"}),ae.map((he,Ct)=>l.jsxs("span",{className:"flex items-center",children:[l.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{eo(ae.slice(0,Ct+1).join("/")+"/")},children:he}),Ct<ae.length-1&&l.jsx("span",{children:"/"})]},Ct))]})]})]})}}];return r||M.push({id:"size",header:"Kích thước",accessorKey:"size",cell:({getValue:L,row:H})=>{const W=L();return l.jsx("span",{children:H.original.isFolder?"-":zg(W)})}},{id:"lastModified",header:"Sửa đổi lần cuối",accessorKey:"lastModified",cell:({row:L})=>{const H=L.original.lastModified;return l.jsx("span",{children:H.toLocaleString()})}},{id:"actions",header:"Hành động",accessorKey:"key",cell:({row:L})=>l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>Sd([L.original.key]),className:"h-8 w-8 p-0",disabled:Ce.has(L.original.key),children:Ce.has(L.original.key)?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):l.jsx(wi,{className:"h-4 w-4"})}),l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>{q(L.original),ee(L.original.name)},className:"h-8 w-8 p-0",children:l.jsx(Rd,{className:"h-4 w-4"})}),l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>C(L.original),className:"h-8 w-8 p-0",children:l.jsx(bi,{className:"h-4 w-4"})})]})}),M},[u,gt,Un,Ce,r]),mi=Mi({data:gt,columns:Nd,state:{rowSelection:Un},enableRowSelection:!0,onRowSelectionChange:to,getCoreRowModel:Di()}),$x=async M=>{var L,H;Ne(!0);try{if(kn(M)){const W=await ie.get(`${t}/api/read-text`,{params:{path:M.key}});We(W.data.content)}try{const W=await ie.get(`${t}/api/read-json`,{params:{path:M.key+".metadata.json"}});return console.log("🚀 ~ loadFileContent ~ responseMetadata:",W),J(((H=(L=W==null?void 0:W.data)==null?void 0:L.content)==null?void 0:H.metadataAttributes)||null)}catch{return J("Lỗi phân tích siêu dữ liệu")}}catch(W){console.error("Error loading file content:",W),R({title:"Lỗi",description:"Không thể tải nội dung tập tin",variant:"destructive"})}finally{Ne(!1)}},kx=async(M,L)=>{$e(!0);try{await ie.post(`${t}/api/modify-text`,{path:M.key,content:L}),R({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),De.current=!0,await ke(),q(null),We(""),tt("rename")}catch(H){console.error("Error saving file content:",H),R({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{$e(!1)}},Lx=async M=>{$e(!0);try{console.log("🚀 ~ saveJsonFile ~ metadataForEdit:",U),await ie.post(`${t}/api/modify-json`,{path:M.key+".metadata.json",content:{metadataAttributes:U}}),R({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),De.current=!0,await ke(),q(null),We(""),tt("rename")}catch(L){console.error("Error saving file content:",L),R({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{$e(!1)}};D.useEffect(()=>{I&&($x(I),tt("rename"))},[I]);const Rx=async(M,L)=>{var H;if(te){R({title:"Đang thu thập website",description:"Vui lòng đợi cho công việc thu thập hiện tại hoàn thành.",variant:"destructive"});return}N(!0);try{const{data:W}=await ie.post(`${t}/api/crawl`,{url:M,limit:L,prefix:f});if(W.id){pt({id:W.id,url:M,limit:L,prefix:f,taskId:((H=W.task)==null?void 0:H.id)||""});const se=localStorage.getItem(td),ae=se?JSON.parse(se):[];ae.some(he=>he.id===W.id)||(ae.unshift({url:M,id:W.id,limit:L,prefix:f,timestamp:Date.now()}),ae.length>20&&(ae.length=20),localStorage.setItem(td,JSON.stringify(ae))),R({title:"Bắt đầu thu thập website",description:`Đã thêm nhiệm vụ thu thập ${M} với giới hạn ${L}. Dữ liệu sẽ có sẵn sau khi thu thập hoàn tất.`}),Ge(!1),mn(""),vn("1")}}catch(W){console.error("Error crawling website:",W),R({title:"Lỗi",description:"Không thể bắt đầu thu thập website",variant:"destructive"})}finally{N(!1)}},Vx=async()=>{try{if(!(te!=null&&te.id))return;pt(null),localStorage.removeItem(pn),R({title:"Đã dừng thu thập",description:`Đã dừng thu thập website ${te.url}`})}catch(M){console.error("Error stopping job:",M),R({title:"Lỗi",description:"Không thể dừng thu thập website",variant:"destructive"})}};return l.jsxs("div",{className:"space-y-4 s3-explr-container",children:[l.jsx(Oa,{className:"s3-explr-breadcrumb",children:l.jsxs(Da,{className:"s3-explr-breadcrumb-list",children:[l.jsx(zo,{className:"s3-explr-breadcrumb-item",children:l.jsx(Ho,{onClick:()=>{p(""),g(""),De.current=!0,setTimeout(()=>{ke()},0)},className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:e})}),Ed.map((M,L)=>l.jsxs(l.Fragment,{children:[l.jsx(Ma,{className:"s3-explr-breadcrumb-separator"},`sep-${L}`),l.jsx(zo,{className:"s3-explr-breadcrumb-item",children:l.jsx(Ho,{onClick:()=>eo(n+Ed.slice(0,L+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:M})},`item-${M}`)]}))]})}),l.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[l.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:l.jsx(Qb,{ref:k,onChange:M=>a(M)})}),l.jsxs(le,{variant:"outline",size:"sm",onClick:()=>{p(f),De.current=!0,ke()},disabled:qt,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[l.jsx(_d,{className:`h-4 w-4 s3-explr-refresh-icon ${qt?"animate-spin":""}`}),"Làm mới"]}),!r&&l.jsxs(l.Fragment,{children:[u.size>0&&l.jsxs(l.Fragment,{children:[l.jsxs(le,{variant:"outline",size:"sm",onClick:()=>Sd(Array.from(u)),disabled:Array.from(u).some(M=>Ce.has(M)),className:"flex items-center gap-2 s3-explr-download-selected-btn",children:[Array.from(u).some(M=>Ce.has(M))?l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}):l.jsx(wi,{className:"h-4 w-4 s3-explr-download-icon"}),"Tải xuống đã chọn (",u.size,")"]}),l.jsxs(Ut,{open:O,onOpenChange:$,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[l.jsx(bi,{className:"h-4 w-4 s3-explr-trash-icon"}),"Xóa đã chọn (",u.size,")"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Xác nhận xóa hàng loạt"}),l.jsxs(yr,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",u.size," mục đã chọn? Hành động này không thể hoàn tác."]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>$(!1),className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{variant:"destructive",onClick:Dx,disabled:P,className:"s3-explr-confirm-delete-btn",children:P?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa đã chọn"})]})]})]})]}),l.jsxs(Ut,{open:v,onOpenChange:h,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-new-folder-btn",disabled:!!s&&!f,children:[l.jsx(Md,{className:"h-4 w-4 s3-explr-folder-plus-icon"}),"Thư mục mới"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsx(Ot,{className:"s3-explr-dialog-header",children:l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Tạo thư mục mới"})}),l.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"name",className:"s3-explr-label",children:"Tên thư mục"}),l.jsx(Mt,{disabled:b,id:"name",value:y,onChange:M=>w(M.target.value),placeholder:"Nhập tên thư mục",className:"s3-explr-input"})]}),l.jsxs(le,{onClick:()=>{y.trim()&&Fx(y,f)},disabled:b,className:"s3-explr-create-btn",children:[b&&l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),b?"Đang tạo...":"Tạo"]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[l.jsx(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-files-btn",onClick:()=>{const M=document.createElement("input");M.type="file",M.multiple=!0,M.onchange=L=>{const H=L.target.files;H&&Cd(H,f,"files")},M.click()},disabled:F!==null||!!s&&!f,children:F==="files"?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Đang tải lên..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Od,{className:"h-4 w-4 s3-explr-upload-icon"}),"Tải lên tập tin"]})}),l.jsx(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-folder-btn",onClick:()=>{const M=document.createElement("input");M.type="file",M.multiple=!0,M.webkitdirectory=!0,M.onchange=L=>{const H=L.target.files;H&&Cd(H,f,"folder")},M.click()},disabled:F!==null||!!s&&!f,children:F==="folder"?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Đang tải lên..."]}):l.jsxs(l.Fragment,{children:[l.jsx(ro,{className:"h-4 w-4 s3-explr-folder-icon"}),"Tải lên thư mục"]})}),te?l.jsx(Vu,{delayDuration:0,children:l.jsxs(Bu,{children:[l.jsx(zu,{asChild:!0,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!0,children:[l.jsx(ve,{className:"h-4 w-4 animate-spin s3-explr-loader"}),te.status?l.jsxs(l.Fragment,{children:["Đang thu thập (",te.status.completed,"/",te.status.total,") - ",Math.floor(pe/60),":",String(pe%60).padStart(2,"0")]}):"Đang thu thập..."]}),l.jsxs(le,{variant:"destructive",size:"sm",onClick:()=>void Vx(),className:"flex items-center gap-2",children:[l.jsx("span",{className:"sr-only",children:"Dừng thu thập"}),l.jsx(Bd,{className:"h-4 w-4"})]})]})}),te.status&&l.jsx(Qs,{side:"right",sideOffset:5,children:l.jsxs("div",{className:"space-y-1 p-2",children:[l.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",te.url]}),l.jsxs("p",{children:["Tiến độ: ",te.status.completed,"/",te.status.total," trang"]}),l.jsxs("p",{children:["Thời gian: ",Math.floor(pe/60),":",String(pe%60).padStart(2,"0")]}),l.jsxs("p",{children:["Trạng thái:"," ",te.status.status==="scraping"?"Đang thu thập":te.status.status==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}):l.jsxs(Ut,{open:hn,onOpenChange:Ge,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!f,children:[l.jsx(kd,{className:"h-4 w-4 s3-explr-globe-icon"}),"Thêm website"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Thêm website"}),l.jsx(yr,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),l.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),l.jsx(Mt,{id:"websiteUrl",value:ft,onChange:M=>mn(M.target.value),placeholder:"https://example.com",type:"url",disabled:x,className:"s3-explr-input"})]}),l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),l.jsx(Mt,{id:"crawlLimit",value:Hn,onChange:M=>{const L=M.target.value;/^\d*$/.test(L)&&vn(L)},placeholder:"1",type:"text",disabled:x,className:"s3-explr-input"}),l.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>{Ge(!1),mn(""),vn("1")},disabled:x,className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{onClick:()=>{ft.trim()&&Rx(ft.trim(),parseInt(Hn)||1)},disabled:x||!ft.trim(),className:"s3-explr-crawl-btn",children:x?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]})]}),l.jsx(Ut,{open:!!E,onOpenChange:M=>!M&&C(null),children:l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Xác nhận xóa"}),l.jsxs(yr,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",E==null?void 0:E.name,"? Hành động này không thể hoàn tác."]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>C(null),className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{variant:"destructive",onClick:()=>Ox(E),disabled:B,className:"s3-explr-confirm-delete-btn",children:B?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),l.jsx(Ut,{open:!!I,onOpenChange:M=>{M||(q(null),J(null),ee(""),We(""),tt("rename"))},children:l.jsxs(Ft,{className:"s3-explr-dialog-content max-w-5xl w-[90%]",children:[l.jsx(Ot,{className:"s3-explr-dialog-header",children:l.jsx(Dt,{className:"s3-explr-dialog-title",children:I!=null&&I.isFolder?"Đổi tên thư mục":kn(I)?"Quản lý tập tin":"Đổi tên tập tin"})}),I&&!I.isFolder&&l.jsxs(hv,{value:Rt,onValueChange:M=>tt(M),children:[l.jsxs(vc,{"aria-checked":!kn(I),className:"grid w-full grid-cols-3 aria-checked:grid-cols-2",children:[l.jsx(Nr,{value:"rename",children:"Đổi tên"}),kn(I)&&l.jsx(Nr,{value:"edit",children:"Sửa nội dung"}),l.jsx(Nr,{value:"edit-metadata",children:"Sửa metadata file"})]}),l.jsx(Tr,{value:"rename",children:l.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:l.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"newName",className:"s3-explr-label",children:"Tên mới"}),l.jsx(Mt,{id:"newName",value:K,onChange:M=>ee(M.target.value),placeholder:"Nhập tên mới",disabled:ce,className:"s3-explr-input"})]})})}),kn(I)&&l.jsx(Tr,{value:"edit",children:l.jsx("div",{className:"space-y-4 py-4",children:we?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(ve,{className:"h-6 w-6 animate-spin"})}):l.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1",children:[l.jsx(jt,{htmlFor:"content",className:"s3-explr-label",children:"Nội dung tập tin"}),l.jsx(Pn,{id:"content",value:je,onChange:M=>We(M.target.value),placeholder:"Nhập nội dung tập tin",className:"min-h-[200px] font-mono",disabled:Te})]})})}),l.jsx(Tr,{value:"edit-metadata",children:l.jsx("div",{className:"space-y-4 py-4",children:we?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(ve,{className:"h-6 w-6 animate-spin"})}):l.jsx("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1",children:U&&typeof U=="object"&&Object.entries(U).map(([M,L])=>l.jsxs("div",{className:"pb-3 flex flex-col gap-2",children:[l.jsxs(jt,{htmlFor:M,className:"s3-explr-label flex items-center gap-1",children:[rg[M]||M,ko(M)&&l.jsx(tg,{className:"h-[12px] w-[12px] text-red-500"})]}),og(M)?l.jsx(Pn,{id:M,value:typeof L=="string"?L:JSON.stringify(L),onChange:H=>{const W={...U,[M]:H.target.value};J(W)},placeholder:"Nhập nội dung tập tin",className:"min-h-[200px] font-mono",disabled:Te||ko(M)}):l.jsx(Mt,{id:M,value:typeof L=="string"?L:JSON.stringify(L),onChange:H=>{const W={...U,[M]:H.target.value};J(W)},placeholder:"Nhập nội dung",className:"s3-explr-input",disabled:Te||ko(M)})]},M))})})})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>{q(null),J(null),ee(""),We("")},className:"s3-explr-cancel-btn",children:"Hủy"}),Rt==="edit"?l.jsx(le,{onClick:()=>I&&kx(I,je),disabled:Te||we,className:"s3-explr-save-btn",children:Te?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):Rt==="edit-metadata"?l.jsx(le,{onClick:()=>U&&typeof U=="object"&&I&&Lx(I),disabled:Te||we,className:"s3-explr-save-btn",children:Te?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):l.jsx(le,{onClick:()=>{K.trim()&&I&&Mx(I,K.trim())},disabled:ce||!K.trim()||K.trim()===(I==null?void 0:I.name),className:"s3-explr-rename-btn",children:ce?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang đổi tên..."]}):"Đổi tên"})]})]})})]})]}),hi&&l.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative s3-explr-error",children:"Đã xảy ra lỗi khi tải danh sách tập tin"}),l.jsx("div",{className:"rounded-md border s3-explr-table-container",children:l.jsxs(wr,{className:"s3-explr-table",children:[l.jsx(br,{className:"s3-explr-table-header",children:mi.getHeaderGroups().map(M=>l.jsx(Ye,{className:"hover:bg-transparent s3-explr-header-row",children:M.headers.map(L=>l.jsx(st,{className:"s3-explr-header-cell",children:L.isPlaceholder?null:Xn(L.column.columnDef.header,L.getContext())},L.id))},M.id))}),l.jsx(xr,{className:"s3-explr-table-body",children:mi.getRowModel().rows.length===0?l.jsx(Ye,{className:"s3-explr-empty-row",children:l.jsx(Oe,{colSpan:Nd.length,className:"h-24 text-center s3-explr-empty-cell",children:i?l.jsxs("div",{className:"text-gray-500 s3-explr-no-results",children:['Không tìm thấy tập tin hoặc thư mục nào khớp với "',i,'"']}):l.jsx("div",{className:"text-gray-500 s3-explr-empty-message",children:qt?"Đang tải nội dung thư mục... Vui lòng đợi":"Thư mục này không chứa tập tin hoặc thư mục con nào"})})}):mi.getRowModel().rows.map(M=>l.jsx(Ye,{className:"h-12 s3-explr-row",children:M.getVisibleCells().map(L=>l.jsx(Oe,{className:"align-middle s3-explr-cell",children:Xn(L.column.columnDef.cell,L.getContext())},L.id))},M.id))})]})}),r&&o&&l.jsxs("div",{className:"flex justify-between items-center mt-4 s3-explr-selector-footer",children:[l.jsxs("div",{className:"text-sm text-gray-500 s3-explr-selection-count",children:[u.size," ",(u.size===1,"tập tin")," đã chọn"]}),l.jsx(le,{variant:"default",onClick:()=>o(Ix()),disabled:u.size===0,className:"s3-explr-ok-btn",children:"OK"})]}),!r&&l.jsx(jc,{})]})});var Ln=e=>e.type==="checkbox",Gt=e=>e instanceof Date,Ae=e=>e==null;const nd=e=>typeof e=="object";var me=e=>!Ae(e)&&!Array.isArray(e)&&nd(e)&&!Gt(e),sx=e=>me(e)&&e.target?Ln(e.target)?e.target.checked:e.target.value:e,ix=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ax=(e,t)=>e.has(ix(t)),lx=e=>{const t=e.constructor&&e.constructor.prototype;return me(t)&&t.hasOwnProperty("isPrototypeOf")},ti=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Ue(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(ti&&(e instanceof Blob||r))&&(n||me(e)))if(t=n?[]:{},!n&&!lx(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=Ue(e[o]));else return e;return t}var qr=e=>Array.isArray(e)?e.filter(Boolean):[],ge=e=>e===void 0,j=(e,t,n)=>{if(!t||!me(e))return n;const r=qr(t.split(/[,[\].]+?/)).reduce((o,s)=>Ae(o)?o:o[s],e);return ge(r)||r===e?ge(e[t])?n:e[t]:r},ct=e=>typeof e=="boolean",ni=e=>/^\w*$/.test(e),rd=e=>qr(e.replace(/["|']|\]/g,"").split(/\.|\[/)),de=(e,t,n)=>{let r=-1;const o=ni(t)?[t]:rd(t),s=o.length,i=s-1;for(;++r<s;){const a=o[r];let u=n;if(r!==i){const c=e[a];u=me(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=u,e=e[a]}return e};const od={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},et={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},bt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};D.createContext(null);var cx=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==et.all&&(t._proxyFormState[i]=!r||et.all),e[i]}});return o},Me=e=>me(e)&&!Object.keys(e).length,ux=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Me(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===et.all)},Kr=e=>Array.isArray(e)?e:[e];function dx(e){const t=D.useRef(e);t.current=e,D.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var ut=e=>typeof e=="string",fx=(e,t,n,r,o)=>ut(e)?(r&&t.watch.add(e),j(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),j(n,s))):(r&&(t.watchAll=!0),n),px=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},sd=e=>({isOnSubmit:!e||e===et.onSubmit,isOnBlur:e===et.onBlur,isOnChange:e===et.onChange,isOnAll:e===et.all,isOnTouch:e===et.onTouched}),id=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Rn=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=j(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(Rn(a,t))break}else if(me(a)&&Rn(a,t))break}}};var gx=(e,t,n)=>{const r=Kr(j(e,n));return de(r,"root",t[n]),de(e,n,r),e},ri=e=>e.type==="file",dt=e=>typeof e=="function",Xr=e=>{if(!ti)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Jr=e=>ut(e),oi=e=>e.type==="radio",Yr=e=>e instanceof RegExp;const ad={value:!1,isValid:!1},ld={value:!0,isValid:!0};var cd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ge(e[0].attributes.value)?ge(e[0].value)||e[0].value===""?ld:{value:e[0].value,isValid:!0}:ld:ad}return ad};const ud={isValid:!1,value:null};var dd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ud):ud;function fd(e,t,n="validate"){if(Jr(e)||Array.isArray(e)&&e.every(Jr)||ct(e)&&!e)return{type:n,message:Jr(e)?e:"",ref:t}}var gn=e=>me(e)&&!Yr(e)?e:{value:e,message:""},pd=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:u,minLength:c,min:f,max:g,pattern:m,validate:p,name:v,valueAsNumber:h,mount:y,disabled:w}=e._f,b=j(t,v);if(!y||w)return{};const S=i?i[0]:s,E=k=>{r&&S.reportValidity&&(S.setCustomValidity(ct(k)?"":k||""),S.reportValidity())},C={},P=oi(s),_=Ln(s),O=P||_,$=(h||ri(s))&&ge(s.value)&&ge(b)||Xr(s)&&s.value===""||b===""||Array.isArray(b)&&!b.length,F=px.bind(null,v,n,C),G=(k,R,I,q=bt.maxLength,U=bt.minLength)=>{const J=k?R:I;C[v]={type:k?q:U,message:J,ref:s,...F(k?q:U,J)}};if(o?!Array.isArray(b)||!b.length:a&&(!O&&($||Ae(b))||ct(b)&&!b||_&&!cd(i).isValid||P&&!dd(i).isValid)){const{value:k,message:R}=Jr(a)?{value:!!a,message:a}:gn(a);if(k&&(C[v]={type:bt.required,message:R,ref:S,...F(bt.required,R)},!n))return E(R),C}if(!$&&(!Ae(f)||!Ae(g))){let k,R;const I=gn(g),q=gn(f);if(!Ae(b)&&!isNaN(b)){const U=s.valueAsNumber||b&&+b;Ae(I.value)||(k=U>I.value),Ae(q.value)||(R=U<q.value)}else{const U=s.valueAsDate||new Date(b),J=ce=>new Date(new Date().toDateString()+" "+ce),K=s.type=="time",ee=s.type=="week";ut(I.value)&&b&&(k=K?J(b)>J(I.value):ee?b>I.value:U>new Date(I.value)),ut(q.value)&&b&&(R=K?J(b)<J(q.value):ee?b<q.value:U<new Date(q.value))}if((k||R)&&(G(!!k,I.message,q.message,bt.max,bt.min),!n))return E(C[v].message),C}if((u||c)&&!$&&(ut(b)||o&&Array.isArray(b))){const k=gn(u),R=gn(c),I=!Ae(k.value)&&b.length>+k.value,q=!Ae(R.value)&&b.length<+R.value;if((I||q)&&(G(I,k.message,R.message),!n))return E(C[v].message),C}if(m&&!$&&ut(b)){const{value:k,message:R}=gn(m);if(Yr(k)&&!b.match(k)&&(C[v]={type:bt.pattern,message:R,ref:s,...F(bt.pattern,R)},!n))return E(R),C}if(p){if(dt(p)){const k=await p(b,t),R=fd(k,S);if(R&&(C[v]={...R,...F(bt.validate,R.message)},!n))return E(R.message),C}else if(me(p)){let k={};for(const R in p){if(!Me(k)&&!n)break;const I=fd(await p[R](b,t),S,R);I&&(k={...I,...F(R,I.message)},E(I.message),n&&(C[v]=k))}if(!Me(k)&&(C[v]={ref:S,...k},!n))return C}}return E(!0),C};function hx(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ge(e)?r++:e[t[r++]];return e}function mx(e){for(const t in e)if(e.hasOwnProperty(t)&&!ge(e[t]))return!1;return!0}function xe(e,t){const n=Array.isArray(t)?t:ni(t)?[t]:rd(t),r=n.length===1?e:hx(e,n),o=n.length-1,s=n[o];return r&&delete r[s],o!==0&&(me(r)&&Me(r)||Array.isArray(r)&&mx(r))&&xe(e,n.slice(0,-1)),e}var si=()=>{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},ii=e=>Ae(e)||!nd(e);function Lt(e,t){if(ii(e)||ii(t))return e===t;if(Gt(e)&&Gt(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(Gt(s)&&Gt(i)||me(s)&&me(i)||Array.isArray(s)&&Array.isArray(i)?!Lt(s,i):s!==i)return!1}}return!0}var gd=e=>e.type==="select-multiple",vx=e=>oi(e)||Ln(e),ai=e=>Xr(e)&&e.isConnected,hd=e=>{for(const t in e)if(dt(e[t]))return!0;return!1};function Zr(e,t={}){const n=Array.isArray(e);if(me(e)||n)for(const r in e)Array.isArray(e[r])||me(e[r])&&!hd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Zr(e[r],t[r])):Ae(e[r])||(t[r]=!0);return t}function md(e,t,n){const r=Array.isArray(e);if(me(e)||r)for(const o in e)Array.isArray(e[o])||me(e[o])&&!hd(e[o])?ge(t)||ii(n[o])?n[o]=Array.isArray(e[o])?Zr(e[o],[]):{...Zr(e[o])}:md(e[o],Ae(t)?{}:t[o],n[o]):n[o]=!Lt(e[o],t[o]);return n}var Vn=(e,t)=>md(e,t,Zr(t)),vd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ge(e)?e:t?e===""?NaN:e&&+e:n&&ut(e)?new Date(e):r?r(e):e;function li(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return ri(t)?t.files:oi(t)?dd(e.refs).value:gd(t)?[...t.selectedOptions].map(({value:n})=>n):Ln(t)?cd(e.refs).value:vd(ge(t.value)?e.ref.value:t.value,e)}var yx=(e,t,n,r)=>{const o={};for(const s of e){const i=j(t,s);i&&de(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Bn=e=>ge(e)?e:Yr(e)?e.source:me(e)?Yr(e.value)?e.value.source:e.value:e;const yd="AsyncFunction";var wx=e=>!!e&&!!e.validate&&!!(dt(e.validate)&&e.validate.constructor.name===yd||me(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===yd)),bx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function wd(e,t,n){const r=j(e,n);if(r||ni(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=j(t,s),a=j(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var xx=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,Cx=(e,t)=>!qr(j(e,t)).length&&xe(e,t);const Sx={mode:et.onSubmit,reValidateMode:et.onChange,shouldFocusError:!0};function Ex(e={}){let t={...Sx,...e},n={submitCount:0,isDirty:!1,isLoading:dt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=me(t.defaultValues)||me(t.values)?Ue(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Ue(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={values:si(),array:si(),state:si()},m=sd(t.mode),p=sd(t.reValidateMode),v=t.criteriaMode===et.all,h=x=>N=>{clearTimeout(c),c=setTimeout(x,N)},y=async x=>{if(!t.disabled&&(f.isValid||x)){const N=t.resolver?Me((await O()).errors):await F(r,!0);N!==n.isValid&&g.state.next({isValid:N})}},w=(x,N)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((x||Array.from(a.mount)).forEach(A=>{A&&(N?de(n.validatingFields,A,N):xe(n.validatingFields,A))}),g.state.next({validatingFields:n.validatingFields,isValidating:!Me(n.validatingFields)}))},b=(x,N=[],A,z,B=!0,V=!0)=>{if(z&&A&&!t.disabled){if(i.action=!0,V&&Array.isArray(j(r,x))){const X=A(j(r,x),z.argA,z.argB);B&&de(r,x,X)}if(V&&Array.isArray(j(n.errors,x))){const X=A(j(n.errors,x),z.argA,z.argB);B&&de(n.errors,x,X),Cx(n.errors,x)}if(f.touchedFields&&V&&Array.isArray(j(n.touchedFields,x))){const X=A(j(n.touchedFields,x),z.argA,z.argB);B&&de(n.touchedFields,x,X)}f.dirtyFields&&(n.dirtyFields=Vn(o,s)),g.state.next({name:x,isDirty:k(x,N),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else de(s,x,N)},S=(x,N)=>{de(n.errors,x,N),g.state.next({errors:n.errors})},E=x=>{n.errors=x,g.state.next({errors:n.errors,isValid:!1})},C=(x,N,A,z)=>{const B=j(r,x);if(B){const V=j(s,x,ge(A)?j(o,x):A);ge(V)||z&&z.defaultChecked||N?de(s,x,N?V:li(B._f)):q(x,V),i.mount&&y()}},P=(x,N,A,z,B)=>{let V=!1,X=!1;const oe={name:x};if(!t.disabled){const te=!!(j(r,x)&&j(r,x)._f&&j(r,x)._f.disabled);if(!A||z){f.isDirty&&(X=n.isDirty,n.isDirty=oe.isDirty=k(),V=X!==oe.isDirty);const pe=te||Lt(j(o,x),N);X=!!(!te&&j(n.dirtyFields,x)),pe||te?xe(n.dirtyFields,x):de(n.dirtyFields,x,!0),oe.dirtyFields=n.dirtyFields,V=V||f.dirtyFields&&X!==!pe}if(A){const pe=j(n.touchedFields,x);pe||(de(n.touchedFields,x,A),oe.touchedFields=n.touchedFields,V=V||f.touchedFields&&pe!==A)}V&&B&&g.state.next(oe)}return V?oe:{}},_=(x,N,A,z)=>{const B=j(n.errors,x),V=f.isValid&&ct(N)&&n.isValid!==N;if(t.delayError&&A?(u=h(()=>S(x,A)),u(t.delayError)):(clearTimeout(c),u=null,A?de(n.errors,x,A):xe(n.errors,x)),(A?!Lt(B,A):B)||!Me(z)||V){const X={...z,...V&&ct(N)?{isValid:N}:{},errors:n.errors,name:x};n={...n,...X},g.state.next(X)}},O=async x=>{w(x,!0);const N=await t.resolver(s,t.context,yx(x||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return w(x),N},$=async x=>{const{errors:N}=await O(x);if(x)for(const A of x){const z=j(N,A);z?de(n.errors,A,z):xe(n.errors,A)}else n.errors=N;return N},F=async(x,N,A={valid:!0})=>{for(const z in x){const B=x[z];if(B){const{_f:V,...X}=B;if(V){const oe=a.array.has(V.name),te=B._f&&wx(B._f);te&&f.validatingFields&&w([z],!0);const pe=await pd(B,s,v,t.shouldUseNativeValidation&&!N,oe);if(te&&f.validatingFields&&w([z]),pe[V.name]&&(A.valid=!1,N))break;!N&&(j(pe,V.name)?oe?gx(n.errors,pe,V.name):de(n.errors,V.name,pe[V.name]):xe(n.errors,V.name))}!Me(X)&&await F(X,N,A)}}return A.valid},G=()=>{for(const x of a.unMount){const N=j(r,x);N&&(N._f.refs?N._f.refs.every(A=>!ai(A)):!ai(N._f.ref))&&we(x)}a.unMount=new Set},k=(x,N)=>!t.disabled&&(x&&N&&de(s,x,N),!Lt(fe(),o)),R=(x,N,A)=>fx(x,a,{...i.mount?s:ge(N)?o:ut(x)?{[x]:N}:N},A,N),I=x=>qr(j(i.mount?s:o,x,t.shouldUnregister?j(o,x,[]):[])),q=(x,N,A={})=>{const z=j(r,x);let B=N;if(z){const V=z._f;V&&(!V.disabled&&de(s,x,vd(N,V)),B=Xr(V.ref)&&Ae(N)?"":N,gd(V.ref)?[...V.ref.options].forEach(X=>X.selected=B.includes(X.value)):V.refs?Ln(V.ref)?V.refs.length>1?V.refs.forEach(X=>(!X.defaultChecked||!X.disabled)&&(X.checked=Array.isArray(B)?!!B.find(oe=>oe===X.value):B===X.value)):V.refs[0]&&(V.refs[0].checked=!!B):V.refs.forEach(X=>X.checked=X.value===B):ri(V.ref)?V.ref.value="":(V.ref.value=B,V.ref.type||g.values.next({name:x,values:{...s}})))}(A.shouldDirty||A.shouldTouch)&&P(x,B,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&ce(x)},U=(x,N,A)=>{for(const z in N){const B=N[z],V=`${x}.${z}`,X=j(r,V);(a.array.has(x)||me(B)||X&&!X._f)&&!Gt(B)?U(V,B,A):q(V,B,A)}},J=(x,N,A={})=>{const z=j(r,x),B=a.array.has(x),V=Ue(N);de(s,x,V),B?(g.array.next({name:x,values:{...s}}),(f.isDirty||f.dirtyFields)&&A.shouldDirty&&g.state.next({name:x,dirtyFields:Vn(o,s),isDirty:k(x,V)})):z&&!z._f&&!Ae(V)?U(x,V,A):q(x,V,A),id(x,a)&&g.state.next({...n}),g.values.next({name:i.mount?x:void 0,values:{...s}})},K=async x=>{i.mount=!0;const N=x.target;let A=N.name,z=!0;const B=j(r,A),V=()=>N.type?li(B._f):sx(x),X=oe=>{z=Number.isNaN(oe)||Gt(oe)&&isNaN(oe.getTime())||Lt(oe,j(s,A,oe))};if(B){let oe,te;const pe=V(),pt=x.type===od.BLUR||x.type===od.FOCUS_OUT,gi=!bx(B._f)&&!t.resolver&&!j(n.errors,A)&&!B._f.deps||xx(pt,j(n.touchedFields,A),n.isSubmitted,p,m),_e=id(A,a,pt);de(s,A,pe),pt?(B._f.onBlur&&B._f.onBlur(x),u&&u(0)):B._f.onChange&&B._f.onChange(x);const qt=P(A,pe,pt,!1),hi=!Me(qt)||_e;if(!pt&&g.values.next({name:A,type:x.type,values:{...s}}),gi)return f.isValid&&(t.mode==="onBlur"?pt&&y():y()),hi&&g.state.next({name:A,..._e?{}:qt});if(!pt&&_e&&g.state.next({...n}),t.resolver){const{errors:ke}=await O([A]);if(X(pe),z){const Qr=wd(n.errors,r,A),gt=wd(ke,r,Qr.name||A);oe=gt.error,A=gt.name,te=Me(ke)}}else w([A],!0),oe=(await pd(B,s,v,t.shouldUseNativeValidation))[A],w([A]),X(pe),z&&(oe?te=!1:f.isValid&&(te=await F(r,!0)));z&&(B._f.deps&&ce(B._f.deps),_(A,te,oe,qt))}},ee=(x,N)=>{if(j(n.errors,N)&&x.focus)return x.focus(),1},ce=async(x,N={})=>{let A,z;const B=Kr(x);if(t.resolver){const V=await $(ge(x)?x:B);A=Me(V),z=x?!B.some(X=>j(V,X)):A}else x?(z=(await Promise.all(B.map(async V=>{const X=j(r,V);return await F(X&&X._f?{[V]:X}:X)}))).every(Boolean),!(!z&&!n.isValid)&&y()):z=A=await F(r);return g.state.next({...!ut(x)||f.isValid&&A!==n.isValid?{}:{name:x},...t.resolver||!x?{isValid:A}:{},errors:n.errors}),N.shouldFocus&&!z&&Rn(r,ee,x?B:a.mount),z},fe=x=>{const N={...i.mount?s:o};return ge(x)?N:ut(x)?j(N,x):x.map(A=>j(N,A))},Ce=(x,N)=>({invalid:!!j((N||n).errors,x),isDirty:!!j((N||n).dirtyFields,x),error:j((N||n).errors,x),isValidating:!!j(n.validatingFields,x),isTouched:!!j((N||n).touchedFields,x)}),Ie=x=>{x&&Kr(x).forEach(N=>xe(n.errors,N)),g.state.next({errors:x?n.errors:{}})},je=(x,N,A)=>{const z=(j(r,x,{_f:{}})._f||{}).ref,B=j(n.errors,x)||{},{ref:V,message:X,type:oe,...te}=B;de(n.errors,x,{...te,...N,ref:z}),g.state.next({name:x,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&z&&z.focus&&z.focus()},We=(x,N)=>dt(x)?g.values.subscribe({next:A=>x(R(void 0,N),A)}):R(x,N,!0),we=(x,N={})=>{for(const A of x?Kr(x):a.mount)a.mount.delete(A),a.array.delete(A),N.keepValue||(xe(r,A),xe(s,A)),!N.keepError&&xe(n.errors,A),!N.keepDirty&&xe(n.dirtyFields,A),!N.keepTouched&&xe(n.touchedFields,A),!N.keepIsValidating&&xe(n.validatingFields,A),!t.shouldUnregister&&!N.keepDefaultValue&&xe(o,A);g.values.next({values:{...s}}),g.state.next({...n,...N.keepDirty?{isDirty:k()}:{}}),!N.keepIsValid&&y()},Ne=({disabled:x,name:N,field:A,fields:z,value:B})=>{if(ct(x)&&i.mount||x){const V=x?void 0:ge(B)?li(A?A._f:j(z,N)._f):B;(x||!x&&!ge(V))&&de(s,N,V),P(N,V,!1,!1,!0)}},Te=(x,N={})=>{let A=j(r,x);const z=ct(N.disabled)||ct(t.disabled);return de(r,x,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:x}},name:x,mount:!0,...N}}),a.mount.add(x),A?Ne({field:A,disabled:ct(N.disabled)?N.disabled:t.disabled,name:x,value:N.value}):C(x,!0,N.value),{...z?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Bn(N.min),max:Bn(N.max),minLength:Bn(N.minLength),maxLength:Bn(N.maxLength),pattern:Bn(N.pattern)}:{},name:x,onChange:K,onBlur:K,ref:B=>{if(B){Te(x,N),A=j(r,x);const V=ge(B.value)&&B.querySelectorAll&&B.querySelectorAll("input,select,textarea")[0]||B,X=vx(V),oe=A._f.refs||[];if(X?oe.find(te=>te===V):V===A._f.ref)return;de(r,x,{_f:{...A._f,...X?{refs:[...oe.filter(ai),V,...Array.isArray(j(o,x))?[{}]:[]],ref:{type:V.type,name:x}}:{ref:V}}}),C(x,!1,void 0,V)}else A=j(r,x,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(ax(a.array,x)&&i.action)&&a.unMount.add(x)}}},$e=()=>t.shouldFocusError&&Rn(r,ee,a.mount),Rt=x=>{ct(x)&&(g.state.next({disabled:x}),Rn(r,(N,A)=>{const z=j(r,A);z&&(N.disabled=z._f.disabled||x,Array.isArray(z._f.refs)&&z._f.refs.forEach(B=>{B.disabled=z._f.disabled||x}))},0,!1))},tt=(x,N)=>async A=>{let z;if(A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist()),t.disabled){N&&await N({...n.errors},A);return}let B=Ue(s);if(g.state.next({isSubmitting:!0}),t.resolver){const{errors:V,values:X}=await O();n.errors=V,B=X}else await F(r);if(xe(n.errors,"root"),Me(n.errors)){g.state.next({errors:{}});try{await x(B,A)}catch(V){z=V}}else N&&await N({...n.errors},A),$e(),setTimeout($e);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Me(n.errors)&&!z,submitCount:n.submitCount+1,errors:n.errors}),z)throw z},hn=(x,N={})=>{j(r,x)&&(ge(N.defaultValue)?J(x,Ue(j(o,x))):(J(x,N.defaultValue),de(o,x,Ue(N.defaultValue))),N.keepTouched||xe(n.touchedFields,x),N.keepDirty||(xe(n.dirtyFields,x),n.isDirty=N.defaultValue?k(x,Ue(j(o,x))):k()),N.keepError||(xe(n.errors,x),f.isValid&&y()),g.state.next({...n}))},Ge=(x,N={})=>{const A=x?Ue(x):o,z=Ue(A),B=Me(x),V=B?o:z;if(N.keepDefaultValues||(o=A),!N.keepValues){if(N.keepDirtyValues){const X=new Set([...a.mount,...Object.keys(Vn(o,s))]);for(const oe of Array.from(X))j(n.dirtyFields,oe)?de(V,oe,j(s,oe)):J(oe,j(V,oe))}else{if(ti&&ge(x))for(const X of a.mount){const oe=j(r,X);if(oe&&oe._f){const te=Array.isArray(oe._f.refs)?oe._f.refs[0]:oe._f.ref;if(Xr(te)){const pe=te.closest("form");if(pe){pe.reset();break}}}}r={}}s=t.shouldUnregister?N.keepDefaultValues?Ue(o):{}:Ue(V),g.array.next({values:{...V}}),g.values.next({values:{...V}})}a={mount:N.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!N.keepIsValid||!!N.keepDirtyValues,i.watch=!!t.shouldUnregister,g.state.next({submitCount:N.keepSubmitCount?n.submitCount:0,isDirty:B?!1:N.keepDirty?n.isDirty:!!(N.keepDefaultValues&&!Lt(x,o)),isSubmitted:N.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:B?{}:N.keepDirtyValues?N.keepDefaultValues&&s?Vn(o,s):n.dirtyFields:N.keepDefaultValues&&x?Vn(o,x):N.keepDirty?n.dirtyFields:{},touchedFields:N.keepTouched?n.touchedFields:{},errors:N.keepErrors?n.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},ft=(x,N)=>Ge(dt(x)?x(s):x,N);return{control:{register:Te,unregister:we,getFieldState:Ce,handleSubmit:tt,setError:je,_executeSchema:O,_getWatch:R,_getDirty:k,_updateValid:y,_removeUnmounted:G,_updateFieldArray:b,_updateDisabledField:Ne,_getFieldArray:I,_reset:Ge,_resetDefaultValues:()=>dt(t.defaultValues)&&t.defaultValues().then(x=>{ft(x,t.resetOptions),g.state.next({isLoading:!1})}),_updateFormState:x=>{n={...n,...x}},_disableForm:Rt,_subjects:g,_proxyFormState:f,_setErrors:E,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(x){i=x},get _defaultValues(){return o},get _names(){return a},set _names(x){a=x},get _formState(){return n},set _formState(x){n=x},get _options(){return t},set _options(x){t={...t,...x}}},trigger:ce,register:Te,handleSubmit:tt,watch:We,setValue:J,getValues:fe,reset:ft,resetField:hn,clearErrors:Ie,unregister:we,setError:je,setFocus:(x,N={})=>{const A=j(r,x),z=A&&A._f;if(z){const B=z.refs?z.refs[0]:z.ref;B.focus&&(B.focus(),N.shouldSelect&&dt(B.select)&&B.select())}},getFieldState:Ce}}function Nx(e={}){const t=D.useRef(),n=D.useRef(),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:dt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ex(e),formState:r});const s=t.current.control;return s._options=e,dx({subject:s._subjects.state,next:i=>{ux(i,s._proxyFormState,s._updateFormState)&&o({...s._formState})}}),D.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),D.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),D.useEffect(()=>{e.values&&!Lt(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),D.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),D.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),D.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),D.useMemo(()=>({...t.current,formState:cx(r,s)}),[r,s])}const bd=({className:e,children:t,content:n,side:r})=>{const[o,s]=D.useState(!1);return l.jsx(Vu,{delayDuration:0,children:l.jsxs(Bu,{open:o,children:[l.jsx(zu,{asChild:!0,children:l.jsx("button",{type:"button",className:Q("cursor-pointer",e),onClick:()=>s(!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onTouchStart:()=>s(!o),onKeyDown:i=>{i.preventDefault(),i.key==="Enter"&&s(!o)},children:t})}),l.jsx(Qs,{side:r,className:n?"":"hidden",children:l.jsx("span",{className:"inline-block",children:n})})]})})},ci=({className:e,...t})=>l.jsx("nav",{role:"navigation","aria-label":"pagination",className:Q("mx-auto flex w-full justify-center",e),...t});ci.displayName="Pagination";const ui=d.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,className:Q("flex flex-row items-center gap-1",e),...t}));ui.displayName="PaginationContent";const xt=d.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,className:Q("",e),...t}));xt.displayName="PaginationItem";const zn=({className:e,isActive:t,size:n="icon",...r})=>l.jsx("a",{"aria-current":t?"page":void 0,className:Q(ka({variant:t?"outline":"ghost",size:n}),e),...r});zn.displayName="PaginationLink";const di=({className:e,...t})=>l.jsxs(zn,{"aria-label":"Go to previous page",size:"default",className:Q("gap-1 pl-2.5",e),...t,children:[l.jsx(Zp,{className:"h-4 w-4"}),l.jsx("span",{children:"Previous"})]});di.displayName="PaginationPrevious";const fi=({className:e,...t})=>l.jsxs(zn,{"aria-label":"Go to next page",size:"default",className:Q("gap-1 pr-2.5",e),...t,children:[l.jsx("span",{children:"Next"}),l.jsx(wa,{className:"h-4 w-4"})]});fi.displayName="PaginationNext";const pi=({className:e,...t})=>l.jsxs("span",{"aria-hidden":!0,className:Q("flex h-9 w-9 items-center justify-center",e),...t,children:[l.jsx(Qp,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"More pages"})]});pi.displayName="PaginationEllipsis";const Tx=(e,t)=>{const[n,r]=D.useState(e);return D.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n},Px=({apiBaseUrl:e="http://localhost:3002"})=>{var P,_;const[t,n]=D.useState([]),[r,o]=D.useState(!1),[s,i]=D.useState([]),[a,u]=D.useState(1),[c,f]=D.useState(1),[g,m]=D.useState(null),[p,v]=D.useState(""),h=Tx(p,500),y=O=>{const $=O.match(/\d{6}/);if(!$)return{month:"",year:""};const F=$[0],G=F.substring(0,2),k=F.substring(2);return{month:G,year:k}},w=O=>O.map(F=>{let G=(F==null?void 0:F.month)||"",k=(F==null?void 0:F.year)||"";if((!G||!k)&&(F!=null&&F.file_name)){const R=y(F.file_name);G=G||R.month,k=k||R.year}return{id:F==null?void 0:F.id,prefix:(F==null?void 0:F.prefix)||"",model:(F==null?void 0:F.model)||"",fileName:(F==null?void 0:F.file_name)||"",code:(F==null?void 0:F.stock_id)||"",month:G,year:k,content:(F==null?void 0:F.text_summary)||"",status:(F==null?void 0:F.status)||"",note:(F==null?void 0:F.note)||"",lastUpdate:F==null?void 0:F.updated_at,stock_id:F==null?void 0:F.stock_id}}),b=O=>{if(!(O!=null&&O.data))return[];const $=w(O==null?void 0:O.data);n($),f(O.pagination.totalPages)},S=async(O=1,$=15)=>{m(O),o(!0);try{const F=await ie.get(`${e}/api/latest-summaries`,{params:{page:O,limit:$,search:p}});(F==null?void 0:F.status)===200?b(F.data):console.error(F)}catch(F){console.error("Error fetching data:",F)}finally{m(null),o(!1)}};D.useEffect(()=>{h&&u(1),S(a)},[a,h]);const E=D.useMemo(()=>[{id:"code",header:"Mã",accessorKey:"code",cell:({row:$})=>l.jsx("span",{className:"flex flex-col",children:$.original.code})},{id:"month",header:"Tháng",accessorKey:"month",cell:({row:$})=>{const F=$.original.month,G=$.original.year;return l.jsx("span",{className:"flex flex-col",children:`${F.toString().padStart(2,"0")}/${G}`})}},{id:"content",header:"Nội dung",accessorKey:"content",cell:({row:$})=>{const F=$.getValue("content");return l.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]",children:F})}},{id:"status",header:"Trạng thái",accessorKey:"status",cell:({row:$})=>{const G=$.original.status!=="unpublish";return l.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0 text-[10px] font-bold ${G?"bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20":"bg-gray-50 text-gray-600 ring-1 ring-inset ring-gray-500/20"}`,children:G?"PUBLISHED":"UNPUBLISHED"})}},{id:"note",header:"Ghi chú",accessorKey:"note",cell:({row:$})=>l.jsx(bd,{content:l.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:$.original.note}),children:l.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[20dvw]",children:$.original.note})})},{id:"last-update",header:"Cập nhật",accessorKey:"last-update",cell:({row:$})=>{const F=new Date($.original.lastUpdate),G=F.getDate(),k=F.getMonth()+1,R=`ngày ${G} tháng ${k}`;return l.jsx("span",{className:"flex flex-col",children:R})}},{accessorKey:"actions",header:()=>l.jsx("div",{className:"font-medium text-right",children:"Hành động"}),cell:({row:$})=>{const[F,G]=D.useState(!1),[k,R]=D.useState(!1),[I,q]=D.useState(!1),{handleSubmit:U,register:J,reset:K}=Nx(),ee=$.original.id,ce=$.getValue("status"),fe=$.getValue("content"),[Ce,Ie]=D.useState(!1),je=async()=>{try{Ie(!0);const we=ce==="unpublish"?"published":"unpublish",Ne=await ie.patch(`${e}/api/toggle-publish/${ee}`,{id:ee,typeAction:"update",status:ce,idInput:ee,stock_id:$.original.stock_id,prefix:$.original.prefix,model:$.original.model,summary_result:$.original.content,note:$.original.note});Ne.status===200?n(Te=>Te.map($e=>$e.id===ee?{...$e,status:we}:$e)):console.error("Failed to toggle publish status:",Ne)}catch(we){console.error("Error toggling publish status:",we)}finally{Ie(!1)}},We=async we=>{G(!0);try{const Ne=await ie.patch(`${e}/api/update-summary`,{note:we.note,text_summary:we.content,id:ee});Ne.status===200?(await S(a),R(!1)):console.error("Failed to update summary:",Ne)}catch(Ne){console.error("Error updating summary:",Ne)}return G(!1)};return l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsx(le,{variant:"outline",size:"sm",onClick:()=>q(!0),className:"px-2 py-0.5 h-7",children:l.jsx(eg,{className:"h-4 w-4"})}),l.jsx(Ut,{open:I,onOpenChange:q,children:l.jsxs(Ft,{className:"max-w-3xl max-h-[80vh]",children:[l.jsx(Ot,{children:l.jsx(Dt,{children:"Nội dung chi tiết"})}),l.jsx("div",{className:"mt-4 overflow-y-auto max-h-[60vh]",children:l.jsx("div",{className:"whitespace-pre-wrap text-[16px] leading-relaxed",children:fe})})]})}),l.jsxs(Ut,{open:k,onOpenChange:we=>{R(we),we?K({content:$.original.content,note:$.original.note}):K()},children:[l.jsx(vr,{asChild:!0,children:l.jsx(le,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"px-2 py-0.5 h-7",children:"Sửa"})}),l.jsx(Ft,{className:"rounded-lg sm:px-3 h-[calc(100dvh-200px)] min-w-[calc(100dvw-112px)]",children:l.jsxs(Ot,{className:"flex flex-col gap-3",children:[l.jsx(Dt,{className:"max-sm:hidden text-center",children:"Sửa summary"}),l.jsxs("form",{className:"flex flex-col gap-3 h-full justify-between",onSubmit:U(We),children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[l.jsx("span",{children:"Nội dung:"}),l.jsx(Pn,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:$.original.answer||"",rows:10,...J("content")})]}),l.jsxs("div",{className:"flex flex-col items-start",children:[l.jsx("span",{children:"Ghi chú:"}),l.jsx(Pn,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:$.original.note||"",rows:1,...J("note")})]})]}),l.jsx("div",{className:"flex justify-end",children:l.jsx(le,{disabled:F,type:"submit",variant:"default",children:F?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):"Ok"})})]})]})})]}),l.jsx(le,{variant:"outline",size:"sm",onClick:je,disabled:Ce,className:"w-[70px] px-2 py-0.5 h-7",children:Ce?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):ce==="unpublish"?"Publish":"Unpublish"})]})}}],[]),C=Mi({data:t,columns:E,state:{columnFilters:s},enableRowSelection:!0,onColumnFiltersChange:i,getFilteredRowModel:bf(),getCoreRowModel:Di()});return l.jsxs("div",{className:"space-y-4 s3-explr-container",children:[l.jsx("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:l.jsxs("div",{className:"relative max-w-sm",children:[l.jsx(Mt,{placeholder:"Tìm kiếm theo mã...",value:p,onChange:O=>v(O.target.value),className:"pr-8"}),p&&l.jsx(le,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6 p-0",onClick:()=>v(""),children:l.jsx($o,{className:"h-4 w-4"})})]})}),l.jsx("div",{className:"rounded-md border s3-explr-table-container",children:l.jsxs(wr,{className:"s3-explr-table",children:[l.jsx(br,{className:"s3-explr-table-header",children:C.getHeaderGroups().map(O=>l.jsx(Ye,{className:"hover:bg-transparent s3-explr-header-row",children:O.headers.map($=>l.jsx(st,{className:"s3-explr-header-cell",children:$.isPlaceholder?null:Xn($.column.columnDef.header,$.getContext())},$.id))},O.id))}),l.jsx(xr,{className:"s3-explr-table-body",children:r?l.jsx(Ye,{children:l.jsx(Oe,{colSpan:E.length,className:"h-24 text-center",children:"Đang tải dữ liệu..."})}):(P=C.getRowModel().rows)!=null&&P.length?(_=C.getRowModel().rows)==null?void 0:_.map(O=>l.jsx(Ye,{className:"h-12 s3-explr-row",children:O.getVisibleCells().map($=>l.jsx(Oe,{className:"align-middle s3-explr-cell",children:Xn($.column.columnDef.cell,$.getContext())},$.id))},O.id)):l.jsx(Ye,{children:l.jsx(Oe,{colSpan:E.length,className:"h-24 text-center",children:"Không có kết quả."})})})]})}),l.jsx("div",{className:"mt-4",children:l.jsx(ci,{children:l.jsxs(ui,{children:[l.jsx(xt,{children:l.jsx(di,{onClick:()=>u(O=>Math.max(1,O-1)),className:a===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:c},(O,$)=>$+1).filter(O=>O===1||O===c||Math.abs(O-a)<=1).map((O,$,F)=>l.jsxs(l.Fragment,{children:[$>0&&F[$-1]!==O-1&&l.jsx(xt,{children:l.jsx(pi,{})},O+"..."),l.jsx(xt,{children:l.jsx(zn,{onClick:()=>u(O),isActive:a===O,className:`cursor-pointer ${r?"pointer-events-none":""}`,children:g===O?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):O})},O)]})),l.jsx(xt,{children:l.jsx(fi,{onClick:()=>u(O=>Math.min(c,O+1)),className:a===c||g!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})},xd=10,Ax=D.memo(({apiBaseUrl:e="http://localhost:3002"})=>{const[t,n]=D.useState(1),[r,o]=D.useState([]),[s,i]=D.useState({total:0,page:1,limit:xd,totalPages:1}),[a,u]=D.useState(!0),[c,f]=D.useState(null),[g,m]=D.useState(new Set),{toast:p}=Ds(),[v,h]=D.useState(!1),y=async C=>{try{f(C);const P=await ie.get(`${e}/api/jobs`,{params:{page:C.toString(),limit:xd.toString()}});o(P.data.data),i(P.data.pagination)}catch{p({variant:"destructive",title:"Error",description:"Failed to fetch jobs. Please try again."})}finally{f(null),u(!1)}};D.useEffect(()=>{y(t)},[t,e]);const w=async C=>{m(P=>new Set(P).add(C.toString()));try{await ie.post(`${e}/api/retry-job`,{jobId:C}),p({title:"Job Restarted",description:`Job ${C} has been successfully restarted.`}),y(t)}catch{p({variant:"destructive",title:"Retry Failed",description:`Failed to restart job ${C}. Please try again.`})}finally{m(P=>{const _=new Set(P);return _.delete(C.toString()),_})}},b=async()=>{h(!0),n(1),await y(1),h(!1)},S=C=>new Date(C).toLocaleString(),E=C=>{if(C=parseFloat(C),C<60)return`${C.toFixed(2)}s`;const P=Math.floor(C/60),_=(C%60).toFixed(0);return`${P}m ${_}s`};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[l.jsx(Jp,{className:"w-8 h-8 text-primary"}),l.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Job Management"}),l.jsx(le,{variant:"outline",size:"icon",onClick:b,disabled:v||a,className:"ml-2",children:l.jsx(ng,{className:`h-4 w-4 ${v?"animate-spin":""}`})})]}),l.jsx("div",{className:"rounded-md border",children:l.jsxs(wr,{children:[l.jsx(br,{children:l.jsxs(Ye,{children:[l.jsx(st,{children:"ID"}),l.jsx(st,{children:"Tên Công Việc"}),l.jsx(st,{children:"Thời Gian Bắt Đầu"}),l.jsx(st,{children:"Thời Gian Cập Nhật"}),l.jsx(st,{children:"Thời Gian Thực Thi"}),l.jsx(st,{children:"Trạng Thái"}),l.jsx(st,{children:"Thao Tác"})]})}),l.jsx(xr,{children:a&&r.length===0?l.jsx(Ye,{children:l.jsx(Oe,{colSpan:7,className:"text-center py-4",children:l.jsx(ve,{className:"w-6 h-6 animate-spin mx-auto"})})}):r.map(C=>{var P,_;return l.jsxs(Ye,{children:[l.jsx(Oe,{className:"!w-[100px]",children:C.id}),l.jsx(Oe,{className:"font-medium",children:(P=C.job_name)==null?void 0:P.replace("Upload file","Summary")}),l.jsx(Oe,{className:"!w-[200px]",children:S(C.created_at)}),l.jsx(Oe,{className:"!w-[200px]",children:S(C.updated_at)}),l.jsx(Oe,{className:"!w-[150px]",children:E(C.execution_time_seconds)}),l.jsx(Oe,{className:"!w-[200px]",children:l.jsx(bd,{content:C.status==="fail"&&C.error?l.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:C.error}):null,children:l.jsx("div",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]
|
|
141
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},xm="DialogDescriptionWarning",Cm=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${kl(xm).contentName}}.`;return d.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Sm=Cl,Em=El,Nm=Tl,Ll=Pl,Rl=Al,Vl=Fl,Bl=Dl,Tm=Il;const Ut=Sm,vr=Em,Pm=Nm,zl=d.forwardRef(({className:e,...t},n)=>l.jsx(Ll,{ref:n,className:Q("s3-explr-ui-dialog-overlay fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));zl.displayName=Ll.displayName;const Ft=d.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Pm,{children:[l.jsx(zl,{}),l.jsxs(Rl,{ref:r,className:Q("s3-explr-ui-dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,l.jsxs(Tm,{className:Q("s3-explr-ui-dialog-close absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[l.jsx($o,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),l.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Ft.displayName=Rl.displayName;const Ot=({className:e,...t})=>l.jsx("div",{className:Q("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ot.displayName="DialogHeader";const Tn=({className:e,...t})=>l.jsx("div",{className:Q("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Tn.displayName="DialogFooter";const Dt=d.forwardRef(({className:e,...t},n)=>l.jsx(Vl,{ref:n,className:Q("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",e),...t}));Dt.displayName=Vl.displayName;const yr=d.forwardRef(({className:e,...t},n)=>l.jsx(Bl,{ref:n,className:Q("s3-explr-ui-dialog-description text-sm text-muted-foreground",e),...t}));yr.displayName=Bl.displayName;const Mt=d.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:Q("s3-explr-ui-input","flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Mt.displayName="Input";var Am="Label",Hl=d.forwardRef((e,t)=>l.jsx(be.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Hl.displayName=Am;var Ul=Hl;const _m=Uo("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 s3-explr-ui-label",{variants:{variant:{default:"s3-explr-ui-label-default",required:"s3-explr-ui-label-required",disabled:"s3-explr-ui-label-disabled"},size:{default:"s3-explr-ui-label-size-default",sm:"s3-explr-ui-label-size-sm",lg:"s3-explr-ui-label-size-lg"}},defaultVariants:{variant:"default",size:"default"}}),jt=d.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Ul,{ref:o,className:Q(_m({variant:t,size:n}),e),...r}));jt.displayName=Ul.displayName;const wr=d.forwardRef(({className:e,...t},n)=>l.jsx("div",{className:Q("relative w-full overflow-auto","s3-explr-ui-table-container"),children:l.jsx("table",{ref:n,className:Q("w-full caption-bottom text-sm","s3-explr-ui-table",e),...t})}));wr.displayName="Table";const br=d.forwardRef(({className:e,...t},n)=>l.jsx("thead",{ref:n,className:Q("[&_tr]:border-b","s3-explr-ui-table-header",e),...t}));br.displayName="TableHeader";const xr=d.forwardRef(({className:e,...t},n)=>l.jsx("tbody",{ref:n,className:Q("[&_tr:last-child]:border-0","s3-explr-ui-table-body",e),...t}));xr.displayName="TableBody";const Fm=d.forwardRef(({className:e,...t},n)=>l.jsx("tfoot",{ref:n,className:Q("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",e),...t}));Fm.displayName="TableFooter";const Ye=d.forwardRef(({className:e,...t},n)=>l.jsx("tr",{ref:n,className:Q("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",e),...t}));Ye.displayName="TableRow";const st=d.forwardRef(({className:e,...t},n)=>l.jsx("th",{ref:n,className:Q("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-head",e),...t}));st.displayName="TableHead";const Oe=d.forwardRef(({className:e,...t},n)=>l.jsx("td",{ref:n,className:Q("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",e),...t}));Oe.displayName="TableCell";const Om=d.forwardRef(({className:e,...t},n)=>l.jsx("caption",{ref:n,className:Q("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",e),...t}));Om.displayName="TableCaption";function cs(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function an(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function jl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function us(...e){return t=>{let n=!1;const r=e.map(o=>{const s=jl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():jl(e[o],null)}}}}function ds(...e){return d.useCallback(us(...e),e)}var fs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Mm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(ps,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(ps,{...r,ref:t,children:n})});fs.displayName="Slot";var ps=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=$m(n);return d.cloneElement(n,{...Im(r,n.props),ref:t?us(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});ps.displayName="SlotClone";var Dm=({children:e})=>l.jsx(l.Fragment,{children:e});function Mm(e){return d.isValidElement(e)&&e.type===Dm}function Im(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $m(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function km(e){const t=e+"CollectionProvider",[n,r]=Pt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:h}=p,y=D.useRef(null),w=D.useRef(new Map).current;return l.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:h})};i.displayName=t;const a=e+"CollectionSlot",u=D.forwardRef((p,v)=>{const{scope:h,children:y}=p,w=s(a,h),b=ds(v,w.collectionRef);return l.jsx(fs,{ref:b,children:y})});u.displayName=a;const c=e+"CollectionItemSlot",f="data-radix-collection-item",g=D.forwardRef((p,v)=>{const{scope:h,children:y,...w}=p,b=D.useRef(null),S=ds(v,b),E=s(c,h);return D.useEffect(()=>(E.itemMap.set(b,{ref:b,...w}),()=>void E.itemMap.delete(b))),l.jsx(fs,{[f]:"",ref:S,children:y})});g.displayName=c;function m(p){const v=s(e+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((E,C)=>w.indexOf(E.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,r]}var Wl=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Rm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(gs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(gs,{...r,ref:t,children:n})});Wl.displayName="Slot";var gs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=Bm(n);return d.cloneElement(n,{...Vm(r,n.props),ref:t?us(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});gs.displayName="SlotClone";var Lm=({children:e})=>l.jsx(l.Fragment,{children:e});function Rm(e){return d.isValidElement(e)&&e.type===Lm}function Vm(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Bm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Gl=zm.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Wl:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Hm=d.createContext(void 0);function ql(e){const t=d.useContext(Hm);return e||t||"ltr"}var hs="rovingFocusGroup.onEntryFocus",Um={bubbles:!1,cancelable:!0},Cr="RovingFocusGroup",[ms,Kl,jm]=km(Cr),[Wm,Xl]=Pt(Cr,[jm]),[Gm,qm]=Wm(Cr),Jl=d.forwardRef((e,t)=>l.jsx(ms.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ms.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Km,{...e,ref:t})})}));Jl.displayName=Cr;var Km=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...g}=e,m=d.useRef(null),p=ds(t,m),v=ql(s),[h=null,y]=Qt({prop:i,defaultProp:a,onChange:u}),[w,b]=d.useState(!1),S=Pe(c),E=Kl(n),C=d.useRef(!1),[P,_]=d.useState(0);return d.useEffect(()=>{const O=m.current;if(O)return O.addEventListener(hs,S),()=>O.removeEventListener(hs,S)},[S]),l.jsx(Gm,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:h,onItemFocus:d.useCallback(O=>y(O),[y]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>_(O=>O+1),[]),onFocusableItemRemove:d.useCallback(()=>_(O=>O-1),[]),children:l.jsx(Gl.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...g,ref:p,style:{outline:"none",...e.style},onMouseDown:an(e.onMouseDown,()=>{C.current=!0}),onFocus:an(e.onFocus,O=>{const $=!C.current;if(O.target===O.currentTarget&&$&&!w){const F=new CustomEvent(hs,Um);if(O.currentTarget.dispatchEvent(F),!F.defaultPrevented){const G=E().filter(U=>U.focusable),k=G.find(U=>U.active),R=G.find(U=>U.id===h),q=[k,R,...G].filter(Boolean).map(U=>U.ref.current);Ql(q,f)}}C.current=!1}),onBlur:an(e.onBlur,()=>b(!1))})})}),Yl="RovingFocusGroupItem",Zl=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=tn(),u=s||a,c=qm(Yl,n),f=c.currentTabStopId===u,g=Kl(n),{onFocusableItemAdd:m,onFocusableItemRemove:p}=c;return d.useEffect(()=>{if(r)return m(),()=>p()},[r,m,p]),l.jsx(ms.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Gl.span,{tabIndex:f?0:-1,"data-orientation":c.orientation,...i,ref:t,onMouseDown:an(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:an(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:an(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=Ym(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=g().filter(b=>b.focusable).map(b=>b.ref.current);if(h==="last")w.reverse();else if(h==="prev"||h==="next"){h==="prev"&&w.reverse();const b=w.indexOf(v.currentTarget);w=c.loop?Zm(w,b+1):w.slice(b+1)}setTimeout(()=>Ql(w))}})})})});Zl.displayName=Yl;var Xm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ym(e,t,n){const r=Jm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Xm[r]}function Ql(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Zm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Qm=Jl,ev=Zl;function ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function tv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ec(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ec(e[o],null)}}}}function nv(...e){return d.useCallback(tv(...e),e)}function rv(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var tc=e=>{const{present:t,children:n}=e,r=ov(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=nv(r.ref,sv(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};tc.displayName="Presence";function ov(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=rv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const c=Sr(r.current);s.current=a==="mounted"?c:"none"},[a]),Ve(()=>{const c=r.current,f=o.current;if(f!==e){const m=s.current,p=Sr(c);e?u("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ve(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,g=p=>{const h=Sr(r.current).includes(p.animationName);if(p.target===t&&h&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},m=p=>{p.target===t&&(s.current=Sr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Sr(e){return(e==null?void 0:e.animationName)||"none"}function sv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function nc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function iv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=nc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():nc(e[o],null)}}}}var rc=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(lv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(vs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(vs,{...r,ref:t,children:n})});rc.displayName="Slot";var vs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=uv(n);return d.cloneElement(n,{...cv(r,n.props),ref:t?iv(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});vs.displayName="SlotClone";var av=({children:e})=>l.jsx(l.Fragment,{children:e});function lv(e){return d.isValidElement(e)&&e.type===av}function cv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function uv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var dv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Er=dv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?rc:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),ys="Tabs",[fv,iC]=Pt(ys,[Xl]),oc=Xl(),[pv,ws]=fv(ys),sc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:u="automatic",...c}=e,f=ql(a),[g,m]=Qt({prop:r,onChange:o,defaultProp:s});return l.jsx(pv,{scope:n,baseId:tn(),value:g,onValueChange:m,orientation:i,dir:f,activationMode:u,children:l.jsx(Er.div,{dir:f,"data-orientation":i,...c,ref:t})})});sc.displayName=ys;var ic="TabsList",ac=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=ws(ic,n),i=oc(n);return l.jsx(Qm,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:l.jsx(Er.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});ac.displayName=ic;var lc="TabsTrigger",cc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=ws(lc,n),a=oc(n),u=fc(i.baseId,r),c=pc(i.baseId,r),f=r===i.value;return l.jsx(ev,{asChild:!0,...a,focusable:!o,active:f,children:l.jsx(Er.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":c,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...s,ref:t,onMouseDown:cs(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?i.onValueChange(r):g.preventDefault()}),onKeyDown:cs(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&i.onValueChange(r)}),onFocus:cs(e.onFocus,()=>{const g=i.activationMode!=="manual";!f&&!o&&g&&i.onValueChange(r)})})})});cc.displayName=lc;var uc="TabsContent",dc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,a=ws(uc,n),u=fc(a.baseId,r),c=pc(a.baseId,r),f=r===a.value,g=d.useRef(f);return d.useEffect(()=>{const m=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(m)},[]),l.jsx(tc,{present:o||f,children:({present:m})=>l.jsx(Er.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:c,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:m&&s})})});dc.displayName=uc;function fc(e,t){return`${e}-trigger-${t}`}function pc(e,t){return`${e}-content-${t}`}var gv=sc,gc=ac,hc=cc,mc=dc;const hv=gv,vc=d.forwardRef(({className:e,...t},n)=>l.jsx(gc,{ref:n,className:Q("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));vc.displayName=gc.displayName;const Nr=d.forwardRef(({className:e,...t},n)=>l.jsx(hc,{ref:n,className:Q("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Nr.displayName=hc.displayName;const Tr=d.forwardRef(({className:e,...t},n)=>l.jsx(mc,{ref:n,className:Q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Tr.displayName=mc.displayName;const Pn=d.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:Q("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Pn.displayName="Textarea";function mv(e,t=[]){let n=[];function r(s,i){const a=d.createContext(i),u=n.length;n=[...n,i];function c(g){const{scope:m,children:p,...v}=g,h=(m==null?void 0:m[e][u])||a,y=d.useMemo(()=>v,Object.values(v));return l.jsx(h.Provider,{value:y,children:p})}function f(g,m){const p=(m==null?void 0:m[e][u])||a,v=d.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${g}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,f]}const o=()=>{const s=n.map(i=>d.createContext(i));return function(a){const u=(a==null?void 0:a[e])||s;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return o.scopeName=e,[r,vv(o,...t)]}function vv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:u,scopeName:c})=>{const g=u(s)[`__scope${c}`];return{...a,...g}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var bs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(wv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return l.jsx(xs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return l.jsx(xs,{...r,ref:t,children:n})});bs.displayName="Slot";var xs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=xv(n);return d.cloneElement(n,{...bv(r,n.props),ref:t?ar(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});xs.displayName="SlotClone";var yv=({children:e})=>l.jsx(l.Fragment,{children:e});function wv(e){return d.isValidElement(e)&&e.type===yv}function bv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function xv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Cv(e){const t=e+"CollectionProvider",[n,r]=mv(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:h}=p,y=D.useRef(null),w=D.useRef(new Map).current;return l.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:h})};i.displayName=t;const a=e+"CollectionSlot",u=D.forwardRef((p,v)=>{const{scope:h,children:y}=p,w=s(a,h),b=He(v,w.collectionRef);return l.jsx(bs,{ref:b,children:y})});u.displayName=a;const c=e+"CollectionItemSlot",f="data-radix-collection-item",g=D.forwardRef((p,v)=>{const{scope:h,children:y,...w}=p,b=D.useRef(null),S=He(v,b),E=s(c,h);return D.useEffect(()=>(E.itemMap.set(b,{ref:b,...w}),()=>void E.itemMap.delete(b))),l.jsx(bs,{[f]:"",ref:S,children:y})});g.displayName=c;function m(p){const v=s(e+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((E,C)=>w.indexOf(E.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,r]}var Sv="VisuallyHidden",Cs=d.forwardRef((e,t)=>l.jsx(be.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Cs.displayName=Sv;var Ss="ToastProvider",[Es,Ev,Nv]=Cv("Toast"),[yc,aC]=Pt("Toast",[Nv]),[Tv,Pr]=yc(Ss),wc=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,u]=d.useState(null),[c,f]=d.useState(0),g=d.useRef(!1),m=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ss}\`. Expected non-empty \`string\`.`),l.jsx(Es.Provider,{scope:t,children:l.jsx(Tv,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:u,onToastAdd:d.useCallback(()=>f(p=>p+1),[]),onToastRemove:d.useCallback(()=>f(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:m,children:i})})};wc.displayName=Ss;var bc="ToastViewport",Pv=["F8"],Ns="toast.viewportPause",Ts="toast.viewportResume",xc=d.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Pv,label:o="Notifications ({hotkey})",...s}=e,i=Pr(bc,n),a=Ev(n),u=d.useRef(null),c=d.useRef(null),f=d.useRef(null),g=d.useRef(null),m=He(t,g,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;d.useEffect(()=>{const y=w=>{var S;r.length!==0&&r.every(E=>w[E]||w.code===E)&&((S=g.current)==null||S.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),d.useEffect(()=>{const y=u.current,w=g.current;if(v&&y&&w){const b=()=>{if(!i.isClosePausedRef.current){const P=new CustomEvent(Ns);w.dispatchEvent(P),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const P=new CustomEvent(Ts);w.dispatchEvent(P),i.isClosePausedRef.current=!1}},E=P=>{!y.contains(P.relatedTarget)&&S()},C=()=>{y.contains(document.activeElement)||S()};return y.addEventListener("focusin",b),y.addEventListener("focusout",E),y.addEventListener("pointermove",b),y.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{y.removeEventListener("focusin",b),y.removeEventListener("focusout",E),y.removeEventListener("pointermove",b),y.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const h=d.useCallback(({tabbingDirection:y})=>{const b=a().map(S=>{const E=S.ref.current,C=[E,...Bv(E)];return y==="forwards"?C:C.reverse()});return(y==="forwards"?b.reverse():b).flat()},[a]);return d.useEffect(()=>{const y=g.current;if(y){const w=b=>{var C,P,_;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const O=document.activeElement,$=b.shiftKey;if(b.target===y&&$){(C=c.current)==null||C.focus();return}const k=h({tabbingDirection:$?"backwards":"forwards"}),R=k.findIndex(I=>I===O);_s(k.slice(R+1))?b.preventDefault():$?(P=c.current)==null||P.focus():(_=f.current)==null||_.focus()}};return y.addEventListener("keydown",w),()=>y.removeEventListener("keydown",w)}},[a,h]),l.jsxs(mh,{ref:u,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&l.jsx(Ps,{ref:c,onFocusFromOutsideViewport:()=>{const y=h({tabbingDirection:"forwards"});_s(y)}}),l.jsx(Es.Slot,{scope:n,children:l.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&l.jsx(Ps,{ref:f,onFocusFromOutsideViewport:()=>{const y=h({tabbingDirection:"backwards"});_s(y)}})]})});xc.displayName=bc;var Cc="ToastFocusProxy",Ps=d.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=Pr(Cc,n);return l.jsx(Cs,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ps.displayName=Cc;var Ar="Toast",Av="toast.swipeStart",_v="toast.swipeMove",Fv="toast.swipeCancel",Ov="toast.swipeEnd",Sc=d.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,u]=Qt({prop:r,defaultProp:o,onChange:s});return l.jsx(en,{present:n||a,children:l.jsx(Iv,{open:a,...i,ref:t,onClose:()=>u(!1),onPause:Pe(e.onPause),onResume:Pe(e.onResume),onSwipeStart:ye(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ye(e.onSwipeMove,c=>{const{x:f,y:g}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:ye(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ye(e.onSwipeEnd,c=>{const{x:f,y:g}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});Sc.displayName=Ar;var[Dv,Mv]=yc(Ar,{onClose(){}}),Iv=d.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:u,onResume:c,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:m,onSwipeEnd:p,...v}=e,h=Pr(Ar,n),[y,w]=d.useState(null),b=He(t,I=>w(I)),S=d.useRef(null),E=d.useRef(null),C=o||h.duration,P=d.useRef(0),_=d.useRef(C),O=d.useRef(0),{onToastAdd:$,onToastRemove:F}=h,G=Pe(()=>{var q;(y==null?void 0:y.contains(document.activeElement))&&((q=h.viewport)==null||q.focus()),i()}),k=d.useCallback(I=>{!I||I===1/0||(window.clearTimeout(O.current),P.current=new Date().getTime(),O.current=window.setTimeout(G,I))},[G]);d.useEffect(()=>{const I=h.viewport;if(I){const q=()=>{k(_.current),c==null||c()},U=()=>{const J=new Date().getTime()-P.current;_.current=_.current-J,window.clearTimeout(O.current),u==null||u()};return I.addEventListener(Ns,U),I.addEventListener(Ts,q),()=>{I.removeEventListener(Ns,U),I.removeEventListener(Ts,q)}}},[h.viewport,C,u,c,k]),d.useEffect(()=>{s&&!h.isClosePausedRef.current&&k(C)},[s,C,h.isClosePausedRef,k]),d.useEffect(()=>($(),()=>F()),[$,F]);const R=d.useMemo(()=>y?Fc(y):null,[y]);return h.viewport?l.jsxs(l.Fragment,{children:[R&&l.jsx($v,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:R}),l.jsx(Dv,{scope:n,onClose:G,children:jn.createPortal(l.jsx(Es.ItemSlot,{scope:n,children:l.jsx(hh,{asChild:!0,onEscapeKeyDown:ye(a,()=>{h.isFocusedToastEscapeKeyDownRef.current||G(),h.isFocusedToastEscapeKeyDownRef.current=!1}),children:l.jsx(be.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":h.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ye(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(h.isFocusedToastEscapeKeyDownRef.current=!0,G()))}),onPointerDown:ye(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ye(e.onPointerMove,I=>{if(!S.current)return;const q=I.clientX-S.current.x,U=I.clientY-S.current.y,J=!!E.current,K=["left","right"].includes(h.swipeDirection),ee=["left","up"].includes(h.swipeDirection)?Math.min:Math.max,ce=K?ee(0,q):0,fe=K?0:ee(0,U),Ce=I.pointerType==="touch"?10:2,Ie={x:ce,y:fe},je={originalEvent:I,delta:Ie};J?(E.current=Ie,_r(_v,g,je,{discrete:!1})):Oc(Ie,h.swipeDirection,Ce)?(E.current=Ie,_r(Av,f,je,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(q)>Ce||Math.abs(U)>Ce)&&(S.current=null)}),onPointerUp:ye(e.onPointerUp,I=>{const q=E.current,U=I.target;if(U.hasPointerCapture(I.pointerId)&&U.releasePointerCapture(I.pointerId),E.current=null,S.current=null,q){const J=I.currentTarget,K={originalEvent:I,delta:q};Oc(q,h.swipeDirection,h.swipeThreshold)?_r(Ov,p,K,{discrete:!0}):_r(Fv,m,K,{discrete:!0}),J.addEventListener("click",ee=>ee.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null}),$v=e=>{const{__scopeToast:t,children:n,...r}=e,o=Pr(Ar,t),[s,i]=d.useState(!1),[a,u]=d.useState(!1);return Rv(()=>i(!0)),d.useEffect(()=>{const c=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:l.jsx(Yo,{asChild:!0,children:l.jsx(Cs,{...r,children:s&&l.jsxs(l.Fragment,{children:[o.label," ",n]})})})},kv="ToastTitle",Ec=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return l.jsx(be.div,{...r,ref:t})});Ec.displayName=kv;var Lv="ToastDescription",Nc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return l.jsx(be.div,{...r,ref:t})});Nc.displayName=Lv;var Tc="ToastAction",Pc=d.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?l.jsx(_c,{altText:n,asChild:!0,children:l.jsx(As,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Tc}\`. Expected non-empty \`string\`.`),null)});Pc.displayName=Tc;var Ac="ToastClose",As=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Mv(Ac,n);return l.jsx(_c,{asChild:!0,children:l.jsx(be.button,{type:"button",...r,ref:t,onClick:ye(e.onClick,o.onClose)})})});As.displayName=Ac;var _c=d.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return l.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Fc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Vv(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Fc(r))}}),t}function _r(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Va(o,s):o.dispatchEvent(s)}var Oc=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function Rv(e=()=>{}){const t=Pe(e);Ve(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Vv(e){return e.nodeType===e.ELEMENT_NODE}function Bv(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function _s(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var zv=wc,Dc=xc,Mc=Sc,Ic=Ec,$c=Nc,kc=Pc,Lc=As;const Hv=zv,Rc=d.forwardRef(({className:e,...t},n)=>l.jsx(Dc,{ref:n,className:Q("s3-explr-ui-toast-viewport fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Rc.displayName=Dc.displayName;const Uv=Uo("s3-explr-ui-toast group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"s3-explr-ui-toast-default border bg-background text-foreground",destructive:"s3-explr-ui-toast-destructive destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Vc=d.forwardRef(({className:e,variant:t,...n},r)=>l.jsx(Mc,{ref:r,className:Q(Uv({variant:t}),e),...n}));Vc.displayName=Mc.displayName;const jv=d.forwardRef(({className:e,...t},n)=>l.jsx(kc,{ref:n,className:Q("s3-explr-ui-toast-action inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));jv.displayName=kc.displayName;const Bc=d.forwardRef(({className:e,...t},n)=>l.jsx(Lc,{ref:n,className:Q("s3-explr-ui-toast-close absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:l.jsx($o,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));Bc.displayName=Lc.displayName;const zc=d.forwardRef(({className:e,...t},n)=>l.jsx(Ic,{ref:n,className:Q("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",e),...t}));zc.displayName=Ic.displayName;const Hc=d.forwardRef(({className:e,...t},n)=>l.jsx($c,{ref:n,className:Q("s3-explr-ui-toast-description text-sm opacity-90",e),...t}));Hc.displayName=$c.displayName;const Wv=1,Gv=1e6;let Fs=0;function qv(){return Fs=(Fs+1)%Number.MAX_SAFE_INTEGER,Fs.toString()}const Os=new Map,Uc=e=>{if(Os.has(e))return;const t=setTimeout(()=>{Os.delete(e),An({type:"REMOVE_TOAST",toastId:e})},Gv);Os.set(e,t)},Kv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Wv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Uc(n):e.toasts.forEach(r=>{Uc(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Fr=[];let Or={toasts:[]};function An(e){Or=Kv(Or,e),Fr.forEach(t=>{t(Or)})}function Xv({...e}){const t=qv(),n=o=>An({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>An({type:"DISMISS_TOAST",toastId:t});return An({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ds(){const[e,t]=d.useState(Or);return d.useEffect(()=>(Fr.push(t),()=>{const n=Fr.indexOf(t);n>-1&&Fr.splice(n,1)}),[e]),{...e,toast:Xv,dismiss:n=>An({type:"DISMISS_TOAST",toastId:n})}}function jc(){const{toasts:e}=Ds();return l.jsxs(Hv,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return l.jsxs(Vc,{...s,className:`s3-explr-ui-toast ${s.className||""}`,children:[l.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&l.jsx(zc,{className:"s3-explr-ui-toast-title",children:n}),r&&l.jsx(Hc,{className:"s3-explr-ui-toast-description",children:r})]}),o&&l.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),l.jsx(Bc,{className:"s3-explr-ui-toast-close"})]},t)}),l.jsx(Rc,{className:"s3-explr-ui-toast-viewport"})]})}function vt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Wc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Wc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Wc(e[o],null)}}}}function _n(...e){return d.useCallback(Jv(...e),e)}var Yv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Fn=Yv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Zv(e,t){e&&jn.flushSync(()=>e.dispatchEvent(t))}var Qv="DismissableLayer",Ms="dismissableLayer.update",ey="dismissableLayer.pointerDownOutside",ty="dismissableLayer.focusOutside",Gc,qc=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kc=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...u}=e,c=d.useContext(qc),[f,g]=d.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),v=_n(t,_=>g(_)),h=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),b=f?h.indexOf(f):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,E=b>=w,C=oy(_=>{const O=_.target,$=[...c.branches].some(F=>F.contains(O));!E||$||(o==null||o(_),i==null||i(_),_.defaultPrevented||a==null||a())},m),P=sy(_=>{const O=_.target;[...c.branches].some(F=>F.contains(O))||(s==null||s(_),i==null||i(_),_.defaultPrevented||a==null||a())},m);return Wa(_=>{b===c.layers.size-1&&(r==null||r(_),!_.defaultPrevented&&a&&(_.preventDefault(),a()))},m),d.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Gc=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),Xc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Gc)}},[f,m,n,c]),d.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),Xc())},[f,c]),d.useEffect(()=>{const _=()=>p({});return document.addEventListener(Ms,_),()=>document.removeEventListener(Ms,_)},[]),l.jsx(Fn.div,{...u,ref:v,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:vt(e.onFocusCapture,P.onFocusCapture),onBlurCapture:vt(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:vt(e.onPointerDownCapture,C.onPointerDownCapture)})});Kc.displayName=Qv;var ny="DismissableLayerBranch",ry=d.forwardRef((e,t)=>{const n=d.useContext(qc),r=d.useRef(null),o=_n(t,r);return d.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Fn.div,{...e,ref:o})});ry.displayName=ny;function oy(e,t=globalThis==null?void 0:globalThis.document){const n=Pe(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){Jc(ey,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function sy(e,t=globalThis==null?void 0:globalThis.document){const n=Pe(e),r=d.useRef(!1);return d.useEffect(()=>{const o=s=>{s.target&&!r.current&&Jc(ty,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Xc(){const e=new CustomEvent(Ms);document.dispatchEvent(e)}function Jc(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Zv(o,s):o.dispatchEvent(s)}const iy=["top","right","bottom","left"],It=Math.min,Be=Math.max,Dr=Math.round,Mr=Math.floor,it=e=>({x:e,y:e}),ay={left:"right",right:"left",bottom:"top",top:"bottom"},ly={start:"end",end:"start"};function Is(e,t,n){return Be(e,It(t,n))}function yt(e,t){return typeof e=="function"?e(t):e}function wt(e){return e.split("-")[0]}function ln(e){return e.split("-")[1]}function $s(e){return e==="x"?"y":"x"}function ks(e){return e==="y"?"height":"width"}function $t(e){return["top","bottom"].includes(wt(e))?"y":"x"}function Ls(e){return $s($t(e))}function cy(e,t,n){n===void 0&&(n=!1);const r=ln(e),o=Ls(e),s=ks(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ir(i)),[i,Ir(i)]}function uy(e){const t=Ir(e);return[Rs(e),t,Rs(t)]}function Rs(e){return e.replace(/start|end/g,t=>ly[t])}function dy(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function fy(e,t,n,r){const o=ln(e);let s=dy(wt(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Rs)))),s}function Ir(e){return e.replace(/left|right|bottom|top/g,t=>ay[t])}function py(e){return{top:0,right:0,bottom:0,left:0,...e}}function Yc(e){return typeof e!="number"?py(e):{top:e,right:e,bottom:e,left:e}}function $r(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Zc(e,t,n){let{reference:r,floating:o}=e;const s=$t(t),i=Ls(t),a=ks(i),u=wt(t),c=s==="y",f=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(u){case"top":p={x:f,y:r.y-o.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:g};break;case"left":p={x:r.x-o.width,y:g};break;default:p={x:r.x,y:r.y}}switch(ln(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const gy=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:g}=Zc(c,r,u),m=r,p={},v=0;for(let h=0;h<a.length;h++){const{name:y,fn:w}=a[h],{x:b,y:S,data:E,reset:C}=await w({x:f,y:g,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});f=b??f,g=S??g,p={...p,[y]:{...p[y],...E}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:f,y:g}=Zc(c,m,u)),h=-1)}return{x:f,y:g,placement:m,strategy:o,middlewareData:p}};async function On(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:u}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:m=!1,padding:p=0}=yt(t,e),v=Yc(p),y=a[m?g==="floating"?"reference":"floating":g],w=$r(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:u})),b=g==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=$r(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:u}):b);return{top:(w.top-C.top+v.top)/E.y,bottom:(C.bottom-w.bottom+v.bottom)/E.y,left:(w.left-C.left+v.left)/E.x,right:(C.right-w.right+v.right)/E.x}}const hy=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:u}=t,{element:c,padding:f=0}=yt(e,t)||{};if(c==null)return{};const g=Yc(f),m={x:n,y:r},p=Ls(o),v=ks(p),h=await i.getDimensions(c),y=p==="y",w=y?"top":"left",b=y?"bottom":"right",S=y?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],C=m[p]-s.reference[p],P=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let _=P?P[S]:0;(!_||!await(i.isElement==null?void 0:i.isElement(P)))&&(_=a.floating[S]||s.floating[v]);const O=E/2-C/2,$=_/2-h[v]/2-1,F=It(g[w],$),G=It(g[b],$),k=F,R=_-h[v]-G,I=_/2-h[v]/2+O,q=Is(k,I,R),U=!u.arrow&&ln(o)!=null&&I!==q&&s.reference[v]/2-(I<k?F:G)-h[v]/2<0,J=U?I<k?I-k:I-R:0;return{[p]:m[p]+J,data:{[p]:q,centerOffset:I-q-J,...U&&{alignmentOffset:J}},reset:U}}}),my=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:u,elements:c}=t,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:h=!0,...y}=yt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=wt(o),b=$t(a),S=wt(a)===a,E=await(u.isRTL==null?void 0:u.isRTL(c.floating)),C=m||(S||!h?[Ir(a)]:uy(a)),P=v!=="none";!m&&P&&C.push(...fy(a,h,v,E));const _=[a,...C],O=await On(t,y),$=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&$.push(O[w]),g){const I=cy(o,i,E);$.push(O[I[0]],O[I[1]])}if(F=[...F,{placement:o,overflows:$}],!$.every(I=>I<=0)){var G,k;const I=(((G=s.flip)==null?void 0:G.index)||0)+1,q=_[I];if(q)return{data:{index:I,overflows:F},reset:{placement:q}};let U=(k=F.filter(J=>J.overflows[0]<=0).sort((J,K)=>J.overflows[1]-K.overflows[1])[0])==null?void 0:k.placement;if(!U)switch(p){case"bestFit":{var R;const J=(R=F.filter(K=>{if(P){const ee=$t(K.placement);return ee===b||ee==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(ee=>ee>0).reduce((ee,ce)=>ee+ce,0)]).sort((K,ee)=>K[1]-ee[1])[0])==null?void 0:R[0];J&&(U=J);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function Qc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function eu(e){return iy.some(t=>e[t]>=0)}const vy=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=yt(e,t);switch(r){case"referenceHidden":{const s=await On(t,{...o,elementContext:"reference"}),i=Qc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:eu(i)}}}case"escaped":{const s=await On(t,{...o,altBoundary:!0}),i=Qc(s,n.floating);return{data:{escapedOffsets:i,escaped:eu(i)}}}default:return{}}}}};async function yy(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=wt(n),a=ln(n),u=$t(n)==="y",c=["left","top"].includes(i)?-1:1,f=s&&u?-1:1,g=yt(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),u?{x:p*f,y:m*c}:{x:m*c,y:p*f}}const wy=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,u=await yy(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:s+u.y,data:{...u,placement:i}}}}},by=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...u}=yt(e,t),c={x:n,y:r},f=await On(t,u),g=$t(wt(o)),m=$s(g);let p=c[m],v=c[g];if(s){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",b=p+f[y],S=p-f[w];p=Is(b,p,S)}if(i){const y=g==="y"?"top":"left",w=g==="y"?"bottom":"right",b=v+f[y],S=v-f[w];v=Is(b,v,S)}const h=a.fn({...t,[m]:p,[g]:v});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[g]:i}}}}}},xy=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:u=!0,crossAxis:c=!0}=yt(e,t),f={x:n,y:r},g=$t(o),m=$s(g);let p=f[m],v=f[g];const h=yt(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(u){const S=m==="y"?"height":"width",E=s.reference[m]-s.floating[S]+y.mainAxis,C=s.reference[m]+s.reference[S]-y.mainAxis;p<E?p=E:p>C&&(p=C)}if(c){var w,b;const S=m==="y"?"width":"height",E=["top","left"].includes(wt(o)),C=s.reference[g]-s.floating[S]+(E&&((w=i.offset)==null?void 0:w[g])||0)+(E?0:y.crossAxis),P=s.reference[g]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[g])||0)-(E?y.crossAxis:0);v<C?v=C:v>P&&(v=P)}return{[m]:p,[g]:v}}}},Cy=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:u=()=>{},...c}=yt(e,t),f=await On(t,c),g=wt(o),m=ln(o),p=$t(o)==="y",{width:v,height:h}=s.floating;let y,w;g==="top"||g==="bottom"?(y=g,w=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=g,y=m==="end"?"top":"bottom");const b=h-f.top-f.bottom,S=v-f.left-f.right,E=It(h-f[y],b),C=It(v-f[w],S),P=!t.middlewareData.shift;let _=E,O=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=b),P&&!m){const F=Be(f.left,0),G=Be(f.right,0),k=Be(f.top,0),R=Be(f.bottom,0);p?O=v-2*(F!==0||G!==0?F+G:Be(f.left,f.right)):_=h-2*(k!==0||R!==0?k+R:Be(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:_});const $=await i.getDimensions(a.floating);return v!==$.width||h!==$.height?{reset:{rects:!0}}:{}}}};function kr(){return typeof window<"u"}function cn(e){return tu(e)?(e.nodeName||"").toLowerCase():"#document"}function ze(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){var t;return(t=(tu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function tu(e){return kr()?e instanceof Node||e instanceof ze(e).Node:!1}function Ze(e){return kr()?e instanceof Element||e instanceof ze(e).Element:!1}function lt(e){return kr()?e instanceof HTMLElement||e instanceof ze(e).HTMLElement:!1}function nu(e){return!kr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ze(e).ShadowRoot}function Dn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Qe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Sy(e){return["table","td","th"].includes(cn(e))}function Lr(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Vs(e){const t=Bs(),n=Ze(e)?Qe(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Ey(e){let t=kt(e);for(;lt(t)&&!un(t);){if(Vs(t))return t;if(Lr(t))return null;t=kt(t)}return null}function Bs(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function un(e){return["html","body","#document"].includes(cn(e))}function Qe(e){return ze(e).getComputedStyle(e)}function Rr(e){return Ze(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kt(e){if(cn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||nu(e)&&e.host||at(e);return nu(t)?t.host:t}function ru(e){const t=kt(e);return un(t)?e.ownerDocument?e.ownerDocument.body:e.body:lt(t)&&Dn(t)?t:ru(t)}function Mn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ru(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ze(o);if(s){const a=zs(i);return t.concat(i,i.visualViewport||[],Dn(o)?o:[],a&&n?Mn(a):[])}return t.concat(o,Mn(o,[],n))}function zs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ou(e){const t=Qe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=lt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Dr(n)!==s||Dr(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Hs(e){return Ze(e)?e:e.contextElement}function dn(e){const t=Hs(e);if(!lt(t))return it(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ou(t);let i=(s?Dr(n.width):n.width)/r,a=(s?Dr(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Ny=it(0);function su(e){const t=ze(e);return!Bs()||!t.visualViewport?Ny:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ze(e)?!1:t}function Wt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Hs(e);let i=it(1);t&&(r?Ze(r)&&(i=dn(r)):i=dn(e));const a=Ty(s,n,r)?su(s):it(0);let u=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,f=o.width/i.x,g=o.height/i.y;if(s){const m=ze(s),p=r&&Ze(r)?ze(r):r;let v=m,h=zs(v);for(;h&&r&&p!==v;){const y=dn(h),w=h.getBoundingClientRect(),b=Qe(h),S=w.left+(h.clientLeft+parseFloat(b.paddingLeft))*y.x,E=w.top+(h.clientTop+parseFloat(b.paddingTop))*y.y;u*=y.x,c*=y.y,f*=y.x,g*=y.y,u+=S,c+=E,v=ze(h),h=zs(v)}}return $r({width:f,height:g,x:u,y:c})}function Us(e,t){const n=Rr(e).scrollLeft;return t?t.left+n:Wt(at(e)).left+n}function iu(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Us(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Py(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=at(r),a=t?Lr(t.floating):!1;if(r===i||a&&s)return n;let u={scrollLeft:0,scrollTop:0},c=it(1);const f=it(0),g=lt(r);if((g||!g&&!s)&&((cn(r)!=="body"||Dn(i))&&(u=Rr(r)),lt(r))){const p=Wt(r);c=dn(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const m=i&&!g&&!s?iu(i,u,!0):it(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-u.scrollLeft*c.x+f.x+m.x,y:n.y*c.y-u.scrollTop*c.y+f.y+m.y}}function Ay(e){return Array.from(e.getClientRects())}function _y(e){const t=at(e),n=Rr(e),r=e.ownerDocument.body,o=Be(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Be(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return Qe(r).direction==="rtl"&&(i+=Be(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Fy(e,t){const n=ze(e),r=at(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,u=0;if(o){s=o.width,i=o.height;const c=Bs();(!c||c&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:s,height:i,x:a,y:u}}function Oy(e,t){const n=Wt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=lt(e)?dn(e):it(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,u=o*s.x,c=r*s.y;return{width:i,height:a,x:u,y:c}}function au(e,t,n){let r;if(t==="viewport")r=Fy(e,n);else if(t==="document")r=_y(at(e));else if(Ze(t))r=Oy(t,n);else{const o=su(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $r(r)}function lu(e,t){const n=kt(e);return n===t||!Ze(n)||un(n)?!1:Qe(n).position==="fixed"||lu(n,t)}function Dy(e,t){const n=t.get(e);if(n)return n;let r=Mn(e,[],!1).filter(a=>Ze(a)&&cn(a)!=="body"),o=null;const s=Qe(e).position==="fixed";let i=s?kt(e):e;for(;Ze(i)&&!un(i);){const a=Qe(i),u=Vs(i);!u&&a.position==="fixed"&&(o=null),(s?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Dn(i)&&!u&&lu(e,i))?r=r.filter(f=>f!==i):o=a,i=kt(i)}return t.set(e,r),r}function My(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Lr(t)?[]:Dy(t,this._c):[].concat(n),r],a=i[0],u=i.reduce((c,f)=>{const g=au(t,f,o);return c.top=Be(g.top,c.top),c.right=It(g.right,c.right),c.bottom=It(g.bottom,c.bottom),c.left=Be(g.left,c.left),c},au(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Iy(e){const{width:t,height:n}=ou(e);return{width:t,height:n}}function $y(e,t,n){const r=lt(t),o=at(t),s=n==="fixed",i=Wt(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const u=it(0);if(r||!r&&!s)if((cn(t)!=="body"||Dn(o))&&(a=Rr(t)),r){const m=Wt(t,!0,s,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}else o&&(u.x=Us(o));const c=o&&!r&&!s?iu(o,a):it(0),f=i.left+a.scrollLeft-u.x-c.x,g=i.top+a.scrollTop-u.y-c.y;return{x:f,y:g,width:i.width,height:i.height}}function js(e){return Qe(e).position==="static"}function cu(e,t){if(!lt(e)||Qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return at(e)===n&&(n=n.ownerDocument.body),n}function uu(e,t){const n=ze(e);if(Lr(e))return n;if(!lt(e)){let o=kt(e);for(;o&&!un(o);){if(Ze(o)&&!js(o))return o;o=kt(o)}return n}let r=cu(e,t);for(;r&&Sy(r)&&js(r);)r=cu(r,t);return r&&un(r)&&js(r)&&!Vs(r)?n:r||Ey(e)||n}const ky=async function(e){const t=this.getOffsetParent||uu,n=this.getDimensions,r=await n(e.floating);return{reference:$y(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ly(e){return Qe(e).direction==="rtl"}const Ry={convertOffsetParentRelativeRectToViewportRelativeRect:Py,getDocumentElement:at,getClippingRect:My,getOffsetParent:uu,getElementRects:ky,getClientRects:Ay,getDimensions:Iy,getScale:dn,isElement:Ze,isRTL:Ly};function Vy(e,t){let n=null,r;const o=at(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const{left:c,top:f,width:g,height:m}=e.getBoundingClientRect();if(a||t(),!g||!m)return;const p=Mr(f),v=Mr(o.clientWidth-(c+g)),h=Mr(o.clientHeight-(f+m)),y=Mr(c),b={rootMargin:-p+"px "+-v+"px "+-h+"px "+-y+"px",threshold:Be(0,It(1,u))||1};let S=!0;function E(C){const P=C[0].intersectionRatio;if(P!==u){if(!S)return i();P?i(!1,P):r=setTimeout(()=>{i(!1,1e-7)},1e3)}S=!1}try{n=new IntersectionObserver(E,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,b)}n.observe(e)}return i(!0),s}function By(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=Hs(e),f=o||s?[...c?Mn(c):[],...Mn(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const g=c&&a?Vy(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(w=>{let[b]=w;b&&b.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!u&&p.observe(c),p.observe(t));let v,h=u?Wt(e):null;u&&y();function y(){const w=Wt(e);h&&(w.x!==h.x||w.y!==h.y||w.width!==h.width||w.height!==h.height)&&n(),h=w,v=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),g==null||g(),(w=p)==null||w.disconnect(),p=null,u&&cancelAnimationFrame(v)}}const zy=wy,Hy=by,Uy=my,jy=Cy,Wy=vy,du=hy,Gy=xy,qy=(e,t,n)=>{const r=new Map,o={platform:Ry,...n},s={...o.platform,_c:r};return gy(e,t,{...o,platform:s})};var Vr=typeof document<"u"?D.useLayoutEffect:D.useEffect;function Br(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Br(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pu(e,t){const n=fu(e);return Math.round(t*n)/n}function Ws(e){const t=d.useRef(e);return Vr(()=>{t.current=e}),t}function Ky(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:u,open:c}=e,[f,g]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=d.useState(r);Br(m,r)||p(r);const[v,h]=d.useState(null),[y,w]=d.useState(null),b=d.useCallback(K=>{K!==P.current&&(P.current=K,h(K))},[]),S=d.useCallback(K=>{K!==_.current&&(_.current=K,w(K))},[]),E=s||v,C=i||y,P=d.useRef(null),_=d.useRef(null),O=d.useRef(f),$=u!=null,F=Ws(u),G=Ws(o),k=Ws(c),R=d.useCallback(()=>{if(!P.current||!_.current)return;const K={placement:t,strategy:n,middleware:m};G.current&&(K.platform=G.current),qy(P.current,_.current,K).then(ee=>{const ce={...ee,isPositioned:k.current!==!1};I.current&&!Br(O.current,ce)&&(O.current=ce,jn.flushSync(()=>{g(ce)}))})},[m,t,n,G,k]);Vr(()=>{c===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,g(K=>({...K,isPositioned:!1})))},[c]);const I=d.useRef(!1);Vr(()=>(I.current=!0,()=>{I.current=!1}),[]),Vr(()=>{if(E&&(P.current=E),C&&(_.current=C),E&&C){if(F.current)return F.current(E,C,R);R()}},[E,C,R,F,$]);const q=d.useMemo(()=>({reference:P,floating:_,setReference:b,setFloating:S}),[b,S]),U=d.useMemo(()=>({reference:E,floating:C}),[E,C]),J=d.useMemo(()=>{const K={position:n,left:0,top:0};if(!U.floating)return K;const ee=pu(U.floating,f.x),ce=pu(U.floating,f.y);return a?{...K,transform:"translate("+ee+"px, "+ce+"px)",...fu(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ee,top:ce}},[n,a,U.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:R,refs:q,elements:U,floatingStyles:J}),[f,R,q,U,J])}const Xy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?du({element:r.current,padding:o}).fn(n):{}:r?du({element:r,padding:o}).fn(n):{}}}},Jy=(e,t)=>({...zy(e),options:[e,t]}),Yy=(e,t)=>({...Hy(e),options:[e,t]}),Zy=(e,t)=>({...Gy(e),options:[e,t]}),Qy=(e,t)=>({...Uy(e),options:[e,t]}),ew=(e,t)=>({...jy(e),options:[e,t]}),tw=(e,t)=>({...Wy(e),options:[e,t]}),nw=(e,t)=>({...Xy(e),options:[e,t]});var rw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ow=rw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),sw="Arrow",gu=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ow.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});gu.displayName=sw;var iw=gu;function hu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function aw(...e){return t=>{let n=!1;const r=e.map(o=>{const s=hu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():hu(e[o],null)}}}}function mu(...e){return d.useCallback(aw(...e),e)}var lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],vu=lw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Jt:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Gs="Popper",[yu,wu]=Pt(Gs),[cw,bu]=yu(Gs),xu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return l.jsx(cw,{scope:t,anchor:r,onAnchorChange:o,children:n})};xu.displayName=Gs;var Cu="PopperAnchor",Su=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bu(Cu,n),i=d.useRef(null),a=mu(t,i);return d.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:l.jsx(vu.div,{...o,ref:a})});Su.displayName=Cu;var qs="PopperContent",[uw,dw]=yu(qs),Eu=d.forwardRef((e,t)=>{var Ne,Te,$e,Rt,tt,hn;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...h}=e,y=bu(qs,n),[w,b]=d.useState(null),S=mu(t,Ge=>b(Ge)),[E,C]=d.useState(null),P=La(E),_=(P==null?void 0:P.width)??0,O=(P==null?void 0:P.height)??0,$=r+(s!=="center"?"-"+s:""),F=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},G=Array.isArray(c)?c:[c],k=G.length>0,R={padding:F,boundary:G.filter(pw),altBoundary:k},{refs:I,floatingStyles:q,placement:U,isPositioned:J,middlewareData:K}=Ky({strategy:"fixed",placement:$,whileElementsMounted:(...Ge)=>By(...Ge,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Jy({mainAxis:o+O,alignmentAxis:i}),u&&Yy({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Zy():void 0,...R}),u&&Qy({...R}),ew({...R,apply:({elements:Ge,rects:ft,availableWidth:mn,availableHeight:Hn})=>{const{width:vn,height:x}=ft.reference,N=Ge.floating.style;N.setProperty("--radix-popper-available-width",`${mn}px`),N.setProperty("--radix-popper-available-height",`${Hn}px`),N.setProperty("--radix-popper-anchor-width",`${vn}px`),N.setProperty("--radix-popper-anchor-height",`${x}px`)}}),E&&nw({element:E,padding:a}),gw({arrowWidth:_,arrowHeight:O}),m&&tw({strategy:"referenceHidden",...R})]}),[ee,ce]=Pu(U),fe=Pe(v);Ve(()=>{J&&(fe==null||fe())},[J,fe]);const Ce=(Ne=K.arrow)==null?void 0:Ne.x,Ie=(Te=K.arrow)==null?void 0:Te.y,je=(($e=K.arrow)==null?void 0:$e.centerOffset)!==0,[We,we]=d.useState();return Ve(()=>{w&&we(window.getComputedStyle(w).zIndex)},[w]),l.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:J?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:We,"--radix-popper-transform-origin":[(Rt=K.transformOrigin)==null?void 0:Rt.x,(tt=K.transformOrigin)==null?void 0:tt.y].join(" "),...((hn=K.hide)==null?void 0:hn.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(uw,{scope:n,placedSide:ee,onArrowChange:C,arrowX:Ce,arrowY:Ie,shouldHideArrow:je,children:l.jsx(vu.div,{"data-side":ee,"data-align":ce,...h,ref:S,style:{...h.style,animation:J?void 0:"none"}})})})});Eu.displayName=qs;var Nu="PopperArrow",fw={top:"bottom",right:"left",bottom:"top",left:"right"},Tu=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=dw(Nu,r),i=fw[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(iw,{...o,ref:n,style:{...o.style,display:"block"}})})});Tu.displayName=Nu;function pw(e){return e!==null}var gw=e=>({name:"transformOrigin",options:e,fn(t){var y,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[c,f]=Pu(n),g={start:"0%",center:"50%",end:"100%"}[f],m=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+u/2;let v="",h="";return c==="bottom"?(v=i?g:`${m}px`,h=`${-u}px`):c==="top"?(v=i?g:`${m}px`,h=`${r.floating.height+u}px`):c==="right"?(v=`${-u}px`,h=i?g:`${p}px`):c==="left"&&(v=`${r.floating.width+u}px`,h=i?g:`${p}px`),{data:{x:v,y:h}}}});function Pu(e){const[t,n="center"]=e.split("-");return[t,n]}var hw=xu,mw=Su,vw=Eu,yw=Tu,ww="Portal",Au=d.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=d.useState(!1);Ve(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?no.createPortal(l.jsx(Fn.div,{...r,ref:t}),i):null});Au.displayName=ww;function bw(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Ks=e=>{const{present:t,children:n}=e,r=xw(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=_n(r.ref,Cw(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Ks.displayName="Presence";function xw(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=bw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const c=zr(r.current);s.current=a==="mounted"?c:"none"},[a]),Ve(()=>{const c=r.current,f=o.current;if(f!==e){const m=s.current,p=zr(c);e?u("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(f&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ve(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,g=p=>{const h=zr(r.current).includes(p.animationName);if(p.target===t&&h&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},m=p=>{p.target===t&&(s.current=zr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function zr(e){return(e==null?void 0:e.animationName)||"none"}function Cw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Sw="VisuallyHidden",_u=d.forwardRef((e,t)=>l.jsx(Fn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));_u.displayName=Sw;var Ew=_u,[Hr,lC]=Pt("Tooltip",[wu]),Ur=wu(),Fu="TooltipProvider",Nw=700,Xs="tooltip.open",[Tw,Js]=Hr(Fu),Ou=e=>{const{__scopeTooltip:t,delayDuration:n=Nw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,[i,a]=d.useState(!0),u=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const f=c.current;return()=>window.clearTimeout(f)},[]),l.jsx(Tw,{scope:t,isOpenDelayed:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:d.useCallback(f=>{u.current=f},[]),disableHoverableContent:o,children:s})};Ou.displayName=Fu;var jr="Tooltip",[Pw,In]=Hr(jr),Du=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,u=Js(jr,e.__scopeTooltip),c=Ur(t),[f,g]=d.useState(null),m=tn(),p=d.useRef(0),v=i??u.disableHoverableContent,h=a??u.delayDuration,y=d.useRef(!1),[w=!1,b]=Qt({prop:r,defaultProp:o,onChange:_=>{_?(u.onOpen(),document.dispatchEvent(new CustomEvent(Xs))):u.onClose(),s==null||s(_)}}),S=d.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),E=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,b(!0)},[b]),C=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),P=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,b(!0),p.current=0},h)},[h,b]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),l.jsx(hw,{...c,children:l.jsx(Pw,{scope:t,contentId:m,open:w,stateAttribute:S,trigger:f,onTriggerChange:g,onTriggerEnter:d.useCallback(()=>{u.isOpenDelayed?P():E()},[u.isOpenDelayed,P,E]),onTriggerLeave:d.useCallback(()=>{v?C():(window.clearTimeout(p.current),p.current=0)},[C,v]),onOpen:E,onClose:C,disableHoverableContent:v,children:n})})};Du.displayName=jr;var Ys="TooltipTrigger",Mu=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=In(Ys,n),s=Js(Ys,n),i=Ur(n),a=d.useRef(null),u=_n(t,a,o.onTriggerChange),c=d.useRef(!1),f=d.useRef(!1),g=d.useCallback(()=>c.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),l.jsx(mw,{asChild:!0,...i,children:l.jsx(Fn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:vt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:vt(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:vt(e.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:vt(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:vt(e.onBlur,o.onClose),onClick:vt(e.onClick,o.onClose)})})});Mu.displayName=Ys;var Zs="TooltipPortal",[Aw,_w]=Hr(Zs,{forceMount:void 0}),Iu=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=In(Zs,t);return l.jsx(Aw,{scope:t,forceMount:n,children:l.jsx(Ks,{present:n||s.open,children:l.jsx(Au,{asChild:!0,container:o,children:r})})})};Iu.displayName=Zs;var fn="TooltipContent",$u=d.forwardRef((e,t)=>{const n=_w(fn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=In(fn,e.__scopeTooltip);return l.jsx(Ks,{present:r||i.open,children:i.disableHoverableContent?l.jsx(ku,{side:o,...s,ref:t}):l.jsx(Fw,{side:o,...s,ref:t})})}),Fw=d.forwardRef((e,t)=>{const n=In(fn,e.__scopeTooltip),r=Js(fn,e.__scopeTooltip),o=d.useRef(null),s=_n(t,o),[i,a]=d.useState(null),{trigger:u,onClose:c}=n,f=o.current,{onPointerInTransitChange:g}=r,m=d.useCallback(()=>{a(null),g(!1)},[g]),p=d.useCallback((v,h)=>{const y=v.currentTarget,w={x:v.clientX,y:v.clientY},b=Iw(w,y.getBoundingClientRect()),S=$w(w,b),E=kw(h.getBoundingClientRect()),C=Rw([...S,...E]);a(C),g(!0)},[g]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(u&&f){const v=y=>p(y,f),h=y=>p(y,u);return u.addEventListener("pointerleave",v),f.addEventListener("pointerleave",h),()=>{u.removeEventListener("pointerleave",v),f.removeEventListener("pointerleave",h)}}},[u,f,p,m]),d.useEffect(()=>{if(i){const v=h=>{const y=h.target,w={x:h.clientX,y:h.clientY},b=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),S=!Lw(w,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,f,i,c,m]),l.jsx(ku,{...e,ref:s})}),[Ow,Dw]=Hr(jr,{isInside:!1}),ku=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,u=In(fn,n),c=Ur(n),{onClose:f}=u;return d.useEffect(()=>(document.addEventListener(Xs,f),()=>document.removeEventListener(Xs,f)),[f]),d.useEffect(()=>{if(u.trigger){const g=m=>{const p=m.target;p!=null&&p.contains(u.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,f]),l.jsx(Kc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:l.jsxs(vw,{"data-state":u.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(xa,{children:r}),l.jsx(Ow,{scope:n,isInside:!0,children:l.jsx(Ew,{id:u.contentId,role:"tooltip",children:o||r})})]})})});$u.displayName=fn;var Lu="TooltipArrow",Mw=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ur(n);return Dw(Lu,n).isInside?null:l.jsx(yw,{...o,...r,ref:t})});Mw.displayName=Lu;function Iw(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function $w(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function kw(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function Lw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,u=t[s].y,c=t[i].x,f=t[i].y;u>r!=f>r&&n<(c-a)*(r-u)/(f-u)+a&&(o=!o)}return o}function Rw(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Vw(t)}function Vw(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Bw=Ou,zw=Du,Hw=Mu,Uw=Iu,Ru=$u;const Vu=Bw,Bu=zw,zu=Hw,Qs=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(Uw,{children:l.jsx(Ru,{ref:r,sideOffset:t,className:Q("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Qs.displayName=Ru.displayName;function jw({title:e,titleId:t,...n},r){return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?d.createElement("title",{id:t},e):null,d.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ww=d.forwardRef(jw);var Gw=function(e){return function(t,n){var r=D.useRef(!1);e(function(){return function(){r.current=!1}},[]),e(function(){if(!r.current)r.current=!0;else return t()},n)}},Hu=function(e){return typeof e=="function"},Uu=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const qw=Gw(D.useEffect);function ju(e){var t=D.useRef(e);return t.current=e,t}var Kw=function(e){Uu&&(Hu(e)||console.error("useUnmount expected parameter is a function, got ".concat(typeof e)));var t=ju(e);D.useEffect(function(){return function(){t.current()}},[])},Wr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Jw(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Wu=Jw,Yw=typeof Wr=="object"&&Wr&&Wr.Object===Object&&Wr,Zw=Yw,Qw=Zw,eb=typeof self=="object"&&self&&self.Object===Object&&self,tb=Qw||eb||Function("return this")(),Gu=tb,nb=Gu,rb=function(){return nb.Date.now()},ob=rb,sb=/\s/;function ib(e){for(var t=e.length;t--&&sb.test(e.charAt(t)););return t}var ab=ib,lb=ab,cb=/^\s+/;function ub(e){return e&&e.slice(0,lb(e)+1).replace(cb,"")}var db=ub,fb=Gu,pb=fb.Symbol,qu=pb,Ku=qu,Xu=Object.prototype,gb=Xu.hasOwnProperty,hb=Xu.toString,$n=Ku?Ku.toStringTag:void 0;function mb(e){var t=gb.call(e,$n),n=e[$n];try{e[$n]=void 0;var r=!0}catch{}var o=hb.call(e);return r&&(t?e[$n]=n:delete e[$n]),o}var vb=mb,yb=Object.prototype,wb=yb.toString;function bb(e){return wb.call(e)}var xb=bb,Ju=qu,Cb=vb,Sb=xb,Eb="[object Null]",Nb="[object Undefined]",Yu=Ju?Ju.toStringTag:void 0;function Tb(e){return e==null?e===void 0?Nb:Eb:Yu&&Yu in Object(e)?Cb(e):Sb(e)}var Pb=Tb;function Ab(e){return e!=null&&typeof e=="object"}var _b=Ab,Fb=Pb,Ob=_b,Db="[object Symbol]";function Mb(e){return typeof e=="symbol"||Ob(e)&&Fb(e)==Db}var Ib=Mb,$b=db,Zu=Wu,kb=Ib,Qu=NaN,Lb=/^[-+]0x[0-9a-f]+$/i,Rb=/^0b[01]+$/i,Vb=/^0o[0-7]+$/i,Bb=parseInt;function zb(e){if(typeof e=="number")return e;if(kb(e))return Qu;if(Zu(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Zu(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$b(e);var n=Rb.test(e);return n||Vb.test(e)?Bb(e.slice(2),n?2:8):Lb.test(e)?Qu:+e}var Hb=zb,Ub=Wu,ei=ob,ed=Hb,jb="Expected a function",Wb=Math.max,Gb=Math.min;function qb(e,t,n){var r,o,s,i,a,u,c=0,f=!1,g=!1,m=!0;if(typeof e!="function")throw new TypeError(jb);t=ed(t)||0,Ub(n)&&(f=!!n.leading,g="maxWait"in n,s=g?Wb(ed(n.maxWait)||0,t):s,m="trailing"in n?!!n.trailing:m);function p(P){var _=r,O=o;return r=o=void 0,c=P,i=e.apply(O,_),i}function v(P){return c=P,a=setTimeout(w,t),f?p(P):i}function h(P){var _=P-u,O=P-c,$=t-_;return g?Gb($,s-O):$}function y(P){var _=P-u,O=P-c;return u===void 0||_>=t||_<0||g&&O>=s}function w(){var P=ei();if(y(P))return b(P);a=setTimeout(w,h(P))}function b(P){return a=void 0,m&&r?p(P):(r=o=void 0,i)}function S(){a!==void 0&&clearTimeout(a),c=0,r=u=o=a=void 0}function E(){return a===void 0?i:b(ei())}function C(){var P=ei(),_=y(P);if(r=arguments,o=this,u=P,_){if(a===void 0)return v(u);if(g)return clearTimeout(a),a=setTimeout(w,t),p(u)}return a===void 0&&(a=setTimeout(w,t)),i}return C.cancel=S,C.flush=E,C}var Kb=qb;const Xb=Xw(Kb);function Jb(){var e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}Jb()||(global.Date=Date);function Yb(e,t){var n;Uu&&(Hu(e)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof e)));var r=ju(e),o=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=D.useMemo(function(){return Xb(function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return r.current.apply(r,il([],sl(i),!1))},o,t)},[]);return Kw(function(){s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function Zb(e,t,n){var r=sl(D.useState({}),2),o=r[0],s=r[1],i=Yb(function(){s({})},n).run;D.useEffect(function(){return i()},t),qw(e,[o])}const Qb=D.forwardRef(({onChange:e},t)=>{const n=D.useRef(null),[r,o]=D.useState("");return D.useImperativeHandle(t,()=>({setValue:s=>{var i;o(s),(i=n.current)==null||i.focus()}})),Zb(()=>{e==null||e(r)},[r],{wait:300}),l.jsxs(l.Fragment,{children:[l.jsx(Mt,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:s=>o(s.target.value),className:"pr-8"}),r&&l.jsx("button",{onClick:()=>{var s;o(""),(s=n.current)==null||s.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:l.jsx(Ww,{className:"h-5 w-5"})})]})}),De={current:!1},td="crawl:jobs",pn="crawl:current_job",ex=e=>{const[t,n]=D.useState(null),[r,o]=D.useState(0);return D.useEffect(()=>{const s=localStorage.getItem(pn);if(s){const i=JSON.parse(s);n(i),i!=null&&i.startTime&&o(Math.floor((Date.now()-i.startTime)/1e3))}},[]),D.useEffect(()=>{if(!(t!=null&&t.startTime))return;const s=setInterval(()=>{o(Math.floor((Date.now()-t.startTime)/1e3))},1e3);return()=>clearInterval(s)},[t==null?void 0:t.startTime]),D.useEffect(()=>{if(!(t!=null&&t.id))return;const s=async()=>{try{const u=(await ie.get(`${e}/api/crawl/${t.id}?taskId=${t.taskId}`)).data;n(c=>{if(!c)return null;const f={...c,status:u};return localStorage.setItem(pn,JSON.stringify(f)),(u.status==="completed"||u.status==="failed")&&setTimeout(()=>{n(null),localStorage.removeItem(pn)},100),f})}catch(a){console.error("Error polling job status:",a)}},i=setInterval(s,3e3);return s(),()=>clearInterval(i)},[t==null?void 0:t.id,e]),{currentJob:t,elapsedTime:r,setCurrentJob:s=>{s&&!s.startTime&&(s.startTime=Date.now()),n(s),s?localStorage.setItem(pn,JSON.stringify(s)):localStorage.removeItem(pn)}}},tx=(e,t,n)=>{const r=[],o=s=>{(e[s]||[]).forEach(a=>{a.name.toLowerCase().includes(t.toLowerCase())&&r.push(a),a.isFolder&&a.key.startsWith(n)&&o(a.key)})};return o(n),r},Gr=(e,t)=>{const n=[],r=o=>{(e[o]||[]).forEach(i=>{n.push(i.key),i.isFolder&&r(i.key)})};return r(t),n},nx=(e,t)=>{const n=[];return(e[t]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Gr(e,o.key))}),n},rx=(e,t,n=[])=>{const[r,o]=D.useState({}),[s,i]=D.useState(!1),[a,u]=D.useState(null),c=D.useRef(t);D.useEffect(()=>{c.current=t},[t]);const f=async()=>{i(!0);try{const g=!De.current;De.current&&(De.current=!1);const m=await ie.get(`${e}/api/files`,{params:{cache:g,displayPrefixes:JSON.stringify(n),prefix:c.current},timeout:3e5});o(m.data),u(null)}catch(g){u(g instanceof Error?g:new Error("Failed to fetch files"))}finally{i(!1)}};return D.useEffect(()=>{f()},[]),{data:r,isLoading:s,error:a,refetch:f}},kn=e=>{var r,o,s;const t=((s=(o=(r=e==null?void 0:e.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:s.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(t||"")},ox=D.memo(({homeLabel:e="Kho tài liệu",apiBaseUrl:t="http://localhost:3002",rootPrefix:n="",asSelector:r=!1,onSelected:o=i=>console.log("Đã chọn:",i),displayPrefixes:s})=>{var Td;const[i,a]=D.useState(""),[u,c]=D.useState(new Set),[f,g]=D.useState(n),[m,p]=D.useState(null),[v,h]=D.useState(!1),[y,w]=D.useState(""),[b,S]=D.useState(!1),[E,C]=D.useState(null),[P,_]=D.useState(!1),[O,$]=D.useState(!1),[F,G]=D.useState(null),k=D.useRef(null),{toast:R}=Ds(),[I,q]=D.useState(null),[U,J]=D.useState(null),[K,ee]=D.useState(""),[ce,fe]=D.useState(!1),[Ce,Ie]=D.useState(new Set),[je,We]=D.useState(""),[we,Ne]=D.useState(!1),[Te,$e]=D.useState(!1),[Rt,tt]=D.useState("rename"),[hn,Ge]=D.useState(!1),[ft,mn]=D.useState(""),[Hn,vn]=D.useState("1"),[x,N]=D.useState(!1),[A,z]=D.useState(!1),[B,V]=D.useState(!1),[X,oe]=D.useState(!1),{currentJob:te,elapsedTime:pe,setCurrentJob:pt}=ex(t),gi=m||n,{data:_e,isLoading:qt,error:hi,refetch:ke}=rx(t,gi,s);D.useEffect(()=>{te!=null&&te.status&&(te.status.status==="completed"?(R({title:"Thu thập website hoàn tất",description:`Đã thu thập thành công ${te.url} với ${te.status.completed} trang`}),De.current=!0,ke()):te.status.status==="failed"&&R({title:"Thu thập website thất bại",description:`Không thể thu thập ${te.url}. Vui lòng thử lại.`,variant:"destructive"}))},[(Td=te==null?void 0:te.status)==null?void 0:Td.status]);const Qr=D.useMemo(()=>_e[f]||[],[_e,f]),gt=D.useMemo(()=>i?tx(_e,i,f):Qr,[Qr,i,f,_e]),Un=D.useMemo(()=>{const M={};return gt.forEach((L,H)=>{u.has(L.key)&&(M[H]=!0)}),M},[u,gt]),_x=M=>{const L=Gr(_e,M);if(L.length===0)return u.has(M)?"all":"none";const H=L.filter(W=>u.has(W)).length;return H===0?"none":H===L.length?"all":"partial"},eo=M=>{oe(!0),p(M),g(M)};D.useEffect(()=>{X&&(De.current=!0,ke().finally(()=>oe(!1)))},[X]);const Fx=async(M,L)=>{S(!0);try{const H=`${L}${M}/`;if((await ie.post(`${t}/api/create-folder`,{prefix:H})).status!==200){R({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"});return}De.current=!0,await ke(),R({title:"Đã tạo thư mục",description:`Đã tạo thành công thư mục "${M}"`}),w(""),h(!1)}catch(H){console.error("Error creating folder:",H),R({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"})}finally{S(!1)}},Cd=async(M,L,H)=>{G(H),z(!0);try{if(sg(M,R))return;let W=localStorage.getItem("dataLogin"),se;try{W&&(W=JSON.parse(W),se=W.user)}catch{W=null}const ae=new FormData;ae.append("prefix",L),Array.from(M).forEach(he=>ae.append("files",he)),se!=null&&se.id&&(console.log("🚀 ~ uploadFiles ~ user:",se),ae.append("metadata",JSON.stringify({creator:se.username,creatorId:se.id,DataSource:"Tệp tải lên"}))),await ie.post(`${t}/api/upload`,ae,{headers:{"Content-Type":"multipart/form-data"}}),p(L),De.current=!0,await ke()}catch(W){console.error("Lỗi tải lên:",W)}finally{G(null),z(!1)}},Ox=async M=>{var L;V(!0);try{await ie.delete(`${t}/api/files`,{data:{paths:[M.key]}});const H=((L=M.key)==null?void 0:L.replace(/^(.*?)(\/.*)?$/,(W,se,ae)=>!ae||ae==="/"?"":se+"/"))||"";p(H),De.current=!0,R({title:"Đã xóa tập tin",description:`Đã xóa thành công "${M.name}"`}),C(null)}catch(H){console.error("Error deleting file:",H),R({title:"Lỗi",description:"Không thể xóa tập tin",variant:"destructive"})}finally{V(!1),await ke()}},to=M=>{const L=new Set(u),H=typeof M=="function"?M(Un):M;new Set(Object.keys(Un).map(Number)).forEach(se=>{const ae=gt[se];ae&&(H[se]||(L.delete(ae.key),ae.isFolder&&Gr(_e,ae.key).forEach(he=>L.delete(he))))}),Object.entries(H).forEach(([se,ae])=>{const he=parseInt(se),Ct=gt[he];Ct&&ae&&(L.add(Ct.key),Ct.isFolder&&Gr(_e,Ct.key).forEach(vi=>L.add(vi)))}),c(L)},Dx=async()=>{var M;_(!0);try{const L=Array.from(u),H=L.map(se=>Object.values(_e).flat().find(ae=>ae.key===se)).filter(se=>se!==void 0);if(H.length===0){R({title:"Lỗi",description:"Không có tập tin nào được chọn để xóa",variant:"destructive"});return}await ie.delete(`${t}/api/files`,{data:{paths:L}});const W=((M=H[0])==null?void 0:M.key.replace(/^(.*?)(\/.*)?$/,(se,ae,he)=>!he||he==="/"?"":ae+"/"))||"";p(W),De.current=!0,ke(),R({title:"Đã xóa tập tin",description:`Đã xóa thành công ${H.length} mục`}),$(!1),c(new Set)}catch(L){console.error("Error deleting files:",L),R({title:"Lỗi",description:"Không thể xóa các tập tin đã chọn",variant:"destructive"})}finally{_(!1)}},Mx=async(M,L)=>{fe(!0);try{const H=M.key;let W;M.isFolder?W=H.split("/").slice(0,-2).join("/")+"/":W=H.substring(0,H.lastIndexOf("/")+1);const se=W+L+(M.isFolder?"/":"");await ie.post(`${t}/api/rename`,{oldPath:H,newPath:se}),De.current=!0,await ke(),R({title:"Đã đổi tên",description:`Đã đổi tên thành công "${M.name}" thành "${L}"`}),q(null),ee(""),J(null)}catch(H){console.error("Error renaming item:",H),R({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{fe(!1)}},Sd=async M=>{Ie(L=>new Set([...L,...M]));try{const L=await ie.post(`${t}/api/download`,{paths:M},{responseType:"blob"}),H=window.URL.createObjectURL(L.data),W=document.createElement("a");W.href=H;const se=L.headers["Content-Disposition"]||L.headers["content-disposition"],ae=se==null?void 0:se.match(/filename="(.+)"/),he=ae?decodeURIComponent(ae[1]):"download.zip";W.setAttribute("download",he),document.body.appendChild(W),W.click(),document.body.removeChild(W),window.URL.revokeObjectURL(H),R({title:"Bắt đầu tải xuống",description:`Đã bắt đầu tải xuống ${M.length} mục${M.length>1,""}`})}catch(L){console.error("Error downloading files:",L),R({title:"Lỗi",description:"Không thể tải xuống tập tin",variant:"destructive"})}finally{Ie(L=>{const H=new Set(L);return M.forEach(W=>H.delete(W)),H})}},Ed=f?f.replace(n,"").split("/").filter(Boolean):[],Ix=()=>Array.from(u).map(M=>{var L;for(const H in _e){const W=(L=_e[H])==null?void 0:L.find(se=>se.key===M);if(W)return W}return null}).filter(M=>M!==null),Nd=D.useMemo(()=>{const M=[{id:"select",header:()=>{const L=nx(_e,f),H=L.length>0&&L.every(se=>u.has(se)),W=L.some(se=>u.has(se));return l.jsx(Go,{checked:H?!0:W?"indeterminate":!1,onCheckedChange:se=>{if(se){const ae=gt.reduce((he,Ct,vi)=>(he[vi]=!0,he),{});to(ae)}else to({})},"aria-label":"Chọn tất cả"})},cell:({row:L})=>{const H=L.original,se=H.isFolder?_x(H.key):u.has(H.key)?"all":"none";return l.jsx("div",{className:"flex items-center",children:l.jsx(Go,{checked:se==="partial"?"indeterminate":se==="all",onCheckedChange:ae=>{const he={...Un};ae?he[L.index]=!0:delete he[L.index],to(he)},"aria-label":"Chọn dòng"})})},enableSorting:!1},{id:"fileName",header:"Tên tập tin",accessorKey:"name",cell:({row:L})=>{const H=L.original,W=H.key.substring(0,H.key.lastIndexOf("/"))||"/",se=i.trim()!==""&&W!==f,ae=W.split("/").filter(Boolean);return l.jsxs("div",{className:"flex flex-col",children:[l.jsxs("div",{className:`flex items-center gap-2 ${H.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{H.isFolder&&eo(H.key)},children:[H.isFolder?l.jsx(ro,{className:"h-5 w-5 text-blue-500"}):null,H.name]}),se&&l.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[l.jsx(ro,{className:"h-4 w-4 text-gray-500 my-auto"}),l.jsxs("span",{className:"flex items-center ml-1",children:[l.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{eo("")},children:"/"}),ae.map((he,Ct)=>l.jsxs("span",{className:"flex items-center",children:[l.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{eo(ae.slice(0,Ct+1).join("/")+"/")},children:he}),Ct<ae.length-1&&l.jsx("span",{children:"/"})]},Ct))]})]})]})}}];return r||M.push({id:"size",header:"Kích thước",accessorKey:"size",cell:({getValue:L,row:H})=>{const W=L();return l.jsx("span",{children:H.original.isFolder?"-":zg(W)})}},{id:"lastModified",header:"Sửa đổi lần cuối",accessorKey:"lastModified",cell:({row:L})=>{const H=L.original.lastModified;return l.jsx("span",{children:H.toLocaleString()})}},{id:"actions",header:"Hành động",accessorKey:"key",cell:({row:L})=>l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>Sd([L.original.key]),className:"h-8 w-8 p-0",disabled:Ce.has(L.original.key),children:Ce.has(L.original.key)?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):l.jsx(wi,{className:"h-4 w-4"})}),l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>{q(L.original),ee(L.original.name)},className:"h-8 w-8 p-0",children:l.jsx(Rd,{className:"h-4 w-4"})}),l.jsx(le,{variant:"ghost",size:"icon",onClick:()=>C(L.original),className:"h-8 w-8 p-0",children:l.jsx(bi,{className:"h-4 w-4"})})]})}),M},[u,gt,Un,Ce,r]),mi=Mi({data:gt,columns:Nd,state:{rowSelection:Un},enableRowSelection:!0,onRowSelectionChange:to,getCoreRowModel:Di()}),$x=async M=>{var L,H;Ne(!0);try{if(kn(M)){const W=await ie.get(`${t}/api/read-text`,{params:{path:M.key}});We(W.data.content)}try{const W=await ie.get(`${t}/api/read-json`,{params:{path:M.key+".metadata.json"}});return console.log("🚀 ~ loadFileContent ~ responseMetadata:",W),J(((H=(L=W==null?void 0:W.data)==null?void 0:L.content)==null?void 0:H.metadataAttributes)||null)}catch{return J("Lỗi phân tích siêu dữ liệu")}}catch(W){console.error("Error loading file content:",W),R({title:"Lỗi",description:"Không thể tải nội dung tập tin",variant:"destructive"})}finally{Ne(!1)}},kx=async(M,L)=>{$e(!0);try{await ie.post(`${t}/api/modify-text`,{path:M.key,content:L}),R({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),De.current=!0,await ke(),q(null),We(""),tt("rename")}catch(H){console.error("Error saving file content:",H),R({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{$e(!1)}},Lx=async M=>{$e(!0);try{console.log("🚀 ~ saveJsonFile ~ metadataForEdit:",U),await ie.post(`${t}/api/modify-json`,{path:M.key+".metadata.json",content:{metadataAttributes:U}}),R({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),De.current=!0,await ke(),q(null),We(""),tt("rename")}catch(L){console.error("Error saving file content:",L),R({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{$e(!1)}};D.useEffect(()=>{I&&(I.isFolder||$x(I),tt("rename"))},[I]);const Rx=async(M,L)=>{var H;if(te){R({title:"Đang thu thập website",description:"Vui lòng đợi cho công việc thu thập hiện tại hoàn thành.",variant:"destructive"});return}N(!0);try{const{data:W}=await ie.post(`${t}/api/crawl`,{url:M,limit:L,prefix:f});if(W.id){pt({id:W.id,url:M,limit:L,prefix:f,taskId:((H=W.task)==null?void 0:H.id)||""});const se=localStorage.getItem(td),ae=se?JSON.parse(se):[];ae.some(he=>he.id===W.id)||(ae.unshift({url:M,id:W.id,limit:L,prefix:f,timestamp:Date.now()}),ae.length>20&&(ae.length=20),localStorage.setItem(td,JSON.stringify(ae))),R({title:"Bắt đầu thu thập website",description:`Đã thêm nhiệm vụ thu thập ${M} với giới hạn ${L}. Dữ liệu sẽ có sẵn sau khi thu thập hoàn tất.`}),Ge(!1),mn(""),vn("1")}}catch(W){console.error("Error crawling website:",W),R({title:"Lỗi",description:"Không thể bắt đầu thu thập website",variant:"destructive"})}finally{N(!1)}},Vx=async()=>{try{if(!(te!=null&&te.id))return;pt(null),localStorage.removeItem(pn),R({title:"Đã dừng thu thập",description:`Đã dừng thu thập website ${te.url}`})}catch(M){console.error("Error stopping job:",M),R({title:"Lỗi",description:"Không thể dừng thu thập website",variant:"destructive"})}};return l.jsxs("div",{className:"space-y-4 s3-explr-container",children:[l.jsx(Oa,{className:"s3-explr-breadcrumb",children:l.jsxs(Da,{className:"s3-explr-breadcrumb-list",children:[l.jsx(zo,{className:"s3-explr-breadcrumb-item",children:l.jsx(Ho,{onClick:()=>{p(""),g(""),De.current=!0,setTimeout(()=>{ke()},0)},className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:e})}),Ed.map((M,L)=>l.jsxs(l.Fragment,{children:[l.jsx(Ma,{className:"s3-explr-breadcrumb-separator"},`sep-${L}`),l.jsx(zo,{className:"s3-explr-breadcrumb-item",children:l.jsx(Ho,{onClick:()=>eo(n+Ed.slice(0,L+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:M})},`item-${M}`)]}))]})}),l.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[l.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:l.jsx(Qb,{ref:k,onChange:M=>a(M)})}),l.jsxs(le,{variant:"outline",size:"sm",onClick:()=>{p(f),De.current=!0,ke()},disabled:qt,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[l.jsx(_d,{className:`h-4 w-4 s3-explr-refresh-icon ${qt?"animate-spin":""}`}),"Làm mới"]}),!r&&l.jsxs(l.Fragment,{children:[u.size>0&&l.jsxs(l.Fragment,{children:[l.jsxs(le,{variant:"outline",size:"sm",onClick:()=>Sd(Array.from(u)),disabled:Array.from(u).some(M=>Ce.has(M)),className:"flex items-center gap-2 s3-explr-download-selected-btn",children:[Array.from(u).some(M=>Ce.has(M))?l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}):l.jsx(wi,{className:"h-4 w-4 s3-explr-download-icon"}),"Tải xuống đã chọn (",u.size,")"]}),l.jsxs(Ut,{open:O,onOpenChange:$,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[l.jsx(bi,{className:"h-4 w-4 s3-explr-trash-icon"}),"Xóa đã chọn (",u.size,")"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Xác nhận xóa hàng loạt"}),l.jsxs(yr,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",u.size," mục đã chọn? Hành động này không thể hoàn tác."]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>$(!1),className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{variant:"destructive",onClick:Dx,disabled:P,className:"s3-explr-confirm-delete-btn",children:P?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa đã chọn"})]})]})]})]}),l.jsxs(Ut,{open:v,onOpenChange:h,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-new-folder-btn",disabled:!!s&&!f,children:[l.jsx(Md,{className:"h-4 w-4 s3-explr-folder-plus-icon"}),"Thư mục mới"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsx(Ot,{className:"s3-explr-dialog-header",children:l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Tạo thư mục mới"})}),l.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"name",className:"s3-explr-label",children:"Tên thư mục"}),l.jsx(Mt,{disabled:b,id:"name",value:y,onChange:M=>w(M.target.value),placeholder:"Nhập tên thư mục",className:"s3-explr-input"})]}),l.jsxs(le,{onClick:()=>{y.trim()&&Fx(y,f)},disabled:b,className:"s3-explr-create-btn",children:[b&&l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),b?"Đang tạo...":"Tạo"]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[l.jsx(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-files-btn",onClick:()=>{const M=document.createElement("input");M.type="file",M.multiple=!0,M.onchange=L=>{const H=L.target.files;H&&Cd(H,f,"files")},M.click()},disabled:F!==null||!!s&&!f,children:F==="files"?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Đang tải lên..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Od,{className:"h-4 w-4 s3-explr-upload-icon"}),"Tải lên tập tin"]})}),l.jsx(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-folder-btn",onClick:()=>{const M=document.createElement("input");M.type="file",M.multiple=!0,M.webkitdirectory=!0,M.onchange=L=>{const H=L.target.files;H&&Cd(H,f,"folder")},M.click()},disabled:F!==null||!!s&&!f,children:F==="folder"?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Đang tải lên..."]}):l.jsxs(l.Fragment,{children:[l.jsx(ro,{className:"h-4 w-4 s3-explr-folder-icon"}),"Tải lên thư mục"]})}),te?l.jsx(Vu,{delayDuration:0,children:l.jsxs(Bu,{children:[l.jsx(zu,{asChild:!0,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!0,children:[l.jsx(ve,{className:"h-4 w-4 animate-spin s3-explr-loader"}),te.status?l.jsxs(l.Fragment,{children:["Đang thu thập (",te.status.completed,"/",te.status.total,") - ",Math.floor(pe/60),":",String(pe%60).padStart(2,"0")]}):"Đang thu thập..."]}),l.jsxs(le,{variant:"destructive",size:"sm",onClick:()=>void Vx(),className:"flex items-center gap-2",children:[l.jsx("span",{className:"sr-only",children:"Dừng thu thập"}),l.jsx(Bd,{className:"h-4 w-4"})]})]})}),te.status&&l.jsx(Qs,{side:"right",sideOffset:5,children:l.jsxs("div",{className:"space-y-1 p-2",children:[l.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",te.url]}),l.jsxs("p",{children:["Tiến độ: ",te.status.completed,"/",te.status.total," trang"]}),l.jsxs("p",{children:["Thời gian: ",Math.floor(pe/60),":",String(pe%60).padStart(2,"0")]}),l.jsxs("p",{children:["Trạng thái:"," ",te.status.status==="scraping"?"Đang thu thập":te.status.status==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}):l.jsxs(Ut,{open:hn,onOpenChange:Ge,children:[l.jsx(vr,{asChild:!0,children:l.jsxs(le,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!f,children:[l.jsx(kd,{className:"h-4 w-4 s3-explr-globe-icon"}),"Thêm website"]})}),l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Thêm website"}),l.jsx(yr,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),l.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),l.jsx(Mt,{id:"websiteUrl",value:ft,onChange:M=>mn(M.target.value),placeholder:"https://example.com",type:"url",disabled:x,className:"s3-explr-input"})]}),l.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),l.jsx(Mt,{id:"crawlLimit",value:Hn,onChange:M=>{const L=M.target.value;/^\d*$/.test(L)&&vn(L)},placeholder:"1",type:"text",disabled:x,className:"s3-explr-input"}),l.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>{Ge(!1),mn(""),vn("1")},disabled:x,className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{onClick:()=>{ft.trim()&&Rx(ft.trim(),parseInt(Hn)||1)},disabled:x||!ft.trim(),className:"s3-explr-crawl-btn",children:x?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]})]}),l.jsx(Ut,{open:!!E,onOpenChange:M=>!M&&C(null),children:l.jsxs(Ft,{className:"s3-explr-dialog-content",children:[l.jsxs(Ot,{className:"s3-explr-dialog-header",children:[l.jsx(Dt,{className:"s3-explr-dialog-title",children:"Xác nhận xóa"}),l.jsxs(yr,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",E==null?void 0:E.name,"? Hành động này không thể hoàn tác."]})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>C(null),className:"s3-explr-cancel-btn",children:"Hủy"}),l.jsx(le,{variant:"destructive",onClick:()=>Ox(E),disabled:B,className:"s3-explr-confirm-delete-btn",children:B?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),l.jsx(Ut,{open:!!I,onOpenChange:M=>{M||(q(null),J(null),ee(""),We(""),tt("rename"))},children:l.jsxs(Ft,{className:"s3-explr-dialog-content max-w-5xl w-[90%]",children:[l.jsx(Ot,{className:"s3-explr-dialog-header",children:l.jsx(Dt,{className:"s3-explr-dialog-title",children:I!=null&&I.isFolder?"Đổi tên thư mục":kn(I)?"Quản lý tập tin":"Đổi tên tập tin"})}),I&&!I.isFolder&&l.jsxs(hv,{value:Rt,onValueChange:M=>tt(M),children:[l.jsxs(vc,{"aria-checked":!kn(I),className:"grid w-full grid-cols-3 aria-checked:grid-cols-2",children:[l.jsx(Nr,{value:"rename",children:"Đổi tên"}),kn(I)&&l.jsx(Nr,{value:"edit",children:"Sửa nội dung"}),l.jsx(Nr,{value:"edit-metadata",children:"Sửa metadata file"})]}),l.jsx(Tr,{value:"rename",children:l.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:l.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1 s3-explr-input-group",children:[l.jsx(jt,{htmlFor:"newName",className:"s3-explr-label",children:"Tên mới"}),l.jsx(Mt,{id:"newName",value:K,onChange:M=>ee(M.target.value),placeholder:"Nhập tên mới",disabled:ce,className:"s3-explr-input"})]})})}),kn(I)&&l.jsx(Tr,{value:"edit",children:l.jsx("div",{className:"space-y-4 py-4",children:we?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(ve,{className:"h-6 w-6 animate-spin"})}):l.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1",children:[l.jsx(jt,{htmlFor:"content",className:"s3-explr-label",children:"Nội dung tập tin"}),l.jsx(Pn,{id:"content",value:je,onChange:M=>We(M.target.value),placeholder:"Nhập nội dung tập tin",className:"min-h-[200px] font-mono",disabled:Te})]})})}),l.jsx(Tr,{value:"edit-metadata",children:l.jsx("div",{className:"space-y-4 py-4",children:we?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(ve,{className:"h-6 w-6 animate-spin"})}):l.jsx("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1",children:U&&typeof U=="object"&&Object.entries(U).map(([M,L])=>l.jsxs("div",{className:"pb-3 flex flex-col gap-2",children:[l.jsxs(jt,{htmlFor:M,className:"s3-explr-label flex items-center gap-1",children:[rg[M]||M,ko(M)&&l.jsx(tg,{className:"h-[12px] w-[12px] text-red-500"})]}),og(M)?l.jsx(Pn,{id:M,value:typeof L=="string"?L:JSON.stringify(L),onChange:H=>{const W={...U,[M]:H.target.value};J(W)},placeholder:"Nhập nội dung tập tin",className:"min-h-[200px] font-mono",disabled:Te||ko(M)}):l.jsx(Mt,{id:M,value:typeof L=="string"?L:JSON.stringify(L),onChange:H=>{const W={...U,[M]:H.target.value};J(W)},placeholder:"Nhập nội dung",className:"s3-explr-input",disabled:Te||ko(M)})]},M))})})})]}),l.jsxs(Tn,{className:"s3-explr-dialog-footer",children:[l.jsx(le,{variant:"outline",onClick:()=>{q(null),J(null),ee(""),We("")},className:"s3-explr-cancel-btn",children:"Hủy"}),Rt==="edit"?l.jsx(le,{onClick:()=>I&&kx(I,je),disabled:Te||we,className:"s3-explr-save-btn",children:Te?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):Rt==="edit-metadata"?l.jsx(le,{onClick:()=>U&&typeof U=="object"&&I&&Lx(I),disabled:Te||we,className:"s3-explr-save-btn",children:Te?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):l.jsx(le,{onClick:()=>{K.trim()&&I&&Mx(I,K.trim())},disabled:ce||!K.trim()||K.trim()===(I==null?void 0:I.name),className:"s3-explr-rename-btn",children:ce?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang đổi tên..."]}):"Đổi tên"})]})]})})]})]}),hi&&l.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative s3-explr-error",children:"Đã xảy ra lỗi khi tải danh sách tập tin"}),l.jsx("div",{className:"rounded-md border s3-explr-table-container",children:l.jsxs(wr,{className:"s3-explr-table",children:[l.jsx(br,{className:"s3-explr-table-header",children:mi.getHeaderGroups().map(M=>l.jsx(Ye,{className:"hover:bg-transparent s3-explr-header-row",children:M.headers.map(L=>l.jsx(st,{className:"s3-explr-header-cell",children:L.isPlaceholder?null:Xn(L.column.columnDef.header,L.getContext())},L.id))},M.id))}),l.jsx(xr,{className:"s3-explr-table-body",children:mi.getRowModel().rows.length===0?l.jsx(Ye,{className:"s3-explr-empty-row",children:l.jsx(Oe,{colSpan:Nd.length,className:"h-24 text-center s3-explr-empty-cell",children:i?l.jsxs("div",{className:"text-gray-500 s3-explr-no-results",children:['Không tìm thấy tập tin hoặc thư mục nào khớp với "',i,'"']}):l.jsx("div",{className:"text-gray-500 s3-explr-empty-message",children:qt?"Đang tải nội dung thư mục... Vui lòng đợi":"Thư mục này không chứa tập tin hoặc thư mục con nào"})})}):mi.getRowModel().rows.map(M=>l.jsx(Ye,{className:"h-12 s3-explr-row",children:M.getVisibleCells().map(L=>l.jsx(Oe,{className:"align-middle s3-explr-cell",children:Xn(L.column.columnDef.cell,L.getContext())},L.id))},M.id))})]})}),r&&o&&l.jsxs("div",{className:"flex justify-between items-center mt-4 s3-explr-selector-footer",children:[l.jsxs("div",{className:"text-sm text-gray-500 s3-explr-selection-count",children:[u.size," ",(u.size===1,"tập tin")," đã chọn"]}),l.jsx(le,{variant:"default",onClick:()=>o(Ix()),disabled:u.size===0,className:"s3-explr-ok-btn",children:"OK"})]}),!r&&l.jsx(jc,{})]})});var Ln=e=>e.type==="checkbox",Gt=e=>e instanceof Date,Ae=e=>e==null;const nd=e=>typeof e=="object";var me=e=>!Ae(e)&&!Array.isArray(e)&&nd(e)&&!Gt(e),sx=e=>me(e)&&e.target?Ln(e.target)?e.target.checked:e.target.value:e,ix=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ax=(e,t)=>e.has(ix(t)),lx=e=>{const t=e.constructor&&e.constructor.prototype;return me(t)&&t.hasOwnProperty("isPrototypeOf")},ti=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Ue(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(ti&&(e instanceof Blob||r))&&(n||me(e)))if(t=n?[]:{},!n&&!lx(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=Ue(e[o]));else return e;return t}var qr=e=>Array.isArray(e)?e.filter(Boolean):[],ge=e=>e===void 0,j=(e,t,n)=>{if(!t||!me(e))return n;const r=qr(t.split(/[,[\].]+?/)).reduce((o,s)=>Ae(o)?o:o[s],e);return ge(r)||r===e?ge(e[t])?n:e[t]:r},ct=e=>typeof e=="boolean",ni=e=>/^\w*$/.test(e),rd=e=>qr(e.replace(/["|']|\]/g,"").split(/\.|\[/)),de=(e,t,n)=>{let r=-1;const o=ni(t)?[t]:rd(t),s=o.length,i=s-1;for(;++r<s;){const a=o[r];let u=n;if(r!==i){const c=e[a];u=me(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=u,e=e[a]}return e};const od={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},et={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},bt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};D.createContext(null);var cx=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==et.all&&(t._proxyFormState[i]=!r||et.all),e[i]}});return o},Me=e=>me(e)&&!Object.keys(e).length,ux=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Me(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===et.all)},Kr=e=>Array.isArray(e)?e:[e];function dx(e){const t=D.useRef(e);t.current=e,D.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var ut=e=>typeof e=="string",fx=(e,t,n,r,o)=>ut(e)?(r&&t.watch.add(e),j(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),j(n,s))):(r&&(t.watchAll=!0),n),px=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},sd=e=>({isOnSubmit:!e||e===et.onSubmit,isOnBlur:e===et.onBlur,isOnChange:e===et.onChange,isOnAll:e===et.all,isOnTouch:e===et.onTouched}),id=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Rn=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=j(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(Rn(a,t))break}else if(me(a)&&Rn(a,t))break}}};var gx=(e,t,n)=>{const r=Kr(j(e,n));return de(r,"root",t[n]),de(e,n,r),e},ri=e=>e.type==="file",dt=e=>typeof e=="function",Xr=e=>{if(!ti)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Jr=e=>ut(e),oi=e=>e.type==="radio",Yr=e=>e instanceof RegExp;const ad={value:!1,isValid:!1},ld={value:!0,isValid:!0};var cd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ge(e[0].attributes.value)?ge(e[0].value)||e[0].value===""?ld:{value:e[0].value,isValid:!0}:ld:ad}return ad};const ud={isValid:!1,value:null};var dd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ud):ud;function fd(e,t,n="validate"){if(Jr(e)||Array.isArray(e)&&e.every(Jr)||ct(e)&&!e)return{type:n,message:Jr(e)?e:"",ref:t}}var gn=e=>me(e)&&!Yr(e)?e:{value:e,message:""},pd=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:u,minLength:c,min:f,max:g,pattern:m,validate:p,name:v,valueAsNumber:h,mount:y,disabled:w}=e._f,b=j(t,v);if(!y||w)return{};const S=i?i[0]:s,E=k=>{r&&S.reportValidity&&(S.setCustomValidity(ct(k)?"":k||""),S.reportValidity())},C={},P=oi(s),_=Ln(s),O=P||_,$=(h||ri(s))&&ge(s.value)&&ge(b)||Xr(s)&&s.value===""||b===""||Array.isArray(b)&&!b.length,F=px.bind(null,v,n,C),G=(k,R,I,q=bt.maxLength,U=bt.minLength)=>{const J=k?R:I;C[v]={type:k?q:U,message:J,ref:s,...F(k?q:U,J)}};if(o?!Array.isArray(b)||!b.length:a&&(!O&&($||Ae(b))||ct(b)&&!b||_&&!cd(i).isValid||P&&!dd(i).isValid)){const{value:k,message:R}=Jr(a)?{value:!!a,message:a}:gn(a);if(k&&(C[v]={type:bt.required,message:R,ref:S,...F(bt.required,R)},!n))return E(R),C}if(!$&&(!Ae(f)||!Ae(g))){let k,R;const I=gn(g),q=gn(f);if(!Ae(b)&&!isNaN(b)){const U=s.valueAsNumber||b&&+b;Ae(I.value)||(k=U>I.value),Ae(q.value)||(R=U<q.value)}else{const U=s.valueAsDate||new Date(b),J=ce=>new Date(new Date().toDateString()+" "+ce),K=s.type=="time",ee=s.type=="week";ut(I.value)&&b&&(k=K?J(b)>J(I.value):ee?b>I.value:U>new Date(I.value)),ut(q.value)&&b&&(R=K?J(b)<J(q.value):ee?b<q.value:U<new Date(q.value))}if((k||R)&&(G(!!k,I.message,q.message,bt.max,bt.min),!n))return E(C[v].message),C}if((u||c)&&!$&&(ut(b)||o&&Array.isArray(b))){const k=gn(u),R=gn(c),I=!Ae(k.value)&&b.length>+k.value,q=!Ae(R.value)&&b.length<+R.value;if((I||q)&&(G(I,k.message,R.message),!n))return E(C[v].message),C}if(m&&!$&&ut(b)){const{value:k,message:R}=gn(m);if(Yr(k)&&!b.match(k)&&(C[v]={type:bt.pattern,message:R,ref:s,...F(bt.pattern,R)},!n))return E(R),C}if(p){if(dt(p)){const k=await p(b,t),R=fd(k,S);if(R&&(C[v]={...R,...F(bt.validate,R.message)},!n))return E(R.message),C}else if(me(p)){let k={};for(const R in p){if(!Me(k)&&!n)break;const I=fd(await p[R](b,t),S,R);I&&(k={...I,...F(R,I.message)},E(I.message),n&&(C[v]=k))}if(!Me(k)&&(C[v]={ref:S,...k},!n))return C}}return E(!0),C};function hx(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ge(e)?r++:e[t[r++]];return e}function mx(e){for(const t in e)if(e.hasOwnProperty(t)&&!ge(e[t]))return!1;return!0}function xe(e,t){const n=Array.isArray(t)?t:ni(t)?[t]:rd(t),r=n.length===1?e:hx(e,n),o=n.length-1,s=n[o];return r&&delete r[s],o!==0&&(me(r)&&Me(r)||Array.isArray(r)&&mx(r))&&xe(e,n.slice(0,-1)),e}var si=()=>{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},ii=e=>Ae(e)||!nd(e);function Lt(e,t){if(ii(e)||ii(t))return e===t;if(Gt(e)&&Gt(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(Gt(s)&&Gt(i)||me(s)&&me(i)||Array.isArray(s)&&Array.isArray(i)?!Lt(s,i):s!==i)return!1}}return!0}var gd=e=>e.type==="select-multiple",vx=e=>oi(e)||Ln(e),ai=e=>Xr(e)&&e.isConnected,hd=e=>{for(const t in e)if(dt(e[t]))return!0;return!1};function Zr(e,t={}){const n=Array.isArray(e);if(me(e)||n)for(const r in e)Array.isArray(e[r])||me(e[r])&&!hd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Zr(e[r],t[r])):Ae(e[r])||(t[r]=!0);return t}function md(e,t,n){const r=Array.isArray(e);if(me(e)||r)for(const o in e)Array.isArray(e[o])||me(e[o])&&!hd(e[o])?ge(t)||ii(n[o])?n[o]=Array.isArray(e[o])?Zr(e[o],[]):{...Zr(e[o])}:md(e[o],Ae(t)?{}:t[o],n[o]):n[o]=!Lt(e[o],t[o]);return n}var Vn=(e,t)=>md(e,t,Zr(t)),vd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ge(e)?e:t?e===""?NaN:e&&+e:n&&ut(e)?new Date(e):r?r(e):e;function li(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return ri(t)?t.files:oi(t)?dd(e.refs).value:gd(t)?[...t.selectedOptions].map(({value:n})=>n):Ln(t)?cd(e.refs).value:vd(ge(t.value)?e.ref.value:t.value,e)}var yx=(e,t,n,r)=>{const o={};for(const s of e){const i=j(t,s);i&&de(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Bn=e=>ge(e)?e:Yr(e)?e.source:me(e)?Yr(e.value)?e.value.source:e.value:e;const yd="AsyncFunction";var wx=e=>!!e&&!!e.validate&&!!(dt(e.validate)&&e.validate.constructor.name===yd||me(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===yd)),bx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function wd(e,t,n){const r=j(e,n);if(r||ni(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=j(t,s),a=j(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var xx=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,Cx=(e,t)=>!qr(j(e,t)).length&&xe(e,t);const Sx={mode:et.onSubmit,reValidateMode:et.onChange,shouldFocusError:!0};function Ex(e={}){let t={...Sx,...e},n={submitCount:0,isDirty:!1,isLoading:dt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=me(t.defaultValues)||me(t.values)?Ue(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Ue(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={values:si(),array:si(),state:si()},m=sd(t.mode),p=sd(t.reValidateMode),v=t.criteriaMode===et.all,h=x=>N=>{clearTimeout(c),c=setTimeout(x,N)},y=async x=>{if(!t.disabled&&(f.isValid||x)){const N=t.resolver?Me((await O()).errors):await F(r,!0);N!==n.isValid&&g.state.next({isValid:N})}},w=(x,N)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((x||Array.from(a.mount)).forEach(A=>{A&&(N?de(n.validatingFields,A,N):xe(n.validatingFields,A))}),g.state.next({validatingFields:n.validatingFields,isValidating:!Me(n.validatingFields)}))},b=(x,N=[],A,z,B=!0,V=!0)=>{if(z&&A&&!t.disabled){if(i.action=!0,V&&Array.isArray(j(r,x))){const X=A(j(r,x),z.argA,z.argB);B&&de(r,x,X)}if(V&&Array.isArray(j(n.errors,x))){const X=A(j(n.errors,x),z.argA,z.argB);B&&de(n.errors,x,X),Cx(n.errors,x)}if(f.touchedFields&&V&&Array.isArray(j(n.touchedFields,x))){const X=A(j(n.touchedFields,x),z.argA,z.argB);B&&de(n.touchedFields,x,X)}f.dirtyFields&&(n.dirtyFields=Vn(o,s)),g.state.next({name:x,isDirty:k(x,N),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else de(s,x,N)},S=(x,N)=>{de(n.errors,x,N),g.state.next({errors:n.errors})},E=x=>{n.errors=x,g.state.next({errors:n.errors,isValid:!1})},C=(x,N,A,z)=>{const B=j(r,x);if(B){const V=j(s,x,ge(A)?j(o,x):A);ge(V)||z&&z.defaultChecked||N?de(s,x,N?V:li(B._f)):q(x,V),i.mount&&y()}},P=(x,N,A,z,B)=>{let V=!1,X=!1;const oe={name:x};if(!t.disabled){const te=!!(j(r,x)&&j(r,x)._f&&j(r,x)._f.disabled);if(!A||z){f.isDirty&&(X=n.isDirty,n.isDirty=oe.isDirty=k(),V=X!==oe.isDirty);const pe=te||Lt(j(o,x),N);X=!!(!te&&j(n.dirtyFields,x)),pe||te?xe(n.dirtyFields,x):de(n.dirtyFields,x,!0),oe.dirtyFields=n.dirtyFields,V=V||f.dirtyFields&&X!==!pe}if(A){const pe=j(n.touchedFields,x);pe||(de(n.touchedFields,x,A),oe.touchedFields=n.touchedFields,V=V||f.touchedFields&&pe!==A)}V&&B&&g.state.next(oe)}return V?oe:{}},_=(x,N,A,z)=>{const B=j(n.errors,x),V=f.isValid&&ct(N)&&n.isValid!==N;if(t.delayError&&A?(u=h(()=>S(x,A)),u(t.delayError)):(clearTimeout(c),u=null,A?de(n.errors,x,A):xe(n.errors,x)),(A?!Lt(B,A):B)||!Me(z)||V){const X={...z,...V&&ct(N)?{isValid:N}:{},errors:n.errors,name:x};n={...n,...X},g.state.next(X)}},O=async x=>{w(x,!0);const N=await t.resolver(s,t.context,yx(x||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return w(x),N},$=async x=>{const{errors:N}=await O(x);if(x)for(const A of x){const z=j(N,A);z?de(n.errors,A,z):xe(n.errors,A)}else n.errors=N;return N},F=async(x,N,A={valid:!0})=>{for(const z in x){const B=x[z];if(B){const{_f:V,...X}=B;if(V){const oe=a.array.has(V.name),te=B._f&&wx(B._f);te&&f.validatingFields&&w([z],!0);const pe=await pd(B,s,v,t.shouldUseNativeValidation&&!N,oe);if(te&&f.validatingFields&&w([z]),pe[V.name]&&(A.valid=!1,N))break;!N&&(j(pe,V.name)?oe?gx(n.errors,pe,V.name):de(n.errors,V.name,pe[V.name]):xe(n.errors,V.name))}!Me(X)&&await F(X,N,A)}}return A.valid},G=()=>{for(const x of a.unMount){const N=j(r,x);N&&(N._f.refs?N._f.refs.every(A=>!ai(A)):!ai(N._f.ref))&&we(x)}a.unMount=new Set},k=(x,N)=>!t.disabled&&(x&&N&&de(s,x,N),!Lt(fe(),o)),R=(x,N,A)=>fx(x,a,{...i.mount?s:ge(N)?o:ut(x)?{[x]:N}:N},A,N),I=x=>qr(j(i.mount?s:o,x,t.shouldUnregister?j(o,x,[]):[])),q=(x,N,A={})=>{const z=j(r,x);let B=N;if(z){const V=z._f;V&&(!V.disabled&&de(s,x,vd(N,V)),B=Xr(V.ref)&&Ae(N)?"":N,gd(V.ref)?[...V.ref.options].forEach(X=>X.selected=B.includes(X.value)):V.refs?Ln(V.ref)?V.refs.length>1?V.refs.forEach(X=>(!X.defaultChecked||!X.disabled)&&(X.checked=Array.isArray(B)?!!B.find(oe=>oe===X.value):B===X.value)):V.refs[0]&&(V.refs[0].checked=!!B):V.refs.forEach(X=>X.checked=X.value===B):ri(V.ref)?V.ref.value="":(V.ref.value=B,V.ref.type||g.values.next({name:x,values:{...s}})))}(A.shouldDirty||A.shouldTouch)&&P(x,B,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&ce(x)},U=(x,N,A)=>{for(const z in N){const B=N[z],V=`${x}.${z}`,X=j(r,V);(a.array.has(x)||me(B)||X&&!X._f)&&!Gt(B)?U(V,B,A):q(V,B,A)}},J=(x,N,A={})=>{const z=j(r,x),B=a.array.has(x),V=Ue(N);de(s,x,V),B?(g.array.next({name:x,values:{...s}}),(f.isDirty||f.dirtyFields)&&A.shouldDirty&&g.state.next({name:x,dirtyFields:Vn(o,s),isDirty:k(x,V)})):z&&!z._f&&!Ae(V)?U(x,V,A):q(x,V,A),id(x,a)&&g.state.next({...n}),g.values.next({name:i.mount?x:void 0,values:{...s}})},K=async x=>{i.mount=!0;const N=x.target;let A=N.name,z=!0;const B=j(r,A),V=()=>N.type?li(B._f):sx(x),X=oe=>{z=Number.isNaN(oe)||Gt(oe)&&isNaN(oe.getTime())||Lt(oe,j(s,A,oe))};if(B){let oe,te;const pe=V(),pt=x.type===od.BLUR||x.type===od.FOCUS_OUT,gi=!bx(B._f)&&!t.resolver&&!j(n.errors,A)&&!B._f.deps||xx(pt,j(n.touchedFields,A),n.isSubmitted,p,m),_e=id(A,a,pt);de(s,A,pe),pt?(B._f.onBlur&&B._f.onBlur(x),u&&u(0)):B._f.onChange&&B._f.onChange(x);const qt=P(A,pe,pt,!1),hi=!Me(qt)||_e;if(!pt&&g.values.next({name:A,type:x.type,values:{...s}}),gi)return f.isValid&&(t.mode==="onBlur"?pt&&y():y()),hi&&g.state.next({name:A,..._e?{}:qt});if(!pt&&_e&&g.state.next({...n}),t.resolver){const{errors:ke}=await O([A]);if(X(pe),z){const Qr=wd(n.errors,r,A),gt=wd(ke,r,Qr.name||A);oe=gt.error,A=gt.name,te=Me(ke)}}else w([A],!0),oe=(await pd(B,s,v,t.shouldUseNativeValidation))[A],w([A]),X(pe),z&&(oe?te=!1:f.isValid&&(te=await F(r,!0)));z&&(B._f.deps&&ce(B._f.deps),_(A,te,oe,qt))}},ee=(x,N)=>{if(j(n.errors,N)&&x.focus)return x.focus(),1},ce=async(x,N={})=>{let A,z;const B=Kr(x);if(t.resolver){const V=await $(ge(x)?x:B);A=Me(V),z=x?!B.some(X=>j(V,X)):A}else x?(z=(await Promise.all(B.map(async V=>{const X=j(r,V);return await F(X&&X._f?{[V]:X}:X)}))).every(Boolean),!(!z&&!n.isValid)&&y()):z=A=await F(r);return g.state.next({...!ut(x)||f.isValid&&A!==n.isValid?{}:{name:x},...t.resolver||!x?{isValid:A}:{},errors:n.errors}),N.shouldFocus&&!z&&Rn(r,ee,x?B:a.mount),z},fe=x=>{const N={...i.mount?s:o};return ge(x)?N:ut(x)?j(N,x):x.map(A=>j(N,A))},Ce=(x,N)=>({invalid:!!j((N||n).errors,x),isDirty:!!j((N||n).dirtyFields,x),error:j((N||n).errors,x),isValidating:!!j(n.validatingFields,x),isTouched:!!j((N||n).touchedFields,x)}),Ie=x=>{x&&Kr(x).forEach(N=>xe(n.errors,N)),g.state.next({errors:x?n.errors:{}})},je=(x,N,A)=>{const z=(j(r,x,{_f:{}})._f||{}).ref,B=j(n.errors,x)||{},{ref:V,message:X,type:oe,...te}=B;de(n.errors,x,{...te,...N,ref:z}),g.state.next({name:x,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&z&&z.focus&&z.focus()},We=(x,N)=>dt(x)?g.values.subscribe({next:A=>x(R(void 0,N),A)}):R(x,N,!0),we=(x,N={})=>{for(const A of x?Kr(x):a.mount)a.mount.delete(A),a.array.delete(A),N.keepValue||(xe(r,A),xe(s,A)),!N.keepError&&xe(n.errors,A),!N.keepDirty&&xe(n.dirtyFields,A),!N.keepTouched&&xe(n.touchedFields,A),!N.keepIsValidating&&xe(n.validatingFields,A),!t.shouldUnregister&&!N.keepDefaultValue&&xe(o,A);g.values.next({values:{...s}}),g.state.next({...n,...N.keepDirty?{isDirty:k()}:{}}),!N.keepIsValid&&y()},Ne=({disabled:x,name:N,field:A,fields:z,value:B})=>{if(ct(x)&&i.mount||x){const V=x?void 0:ge(B)?li(A?A._f:j(z,N)._f):B;(x||!x&&!ge(V))&&de(s,N,V),P(N,V,!1,!1,!0)}},Te=(x,N={})=>{let A=j(r,x);const z=ct(N.disabled)||ct(t.disabled);return de(r,x,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:x}},name:x,mount:!0,...N}}),a.mount.add(x),A?Ne({field:A,disabled:ct(N.disabled)?N.disabled:t.disabled,name:x,value:N.value}):C(x,!0,N.value),{...z?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Bn(N.min),max:Bn(N.max),minLength:Bn(N.minLength),maxLength:Bn(N.maxLength),pattern:Bn(N.pattern)}:{},name:x,onChange:K,onBlur:K,ref:B=>{if(B){Te(x,N),A=j(r,x);const V=ge(B.value)&&B.querySelectorAll&&B.querySelectorAll("input,select,textarea")[0]||B,X=vx(V),oe=A._f.refs||[];if(X?oe.find(te=>te===V):V===A._f.ref)return;de(r,x,{_f:{...A._f,...X?{refs:[...oe.filter(ai),V,...Array.isArray(j(o,x))?[{}]:[]],ref:{type:V.type,name:x}}:{ref:V}}}),C(x,!1,void 0,V)}else A=j(r,x,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(ax(a.array,x)&&i.action)&&a.unMount.add(x)}}},$e=()=>t.shouldFocusError&&Rn(r,ee,a.mount),Rt=x=>{ct(x)&&(g.state.next({disabled:x}),Rn(r,(N,A)=>{const z=j(r,A);z&&(N.disabled=z._f.disabled||x,Array.isArray(z._f.refs)&&z._f.refs.forEach(B=>{B.disabled=z._f.disabled||x}))},0,!1))},tt=(x,N)=>async A=>{let z;if(A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist()),t.disabled){N&&await N({...n.errors},A);return}let B=Ue(s);if(g.state.next({isSubmitting:!0}),t.resolver){const{errors:V,values:X}=await O();n.errors=V,B=X}else await F(r);if(xe(n.errors,"root"),Me(n.errors)){g.state.next({errors:{}});try{await x(B,A)}catch(V){z=V}}else N&&await N({...n.errors},A),$e(),setTimeout($e);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Me(n.errors)&&!z,submitCount:n.submitCount+1,errors:n.errors}),z)throw z},hn=(x,N={})=>{j(r,x)&&(ge(N.defaultValue)?J(x,Ue(j(o,x))):(J(x,N.defaultValue),de(o,x,Ue(N.defaultValue))),N.keepTouched||xe(n.touchedFields,x),N.keepDirty||(xe(n.dirtyFields,x),n.isDirty=N.defaultValue?k(x,Ue(j(o,x))):k()),N.keepError||(xe(n.errors,x),f.isValid&&y()),g.state.next({...n}))},Ge=(x,N={})=>{const A=x?Ue(x):o,z=Ue(A),B=Me(x),V=B?o:z;if(N.keepDefaultValues||(o=A),!N.keepValues){if(N.keepDirtyValues){const X=new Set([...a.mount,...Object.keys(Vn(o,s))]);for(const oe of Array.from(X))j(n.dirtyFields,oe)?de(V,oe,j(s,oe)):J(oe,j(V,oe))}else{if(ti&&ge(x))for(const X of a.mount){const oe=j(r,X);if(oe&&oe._f){const te=Array.isArray(oe._f.refs)?oe._f.refs[0]:oe._f.ref;if(Xr(te)){const pe=te.closest("form");if(pe){pe.reset();break}}}}r={}}s=t.shouldUnregister?N.keepDefaultValues?Ue(o):{}:Ue(V),g.array.next({values:{...V}}),g.values.next({values:{...V}})}a={mount:N.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!N.keepIsValid||!!N.keepDirtyValues,i.watch=!!t.shouldUnregister,g.state.next({submitCount:N.keepSubmitCount?n.submitCount:0,isDirty:B?!1:N.keepDirty?n.isDirty:!!(N.keepDefaultValues&&!Lt(x,o)),isSubmitted:N.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:B?{}:N.keepDirtyValues?N.keepDefaultValues&&s?Vn(o,s):n.dirtyFields:N.keepDefaultValues&&x?Vn(o,x):N.keepDirty?n.dirtyFields:{},touchedFields:N.keepTouched?n.touchedFields:{},errors:N.keepErrors?n.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},ft=(x,N)=>Ge(dt(x)?x(s):x,N);return{control:{register:Te,unregister:we,getFieldState:Ce,handleSubmit:tt,setError:je,_executeSchema:O,_getWatch:R,_getDirty:k,_updateValid:y,_removeUnmounted:G,_updateFieldArray:b,_updateDisabledField:Ne,_getFieldArray:I,_reset:Ge,_resetDefaultValues:()=>dt(t.defaultValues)&&t.defaultValues().then(x=>{ft(x,t.resetOptions),g.state.next({isLoading:!1})}),_updateFormState:x=>{n={...n,...x}},_disableForm:Rt,_subjects:g,_proxyFormState:f,_setErrors:E,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(x){i=x},get _defaultValues(){return o},get _names(){return a},set _names(x){a=x},get _formState(){return n},set _formState(x){n=x},get _options(){return t},set _options(x){t={...t,...x}}},trigger:ce,register:Te,handleSubmit:tt,watch:We,setValue:J,getValues:fe,reset:ft,resetField:hn,clearErrors:Ie,unregister:we,setError:je,setFocus:(x,N={})=>{const A=j(r,x),z=A&&A._f;if(z){const B=z.refs?z.refs[0]:z.ref;B.focus&&(B.focus(),N.shouldSelect&&dt(B.select)&&B.select())}},getFieldState:Ce}}function Nx(e={}){const t=D.useRef(),n=D.useRef(),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:dt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ex(e),formState:r});const s=t.current.control;return s._options=e,dx({subject:s._subjects.state,next:i=>{ux(i,s._proxyFormState,s._updateFormState)&&o({...s._formState})}}),D.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),D.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),D.useEffect(()=>{e.values&&!Lt(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),D.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),D.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),D.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),D.useMemo(()=>({...t.current,formState:cx(r,s)}),[r,s])}const bd=({className:e,children:t,content:n,side:r})=>{const[o,s]=D.useState(!1);return l.jsx(Vu,{delayDuration:0,children:l.jsxs(Bu,{open:o,children:[l.jsx(zu,{asChild:!0,children:l.jsx("button",{type:"button",className:Q("cursor-pointer",e),onClick:()=>s(!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onTouchStart:()=>s(!o),onKeyDown:i=>{i.preventDefault(),i.key==="Enter"&&s(!o)},children:t})}),l.jsx(Qs,{side:r,className:n?"":"hidden",children:l.jsx("span",{className:"inline-block",children:n})})]})})},ci=({className:e,...t})=>l.jsx("nav",{role:"navigation","aria-label":"pagination",className:Q("mx-auto flex w-full justify-center",e),...t});ci.displayName="Pagination";const ui=d.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,className:Q("flex flex-row items-center gap-1",e),...t}));ui.displayName="PaginationContent";const xt=d.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,className:Q("",e),...t}));xt.displayName="PaginationItem";const zn=({className:e,isActive:t,size:n="icon",...r})=>l.jsx("a",{"aria-current":t?"page":void 0,className:Q(ka({variant:t?"outline":"ghost",size:n}),e),...r});zn.displayName="PaginationLink";const di=({className:e,...t})=>l.jsxs(zn,{"aria-label":"Go to previous page",size:"default",className:Q("gap-1 pl-2.5",e),...t,children:[l.jsx(Zp,{className:"h-4 w-4"}),l.jsx("span",{children:"Previous"})]});di.displayName="PaginationPrevious";const fi=({className:e,...t})=>l.jsxs(zn,{"aria-label":"Go to next page",size:"default",className:Q("gap-1 pr-2.5",e),...t,children:[l.jsx("span",{children:"Next"}),l.jsx(wa,{className:"h-4 w-4"})]});fi.displayName="PaginationNext";const pi=({className:e,...t})=>l.jsxs("span",{"aria-hidden":!0,className:Q("flex h-9 w-9 items-center justify-center",e),...t,children:[l.jsx(Qp,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"More pages"})]});pi.displayName="PaginationEllipsis";const Tx=(e,t)=>{const[n,r]=D.useState(e);return D.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n},Px=({apiBaseUrl:e="http://localhost:3002"})=>{var P,_;const[t,n]=D.useState([]),[r,o]=D.useState(!1),[s,i]=D.useState([]),[a,u]=D.useState(1),[c,f]=D.useState(1),[g,m]=D.useState(null),[p,v]=D.useState(""),h=Tx(p,500),y=O=>{const $=O.match(/\d{6}/);if(!$)return{month:"",year:""};const F=$[0],G=F.substring(0,2),k=F.substring(2);return{month:G,year:k}},w=O=>O.map(F=>{let G=(F==null?void 0:F.month)||"",k=(F==null?void 0:F.year)||"";if((!G||!k)&&(F!=null&&F.file_name)){const R=y(F.file_name);G=G||R.month,k=k||R.year}return{id:F==null?void 0:F.id,prefix:(F==null?void 0:F.prefix)||"",model:(F==null?void 0:F.model)||"",fileName:(F==null?void 0:F.file_name)||"",code:(F==null?void 0:F.stock_id)||"",month:G,year:k,content:(F==null?void 0:F.text_summary)||"",status:(F==null?void 0:F.status)||"",note:(F==null?void 0:F.note)||"",lastUpdate:F==null?void 0:F.updated_at,stock_id:F==null?void 0:F.stock_id}}),b=O=>{if(!(O!=null&&O.data))return[];const $=w(O==null?void 0:O.data);n($),f(O.pagination.totalPages)},S=async(O=1,$=15)=>{m(O),o(!0);try{const F=await ie.get(`${e}/api/latest-summaries`,{params:{page:O,limit:$,search:p}});(F==null?void 0:F.status)===200?b(F.data):console.error(F)}catch(F){console.error("Error fetching data:",F)}finally{m(null),o(!1)}};D.useEffect(()=>{h&&u(1),S(a)},[a,h]);const E=D.useMemo(()=>[{id:"code",header:"Mã",accessorKey:"code",cell:({row:$})=>l.jsx("span",{className:"flex flex-col",children:$.original.code})},{id:"month",header:"Tháng",accessorKey:"month",cell:({row:$})=>{const F=$.original.month,G=$.original.year;return l.jsx("span",{className:"flex flex-col",children:`${F.toString().padStart(2,"0")}/${G}`})}},{id:"content",header:"Nội dung",accessorKey:"content",cell:({row:$})=>{const F=$.getValue("content");return l.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]",children:F})}},{id:"status",header:"Trạng thái",accessorKey:"status",cell:({row:$})=>{const G=$.original.status!=="unpublish";return l.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0 text-[10px] font-bold ${G?"bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20":"bg-gray-50 text-gray-600 ring-1 ring-inset ring-gray-500/20"}`,children:G?"PUBLISHED":"UNPUBLISHED"})}},{id:"note",header:"Ghi chú",accessorKey:"note",cell:({row:$})=>l.jsx(bd,{content:l.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:$.original.note}),children:l.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[20dvw]",children:$.original.note})})},{id:"last-update",header:"Cập nhật",accessorKey:"last-update",cell:({row:$})=>{const F=new Date($.original.lastUpdate),G=F.getDate(),k=F.getMonth()+1,R=`ngày ${G} tháng ${k}`;return l.jsx("span",{className:"flex flex-col",children:R})}},{accessorKey:"actions",header:()=>l.jsx("div",{className:"font-medium text-right",children:"Hành động"}),cell:({row:$})=>{const[F,G]=D.useState(!1),[k,R]=D.useState(!1),[I,q]=D.useState(!1),{handleSubmit:U,register:J,reset:K}=Nx(),ee=$.original.id,ce=$.getValue("status"),fe=$.getValue("content"),[Ce,Ie]=D.useState(!1),je=async()=>{try{Ie(!0);const we=ce==="unpublish"?"published":"unpublish",Ne=await ie.patch(`${e}/api/toggle-publish/${ee}`,{id:ee,typeAction:"update",status:ce,idInput:ee,stock_id:$.original.stock_id,prefix:$.original.prefix,model:$.original.model,summary_result:$.original.content,note:$.original.note});Ne.status===200?n(Te=>Te.map($e=>$e.id===ee?{...$e,status:we}:$e)):console.error("Failed to toggle publish status:",Ne)}catch(we){console.error("Error toggling publish status:",we)}finally{Ie(!1)}},We=async we=>{G(!0);try{const Ne=await ie.patch(`${e}/api/update-summary`,{note:we.note,text_summary:we.content,id:ee});Ne.status===200?(await S(a),R(!1)):console.error("Failed to update summary:",Ne)}catch(Ne){console.error("Error updating summary:",Ne)}return G(!1)};return l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsx(le,{variant:"outline",size:"sm",onClick:()=>q(!0),className:"px-2 py-0.5 h-7",children:l.jsx(eg,{className:"h-4 w-4"})}),l.jsx(Ut,{open:I,onOpenChange:q,children:l.jsxs(Ft,{className:"max-w-3xl max-h-[80vh]",children:[l.jsx(Ot,{children:l.jsx(Dt,{children:"Nội dung chi tiết"})}),l.jsx("div",{className:"mt-4 overflow-y-auto max-h-[60vh]",children:l.jsx("div",{className:"whitespace-pre-wrap text-[16px] leading-relaxed",children:fe})})]})}),l.jsxs(Ut,{open:k,onOpenChange:we=>{R(we),we?K({content:$.original.content,note:$.original.note}):K()},children:[l.jsx(vr,{asChild:!0,children:l.jsx(le,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"px-2 py-0.5 h-7",children:"Sửa"})}),l.jsx(Ft,{className:"rounded-lg sm:px-3 h-[calc(100dvh-200px)] min-w-[calc(100dvw-112px)]",children:l.jsxs(Ot,{className:"flex flex-col gap-3",children:[l.jsx(Dt,{className:"max-sm:hidden text-center",children:"Sửa summary"}),l.jsxs("form",{className:"flex flex-col gap-3 h-full justify-between",onSubmit:U(We),children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[l.jsx("span",{children:"Nội dung:"}),l.jsx(Pn,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:$.original.answer||"",rows:10,...J("content")})]}),l.jsxs("div",{className:"flex flex-col items-start",children:[l.jsx("span",{children:"Ghi chú:"}),l.jsx(Pn,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:$.original.note||"",rows:1,...J("note")})]})]}),l.jsx("div",{className:"flex justify-end",children:l.jsx(le,{disabled:F,type:"submit",variant:"default",children:F?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):"Ok"})})]})]})})]}),l.jsx(le,{variant:"outline",size:"sm",onClick:je,disabled:Ce,className:"w-[70px] px-2 py-0.5 h-7",children:Ce?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):ce==="unpublish"?"Publish":"Unpublish"})]})}}],[]),C=Mi({data:t,columns:E,state:{columnFilters:s},enableRowSelection:!0,onColumnFiltersChange:i,getFilteredRowModel:bf(),getCoreRowModel:Di()});return l.jsxs("div",{className:"space-y-4 s3-explr-container",children:[l.jsx("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:l.jsxs("div",{className:"relative max-w-sm",children:[l.jsx(Mt,{placeholder:"Tìm kiếm theo mã...",value:p,onChange:O=>v(O.target.value),className:"pr-8"}),p&&l.jsx(le,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6 p-0",onClick:()=>v(""),children:l.jsx($o,{className:"h-4 w-4"})})]})}),l.jsx("div",{className:"rounded-md border s3-explr-table-container",children:l.jsxs(wr,{className:"s3-explr-table",children:[l.jsx(br,{className:"s3-explr-table-header",children:C.getHeaderGroups().map(O=>l.jsx(Ye,{className:"hover:bg-transparent s3-explr-header-row",children:O.headers.map($=>l.jsx(st,{className:"s3-explr-header-cell",children:$.isPlaceholder?null:Xn($.column.columnDef.header,$.getContext())},$.id))},O.id))}),l.jsx(xr,{className:"s3-explr-table-body",children:r?l.jsx(Ye,{children:l.jsx(Oe,{colSpan:E.length,className:"h-24 text-center",children:"Đang tải dữ liệu..."})}):(P=C.getRowModel().rows)!=null&&P.length?(_=C.getRowModel().rows)==null?void 0:_.map(O=>l.jsx(Ye,{className:"h-12 s3-explr-row",children:O.getVisibleCells().map($=>l.jsx(Oe,{className:"align-middle s3-explr-cell",children:Xn($.column.columnDef.cell,$.getContext())},$.id))},O.id)):l.jsx(Ye,{children:l.jsx(Oe,{colSpan:E.length,className:"h-24 text-center",children:"Không có kết quả."})})})]})}),l.jsx("div",{className:"mt-4",children:l.jsx(ci,{children:l.jsxs(ui,{children:[l.jsx(xt,{children:l.jsx(di,{onClick:()=>u(O=>Math.max(1,O-1)),className:a===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:c},(O,$)=>$+1).filter(O=>O===1||O===c||Math.abs(O-a)<=1).map((O,$,F)=>l.jsxs(l.Fragment,{children:[$>0&&F[$-1]!==O-1&&l.jsx(xt,{children:l.jsx(pi,{})},O+"..."),l.jsx(xt,{children:l.jsx(zn,{onClick:()=>u(O),isActive:a===O,className:`cursor-pointer ${r?"pointer-events-none":""}`,children:g===O?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):O})},O)]})),l.jsx(xt,{children:l.jsx(fi,{onClick:()=>u(O=>Math.min(c,O+1)),className:a===c||g!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})},xd=10,Ax=D.memo(({apiBaseUrl:e="http://localhost:3002"})=>{const[t,n]=D.useState(1),[r,o]=D.useState([]),[s,i]=D.useState({total:0,page:1,limit:xd,totalPages:1}),[a,u]=D.useState(!0),[c,f]=D.useState(null),[g,m]=D.useState(new Set),{toast:p}=Ds(),[v,h]=D.useState(!1),y=async C=>{try{f(C);const P=await ie.get(`${e}/api/jobs`,{params:{page:C.toString(),limit:xd.toString()}});o(P.data.data),i(P.data.pagination)}catch{p({variant:"destructive",title:"Error",description:"Failed to fetch jobs. Please try again."})}finally{f(null),u(!1)}};D.useEffect(()=>{y(t)},[t,e]);const w=async C=>{m(P=>new Set(P).add(C.toString()));try{await ie.post(`${e}/api/retry-job`,{jobId:C}),p({title:"Job Restarted",description:`Job ${C} has been successfully restarted.`}),y(t)}catch{p({variant:"destructive",title:"Retry Failed",description:`Failed to restart job ${C}. Please try again.`})}finally{m(P=>{const _=new Set(P);return _.delete(C.toString()),_})}},b=async()=>{h(!0),n(1),await y(1),h(!1)},S=C=>new Date(C).toLocaleString(),E=C=>{if(C=parseFloat(C),C<60)return`${C.toFixed(2)}s`;const P=Math.floor(C/60),_=(C%60).toFixed(0);return`${P}m ${_}s`};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[l.jsx(Jp,{className:"w-8 h-8 text-primary"}),l.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Job Management"}),l.jsx(le,{variant:"outline",size:"icon",onClick:b,disabled:v||a,className:"ml-2",children:l.jsx(ng,{className:`h-4 w-4 ${v?"animate-spin":""}`})})]}),l.jsx("div",{className:"rounded-md border",children:l.jsxs(wr,{children:[l.jsx(br,{children:l.jsxs(Ye,{children:[l.jsx(st,{children:"ID"}),l.jsx(st,{children:"Tên Công Việc"}),l.jsx(st,{children:"Thời Gian Bắt Đầu"}),l.jsx(st,{children:"Thời Gian Cập Nhật"}),l.jsx(st,{children:"Thời Gian Thực Thi"}),l.jsx(st,{children:"Trạng Thái"}),l.jsx(st,{children:"Thao Tác"})]})}),l.jsx(xr,{children:a&&r.length===0?l.jsx(Ye,{children:l.jsx(Oe,{colSpan:7,className:"text-center py-4",children:l.jsx(ve,{className:"w-6 h-6 animate-spin mx-auto"})})}):r.map(C=>{var P,_;return l.jsxs(Ye,{children:[l.jsx(Oe,{className:"!w-[100px]",children:C.id}),l.jsx(Oe,{className:"font-medium",children:(P=C.job_name)==null?void 0:P.replace("Upload file","Summary")}),l.jsx(Oe,{className:"!w-[200px]",children:S(C.created_at)}),l.jsx(Oe,{className:"!w-[200px]",children:S(C.updated_at)}),l.jsx(Oe,{className:"!w-[150px]",children:E(C.execution_time_seconds)}),l.jsx(Oe,{className:"!w-[200px]",children:l.jsx(bd,{content:C.status==="fail"&&C.error?l.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:C.error}):null,children:l.jsx("div",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]
|
|
142
142
|
${C.status==="done"?"bg-green-100 text-green-800":C.status==="fail"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:C.status==="fail"?"FAILED":(_=C.status)==null?void 0:_.toUpperCase()})})}),l.jsx(Oe,{className:"!w-[200px]",children:C.status==="fail"?l.jsx(le,{variant:"outline",size:"sm",onClick:()=>w(C.id),disabled:g.has(C.id.toString()),className:"h-[32px]",children:g.has(C.id.toString())?l.jsxs(l.Fragment,{children:[l.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Đang thử lại..."]}):"Thử Lại"}):l.jsx("div",{className:"h-[32px]"})})]},C.id)})})]})}),l.jsx("div",{className:"mt-4",children:l.jsx(ci,{children:l.jsxs(ui,{children:[l.jsx(xt,{children:l.jsx(di,{onClick:()=>n(C=>Math.max(1,C-1)),className:t===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:s.totalPages},(C,P)=>P+1).filter(C=>C===1||C===s.totalPages||Math.abs(C-t)<=1).map((C,P,_)=>l.jsxs(l.Fragment,{children:[P>0&&_[P-1]!==C-1&&l.jsx(xt,{children:l.jsx(pi,{})},C+"..."),l.jsx(xt,{children:l.jsx(zn,{onClick:()=>n(C),isActive:t===C,className:`cursor-pointer ${c!==null?"pointer-events-none":""}`,children:c===C?l.jsx(ve,{className:"h-4 w-4 animate-spin"}):C})},C)]})),l.jsx(xt,{children:l.jsx(fi,{onClick:()=>n(C=>Math.min(s.totalPages,C+1)),className:t===s.totalPages||c!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),l.jsx(jc,{})]})});qe.Job=Ax,qe.S3Explorer=ox,qe.Summary=Px,Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"})});
|
|
143
143
|
//# sourceMappingURL=s3-explorer.umd.cjs.map
|