1import{j as r,u as L,b as O,r as R,L as M,a3 as V,a2 as Y}from"./index-SfRhvKf7.js";import{S as X}from"./pencil-DVePWa1x.js";import{S as z}from"./calender-line-BET5OKKt.js";import{S as J}from"./pin-Denya4F3.js";import{S as W}from"./bank-CNkDLRjo.js";import{S as H}from"./camera-BwPkgJ9T.js";import{S as K}from"./location2-Di5pvMbZ.js";import{u as T}from"./useUserById-BNZiC8hR.js";import{u as G}from"./useTermLabels-B5MeO3zU.js";import{a as Z,b as ee}from"./useQuestionsListTranslation-CO_dlGne.js";import{a as re,u as ae}from"./useBids-D1fwK0QU.js";import{g as te}from"./request-BjJmmtz9.js";import{g as B,f as w,n as P,a as se}from"./forumPriceBadge-tm6TIHdC.js";import{e as ne,r as oe}from"./repositoryCurrency-DOoHkR5x.js";import{r as de}from"./requestAuthorName-CpK6k-3N.js";import{C as ie}from"./chevron-right-C3pavqAe.js";const U=new Set(["SOLVED","CANCELLED_BY_OWNER","CLOSED_BY_MOD","ARCHIVED_NO_PARTICIPATION"]),F=new Set(["FULFILLED","DELIVERED","COMPLETED"]),$=new Set(["CANCELED","REJECTED","EXPIRED"]),le={open:"bg-success-50 text-success-700 dark:bg-success-500/15 dark:text-success-300",progress:"bg-warning-50 text-warning-700 dark:bg-warning-500/15 dark:text-warning-300",complete:"bg-blue-light-50 text-blue-light-700 dark:bg-blue-light-500/15 dark:text-blue-light-300",closed:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"},ce={voluntary:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300",fixed:"bg-brand-600 text-white dark:bg-brand-500",invite:"bg-brand-50 text-brand-500 dark:bg-brand-500/15 dark:text-brand-300"},ue={question:"bg-indigo-50 text-indigo-700 dark:bg-indigo-950/30 dark:text-indigo-300",document:"bg-brand-50 text-brand-700 dark:bg-brand-500/15 dark:text-brand-300"},me=e=>{if(e instanceof Date)return e;if(e&&typeof e=="object"&&"toDate"in e&&typeof e.toDate=="function"){const a=e.toDate();return a instanceof Date?a:null}return null},q=(e,a)=>{const n=me(e);return n?Y(n,{addSuffix:!0}):a},ge=e=>{if(!e)return"?";const a=e.split(/\s+/).filter(Boolean);return a.length===0?"?":`${a[0][0]}${a.length>1?a[a.length-1][0]:""}`.toUpperCase()},fe=(e,a,n)=>[e?.trim(),[a?.firstname,a?.lastname].filter(Boolean).join(" ").trim()].find(t=>t&&!t.includes("@"))||n,Q=(e,a)=>w(e.amount,P(e.currency,"EUR"),a),_=({to:e,title:a,accessibleTitle:n,type:t,typeLabel:u,ageLabel:m,authorName:i,authorAvatarUrl:o,status:x,compensationLabel:y,compensationTone:C,relationshipLabel:g,children:b})=>r.jsx(M,{to:e,"aria-label":n,className:"group block rounded-2xl outline-none focus-visible:ring-4 focus-visible:ring-brand-500/20","data-testid":"request-card-v3-link",children:r.jsxs("article",{className:"rounded-2xl border border-gray-200 bg-white p-5 shadow-theme-xs transition-colors hover:border-gray-300 dark:border-gray-800 dark:bg-gray-900 dark:hover:border-gray-700 sm:px-[22px]","data-testid":"request-card-v3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${ue[t]}`,children:[t==="question"?r.jsx(X,{className:"h-3 w-3","aria-hidden":"true"}):r.jsx(H,{className:"h-3 w-3","aria-hidden":"true"}),u]}),r.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:m})]}),r.jsx("h3",{className:"mt-3 text-[16.5px] font-semibold leading-[1.38] text-gray-800 transition-colors group-hover:text-gray-950 dark:text-gray-100 dark:group-hover:text-white",children:a}),b,r.jsx("div",{className:"my-4 h-px bg-gray-200 dark:bg-gray-800","aria-hidden":"true"}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2","data-testid":"request-card-v3-author-compensation",children:[o?r.jsx("div",{className:"h-6 w-6 shrink-0 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700","data-testid":"request-card-v3-author-avatar",children:r.jsx(V,{source:o,variant:"thumb",alt:"",className:"h-full w-full object-cover"})}):r.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gray-200 text-[10.5px] font-semibold text-gray-600 dark:bg-gray-700 dark:text-gray-200","aria-hidden":"true","data-testid":"request-card-v3-author-avatar",children:ge(i)}),i?r.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-gray-500 dark:text-gray-400","data-testid":"request-card-v3-author-name",children:i}):null,r.jsx("span",{className:`inline-flex shrink-0 items-center rounded-full px-2.5 py-1 text-xs font-medium ${ce[C]}`,"data-testid":"request-card-v3-compensation",children:y})]}),r.jsx("span",{className:`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium ${le[x.tone]}`,children:x.label})]}),g?r.jsx("div",{className:"mt-2.5 flex justify-end",children:r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-700 px-2.5 py-1 text-xs font-medium text-white dark:bg-gray-200 dark:text-gray-900","data-testid":"request-card-v3-relationship",children:[g,r.jsx(ie,{className:"h-3 w-3",strokeWidth:2.2,"aria-hidden":"true"})]})}):null]})}),xe=(e,a)=>e.status==="SOLVED"?{label:a("qna.statusSolved","Solved"),tone:"complete"}:U.has(e.status)?{label:a("qna.statusClosed","Closed"),tone:"closed"}:e.status!=="OPEN"?{label:a("forum.requestCard.inProgress","In progress"),tone:"progress"}:{label:a("qna.statusOpen","Open"),tone:"open"},pe=({question:e,translatedTitle:a,isTranslating:n})=>{const{t,i18n:u}=L(),{user:m}=O(),{user:i}=T(e.userId),o=m?.uid===e.userId,x=U.has(e.status),y=!!(m?.uid&&e.assignedResearcherId===m.uid),C=!!(o&&e.openForPaidOffers&&!x&&!e.acceptedBidId),{count:g,loading:b}=Z(e.id,C),{bid:N}=ee(e.id,e.openForPaidOffers&&!o&&!x?m?.uid??null:null),d=R.useMemo(()=>Object.entries(e.tags).filter(([,s])=>!!s),[e.tags]),E=R.useMemo(()=>d.map(([,s])=>s),[d]),j=R.useMemo(()=>d.map(([s])=>s),[d]),S=u.language?.split("-")[0]||"en",{labels:I}=G(E,S,j),k=fe(void 0,i,t("common.anonymous","Anonymous")),h=e.acceptedBidId?B(e.paymentDetails,"EUR"):null;let v=t("forum.requestCard.voluntary","Voluntary"),f="voluntary";
1e.openForPaidOffers&&(h?(v=w(h.amountMajor,h.currency,u.language),f="fixed"):(v=t("forum.requestCard.offersInvited","Offers invited"),f="invite"));let l=null;return y?l=t("forum.requestCard.assignedToYou","Assigned to you"):o&&!b&&g>0?l=t("forum.requestCard.offersToReview","{{count}} offers to review").replace("{{count}}",String(g)):o?l=t("forum.requestCard.postedByYou","Posted by you"):N?.status==="ACTIVE"?l=`${t("forum.requestStatus.offerSent","You sent an offer")} â ${Q(N,u.language)}`:N?.status==="ACCEPTED"&&(l=t("forum.requestStatus.offerAccepted","Your offer was accepted")),r.jsx(_,{to:`/requests/questions/${e.id}`,accessibleTitle:a||e.title,title:r.jsxs(r.Fragment,{children:[n?r.jsx("span",{className:"mr-2 inline-flex h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-500 border-t-transparent motion-reduce:animate-none","aria-label":t("common.loading","Loading")}):null,a||e.title]}),type:"question",typeLabel:t("forum.requestCard.researchQuestion","Research question"),ageLabel:q(e.createdAt,t("common.recently","Recently")),authorName:k,authorAvatarUrl:i?.avatarUrl,status:xe(e,t),compensationLabel:f==="fixed"?`${v} ${t("forum.requestCard.reward","reward")}`:v,compensationTone:f,relationshipLabel:l,children:r.jsx("div",{className:"mt-3 flex flex-wrap gap-[7px]",children:d.map(([s,c])=>r.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:s==="region"?r.jsx(K,{className:"h-3 w-3","aria-hidden":"true"}):s==="period"?r.jsx(z,{className:"h-3 w-3","aria-hidden":"true"}):r.jsx(J,{className:"h-3 w-3","aria-hidden":"true"})}),r.jsx("span",{className:"truncate",children:I[c]||c})]},`${s}-${c}`))})})},ye=(e,a)=>F.has(e.status)?{label:a("forum.requestCard.completed","Completed"),tone:"complete"}:$.has(e.status)?{label:a("qna.statusClosed","Closed"),tone:"closed"}:e.status==="REQUESTED"?{label:a("qna.statusOpen","Open"),tone:"open"}:{label:a("forum.requestCard.inProgress","In progress"),tone:"progress"},be=({request:e})=>{const{t:a,i18n:n}=L(),{user:t,firestoreUser:u}=O(),{user:m}=T(e.requestorId),i=e,o=t?.uid===e.requestorId,x=F.has(e.status)||$.has(e.status),y=i.archiveRepositoryId,C=e.countryISOA3?.trim().toUpperCase()||ne(y)||void 0,g=oe({countryISOA3:C,archiveRepositoryId:y}),b=e.pricingMode??"FIXED",N=!o&&!!t?.uid,{bid:d}=re(e.id,N?t?.uid??null:null),E=!!(o&&b==="OPEN_FOR_BIDS"&&!e.acceptedBidId&&!x),{count:j,loading:S}=ae(e.id,E),k=!!(!!(e.serviceProviderId||e.acceptedBidId)&&t?.uid&&(t.uid===e.serviceProviderId||e.acceptedBidId&&d?.id===e.acceptedBidId)),h=o&&u?u:m,v=de(e.requestorName,h),f=e.acceptedBidId?B(e.paymentDetails,e.currency??g??"EUR"):null,l=P(e.currency??g,"EUR");let s,c;b==="FIXED"?(s=typeof e.fixedPrice=="number"&&Number.isFinite(e.fixedPrice)?w(e.fixedPrice,l,n.language):se(l,n.language),c="fixed"):f&&k?(s=w(f.amountMajor,f.currency,n.language),c="fixed"):(s=a("forum.requestCard.offersInvited","Offers invited"),c="invite");let p=null;k?p=a("forum.requestCard.assignedToYou","Assigned to you"):o&&!S&&j>0?p=a("forum.requestCard.offersToReview","{{count}} offers to review").replace("{{count}}",String(j)):o?p=a("forum.requestCard.postedByYou","Posted by you"):d?.status==="ACTIVE"?p=`${a("forum.requestStatus.offerSent","You sent an offer")} â ${Q(d,n.language)}`:d?.status==="ACCEPTED"?p=a("forum.requestStatus.offerAccepted","Your offer was accepted"):d&&["REJECTED","SUPERSEDED","EXPIRED"].includes(d.status)&&(p=a("forum.requestStatus.offerNotAccepted","Your offer was not accepted"));const D=i.archiveRepositoryName||e.repositoryName,A=te(e,n.language);return r.jsx(_,{to:`/requests/${e.id}`,title:A,accessibleTitle:A,type:"document",typeLabel:a("forum.requestCard.documentCopyRequest","Document-copy request"),ageLabel:q(e.dateSubmitted??e.createdAt,a("common.recently","Recently")),authorName:v,authorAvatarUrl:e.requestorAvatarUrl||h?.avatarUrl,status:ye(e,a),compensationLabel:c==="fixed"?`${s} ${a("forum.requestCard.reward","reward")}`:s,compensationTone:c,relationshipLabel:p,children:D?r.jsxs("div",{className:"mt-3 rounded-lg bg-gray-100 px-3 py-2.5 dark:bg-gray-800","data-testid":"request-card-v3-repository",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-sm font-semibold text-gray-800 dark:text-gray-100",children:[r.jsx(W,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:D})]}),i.callNumber?r.jsx("div",{className:"mt-1 space-y-0.5 pl-5 text-xs text-gray-500 dark:text-gray-400",children:r.jsxs("div",{className:"text-gray-400 dark:text-gray-500",children:[a("forum.requestCard.callNumber","Call no.")," ",i.callNumber]})}):null]}):null})},Be=e=>e.kind==="question"?r.jsx(pe,{...e}):r.jsx(be,{...e}),Pe=({loadingLabel:e})=>r.jsx("div",{role:"status","aria-label":e,className:"animate-pulse motion-reduce:animate-none",children:r.jsxs("article",{className:"rounded-2xl border border-gray-200 bg-white p-5 shadow-theme-xs dar
1k:border-gray-800 dark:bg-gray-900 sm:px-[22px]","data-testid":"request-card-v3-skeleton",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"h-6 w-28 rounded-full bg-gray-100 dark:bg-gray-800"}),r.jsx("div",{className:"h-3 w-16 rounded bg-gray-100 dark:bg-gray-800"})]}),r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx("div",{className:"h-5 w-5/6 rounded bg-gray-200 dark:bg-gray-700"}),r.jsx("div",{className:"h-5 w-2/3 rounded bg-gray-200 dark:bg-gray-700"})]}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-[7px]",children:[r.jsx("div",{className:"h-6 w-24 rounded-full bg-gray-100 dark:bg-gray-800"}),r.jsx("div",{className:"h-6 w-32 rounded-full bg-gray-100 dark:bg-gray-800"}),r.jsx("div",{className:"h-6 w-20 rounded-full bg-gray-100 dark:bg-gray-800"})]}),r.jsx("div",{className:"my-4 h-px bg-gray-200 dark:bg-gray-800"}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2","data-testid":"request-card-v3-skeleton-author-compensation",children:[r.jsx("div",{className:"h-6 w-6 shrink-0 rounded-full bg-gray-200 dark:bg-gray-700"}),r.jsx("div",{className:"h-3 min-w-0 w-24 rounded bg-gray-100 dark:bg-gray-800"}),r.jsx("div",{className:"h-6 w-20 shrink-0 rounded-full bg-gray-100 dark:bg-gray-800"})]}),r.jsx("div",{className:"h-6 w-14 rounded-full bg-gray-100 dark:bg-gray-800"})]}),r.jsx("div",{className:"mt-2.5 flex items-center justify-end",children:r.jsx("div",{className:"h-6 w-28 rounded-full bg-gray-200 dark:bg-gray-700"})})]})});export{Pe as R,Be as a};
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.