PageSourceSearch

https://portal.commoninterest.com/assets/documents-DV6yVZnf.js

js commoninterest.com collected 2026-09-24 13:28:14 UTC 46,277 bytes, 1 lines download raw bytes

1import{s as Le,j as t,F as k,E as It,d3 as Dt,d4 as Ft,d5 as Ot,d6 as kt,u as X,T as ft,bU as ne,c as $t,d7 as pt,r as p,t as Ge,d8 as vt,n as le,I as Ke,cy as tt,S as fe,d9 as ht,cX as _t,q as Me,da as At,bn as Ve,cL as Lt,db as Tt,cJ as zt,bJ as Ut,dc as qt,M as Te,B as gt,dd as xt,a2 as Bt,cS as Ht,bg as Vt,de as Yt,cT as Gt,df as Kt,cU as Wt,dg as Xt,aE as Jt,a_ as bt,dh as Zt,at as Qt}from"./elements-DVh2jUIM.js";import{x as ze,K as We,L as ke,$ as Pe,a2 as Xe,aA as Je,G as Ee,X as Se,B as W,a_ as $e,j as me,a$ as Ue,D as wt,o as Ze,p as en,k as tn,P as nn,N as on,R as nt}from"./index-DeQvL4I7.js";import{u as rn}from"./useAuthorization-D7B2eQha.js";import{u as pe}from"./useRedesign-DVyq07A4.js";import{u as qe}from"./useIsMobile-Davbtvz5.js";import{u as ve}from"./useMutation-CfDMVIpo.js";import{u as yt}from"./useModalActions-raurWri4.js";import{M as jt}from"./ModernPortalPage-C8UaH3aE.js";import{A as Be}from"./authorization-CE7gncHO.js";import{u as sn}from"./user-securities-BKbGEnXf.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";function Nt({breadcrumbs:e,associationId:l}){const o=ze(),{width:a}=Le();return t.jsxs("div",{className:"font-semibold tablet:text-lg text-base flex items-center",children:[t.jsx(k,{icon:It,className:"mr-2"}),t.jsx("div",{className:"flex items-center w-full",children:a>We?e.map((i,r)=>t.jsxs("div",{className:"truncate max-w-48 min-w-0",children:[t.jsx(ke,{to:`/community/documents/a/${l}/f/${i.id}`,className:"font-medium mr-1 hover:opacity-70",children:i==null?void 0:i.name},i.id),t.jsx("span",{className:"mr-1",children:r<e.length-1?"/":""})]},i.id)):t.jsxs("div",{className:"flex items-center flex-nowrap",children:[e.length>2&&t.jsx("span",{className:"mr-1 text-nowrap",children:".../"}),t.jsx("div",{className:"truncate max-w-32 mr-1 min-w-0",children:t.jsx(ke,{to:`/community/documents/a/${l}/f/${e.length>2?e[e.length-2].id:e[0].id}`,className:"font-medium hover:opacity-70",children:e.length>1?e[e.length-2].name:e[0].name})}),e.length>1&&t.jsx("span",{children:"/"}),e.length>1&&t.jsx("div",{className:"truncate max-w-32 ml-1 min-w-0",children:t.jsx(ke,{to:`/community/documents/a/${l}/f/${e[e.length-1].id}`,className:"font-medium hover:opacity-70",children:e[e.length-1].name})}),e.length>2&&t.jsx(Dt,{className:"relative",children:({open:i})=>t.jsxs(t.Fragment,{children:[t.jsx(Ft,{className:"w-8 h-8",id:"documents-nav-btn",children:t.jsx(k,{icon:Ot,className:`cursor-pointer text-lg transform transition-transform duration-200 ${i?"rotate-180":"rotate-0"}`})}),t.jsx(kt,{className:"absolute rounded-lg z-50 shadow-lg border-2 border-input-border/50 py-1 bg-white top-8 -right-4",id:"documents-nav-container",children:e.slice(0,-2).map(r=>t.jsx("button",{className:"text-left hover:bg-input-active/25 px-2 w-full h-8 max-w-40 truncate",onClick:()=>o(`/community/documents/a/${l}/f/${r.id}`),id:"document-nav-select",children:r.name},r.id))})]})})]})})]})}function Ct({totalCount:e,onClear:l}){const{t:o}=X();return t.jsxs("div",{className:"flex items-center gap-2",children:[e!=null&&e>0?t.jsx("p",{className:"text-base-fg",children:t.jsx(ft,{i18nKey:e>1?"documents.foundCount_plural":"documents.foundCount",values:{count:e},components:{bold:t.jsx("strong",{})}})}):t.jsx("p",{className:"text-base-fg",children:o("documents.noneFound")}),t.jsx("button",{type:"button",onClick:l,"aria-label":o("documents.clearSearch"),className:"p-1 rounded hover:bg-base-hover focus:outline-none focus:ring-2 focus:ring-primary-focus flex items-center gap-2",children:t.jsx("em",{className:"underline",children:o("documents.clearSearch")})})]})}var be={},we={},ot;function an(){if(ot)return we;ot=1,Object.defineProperty(we,"__esModule",{value:!0}),we.PopoverPortal=void 0;var e=ne(),l=$t(),o=function(a){var i=a.container,r=a.element,m=a.scoutElement,c=a.children;return(0,e.useLayoutEffect)(function(){return i.appendChild(r),i.appendChild(m),function(){i.removeChild(r),i.removeChild(m)}},[i,r,m]),(0,l.createPortal)(c,r)};return we.PopoverPortal=o,we}var ye={},rt;function Qe(){return rt||(rt=1,(function(e){var l=ye&&ye.__assign||function(){return l=Object.assign||function(s){for(var n,w=1,g=arguments.length;w<g;w++){n=arguments[w];for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&(s[d]=n[d])}return s},l.apply(this,arguments)};
1Object.defineProperty(e,"__esModule",{value:!0}),e.getNudgedPopoverRect=e.getNewPopoverRect=e.popoverRectForPosition=e.createContainer=e.rectsAreEqual=e.createRect=e.EMPTY_RECT=void 0,e.EMPTY_RECT={top:0,left:0,right:0,bottom:0,width:0,height:0};var o=function(s){var n=s.top,w=s.left,g=s.width,d=s.height;return{top:n,left:w,width:g,height:d,right:w+g,bottom:n+d}};e.createRect=o;var a=function(s,n){return s===n||(s==null?void 0:s.bottom)===(n==null?void 0:n.bottom)&&(s==null?void 0:s.height)===(n==null?void 0:n.height)&&(s==null?void 0:s.left)===(n==null?void 0:n.left)&&(s==null?void 0:s.right)===(n==null?void 0:n.right)&&(s==null?void 0:s.top)===(n==null?void 0:n.top)&&(s==null?void 0:s.width)===(n==null?void 0:n.width)};e.rectsAreEqual=a;var i=function(s){var n=s.containerStyle,w=s.containerClassName,g=window.document.createElement("div");return w&&(g.className=w),Object.assign(g.style,n),g};e.createContainer=i;var r=function(s,n,w,g,d){var f=n.left+n.width/2,h=n.top+n.height/2,v=w.width,x=w.height,u,N;switch(s){case"left":u=h-x/2,N=n.left-g-v,d==="start"&&(u=n.top),d==="end"&&(u=n.bottom-x);break;case"bottom":u=n.bottom+g,N=f-v/2,d==="start"&&(N=n.left),d==="end"&&(N=n.right-v);break;case"right":u=h-x/2,N=n.right+g,d==="start"&&(u=n.top),d==="end"&&(u=n.bottom-x);break;default:u=n.top-x-g,N=f-v/2,d==="start"&&(N=n.left),d==="end"&&(N=n.right-v);break}return(0,e.createRect)({left:N,top:u,width:v,height:x})};e.popoverRectForPosition=r;var m=function(s,n){var w=s.position,g=s.align,d=s.childRect,f=s.popoverRect,h=s.boundaryRect,v=s.padding,x=s.reposition,u=(0,e.popoverRectForPosition)(w,d,f,v,g),N=x&&(w==="top"&&u.top<h.top+n||w==="left"&&u.left<h.left+n||w==="right"&&u.right>h.right-n||w==="bottom"&&u.bottom>h.bottom-n);return{rect:u,boundaryViolation:N}};e.getNewPopoverRect=m;var c=function(s,n,w){var g=n.top+w,d=n.left+w,f=n.right-w,h=n.bottom-w,v=s.top<g?g:s.top;v=v+s.height>h?h-s.height:v;var x=s.left<d?d:s.left;return x=x+s.width>f?f-s.width:x,(0,e.createRect)(l(l({},s),{top:v,left:x}))};e.getNudgedPopoverRect=c})(ye)),ye}var je={},Ne={},st;function ln(){if(st)return Ne;st=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.useElementRef=void 0;var e=ne(),l=Qe(),o=function(a){var i=a.containerClassName,r=a.containerStyle,m=(0,e.useRef)(),c=(0,e.useState)(function(){return(0,l.createContainer)({containerStyle:r,containerClassName:i})})[0];return(0,e.useLayoutEffect)(function(){c.className=i},[i,c]),(0,e.useLayoutEffect)(function(){Object.assign(c.style,r)},[r,c]),m.current=c,m};return Ne.useElementRef=o,Ne}var it;function cn(){if(it)return je;it=1,Object.defineProperty(je,"__esModule",{value:!0}),je.usePopover=void 0;var e=ne(),l=Qe(),o=ln(),a={position:"fixed",overflow:"visible",top:"0px",left:"0px"},i={position:"fixed",top:"0px",left:"0px",width:"0px",height:"0px",visibility:"hidden"},r=function(m){var c=m.isOpen,s=m.childRef,n=m.positions,w=m.containerClassName,g=m.parentElement,d=m.transform,f=m.transformMode,h=m.align,v=m.padding,x=m.reposition,u=m.boundaryInset,N=m.boundaryElement,F=m.onPositionPopover,O=(0,o.useElementRef)({containerClassName:"react-tiny-popover-scout",containerStyle:i}),S=(0,o.useElementRef)({containerClassName:w!=null&&w.length>0&&w!=="react-tiny-popover-container"?"react-tiny-popover-container ".concat(w):"react-tiny-popover-container",containerStyle:a}),U=(0,e.useCallback)(function(E){var q,I,A=E===void 0?{}:E,H=A.positionIndex,V=H===void 0?0:H,Y=A.parentRect,L=Y===void 0?g.getBoundingClientRect():Y,b=A.childRect,C=b===void 0?(q=s==null?void 0:s.current)===null||q===void 0?void 0:q.getBoundingClientRect():b,R=A.scoutRect,P=R===void 0?(I=O==null?void 0:O.current)===null||I===void 0?void 0:I.getBoundingClientRect():R,z=A.popoverRect,$=z===void 0?S.current.getBoundingClientRect():z,y=A.boundaryRect,D=y===void 0?N===g?L:N.getBoundingClientRect():y;if(!(!C||!L||!c)){if(d&&f==="absolute"){var j=typeof d=="function"?d({childRect:C,popoverRect:$,parentRect:L,boundaryRect:D,padding:v,align:h,nudgedTop:0,nudgedLeft:0,boundaryInset:u,violations:l.EMPTY_RECT,hasViolations:!1}):d,T=j.top,he=j.left,B=Math.round(L.left+he-P.left),ge=Math.round(L.top+T-P.top);S.current.style.transform="translate(".concat(B,"px, ").concat(ge,"px)"),F({childRect:C,popoverRect:(0,l.createRect)({left:B,top:ge,width:$.width,height:$.height}),parentRect:L,boundaryRect:D,padding:v,align:h,transform:{top:T,left:he},nudgedTop:0,nudgedLeft:0,boundaryInset:u,violations:l.EMPTY_RECT,hasViolations:!1});return}var Z=V===n.length,xe=Z?n[0]:n[V],G=(0,l.getNewPopoverRect)({childRect:C,popoverRect:$,boundaryRect:D,position:xe,align:h,padding:v,reposition:x}
1,u),oe=G.rect,He=G.boundaryViolation;if(He&&x&&!Z){U({positionIndex:V+1,childRect:C,popoverRect:$,parentRect:L,boundaryRect:D});return}var ce=oe.top,re=oe.left,J=oe.width,Ie=oe.height,se=x&&!Z,ue=(0,l.getNudgedPopoverRect)(oe,D,u),De=ue.left,Fe=ue.top,ee=ce,M=re;se&&(ee=Fe,M=De),ee=Math.round(ee-P.top),M=Math.round(M-P.left),S.current.style.transform="translate(".concat(M,"px, ").concat(ee,"px)");var _={top:D.top+u-ee,left:D.left+u-M,right:M+J-D.right+u,bottom:ee+Ie-D.bottom+u},K={childRect:C,popoverRect:(0,l.createRect)({left:M,top:ee,width:J,height:Ie}),parentRect:L,boundaryRect:D,position:xe,align:h,padding:v,nudgedTop:Fe-ce,nudgedLeft:De-re,boundaryInset:u,violations:{top:_.top<=0?0:_.top,left:_.left<=0?0:_.left,right:_.right<=0?0:_.right,bottom:_.bottom<=0?0:_.bottom},hasViolations:_.top>0||_.left>0||_.right>0||_.bottom>0};if(d){F(K);var de=typeof d=="function"?d(K):d,te=de.top,Q=de.left;S.current.style.transform="translate(".concat(Math.round(M+(Q??0)),"px, ").concat(Math.round(ee+(te??0)),"px)"),K.nudgedLeft+=Q??0,K.nudgedTop+=te??0,K.transform={top:te,left:Q}}F(K)}},[g,s,O,S,N,c,d,f,n,h,v,x,u,F]);return{positionPopover:U,popoverRef:S,scoutRef:O}};return je.usePopover=r,je}var Ce={},at;function un(){if(at)return Ce;at=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.useMemoizedArray=void 0;var e=ne(),l=function(o){var a=(0,e.useRef)(o),i=(0,e.useMemo)(function(){if(a.current===o)return a.current;if(a.current.length!==o.length)return a.current=o,o;for(var r=0;r<o.length;r+=1)if(o[r]!==a.current[r])return a.current=o,o;return a.current},[o]);return i};return Ce.useMemoizedArray=l,Ce}var Re={},lt;function dn(){if(lt)return Re;lt=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.useHandlePrevValues=void 0;var e=ne(),l=function(o){var a=(0,e.useRef)(o.positions),i=(0,e.useRef)(o.reposition),r=(0,e.useRef)(o.transformMode),m=(0,e.useRef)(o.transform),c=(0,e.useRef)(o.boundaryElement),s=(0,e.useRef)(o.boundaryInset),n=(0,e.useCallback)(function(){a.current=o.positions,i.current=o.reposition,r.current=o.transformMode,m.current=o.transform,c.current=o.boundaryElement,s.current=o.boundaryInset},[o.boundaryElement,o.boundaryInset,o.positions,o.reposition,o.transform,o.transformMode]);return{prev:{positions:a.current,reposition:i.current,transformMode:r.current,transform:m.current,boundaryElement:c.current,boundaryInset:s.current},updatePrevValues:n}};return Re.useHandlePrevValues=l,Re}var ie={},ct;function Rt(){if(ct)return ie;ct=1;var e=ie&&ie.__assign||function(){return e=Object.assign||function(a){for(var i,r=1,m=arguments.length;r<m;r++){i=arguments[r];for(var c in i)Object.prototype.hasOwnProperty.call(i,c)&&(a[c]=i[c])}return a},e.apply(this,arguments)};Object.defineProperty(ie,"__esModule",{value:!0}),ie.useArrowContainer=void 0;var l=ne(),o=function(a){var i=a.childRect,r=a.popoverRect,m=a.position,c=a.arrowSize,s=a.arrowColor,n=(0,l.useMemo)(function(){return{padding:c}},[c]),w=(0,l.useMemo)(function(){return e({position:"absolute"},(function(){var g=c*2,d=i.top-r.top+i.height/2-g/2,f=i.left-r.left+i.width/2-g/2,h=c,v=r.width-c,x=r.height-c;switch(f=f<h?h:f,f=f+g>v?v-g:f,d=d<h?h:d,d=d+g>x?x-g:d,d=Number.isNaN(d)?0:d,f=Number.isNaN(f)?0:f,m){case"right":return{borderTop:"".concat(c,"px solid transparent"),borderBottom:"".concat(c,"px solid transparent"),borderRight:"".concat(c,"px solid ").concat(s),left:0,top:d};case"left":return{borderTop:"".concat(c,"px solid transparent"),borderBottom:"".concat(c,"px solid transparent"),borderLeft:"".concat(c,"px solid ").concat(s),right:0,top:d};case"bottom":return{borderLeft:"".concat(c,"px solid transparent"),borderRight:"".concat(c,"px solid transparent"),borderBottom:"".concat(c,"px solid ").concat(s),top:0,left:f};case"top":return{borderLeft:"".concat(c,"px solid transparent"),borderRight:"".concat(c,"px solid transparent"),borderTop:"".concat(c,"px solid ").concat(s),bottom:0,left:f};default:return{display:"hidden"}}})())},[s,c,i.height,i.left,i.top,i.width,r.height,r.left,r.top,r.width,m]);return{arrowContainerStyle:n,arrowStyle:w}};return ie.useArrowContainer=o,ie}var ae={},ut;function mn(){if(ut)return ae;ut=1;var e=ae&&ae.__assign||function(){return e=Object.assign||function(r){for(var m,c=1,s=arguments.length;c<s;c++){m=arguments[c];for(var n in m)Object.prototype.hasOwnProperty.call(m,n)&&(r[n]=m[n])}return r},e.apply(this,arguments)};
1Object.defineProperty(ae,"__esModule",{value:!0}),ae.ArrowContainer=void 0;var l=pt(),o=ne(),a=Rt(),i=function(r){var m=r.childRect,c=r.popoverRect,s=r.position,n=r.arrowColor,w=r.arrowSize,g=r.arrowClassName,d=r.arrowStyle,f=r.className,h=r.children,v=r.style,x=(0,a.useArrowContainer)({childRect:m,popoverRect:c,position:s,arrowColor:n,arrowSize:w}),u=x.arrowContainerStyle,N=x.arrowStyle,F=(0,o.useMemo)(function(){return e(e({},u),v)},[u,v]),O=(0,o.useMemo)(function(){return e(e({},N),d)},[N,d]);return(0,l.jsxs)("div",{className:f,style:F,children:[(0,l.jsx)("div",{style:O,className:g}),h]})};return ae.ArrowContainer=i,ae}var dt;function fn(){return dt||(dt=1,(function(e){var l=be&&be.__assign||function(){return l=Object.assign||function(f){for(var h,v=1,x=arguments.length;v<x;v++){h=arguments[v];for(var u in h)Object.prototype.hasOwnProperty.call(h,u)&&(f[u]=h[u])}return f},l.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Popover=e.usePopover=e.ArrowContainer=e.useArrowContainer=void 0;var o=pt(),a=ne(),i=an(),r=Qe(),m=cn();Object.defineProperty(e,"usePopover",{enumerable:!0,get:function(){return m.usePopover}});var c=un(),s=dn(),n=Rt();Object.defineProperty(e,"useArrowContainer",{enumerable:!0,get:function(){return n.useArrowContainer}});var w=mn();Object.defineProperty(e,"ArrowContainer",{enumerable:!0,get:function(){return w.ArrowContainer}});var g=["top","left","right","bottom"],d=(0,a.forwardRef)(function(f,h){var v=f.isOpen,x=f.children,u=f.content,N=f.positions,F=N===void 0?g:N,O=f.align,S=O===void 0?"center":O,U=f.padding,E=U===void 0?0:U,q=f.reposition,I=q===void 0?!0:q,A=f.parentElement,H=A===void 0?window.document.body:A,V=f.boundaryElement,Y=V===void 0?H:V,L=f.containerClassName,b=f.containerStyle,C=f.transform,R=f.transformMode,P=R===void 0?"absolute":R,z=f.boundaryInset,$=z===void 0?0:z,y=f.onClickOutside,D=f.clickOutsideCapture,j=D===void 0?!1:D,T=(0,c.useMemoizedArray)(Array.isArray(F)?F:[F]),he=(0,s.useHandlePrevValues)({positions:T,reposition:I,transformMode:P,transform:C,boundaryElement:Y,boundaryInset:$}),B=he.prev,ge=he.updatePrevValues,Z=(0,a.useRef)(),xe=(0,a.useState)({align:S,nudgedLeft:0,nudgedTop:0,position:T[0],padding:E,childRect:r.EMPTY_RECT,popoverRect:r.EMPTY_RECT,parentRect:r.EMPTY_RECT,boundaryRect:r.EMPTY_RECT,boundaryInset:$,violations:r.EMPTY_RECT,hasViolations:!1}),G=xe[0],oe=xe[1],He=(0,a.useCallback)(function(M){return oe(M)},[]),ce=(0,m.usePopover)({isOpen:v,childRef:Z,containerClassName:L,parentElement:H,boundaryElement:Y,transform:C,transformMode:P,positions:T,align:S,padding:E,boundaryInset:$,reposition:I,onPositionPopover:He}),re=ce.positionPopover,J=ce.popoverRef,Ie=ce.scoutRef;(0,a.useLayoutEffect)(function(){var M=!0,_=function(){var K,de;if(v&&M){var te=(K=Z==null?void 0:Z.current)===null||K===void 0?void 0:K.getBoundingClientRect(),Q=(de=J==null?void 0:J.current)===null||de===void 0?void 0:de.getBoundingClientRect();te!=null&&Q!=null&&(!(0,r.rectsAreEqual)(te,G.childRect)||Q.width!==G.popoverRect.width||Q.height!==G.popoverRect.height||G.padding!==E||G.align!==S||T!==B.positions||I!==B.reposition||P!==B.transformMode||C!==B.transform||Y!==B.boundaryElement||$!==B.boundaryInset)&&re(),ge(),M&&window.requestAnimationFrame(_)}};return _(),function(){M=!1}},[S,Y,$,v,E,J,G.align,G.childRect,G.padding,G.popoverRect.height,G.popoverRect.width,re,T,B.boundaryElement,B.boundaryInset,B.positions,B.reposition,B.transform,B.transformMode,I,C,P,ge]),(0,a.useEffect)(function(){var M=J.current;return Object.assign(M.style,b),function(){Object.keys(b??{}).forEach(function(_){return delete M.style[_]})}},[b,v,J]);var se=(0,a.useCallback)(function(M){var _,K;v&&!(!((_=J.current)===null||_===void 0)&&_.contains(M.target))&&!(!((K=Z.current)===null||K===void 0)&&K.contains(M.target))&&(y==null||y(M))},[v,y,J]),ue=(0,a.useCallback)(function(){Z.current&&v&&window.requestAnimationFrame(function(){return re()})},[re,v]);(0,a.useEffect)(function(){var M=H.ownerDocument.body;return M.addEventListener("click",se,j),M.addEventListener("contextmenu",se,j),window.addEventListener("resize",ue),function(){M.removeEventListener("click",
1se,j),M.removeEventListener("contextmenu",se,j),window.removeEventListener("resize",ue)}},[j,se,ue,H]);var De=(0,a.useCallback)(function(M){Z.current=M,h!=null&&(typeof h=="object"?h.current=M:typeof h=="function"&&h(M))},[h]),Fe=function(){return(0,a.cloneElement)(x,{ref:De})},ee=function(){return v?(0,o.jsx)(i.PopoverPortal,{element:J.current,scoutElement:Ie.current,container:H,children:typeof u=="function"?u(G):u}):null};return(0,o.jsxs)(o.Fragment,{children:[Fe(),ee()]})});e.Popover=(0,a.forwardRef)(function(f,h){return typeof window>"u"?f.children:(0,o.jsx)(d,l({},f,{ref:h}))})})(be)),be}var et=fn();function Mt({id:e,document:l}){const{associationId:o}=Pe(),{t:a}=X(),[i,r]=p.useState(!1),m=p.useRef(null);Ge(s=>{i&&s.target!==m.current&&r(!1)});const c=async()=>{if(l.type==="file")navigator.clipboard.writeText(window.location.href);else{const s=`${window.location.origin}/community/documents/a/${o}/f/${l.id}`;navigator.clipboard.writeText(s)}le({message:"URL copied to clipboard.",type:"success"})};return t.jsx(et.Popover,{isOpen:i,reposition:!1,content:()=>t.jsx("p",{className:"absolute bg-input-bg shadow-lg -left-12 focus:outline-none bottom-0 w-24 rounded-md text-center py-2",children:a("documents.copyLink")}),children:t.jsx("button",{ref:m,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onClick:c,id:`copy-link-btn-${e}`,"aria-label":a("documents.copyLinkAriaLabel"),children:t.jsx(k,{icon:vt})})})}const Pt=p.forwardRef(({onSearch:e,isPending:l},o)=>{const a=pe(),{t:i}=X(),[r,m]=p.useState("");return p.useImperativeHandle(o,()=>({clearSearch(){m("")}})),t.jsxs("div",{className:"flex items-center gap-1 max-mobile:w-full",children:[t.jsx(Ke,{type:"text",placeholder:a?i("documents.search"):"Search documents by name",className:"w-96 max-mobile:w-full",inputClassName:"h-9",value:r,onChange:c=>{m(c.target.value)},onKeyDown:c=>{c.key==="Enter"&&!l&&e(r)},startIcon:t.jsx(k,{icon:tt,className:"ml-2"}),id:"directory-search"}),t.jsx("button",{className:"h-9 w-12 bg-input-active rounded-md flex items-center justify-center shrink-0",id:"directory-search-btn",onClick:()=>e(r),disabled:!r||l,children:l?t.jsx(fe,{size:"sm",color:"white"}):t.jsx(k,{icon:tt,className:"text-base-bg"})})]})});function Et({file:e}){const[l,o]=p.useState(!1),a=p.useRef(null);Ge(r=>{l&&r.target!==a.current&&o(!1)});const{t:i}=X();return t.jsx(et.Popover,{isOpen:l,reposition:!1,content:()=>t.jsx("p",{className:"absolute bg-input-bg shadow-lg -left-12 focus:outline-none bottom-0 w-24 rounded-md text-center py-2",children:i("documents.download")}),children:t.jsx("button",{onClick:()=>{Xe({url:e.documentUrl,fileName:e.name},()=>{const r=document.createElement("a");r.href=e.documentUrl,r.download=e.name,document.body.appendChild(r),r.click(),document.body.removeChild(r)})},ref:a,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),id:`file-download-btn-${e.id}`,"aria-label":i("documents.downloadAriaLabel"),children:t.jsx(k,{icon:ht})})})}function _e({data:e,display:l,associationId:o,isSearching:a}){const i=qe();if(!e||!o)return null;const r=()=>t.jsxs("div",{className:Me("ml-[27px] mb-3 flex items-center justify-between gap-2",a&&"mt-[6px]"),id:"mobile-display",children:[t.jsx("p",{id:`mobile-file-visibility-${e.id}`,children:Ve(e.visibility)}),e.type==="file"&&t.jsx("div",{className:"h-1 w-1 rounded-full bg-base-fg"}),t.jsx("p",{id:`mobile-file-date-${e.id}`,children:e.type==="folder"?"":Je(e.lastModified,"MM/dd/yyyy hh:mm a")})]});return e.type==="file"?t.jsxs("div",{onClick:()=>{Xe({url:e.documentUrl,fileName:e.name},()=>{window.open(`/document/${o}/${e.id}/preview?name=${e.name}`,"newwindow","width=600,height=600,noopener,noreferrer")})},className:"flex mobile:items-center h-full w-full mobile:flex-row flex-col items-start",id:`navigate-file-${e.id}`,role:"button",children:[t.jsxs("div",{className:"flex items-center mobile:h-auto mobile:mt-0 mt-3 h-4",children:[t.jsx(k,{icon:_t(e.name),className:"text-base-icon mr-2"}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:Me("text-base-link truncate",i&&"font-medium w-56",a&&"h-8"),children:l}),a&&e.fullPath&&t.jsx("span",{className:"text-xs italic text-base-fg-muted truncate w-56",children:e.fullPath})]})]}),i&&r()]}):t.jsxs(ke,{to:`/community/documents/a/${o}/f/${e.id}`,className:"flex mobile:items-center h-full w-full mobile:flex-row flex-col items-start",id:`navigate-folder-${e.id}`,children:[t.jsxs("div",{className:"flex items-center mobile:h-auto mobile:mt-0 mt-3 h-4",children:[t.jsx(k,{icon:At,className:"text-base-icon mr-2"}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:Me("truncate",i&&"text-input-active font-medium w-56"),children:l}),a&&e.fullPath&&t.jsx("span",{className:"text-xs italic truncate w-56",children:e.fullPath})]})]}),i&&r()]})}function Ae({data:e,hasAddUpdatePerms:l,hasDeletePerms:o}){const{t:a}=X(),[i,r]=p.useState(!1),m=p.useRef(),{width:c}=Le(),s=ze(),n=Ee(),[w,g]=p.useState(null),d=Pe(),f=d.folderId?parseInt(d.folderId):1,h=Se();Ge(u=>{i&&u.target!==m.current&&r(!1)});const v=[l&&(e==null?void 0:e.type)!=="folder"&&{label:a("documents.rename"),icon:Lt,action:()=>g("rename"),id:`menu-rename-btn-${e==null?void 0:e.id}`},l&&{label:a("documents.duplicate"),icon:Tt,action:async()=>
1{if(!(n!=null&&n.id)||!(e!=null&&e.id))return;(e.type==="folder"?W.createDirectory(n.id,f,{templateDirectoryId:e.id,name:null}):W.duplicateDocument(n.id,e.id,{duplicatedFileName:e.name,parentId:f})).then(()=>{h.revalidate(),le({message:a("documents.duplicateSuccess"),type:"success"})})},id:`menu-duplicate-btn-${e==null?void 0:e.id}`},o&&(e==null?void 0:e.type)!=="folder"&&{label:a("documents.delete"),icon:zt,action:()=>g("delete"),id:`menu-delete-btn-${e==null?void 0:e.id}`}].filter(Boolean);if(!e||c>$e&&v.length===0)return null;const x=()=>{if(!(n!=null&&n.id))return null;switch(w){case"delete":return t.jsx(pn,{directory:e,associationId:n==null?void 0:n.id,setModal:g});case"rename":return t.jsx(vn,{directory:e,associationId:n==null?void 0:n.id,setModal:g})}};return t.jsxs(t.Fragment,{children:[t.jsx(et.Popover,{isOpen:i,reposition:!1,content:()=>t.jsxs("ul",{className:"absolute bg-input-bg shadow-lg focus:outline-none right-2 bottom-0 w-[160px] rounded-md",children:[c<$e&&t.jsxs("div",{className:"border-b-2 border-base-border",children:[e.type==="folder"&&t.jsx(Oe,{label:a("documents.open"),icon:qt,action:()=>s(`/community/documents/a/${n==null?void 0:n.id}/f/${e.id}`),elementId:`menu-open-btn-${e.id}`}),t.jsx(Oe,{label:a("documents.copyLink"),icon:vt,action:()=>{if(e.type==="file")navigator.clipboard.writeText(window.location.href);else{const u=`${window.location.origin}/community/documents/a/${n==null?void 0:n.id}/f/${e.id}`;navigator.clipboard.writeText(u)}le({message:"URL copied to clipboard.",type:"success"})},elementId:`menu-copy-btn-${e.id}`}),e.type==="file"&&t.jsx(Oe,{label:a("documents.download"),icon:ht,action:()=>{Xe({url:e.documentUrl,fileName:e.name},()=>{const u=document.createElement("a");u.href=e.documentUrl,u.download=e.name,document.body.appendChild(u),u.click(),document.body.removeChild(u)})},elementId:`menu-download-btn-${e.id}`})]}),v.map(u=>t.jsx(Oe,{label:u.label,icon:u.icon,action:u.action,elementId:u.id},u.label))]}),children:t.jsx("button",{onClick:u=>{m.current=u.target,r(!0)},"data-qa":`doc-menu-${e.id}`,"aria-label":a("documents.menuAriaLabel"),children:t.jsx(k,{icon:Ut,className:"text-neutral-fg"})})}),x()]})}const Oe=e=>t.jsx("li",{className:"flex gap-2",children:t.jsxs("button",{className:"cursor-pointer select-none py-2 px-3 hover:bg-input-active/10 w-full flex items-center gap-4",onClick:e.action,id:e.elementId,children:[t.jsx(k,{icon:e.icon}),t.jsx("span",{children:e.label})]})},e.label),pn=({directory:e,associationId:l,setModal:o})=>{const a=pe(),i=Se(),{t:r}=X(),[m,c]=p.useState(!0),s=()=>{c(!1),o(null)},{mutate:n,isPending:w}=ve({mutationFn:()=>e.type==="folder"?W.deleteDirectory(l,e.id):W.deleteDocument(l,e.id),onSuccess:()=>{le({message:r("documents.deleteSuccess",{name:e.name}),type:"success"}),s(),i.revalidate()}});return t.jsx(Te,{open:m,onClose:s,title:r("documents.deleteModalTitle").toString(),actions:[{text:w?t.jsx(fe,{color:"white",className:"h-8 w-8"}):r("documents.delete").toString(),onClick:async()=>n(),variant:"danger",id:`delete-btn-${e.id}`},{text:r("documents.cancel").toString(),onClick:s,id:`delete-cancel-btn-${e.id}`,...a&&{variant:"passive"}}],children:t.jsx(ft,{i18nKey:"documents.deleteModalDescription",values:{name:e.name},components:{bold:t.jsx("strong",{})}})})},vn=({directory:e,associationId:l,setModal:o})=>{const a=pe(),{t:i}=X(),r=Se(),[m,c]=p.useState(!0),[s,n]=p.useState(e.name.includes(".")?e.name.slice(0,e.name.lastIndexOf(".")):e.name),w=Pe(),g=w.folderId?parseInt(w.folderId):1,d=()=>{c(!1),n(""),o(null)},{mutate:f,isPending:h}=ve({mutationFn:()=>{if(e.type==="folder")return W.renameDirectory(l,e.id,{name:s});{const x=e.name.split(".").pop();return W.renameDocument(l,e.id,{fileName:`${s}.${x}`,parentId:g})}},onSuccess:()=>{le({message:i("documents.renameSuccess",{name:e.name}),type:"success"}),d(),r.revalidate()},onError:x=>{var u;((u=x.response)==null?void 0:u.data)==="Document with the same name already exists in the parent folder"&&le({message:i("documents.renameError"),type:"error"})}}),v=a?i("documents.documentName"):i("documents.nameType",{name:Ve(e.type)});return t.jsx(Te,{open:m,onClose:d,title:a?i("documents.renameDocument"):i("documents.renameType",{type:Ve(e.type)}),actions:[{text:h?t.jsx(fe,{color:"white",className:"h-8 w-8"}):i("documents.save"),onClick:async()=>f(),variant:"primary",disabled:!s||h,id:`rename-btn-${e.id}`},{text:i("documents.cancel").toString(),onClick:d,id:`rename-cancel-btn-${e.id}`,...a&&{variant:"passive"}}],children:t.jsx(Ke,{type:"text",label:v,value:s,onChange:x=>n(x.target.value),placeholder:v,disabled:h,id:`rename-input-${e.id}`})})},Ye=120,hn=Ye*1024*1024;function gn(){const e=Ee(),l=Se(),{folderId:o}=Pe(),{isModalOpen:a,openModal:i,closeModal:r}=yt(),{t:m}=X(),[c,s]=p.useState({}),n=p.useCallback((d,f)=>{s(h=>({...h,[d]:f}))},[]),w=p.useCallback(()=>{s({})},[]),{mutate:g}=ve({mutationFn:async d=>{if(!(e!=null&&e.id))throw new Error("Association ID is required");await Promise.all(d.files.map(async f=>{var h,v,x;try{await W.uploadDocument(e.id,f,o?parseInt(o):1,{onUploadProgress:u=>{d.onProgress(f.name,u.loaded,u.total||0,!1)},validateStatus:u=>u!==200?(d.onProgress(f.name,0,0,!0),!1):!0,suppressToast:!0}),n(f.name,!0)}catch(u){d.onProgress(f.name,0,0,!0);const N=u,F=((h=N.response)==null?void 0:h.status)||"Error",O=((x=(v=N.response)==null?void 0:v.data)==null?void 0:x.detail)||"Upload failed",S=`${F}: ${O}`;n(f.name,S)}}))},onSuccess:()=>(l.revalidate(),()=>window.removeEventListener("beforeunload",d=>{d.preventDefault()})),onError:()=>()=>window.removeEventListener("beforeunload",d=>{d.preventDefault()})});return t.jsxs(t.Fragment,{children:[t.jsx(gt,{type:"button",variant:"passive",size:"sm",startIcon:t.jsx(k,{icon:xt}),id:"upload-file-btn",className:"text-nowrap",onClick:i,children:m("documents.uploadFile")}),t.jsx(xn,{isOpen:a,onClose:r,onUpload:(d,f)=>g({files:d,onProgress:f}),isDrawerActive:!0,responses:c,onResetError:w})]})}function xn({isOpen:e,onClose:l,onUpload:o,isDrawerActive:a=!1,responses:i,onResetError:r}){const m=pe(),{t:c}=X(),s=qe(),[n,w]=p.useState(!1),[g,d]=p.useState([]),[f,h]=p.useState(!1),[v,x]=p.useState({}),u=p.useCallback(()=>Object.keys(v).length>0&&Object.values(v).some(b=>b<100&&b>0),[v]),N=p.useCallback(()=>Object.keys(v).length>0&&Object.values(v).every(b=>b===100||b===0),[v]);p.useEffect(()=>{const b=()=>{h(a&&s)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[a,s]),p.useEffect(()=>{g.length>0&&window.addEventListener("beforeunload",b=>{b.preventDefault()})},[g]);const F=p.useCallback(()=>!!(g.length===0||u()),[g,u]),O=p.useCallback(()=>{u()&&!N()||(d([]),x({}),r(),l())},[l,u,N,r]),S=p.useCallback(b=>b.size>
1hn?(le({type:"error",title:c("documents.fileSizeError"),message:c("documents.fileSizeErrorMessage",{fileName:b.name,fileSize:(b.size/(1024*1024)).toFixed(2),maxSize:Ye})}),!1):!0,[c]),U=p.useCallback(b=>{u()||(b.preventDefault(),b.stopPropagation(),b.type==="dragenter"||b.type==="dragover"?w(!0):b.type==="dragleave"&&w(!1))},[u]),E=p.useCallback(b=>{Object.keys(v).length>0&&(d([]),x({})),d(C=>[...b,...C])},[v]),q=p.useCallback(b=>{if(u())return;b.preventDefault(),b.stopPropagation(),w(!1);const C=[];for(const R of b.dataTransfer.files)R.type&&S(R)&&C.push(R);C.length>0&&E(C)},[u,S,E]),I=p.useCallback(b=>{if(!u()&&b.target.files){const C=[];for(const R of Array.from(b.target.files))S(R)&&C.push(R);C.length>0&&E(C)}},[u,S,E]),A=p.useCallback(()=>{o(g,(C,R,P,z)=>{x(z?$=>({...$,[C]:0}):$=>({...$,[C]:R/P*100}))})},[g,o]),H=p.useCallback(b=>{const C=g.filter((R,P)=>P!==b);x(R=>{const P={...R};return delete P[g[b].name],P}),d(C)},[g]);function V(b,C,R){const P=C[b],z=R==null?void 0:R[b];return P===0||z!==!0&&z!==void 0?m?t.jsx(k,{className:"text-error",icon:Vt}):t.jsx(k,{className:"text-error",icon:Yt}):P===100?m?t.jsx(k,{className:"text-success",icon:Gt}):t.jsx(k,{className:"text-success",icon:Kt}):P!==void 0&&P>0&&P<100?m?t.jsx(k,{icon:Wt}):t.jsx(k,{icon:Xt}):null}const Y=()=>t.jsx("div",{className:"flex flex-col h-full",children:t.jsxs("div",{className:"p-3",children:[t.jsx("div",{className:"flex flex-col mb-3 text-pretty",children:c("documents.permissionCascading")}),t.jsxs("div",{className:Me("relative flex flex-col items-center justify-center rounded-lg border-2 border-dashed border-[#7B8794] p-6",n&&"border-[#1A8FFB] bg-blue-50",u()&&"opacity-50 cursor-not-allowed"),onDragEnter:U,onDragLeave:U,onDragOver:U,onDrop:q,children:[t.jsx(k,{icon:xt,className:"mb-4 h-8 w-8 text-[#0F98FA]"}),t.jsxs("div",{className:"text-center mb-5",children:[t.jsx("p",{className:"text-base font-semibold text-[#181725]",children:c("documents.dragAndDropFiles")}),t.jsx("p",{className:"text-base-link underline text-sm",children:c("documents.browseFiles")})]}),t.jsx("p",{className:"text-sm text-[#7B8794]",children:c("documents.maxFileSize",{size:Ye})}),t.jsx("input",{type:"file",className:"absolute inset-0 cursor-pointer opacity-0",onChange:I,multiple:!0,disabled:u()})]}),g.length>0&&t.jsxs(t.Fragment,{children:[!m&&t.jsxs("p",{className:"font-medium",children:[c("documents.selectedFiles"),":"]}),t.jsx("div",{className:m?"mt-4 px-1 max-h-[200px] overflow-y-auto":"mt-4 max-h-[200px] overflow-y-auto rounded-lg border border-[#7B8794] p-4",children:t.jsx("ul",{className:"mt-2 space-y-3",children:g.map((b,C)=>{const R=i==null?void 0:i[b.name],P=R!==!0&&(R===void 0||R==="")?m?"neutral":"primary":R!==!0?"error":"success",z=typeof R=="string"?R:"";return t.jsxs("li",{className:"text-sm",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[V(b.name,v,i),t.jsx("span",{className:"w-full truncate text-left",children:b.name.length>20?`${b.name.slice(0,20)}...${b.name.slice(-10)}`:b.name}),t.jsx("button",{hidden:u(),type:"button",className:m?"text-input-icon hover:text-input-icon/80 flex-shrink-0":"text-[#0B4E74] hover:text-[#043B59] flex-shrink-0",onClick:()=>H(C),children:t.jsx(k,{icon:Bt,className:m?"h-4 w-4":"h-5 w-5"})})]}),v[b.name]!==void 0&&t.jsx(Ht,{progress:v[b.name],variant:P,errorMessage:z,className:"mt-2"})]},C)})})})]})]})}),L=p.useMemo(()=>[{text:c("documents.upload"),onClick:async()=>{A()},disabled:F(),variant:"primary",id:"modal-upload-file-btn"},{text:c("documents.cancel"),onClick:async()=>{O()},disabled:u()&&!N(),...m&&{variant:"passive"},id:"modal-cancel-btn"}],[N,A,F,m,u,O,c]);return t.jsx(Te,{open:e,title:c("documents.uploadFile"),onClose:O,padded:!1,actions:L,isDrawerActive:f,className:"max-h-[80vh]",children:Y()})}function bn({associationId:e}){const{t:l}=X(),{isModalOpen:o,openModal:a,closeModal:i}=yt();return t.jsxs(t.Fragment,{children:[t.jsx(gt,{type:"button",variant:"primary",size:"sm",startIcon:t.jsx(k,{icon:Jt}),id:"new-folder-btn",className:"text-nowrap",onClick:a,children:l("documents.newFolder")}),t.jsx(wn,{associationId:e,createFolderModalOpen:o,closeModal:i})]})}const wn=({associationId:e,createFolderModalOpen:l,closeModal:o})=>{const a=pe(),{t:i}=X(),r=Pe(),m=r.folderId?parseInt(r.folderId):1,c=Se(),[s,n]=p.useState(""),w=()=>{o(),n("")},{mutate:g,isPending:d}=ve({mutationFn:()=>W.createDirectory(e,m,{name:s,templateDirectoryId:null}),onSuccess:()=>{w(),c.revalidate()}});return t.jsxs(Te,{open:l,onClose:w,title:i("documents.createNewFolder"),actions:[{text:d?t.jsx(fe,{color:"white",className:"h-8 w-8"}):i("documents.create"),onClick:async()=>g(),variant:"primary",disabled:!s||d,id:"create-folder-btn"},{text:i("documents.cancel").toString(),onClick:()=>Promise.resolve(w()),id:"create-folder-cancel-btn",...a&&{variant:"passive"}}],children:[t.jsx(Ke,{type:"text",label:i("documents.folderName"),value:s,onChange:f=>n(f.target.value),placeholder:i("documents.folderName"),disabled:d,id:"create-folder-input"}),t.jsx("p",{className:"mt-2",children:i("documents.createDisclaimer")})]})};function St({isTopLevel:e}){const l=Ee();return l?t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(gn,{}),!e&&t.jsx(bn,{associationId:l.id})]}):null}const yn=({loaderData:e,allowedPerms:l})=>{const o=me(i=>i.isLoggedIn);if(Ue)return t.jsx(jn,{...e,allowedPerms:l});const a={};return e.folderId&&(a.id=e.folderId.toString()),t.jsx(Be,{controller:o?"Homeowner_v2":"Home_v2",action:"Documents",requireAuth:o,children:t.jsx(jt,{controller:o?"Homeowner_v2":"Home_v2",action:"Documents",params:a})})};function jn({documents:e,breadcrumbs:l,documentPermissionsSet:o,associationId:a,allowedPerms:i}){const r=wt(),m=ze(),c=Ze(),{t:s}=X(),n=Ee(),w=qe(),g=me(j=>j.selectedAssociationId),d=me(j=>j.isLoggedIn),{width:f}=Le(),[h,v]=p.useState(),[x,u]=p.useState(!1),[N,F]=p.useState(null),O=p.useRef(null),S=o==null?void 0:o.some(j=>i.has(j)??!1),U=(o==null?void 0:o.includes("delete"))??!1,[E,q]=p.useState(!1),I=p.useMemo(()=>(n==null?void 0:n.id)||a||g||void 0,[n==null?void 0:n.id,g,a]),{data:A,isLoading:H}=en({queryKey:["userSecurities"],queryFn:()=>tn.getUserSecurities({apiVersion:"v2",associationId:I??void 0}),enabled:!!I&&d});p.useEffect(()=>{q((A==null?void 0:A.some(j=>(j==null?void 0:j.permission)==="boardDocumentManagement"))??!1)},[A]);const V=p.useMemo(()=>(l==null?void 0:l.length)<=1,[l]),{mutate:Y,isPending:L}=ve({mutationFn:async j=>{const{totalResults:T}=await W.searchDocuments(I||0,{search:j,pageSize:1});return W.searchDocuments(I||0,{search:j,pageSize:Math.min(T,1e3)})},onSuccess:j=>{u(!0),v(j)}}),b=p.useCallback(j=>{F(j)},[F]);p.useEffect(()=>{N&&L?N.api.setGridOption("loading",!0):N==null||N.api.setGridOption("loading",!1)},[N,L]);const C=()=>{var j;v(void 0),u(!1),(j=O.current)==null||j.clearSearch()};p.useEffect(()=>{I&&!c.pathname.includes(`/community/documents/a/${I}`)&&m(`${c.pathname.includes("/public")?"/public":""}/community/documents/a/${I}/f/1`)},[I,c.pathname,m]);const[R,P]=p.useState(0);p.useEffect(()=>{r.state==="loading"&&P(window.scrollY)},[r.state]),p.useEffect(()=>{window.scrollTo(0,R)},[e,R]);const z=p.useMemo(()=>({data:j,isSearching:T})=>j?t.jsxs("div",{className:"flex items-center justify-between w-full pt-2",children:[t.jsx("div",{children:t.jsx(_e,{data:j,associationId:I,display:(j==null?void 0:j.name)??"",isSearching:T})}),t.jsx("div",{className:"mb-3",children:t.jsx(Ae,{data:j,hasAddUpdatePerms:S,hasDeletePerms:U})})]}):null,[I,S,U]),$=p.useMemo(()=>[{field:"name",headerName:"Name",floatingFilter:!1,flex:1,resizable:!1,suppressMovable:!0,cellRenderer:({data:j})=>t.jsx(z,{data:j,isSearching:x})}],[z,x]),y=p.useMemo(()=>[{field:"name",headerName:"Name",resizable:!0,flex:1,floatingFilter:!1,suppressMovable:!0,cellRenderer:({data:j,value:T})=>t.jsx(_e,{data:j,display:T,associationId:I,isSearching:x})},{field:"visibility",headerName:"Who Can Access",resizable:!0,floatingFilter:!1,flex:1,suppressMovable:!0,hide:!(n!=null&&n.isBoardMember),cellRenderer:({data:j,value:T})=>t.jsx("div",{className:"w-full h-full flex items-center",children:t.jsx("p",{id:`visibility-${j==null?void 0:j.id}`,children:T.charAt(0).toUpperCase()+T.slice(1)})})},{field:"lastModified",headerName:"Last Modified",resizable:!0,floatingFilter:!1,suppressMovable:!0,filterParams:{filterOptions:["greaterThan","lessThan","inRange"]},flex:1,cellRenderer:({data:j,value:T})=>t.jsx("div",{className:"w-full h-full flex items-center",children:t.jsx("p",{id:`date-${j==null?void 0:j.id}`,children:Je(T,"MM/dd/yyyy hh:mm a")})})},{width:120,resizable:!1,sortable:!1,suppressMovable:!0,suppressHeaderMenuButton:!0,cellRenderer:({data:j})=>t.jsxs("div",{className:"flex items-center justify-center gap-3 text-base h-full w-full",children:[f>=$e&&j&&t.jsxs(t.Fragment,{children:[t.jsx(Mt,{id:j.id,document:j}),(j==null?void 0:j.type)==="file"&&t.jsx(Et,{file:j})]}),t.jsx(Ae,{data:j,hasAddUpdatePerms:S,hasDeletePerms:U})]})}],[n==null?void 0:n.isBoardMember,I,S,U,x,f]),D=p.useMemo(()=>f>=We?y:$,[f,y,$]);return H?t.jsx("div",{className:"w-full h-full flex justify-center items-center",children:t.jsx(fe,{})}):t.jsx(Be,{controller:d?"Homeowner_v2":"Home_v2",action:"Documents",requireAuth:d,children:t.jsxs("div",{className:"w-full bg-base-fill rounded-xl",children:[t.jsxs("div",{className:"px-4 py-6 space-y-4",children:[t.jsxs("div",{className:"flex justify-between tablet:items-center items-start gap-4 text-base-fg tablet:flex-row flex-col",children:[l.length>0&&(x?t.jsx(Ct,{totalCount:h==null?void 0:h.totalResults,onClear:C}):t.jsx(Nt,{associationId:I,breadcrumbs:l})),E&&S&&t.jsx(St,{isTopLevel:V})]}),t.jsx(Pt,{ref:O,onSearch:Y,isPending:L})]}),t.jsx("div",{className:"w-full h-full px-4",children:t.jsx(bt,{rowData:(h==null?void 0:h.documents)??e,resetPaginationOnDataChange:!0,columnDefs:D,overlayNoRowsTemplate:x?s("documents.noSearchResults"):V?s("documents.noFiles").toString():s("documents.emptyFolder").toString(),rowHeight:70,getRowId:j=>j.data.id.toString(),enableExport:!1,getGridRef:b,pageSizeFromParent:25,isMobile:w})})]})})}const Nn=({loaderData:e,allowedPerms:l})=>{const o=me(i=>i.isLoggedIn);if(Ue)return t.jsx(Cn,{...e,allowedPerms:l});const a={};return e.folderId&&(a.id=e.folderId.toString()),t.jsx(Be,{controller:o?"Homeowner_v2":"Home_v2",action:"Documents",requireAuth:o,children:t.jsx(jt,{controller:o?"Homeowner_v2":"Home_v2",action:"Documents",params:a})})};function Cn({documents:e,breadcrumbs:l,documentPermissionsSet:o,associationId:a,allowedPerms:i}){const r=wt(),m=ze(),c=Ze(),{t:s}=X(),n=Ee(),w=qe(),g=me(y=>y.selectedAssociationId),d=me(y=>y.isLoggedIn),{width:f}=Le(),[h,v]=p.useState(),[x,u]=p.useState(!1),N=p.useRef(null),F=o==null?void 0:o.some(y=>
1i.has(y)??!1),O=(o==null?void 0:o.includes("delete"))??!1,[S,U]=p.useState(!1),E=p.useMemo(()=>(n==null?void 0:n.id)||a||g||void 0,[n==null?void 0:n.id,g,a]),{data:q,isLoading:I}=sn({associationId:E,apiVersion:"v2",isLoggedIn:d});p.useEffect(()=>{U((q==null?void 0:q.some(({permission:y})=>y==="boardDocumentManagement"))??!1)},[q]);const A=p.useMemo(()=>(l==null?void 0:l.length)<=1,[l]),{mutate:H,isPending:V}=ve({mutationFn:async y=>{if(!y){Y();return}const{totalResults:D}=await W.searchDocuments(E||0,{search:y,pageSize:1});return W.searchDocuments(E||0,{search:y,pageSize:Math.min(D,1e3)})},onSuccess:y=>{y&&(u(!0),v(y))}}),Y=()=>{var y;v(void 0),u(!1),(y=N.current)==null||y.clearSearch()};p.useEffect(()=>{E&&!c.pathname.includes(`/community/documents/a/${E}`)&&m(`${c.pathname.includes("/public")?"/public":""}/community/documents/a/${E}/f/1`)},[E,c.pathname,m]);const[L,b]=p.useState(0);p.useEffect(()=>{r.state==="loading"&&b(window.scrollY)},[r.state]),p.useEffect(()=>{window.scrollTo(0,L)},[e,L]);const C=p.useMemo(()=>({data:y,isSearching:D})=>y?t.jsxs("div",{className:"flex items-center justify-between w-full pt-2",children:[t.jsx("div",{children:t.jsx(_e,{data:y,associationId:E,display:(y==null?void 0:y.name)??"",isSearching:D})}),t.jsx("div",{className:"mb-3",children:t.jsx(Ae,{data:y,hasAddUpdatePerms:F,hasDeletePerms:O})})]}):null,[E,F,O]),R=p.useMemo(()=>[{field:"name",headerName:"Name",floatingFilter:!1,flex:1,resizable:!1,suppressMovable:!0,cellRenderer:({data:y})=>t.jsx(C,{data:y,isSearching:x})}],[C,x]),P=p.useMemo(()=>[{field:"name",headerName:s("documents.name"),flex:1,floatingFilter:!1,suppressMovable:!0,cellRenderer:({data:y,value:D})=>t.jsx(_e,{data:y,display:D,associationId:E,isSearching:x})},{field:"visibility",headerName:s("documents.access"),floatingFilter:!1,flex:1,suppressMovable:!0,hide:!(n!=null&&n.isBoardMember),cellRenderer:({data:y,value:D})=>t.jsx("div",{className:"w-full h-full flex items-center",children:t.jsx("p",{id:`visibility-${y==null?void 0:y.id}`,children:D.charAt(0).toUpperCase()+D.slice(1)})})},{field:"lastModified",headerName:s("documents.lastModified"),floatingFilter:!1,suppressMovable:!0,filterParams:{filterOptions:["greaterThan","lessThan","inRange"]},flex:1,cellRenderer:({data:y,value:D})=>t.jsx("div",{className:"w-full h-full flex items-center",children:t.jsx("p",{id:`date-${y==null?void 0:y.id}`,children:Je(D,"MM/dd/yyyy hh:mm a")})})},{width:120,resizable:!1,sortable:!1,suppressMovable:!0,suppressHeaderMenuButton:!0,cellRenderer:({data:y})=>t.jsxs("div",{className:"flex items-center justify-center gap-3 text-base h-full w-full",children:[f>=$e&&y&&t.jsxs(t.Fragment,{children:[t.jsx(Mt,{id:y.id,document:y}),(y==null?void 0:y.type)==="file"&&t.jsx(Et,{file:y})]}),t.jsx(Ae,{data:y,hasAddUpdatePerms:F,hasDeletePerms:O})]})}],[n==null?void 0:n.isBoardMember,E,F,O,x,s,f]),z=p.useMemo(()=>f>=We?P:R,[f,P,R]),$=(h==null?void 0:h.documents)??e;return I?t.jsx("div",{className:"w-full h-full flex justify-center items-center",children:t.jsx(fe,{})}):t.jsx(Be,{controller:d?"Homeowner_v2":"Home_v2",action:"Documents",requireAuth:d,children:t.jsxs("div",{className:"documents-page w-full px-8 bg-base-fill rounded-xl",children:[t.jsxs("div",{className:"py-6 flex flex-col gap-4",children:[t.jsx("div",{className:"flex justify-between tablet:items-center items-start gap-4 tablet:flex-row flex-col",children:l.length>0&&(x?t.jsx(Ct,{totalCount:h==null?void 0:h.totalResults,onClear:Y}):t.jsx(Nt,{associationId:E,breadcrumbs:l}))}),t.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[t.jsx(Pt,{ref:N,onSearch:H,isPending:V}),S&&F&&t.jsx(St,{isTopLevel:A})]})]}),t.jsx("div",{className:"w-full h-full",children:$.length===0?t.jsx(Rn,{isSearching:x}):t.jsx(bt,{rowData:$,resetPaginationOnDataChange:!0,columnDefs:z,rowHeight:70,getRowId:y=>y.data.id.toString(),enableExport:!1,pageSizeFromParent:25,isMobile:w,loading:V})})]})})}const Rn=({isSearching:e})=>{const{t:l}=X();return t.jsx("div",{className:Me("h-[180px]",e&&"max-mobile:h-[200px]"),children:t.jsx("div",{className:"flex flex-col items-center gap-1 px-4 py-10 border border-base-border rounded-md mx-4",children:e?t.jsxs(t.Fragment,{children:[t.jsx(k,{className:"w-6 h-6",icon:Zt}),t.jsx("p",{children:l("documents.noResultsFound")}),t.jsx("p",{className:"text-sm max-mobile:text-center",children:l("documents.noSearchResults")})]}):t.jsxs(t.Fragment,{children:[t.jsx(k,{className:"w-6 h-6",icon:Qt}),t.jsx("p",{children:l("documents.noDocumentsAvailable")}),t.jsx("p",{className:"text-sm max-mobile:text-center",children:l("documents.noDocumentsAvailableBody")})]})})})},Ln={title:"Documents",showPropertySelector:!0,customContentId:Ue?["Documents","Homeowner_v2"]:void 0,showAi:!0};async function Tn({params:e}){if(!Ue)return{folderId:e.id?parseInt(e.id):1,documents:[],breadcrumbs:[],associationId:void 0};const l=e.folderId?parseInt(e.folderId):1,o=e.associationId?parseInt(e.associationId):void 0;if(!o)return{folderId:l,documents:[],breadcrumbs:[],documentPermissionsSet:[],associationId:void 0};const[a,i]=await Promise.allSettled([W.getDocuments(o,{parentId:l}),W.getDocumentsPermissions(o)]),r=a.status==="fulfilled"?a.value.items:[],m=a.status==="fulfilled"?a.value.breadcrumbs:[],c=i.status==="fulfilled"?i.value:[],s=r.sort((n,w)=>
1n.type!==w.type?n.type==="folder"?-1:1:n.name.localeCompare(w.name));return{folderId:l,documents:s,breadcrumbs:m,documentPermissionsSet:c,associationId:o}}const mt=new Set(["add-update","add/update","add","update"]);function zn(){const e=nn(),l=pe(),{isLoggedIn:o}=rn(),{embedded:a}=on(),i=Ze(),r=m=>{const c=m?"/public/community/documents":"/community/documents",s=i.pathname.replace(/^.*\/documents/,"");return c+s+i.search+i.hash};return!l&&i.pathname.startsWith("/public/community/documents")?t.jsx(nt,{to:r(!1),replace:!0}):l&&!o&&!a&&!i.pathname.startsWith("/public/community/documents")?t.jsx(nt,{to:r(!0),replace:!0}):l?t.jsx(Nn,{loaderData:e,allowedPerms:mt}):t.jsx(yn,{loaderData:e,allowedPerms:mt})}export{zn as Component,Ln as handle,Tn as loader};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.