1import{r as t,j as r}from"./index-1cd9a41c.js";import{e as O,f as Q,g as X,h as Z,i as ee,j as te,p as oe,B as re,k as se,S as ae,l as ne,m as le}from"./app-loader.container-fe4c55c6.js";import{S as ce,E as ie}from"./styles-f75ff462.js";import{E as ue}from"./component-4b3f7107.js";import{f as D,c as d}from"./page.module-18c923f6.js";import de from"./index-2e2cfb57.js";import"./menu.component-cfe7d374.js";import"./chevron-left-8c43e81a.js";import"./delete-bucket-4ccfa79b.js";import"./eye-invisible-001e4f42.js";import"./index-29c51a3d.js";import"./sortable.esm-a8c7a89a.js";import"./index-a077883f.js";const B=l=>l.trim().toLocaleLowerCase("en"),E=l=>{if(typeof window>"u")return l;const c=new URL(l,window.location.origin);return["localhost","127.0.0.1"].includes(c.hostname)&&c.port==="3001"&&(c.port="3000"),c.toString()},me=l=>{let c=(l==null?void 0:l.parentElement)??null;for(;c;){const i=window.getComputedStyle(c).overflowY;if(i==="auto"||i==="scroll"||i==="overlay")return c;c=c.parentElement}return null},je=t.memo(()=>{const{id:l,category:c}=O(),{equipmentService:i,userService:L}=Q(),{user:m}=X(),{lang:k}=Z(),h=ee(),[w,M]=t.useState(),[C,v]=t.useState([]),[s,_]=t.useState(),[A,b]=t.useState(!0),[F,S]=t.useState(!1),[P,z]=t.useState(!1),[R,T]=te(1500),x=t.useRef(null),y=t.useRef(null),U=t.useRef(!1),I=m.type==="LoggedIn"&&m.username.toLocaleLowerCase()===l.toLocaleLowerCase();t.useEffect(()=>{let e=!0;return(async()=>{b(!0),S(!1);let o;if(I&&m.type==="LoggedIn")o=m.userId,_({id_user:m.userId,name:m.name,last_name:m.last_name,username:m.username,photo_link:m.photo_link});else{const g=await L.getBasicUserInfo(l);if(!e)return;if(g.type!=="success"){S(!0),b(!1);return}o=g.value.id_user,_(g.value)}const n=await i.getItems(I?void 0:o);if(!e)return;if(n.type!=="success"){S(!0),b(!1);return}const p=B(c),u=n.value.filter(g=>!g.is_draft&&[g.category.code,g.category.id].some(K=>B(K)===p)),f=u[0];f?(M(f.category),v(u)):S(!0),b(!1)})(),()=>{e=!1}},[i,I,c,m,L,l]),t.useEffect(()=>{if(!w)return;const e=me(x.current);y.current=e;const a=o=>{var u;const n=o==null?void 0:o.target;n instanceof HTMLElement&&x.current&&n.contains(x.current)&&(y.current=n);const p=Math.max(((u=y.current)==null?void 0:u.scrollTop)??0,window.scrollY,document.documentElement.scrollTop,document.body.scrollTop);z(p>=300)};return a(),document.addEventListener("scroll",a,{capture:!0,passive:!0}),window.addEventListener("scroll",a,{passive:!0}),()=>{document.removeEventListener("scroll",a,!0),window.removeEventListener("scroll",a),y.current=null}},[w]),t.useEffect(()=>{if(!w||U.current||!window.location.hash)return;const e=window.location.hash.slice(1);let a=e;try{a=decodeURIComponent(e)}catch{}const o=window.requestAnimationFrame(()=>{const n=document.getElementById(a);n&&(n.scrollIntoView({block:"start"}),U.current=!0)});return()=>window.cancelAnimationFrame(o)},[w,C]);const Y=t.useCallback(()=>{const e=y.current;if(e){e.scrollTo({top:0,behavior:"smooth"});return}window.scrollTo({top:0,behavior:"smooth"})},[]),N=t.useCallback(()=>{window.location.assign(E(`/@${encodeURIComponent(l)}/equipment`))},[l]),q=t.useCallback(async()=>{await navigator.clipboard.writeText(window.location.href),T()},[T]),H=t.useCallback(e=>{window.location.assign(`/my/equipment?editItem=${encodeURIComponent(e.id)}`)},[]),V=t.useCallback(async e=>(await i.unpublishItem(e)).type!=="success"?!1:(v(o=>o.filter(n=>n.id!==e)),!0),[i]),G=t.useCallback(async e=>(await i.deleteItem(e)).type!=="success"?!1:(v(o=>o.filter(n=>n.id!==e)),!0),[i]),W=t.useCallback(async(e,a)=>{const o=await i.reorderItems(e,a);if(o.type!=="success")return!1;const n=o.value.filter(p=>!p.is_draft&&p.category.id===e);return v(n),!0},[i]),j=t.useMemo(()=>{const e=C[0];if(!e)return"";const a=C.reduce((u,f)=>Date.parse(f.created_at)<Date.parse(u)?f.created_at:u,e.created_at),o=C.reduce((u,f)=>Date.parse(f.updated_at)>Date.parse(u)?f.updated_at:u,e.updated_at),n=D(a,k),p=D(o,k);return n&&p?(h("profile/equipment/category-dates")??"").replace("{created}",n).replace("{updated}",p):""},[C,k,h]),J=t.useMemo(()=>{var e,a,o;return s?r.jsxs("div",{className:d.meta,children:[r.jsxs("a",{className:d.author,href:`/@${encodeURIComponent(s.username)}`,children:[s.photo_link?r.jsx("img",{className:d.avatar,src:oe(s.photo_link)??s.photo_link,alt:""}):r.jsx("span",{className:d.avatarFallback,"aria-hidden":"true",children:`${((e=s.name)==null?void 0:e[0])??""}${((a=s.last_name)==null?void 0:a[0])??""}`.toUpperCase()||((o=s.username[0])==null?void 0:o.toUpperCase())}),r.jsxs("span",{className:d.authorDetails,children:[r.jsx("span",{className:d.authorName,children:`${s.name} ${s.last_name}`.trim()||`@${s.username}`}),j&&r.jsx("span",{className:d.authorRole,children:j})]})]}),r.jsx("div",{className:d.actions,children:r.jsxs(re,{type:"button",size:"md",leftIcon:r.jsx(ce,{}),onClick:()=>void q(),children:[R&&r.jsx(se,{forceShow:!0,placement:"bottom",children:h("profile/equipment/link-copied")}),h("profile/route-card/menu/share")]})})]}):void 0},[s,j,q,R,h]),$=t.useMemo(()=>s?{id:`author-${s.username}`,label:`${s.name} ${s.last_name}`.trim()||`@${s.username}`,link:E(`/@${encodeURIComponent(s.username)}`),external:!0}:void 0,[s]);return A?r.jsx(ae,{}):F||!w?r.jsx(de,{}):r.jsxs("main",{ref:x,className:d.page,children:[r.jsx(ie,{type:"button","aria-label":h("actions/close")??"Close",onClick:N,children:r.jsx(ne,{})}),P&&r.jsx("button",{className:d.scrollTopButton,type:"button","aria-label":h("profile/equipment/scroll-to-top")??"Back to top",onClick:Y,children:r.jsx(le,{})}),r.jsx("div",{className:d.content,children:r.jsx(ue,{category:w,items:C,isCurrentUser:I,onBack:N,onEdit:H,onUnpublish:V,onDelete:G,onReorder:W,onAdd:()=>{},headerMeta:J,...$!==void 0&&{breadcrumbAuthor:$},equipmentBreadcrumbLink:E(`/@${encodeURIComponent(l)}/equipment`),breadcrumbsUseDocumentNavigation:!0,standalone:!0})})]})});export{je as default};
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.