PageSourceSearch

https://app.planify.design/assets/ClientReviewDashboard-CxsnmGpn.js

js planify.design collected 2026-10-02 00:21:49 UTC 178,573 bytes, 12 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/portalSentry-DTSK8oUl.js","assets/index-QSrj4ChD.js","assets/index-D37vedEB.css","assets/recovery-CCRcLomd.js","assets/ProposalTab-BqaH8-2b.js","assets/App-CBxPpZok.js","assets/App-BJwSwUda.css","assets/CanvasCreationsTab-CBkfeb9-.js","assets/CreationAnnotationPin-CZf9HPjZ.js","assets/displayOrder-oLKnDjl3.js","assets/resolvePrimaryAttachment-DPLbErfx.js","assets/ReviewPortalVisibilityButton-CYxLCZA-.js","assets/ungroup-CyoA_dRM.js","assets/map-pin-d3r-Kl1x.js","assets/InspirationsTab-CAhPALEp.js","assets/imageResize-DIZL-JRW.js","assets/isAppleSafari-D-K9oeP5.js","assets/questionnaireInspirationMarker-qBb6wj2f.js","assets/save-PdwH7pYT.js","assets/DocumentsTab-Bqj-HI3S.js","assets/DocumentCommentBadge-Ozai69rR.js","assets/archive-DrCd1H_j.js","assets/usePortalSchedule-CFKBKk9L.js","assets/useQuery-BHHScgr7.js","assets/PortalScheduleTab-CtHm-BX3.js","assets/PortalScheduleAgenda-DV3JiUaB.js","assets/zoom-out-CTS_JXfc.js"])))=>i.map(i=>d[i]);
2var ii=Object.defineProperty;var li=(t,a,r)=>a in t?ii(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var zn=(t,a,r)=>li(t,typeof a!="symbol"?a+"":a,r);import{c as xr,r as n,u as ae,j as e,M as ci,_ as tt,l as di}from"./index-QSrj4ChD.js";import{aV as ui,aW as gr,c as rs,aX as Ls,aY as ma,aZ as Mt,a_ as pa,a$ as ct,aa as mi,R as jt,t as _,F as oe,b0 as pi,b1 as hi,b2 as ha,b3 as fi,b4 as xi,b5 as We,a9 as br,a6 as gi,ap as Nt,D as wr,n as yr,p as vr,aB as bi,_ as Ge,b6 as jr,b7 as Bn,b8 as ja,b9 as ns,ba as wi,aN as Nr,bb as Na,bc as os,L as vt,ao as yi,$ as _a,bd as _r,be as Sr,aj as kr,ak as Cr,al as Ir,at as Pr,bf as vi,a1 as Tr,a2 as Rr,bg as ji,bh as Ni,a4 as Er,bi as _i,bj as Si,bk as ki,bl as Ci,bm as Ii,bn as Pi,bo as Ti,bp as Ri,Q as Sa,bq as Ar,br as Un,bs as Ei,bt as Ai,bu as Di,bv as ka,bw as Ca,bx as Dr,by as Lr,a8 as fa,bz as xa,T as ga,bA as ba,bB as Ia,bC as Li,bD as Mi,bE as Mr,bF as Fi,bG as Oi,P as Gn,O as wa,bH as ra,bI as Wi,bJ as $i,bK as Vi,bL as zi,bM as Bi,bN as Ui,bO as Gi,bP as Hi,aQ as Ki,ad as qi,bQ as Yi,o as Qi,ae as Xi,bR as Ji,bS as Zi,bT as el,ai as ya,bU as tl,v as sl,aD as al,bV as nl,bW as rl,bX as ol,bY as il,bZ as oa,b_ as Hn,b$ as ll,c0 as cl,c1 as dl,c2 as ul,c3 as Kn,c4 as Ms,c5 as ia,c6 as ml,G as qn,am as pl,c7 as hl,aK as fl,c8 as xl,c9 as gl,aR as bl,ca as Yn,aS as wl,cb as Qn,cc as Xn,aT as as,cd as yl,ce as Fs,cf as vl,cg as jl,ch as Nl,ci as is}from"./App-CBxPpZok.js";import{P as et,v as _l,R as Fr,T as Or,a as Wr,s as $r,D as ts,p as Jn,r as Zn,b as Sl,c as er,i as kl,m as tr,d as sr,e as Cl,f as ar,g as Il,h as Pl,j as la,k as ca,l as Os,n as Tl}from"./resolvePrimaryAttachment-DPLbErfx.js";import{u as Rl}from"./usePortalSchedule-CFKBKk9L.js";/**
3 * @license lucide-react v0.511.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const El=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}],["path",{d:"M3 16v5h5",key:"1t08am"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 8V3h5",key:"1ln10m"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],Vr=xr("expand",El);/**
8 * @license lucide-react v0.511.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Al=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Dl=xr("rows-3",Al);function zr(t,a,r){const i=ui(t);if(i){const c=r(i.labelKey);if(c&&c!==i.labelKey)return c}return a}async function Ll(t){for(let a=0;a<2;a++){const r=await ha(t,{timeoutMs:fi});if(!("error"in r&&typeof r.error=="string")&&"project_id"in r&&r.project_id)return r;a===0&&await new Promise(c=>setTimeout(c,450))}return null}const Ws=5e3,Ml=({onAuthSuccess:t})=>{const{linkToken:a}=gr(),[r,i]=n.useState(""),[c,l]=n.useState(null),[h,x]=n.useState(null),[m,g]=n.useState(null),[w,y]=n.useState(!1),[b,j]=n.useState(!1),[R,L]=n.useState(null),[O,E]=n.useState(null),[M,C]=n.useState(0),[D,p]=n.useState(null),[,fe]=n.useState(0),ue=n.useRef(null),te=n.useRef(!1),Z=3e3,{toast:q}=rs(),{t:S}
12=ae("common",{useSuspense:!1}),le=D==null?0:Math.max(0,Math.ceil((D-Date.now())/1e3));n.useEffect(()=>{if(D==null||D<=Date.now())return;const B=window.setInterval(()=>fe(Y=>Y+1),1e3);return()=>window.clearInterval(B)},[D]),n.useEffect(()=>{if(R!==!0)return;const B=document.title;return document.title=S("reviewPortalDocumentTitle"),()=>{document.title=B}},[R,S]),n.useEffect(()=>{(async()=>{if(!a){L(!1);return}try{const Y=await hi(a);if(Y.valid===!0){E({pin_length_min:Y.pin_length_min,pin_length_max:Y.pin_length_max}),L(!0);return}E(null);const P=Y.reason;if(P==="invalid"){L(!1);return}if(P==="inactive"){q({title:S("linkDeactivated"),description:S("linkDeactivatedDescription"),variant:"destructive"}),L(!1);return}if(P==="locked"){q({title:S("tooManyAttempts"),description:S("tooManyAttemptsDescription"),variant:"destructive"}),L(!1);return}L(!1)}catch(Y){const P=Y?.status,H=Y instanceof Error?Y.message:"";if(P===500||P===502||H==="portal_config_error"||H.includes("portal_pin_policy")||H.includes("portal_status_malformed")){E(null),q({title:S("portalPin.statusPolicyError"),description:S("portalPin.statusPolicyError"),variant:"destructive"}),L(!1);return}if(P===429){q({title:S("tooFast"),description:S("pleaseWaitSeconds",{seconds:60}),variant:"destructive"}),E(Ls),L(!0);return}/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?(E(Ls),L(!0)):L(!1)}})()},[a,q,S]),n.useCallback(()=>{l(null),p(null)},[]);const me=O??Ls,X=me.pin_length_max,ce=B=>{const Y=B.replace(/[^0-9]/g,"").slice(0,X);i(Y),c&&l(null),D!=null&&D<=Date.now()&&p(null),h&&x(null)},A=n.useCallback(B=>{if(B.code==="verify_post_verify_row_missing")return S("verifyPostVerifyRowMissing");if(B.error==="Failed to create session")return S("portalVerifySessionCreateFailed");const Y=(B.error||"").toLowerCase();if(Y.includes("timed out")||Y.includes("request timed out")||B.httpStatus===502||B.httpStatus===503||B.httpStatus===504)return S("portalVerifyNetworkOrTimeout");if(B.httpStatus===429||B.error==="Too many verification attempts. Please wait before trying again."){const P=Math.max(1,Number(B.retry_after_seconds)||1);return S("pleaseWaitSeconds",{seconds:P})}return B.error==="Maximum attempts reached"?S("tooManyAttemptsDescription"):B.error==="Invalid PIN"&&typeof B.attempts_remaining=="number"?S("incorrectPinAttemptsRemaining",{count:B.attempts_remaining}):B.error==="Invalid PIN"?S("invalidPin"):B.error},[S]),ge=n.useCallback(async B=>{const Y=await Ll(B);if(!Y?.project_id)return!1;const P=ue.current;if(!P?.expires_at)return!1;const H={projectId:Y.project_id,expiresAt:P.expires_at,grantedAt:P.access_granted_at??new Date().toISOString(),linkToken:a,portalSessionToken:B,mode:"edge_proxy"};ma("review_access_token",JSON.stringify(H));try{Mt(et)}catch{}return q({title:S("accessGranted"),description:S("accessGrantedDescription")}),t(Y.project_id),g(null),x(null),ue.current=null,!0},[a,t,S,q]),ke=async()=>{if(m){x(null),j(!0);try{await ge(m)||(x(S("sessionLoadFailedDescription")),q({title:S("sessionLoadFailedTitle"),description:S("sessionLoadFailedDescription"),variant:"destructive",duration:Ws}))}finally{j(!1)}}},pe=async B=>{B.preventDefault();const Y=r.replace(/[^0-9]/g,""),P=O??Ls,H=_l(Y,P);if(!H.valid){const $=H.errorKey;l($==="portalPin.lengthRangeError"?S("portalPin.lengthRangeError",{min:P.pin_length_min,max:P.pin_length_max}):S("portalPin.nonDigitError"));return}if(le>0){q({title:S("tooFast"),description:S("pleaseWaitSeconds",{seconds:le}),variant:"destructive"});return}const je=Date.now();if(je-M<Z){const $=Math.ceil((Z-(je-M))/1e3);q({title:S("tooFast"),description:S("pleaseWaitSeconds",{seconds:$}),variant:"destructive"});return}if(!te.current){te.current=!0,C(je),x(null),g(null),ue.current=null,l(null),D!=null&&D<=Date.now()&&p(null),y(!0);try{const $=await xi(a||"",Y);if(!$.success){const Ee=A($);l(Ee),typeof $.retry_after_seconds=="number"&&$.retry_after_seconds>0&&p(Date.now()+$.retry_after_seconds*1e3);const xe=$.httpStatus===429?S("tooFast"):$.error==="Maximum attempts reached"?S("tooManyAttempts"):S("verificationFailed");q({title:xe,description:Ee,variant:"destructive",duration:Ws});return}ue.current={expires_at:$.expires_at,access_granted_at:$.access_granted_at};const He=$.portal_session_token;g(He),y(!1),j(!0),await ge(He)||(x(S("sessionLoadFailedDescription")),q({title:S("sessionLoadFailedTitle"),description:S("sessionLoadFailedDescription"),variant:"destructive",duration:Ws}))}catch{q({title:S("verificationError"),description:S("verificationErrorDescription"),variant:"destructive",duration:Ws})}finally{te.current=!1,y(!1),j(!1)}}},we=w||b;return R===!1?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"max-w-md w-full space-y-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pa,{className:"mx-auto h-16 w-16 text-red-500 mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:S("invalidLink")}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:S("invalidLinkDescription")}),e.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700",children:S("contactProjectOwner")})})]})})}):R===null?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}
12),e.jsx("p",{className:"text-muted-foreground",children:S("validatingLink")})]})}):e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50",children:[e.jsx("div",{className:"absolute top-6 right-6",children:e.jsx(ct,{})}),e.jsxs("div",{className:"max-w-md w-full space-y-8 px-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto h-20 w-20 bg-blue-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(mi,{className:"h-10 w-10 text-blue-600"})}),e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:S("enterAccessPin")}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:S("enterPinDescription")})]}),e.jsxs("form",{method:"post",onSubmit:pe,className:"space-y-6",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"portal-pin",className:"sr-only",children:S("pinLabel")}),e.jsx(jt,{id:"portal-pin",name:"pin",type:"password",value:r,onChange:B=>ce(B.target.value),placeholder:S("enterPinPlaceholder"),inputMode:"numeric",pattern:"[0-9]*",autoComplete:"one-time-code",minLength:me.pin_length_min,maxLength:X,required:!0,"aria-invalid":!!c,"aria-describedby":c||h?"portal-pin-error":void 0,className:_("text-center text-2xl tracking-widest h-14 border-2 focus:border-blue-500",c&&"border-destructive"),autoFocus:!0,disabled:we}),(c||h||le>0)&&e.jsxs("div",{id:"portal-pin-error",role:"alert",className:"text-sm text-destructive space-y-1",children:[c?e.jsx("p",{children:c}):null,h?e.jsx("p",{children:h}):null,le>0?e.jsx("p",{children:S("portalTryAgainIn",{minutes:Math.floor(le/60),seconds:le%60})}):null]})]}),e.jsx(oe,{type:"submit",disabled:we||le>0||r.replace(/[^0-9]/g,"").length<me.pin_length_min,className:"w-full h-12 text-lg",children:we?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-white mr-2"}),S(w?"verifying":"loadingSession")]}):e.jsxs(e.Fragment,{children:[e.jsx(pi,{className:"h-5 w-5 mr-2"}),S("accessReview")]})}),h&&m?e.jsx(oe,{type:"button",variant:"outline",className:"w-full",disabled:b,onClick:ke,children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary mr-2"}),S("loadingSession")]}):S("portalRetryLoadSession")}):null]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-xs text-gray-500",children:S("linkExpiresSecurity")}),e.jsx("p",{className:"text-xs text-gray-400",children:S("pinSecurityNote")})]})]})]})},Pa="openExternal";function Fl(t){return/Android/i.test(t)?"android":/iPhone|iPad|iPod/i.test(t)||typeof navigator<"u"&&navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"ios":"other"}function Br(t=typeof navigator<"u"?navigator.userAgent:""){const a=t||"",r=Fl(a),i=/Instagram/i.test(a),c=/FBAN|FBAV|FB_IAB/i.test(a),l=/(?:^|;)\s*Messenger\b/i.test(a)||/Messenger/i.test(a)&&c,h=/\bwv\)/i.test(a)||/; wv\b/i.test(a);return{isInApp:i||c||l,isInstagram:i,isFacebookApp:c,isMessenger:l,isLikelyWebView:h,platform:r}}function Ol(t){const a=t.get(Pa);return a==="1"||a==="true"||a==="yes"}function Wl(t=typeof window<"u"?window.location.href:""){try{const a=new URL(t);return a.searchParams.set(Pa,"1"),a.toString()}catch{return t}}function $l(t){try{const a=new URL(t);return a.searchParams.delete(Pa),a.toString()}catch{return t}}function Vl(t){let a;try{a=new URL(t)}catch{return t}const r=a.protocol.replace(":","")||"https",i=`${a.host}${a.pathname}${a.search}${a.hash}`,c=encodeURIComponent(t);return`intent://${i}#Intent;scheme=${r};package=com.android.chrome;S.browser_fallback_url=${c};end`}function zl(t){try{const a=new URL(t);return`x-safari-https://${`${a.host}${a.pathname}${a.search}${a.hash}`}`}catch{return t}}const Ur="planify:portal-in-app-gate-continue";function Bl(){if(typeof sessionStorage>"u")return!1;try{return sessionStorage.getItem(Ur)==="1"}catch{return!1}}function Ul(){try{sessionStorage.setItem(Ur,"1")}catch{}}const Gl=({onContinueAnyway:t,onGateEvent:a,portalUrl:r})=>{const{t:i}
12=ae("common",{useSuspense:!1}),{toast:c}=rs(),l=r||(typeof window<"u"?window.location.href:""),{platform:h}=Br(),x=n.useCallback(()=>{a?.("open_browser");const w=Wl(l);try{if(h==="android"){window.location.href=Vl(w);return}if(h==="ios"){window.location.href=zl(w);return}window.open(w,"_blank","noopener,noreferrer")}catch{c({title:i("portalInAppGateOpenFailedTitle","Could not open browser"),description:i("portalInAppGateOpenFailedDescription","Copy the link below and paste it into Safari or Chrome."),variant:"destructive"})}},[a,h,l,i,c]),m=n.useCallback(async()=>{a?.("copy_link");const w=$l(l);try{await navigator.clipboard.writeText(w),c({title:i("portalInAppGateCopiedTitle","Link copied"),description:i("portalInAppGateCopiedDescription","Paste it in Safari or Chrome.")})}catch{c({title:i("portalInAppGateCopyFailedTitle","Copy failed"),description:i("portalInAppGateCopyFailedDescription","Long-press the address bar to copy the link, or ask your designer to resend the link."),variant:"destructive"})}},[a,l,i,c]),g=n.useCallback(()=>{a?.("continue_anyway"),Ul(),t()},[t,a]);return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50 px-6 py-10",children:[e.jsx("div",{className:"absolute top-6 right-6",children:e.jsx(ct,{})}),e.jsxs("div",{className:"max-w-md w-full space-y-6 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-amber-100",children:e.jsx(We,{className:"h-8 w-8 text-amber-700","aria-hidden":!0})}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:i("portalInAppGateTitle","Open in your browser")}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:i("portalInAppGateBody","This app’s preview browser can lose your session. For a stable client portal, open this link in Safari or Chrome.")}),e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-left text-xs text-amber-900",children:[e.jsx("p",{className:"font-medium mb-1",children:i("portalInAppGateInstructionsTitle","How to open in browser")}),e.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[e.jsx("li",{children:i("portalInAppGateInstructionIos","iPhone/iPad: tap ··· or the share icon, then “Open in Safari” (or your browser).")}),e.jsx("li",{children:i("portalInAppGateInstructionAndroid","Android: tap ··· in the top corner, then “Open in Chrome” or “Open in browser”.")})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(oe,{type:"button",size:"lg",className:"w-full h-12 text-base",onClick:x,children:[e.jsx(We,{className:"mr-2 h-5 w-5"}),i("portalInAppGateOpenBrowser","Open in browser")]}),e.jsxs(oe,{type:"button",size:"lg",variant:"outline",className:"w-full h-12 text-base",onClick:m,children:[e.jsx(br,{className:"mr-2 h-5 w-5"}),i("portalInAppGateCopyLink","Copy link")]}),e.jsxs("button",{type:"button",onClick:g,className:"text-sm text-gray-500 hover:text-gray-800 underline underline-offset-2 pt-2",children:[i("portalInAppGateContinueAnyway","Continue here anyway"),e.jsx(gi,{className:"inline h-3 w-3 ml-1 align-middle","aria-hidden":!0})]})]})]})]})};function Hl(t,a){const r=new Date(t);return Number.isNaN(r.getTime())?null:new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function Ta({message:t,className:a,compact:r=!1,timestamp:i}){const{t:c,i18n:l}=ae(),h=(l.resolvedLanguage||l.language||"en").split(/[-_]/)[0]||"en",x=i?Hl(i,h):null;return e.jsxs("div",{className:_("w-full min-w-0 rounded-lg border border-gray-200/60 bg-slate-50/90","border-l-[3px] border-l-amber-400/80",r?"px-3.5 py-3":"px-4 py-3.5 sm:px-4 sm:py-4",a),children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[e.jsx("span",{className:_("font-semibold uppercase tracking-wider text-gray-500",r?"text-[9px]":"text-[10px]"),children:c("designer")}),x?e.jsx("time",{dateTime:i??void 0,className:_("text-gray-400",r?"text-[9px]":"text-[10px]"),children:x}):null]}),e.jsx("p",{className:_("whitespace-pre-line break-words leading-relaxed text-gray-700",r?"text-[11px]":"text-sm"),children:t})]})}function Gr({onClick:t,disabled:a=!1,submitting:r=!1,fullWidth:i=!0,className:c}){const{t:l}=ae();return e.jsx("button",{type:"button",onClick:t,disabled:a,className:_("inline-flex items-center justify-center rounded-md bg-gray-900 px-3 py-1.5 text-xs font-medium text-white shadow-sm transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50",i&&"w-full",c),children:l(r?"saving":"save")})}const Kl='textarea, input, button, a, label, [data-portal-interactive], [contenteditable="true"]';function va(t){return t instanceof Element&&!!t.closest(Kl)}function Ra({chosen:t,disabled:a,onChoose:r,className:i,compact:c=!1}){const{t:l}=ae();return e.jsx("button",{type:"button",disabled:a,"aria-pressed":t,onClick:h=>{h.stopPropagation(),a||r()},className:_("group z-20 flex cursor-pointer items-center transition-all",c?_("h-8 w-full cursor-pointer items-center justify-center rounded-lg px-3 text-xs shadow-2xs transition-all",t?"gap-1.5 bg-emerald-600 font-bold text-white shadow-xs":"gap-2 border border-slate-300 bg-white font-semibold text-slate-700 hover:border-slate-800 hover:text-slate-900",a&&"cursor-not-allowed opacity-60 hover:border-slate-300 hover:bg-white hover:text-slate-700"):_("items-center gap-2 rounded-xl px-3.5 py-2 text-xs font-bold",t?"gap-1.5 bg-emerald-600 text-white shadow-xs":"border-2 border-slate-300 bg-white text-slate-800 shadow-2xs hover:border-slate-900 hover:bg-slate-900 hover:text-white",a&&"cursor-not-allowed opacity-60 hover:border-slate-300 hover:bg-white hover:text-slate-800"),i),children:t?e.jsxs(e.Fragment,{children:[e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0",strokeWidth:2.5,"aria-hidden":!0}),l("reviewChosen")]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:_("h-3.5 w-3.5 shrink-0 rounded-full border-2",c?"border-slate-400":"border-slate-400 group-hover:border-white"),"aria-hidden":!0}),l("reviewSelectOption")]})})}const ql=_("overscroll-y-contain [-webkit-overflow-scrolling:touch]","max-md:scrollbar-hide","md:[scrollbar-width:thin] md:[scrollbar-color:theme(colors.neutral.300)_transparent]","md:[&::-webkit-scrollbar]:w-1.5","md:[&::-webkit-scrollbar-thumb]:rounded-full md:[&::-webkit-scrollbar-thumb]:bg-neutral-300","md:[&::-webkit-scrollbar-track]:bg-transparent");function Yl({children:t,className:a,scrollKey:r}){const i=n.useRef(null),[c,l]=n.useState({hasOverflow:!1,canScrollDown:!1,thumbTop:0,thumbHe
12ight:0}),h=n.useCallback(()=>{const x=i.current;if(!x)return;const{scrollTop:m,scrollHeight:g,clientHeight:w}=x,y=g>w+2,b=y&&m+w<g-2,j=y?w/g:1,R=y?Math.max(28,w*j):0,L=Math.max(0,w-R),O=Math.max(1,g-w),E=y?m/O*L:0;l({hasOverflow:y,canScrollDown:b,thumbTop:E,thumbHeight:R})},[]);return n.useEffect(()=>{const x=i.current;if(!x)return;h();const m=new ResizeObserver(h);return m.observe(x),x.firstElementChild&&m.observe(x.firstElementChild),x.addEventListener("scroll",h,{passive:!0}),window.addEventListener("resize",h),()=>{m.disconnect(),x.removeEventListener("scroll",h),window.removeEventListener("resize",h)}},[h,r]),n.useEffect(()=>{i.current?.scrollTo({top:0}),h()},[r,h]),e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:i,className:_("h-full min-h-0 overflow-y-auto",ql,a),children:t}),c.hasOverflow?e.jsx("div",{className:"pointer-events-none absolute bottom-2 right-1.5 top-2 z-10 w-2 rounded-full bg-neutral-100/95 shadow-inner md:hidden","aria-hidden":!0,children:e.jsx("div",{className:"absolute left-0 w-full rounded-full bg-neutral-400",style:{height:c.thumbHeight,top:c.thumbTop}})}):null,c.canScrollDown?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-[1] h-10 bg-gradient-to-t from-white via-white/80 to-transparent md:hidden","aria-hidden":!0}):null]})}function Ql(t){return(t.file_type||"").startsWith("image/")}function Hr(t,a){return n.useMemo(()=>{if(t.length>0)return t;const r=a?.trim();return r?[{id:"__primary__",url:r,isPrimary:!0}]:[]},[t,a])}function nr({images:t,fallbackUrl:a,alt:r,variant:i="default",index:c,onIndexChange:l,onExpand:h}){const{t:x}=ae(),m=Hr(t,a),g=m.length>0?Math.min(c,m.length-1):0,w=m[g],y=i==="compact";return n.useEffect(()=>{m.length>0&&c>=m.length&&l(0)},[m.length,c,l]),m.length===0?e.jsx("div",{className:_("flex w-full items-center justify-center bg-neutral-100/80 text-sm text-neutral-400",y?"h-full":"aspect-[4/5] rounded-xl"),children:x("noImage")}):e.jsxs("div",{className:_("flex w-full flex-col",y?"h-full gap-2":"items-center gap-3 md:gap-4"),children:[e.jsxs("button",{type:"button",onClick:h,className:_("group relative flex w-full cursor-pointer items-center justify-center overflow-hidden bg-neutral-100/60",y?"min-h-0 flex-1 rounded-none":"aspect-[4/5] rounded-xl"),"aria-label":x("reviewGalleryView"),children:[w?.url?e.jsx(Bn,{src:w.url,alt:r,className:"h-full w-full transition-transform duration-300 group-hover:scale-[1.02]",fit:"contain",priority:!0,quality:88,width:900,height:1125,sizes:"(max-width: 768px) 95vw, 45vw"}):null,e.jsx("span",{className:"pointer-events-none absolute left-2 top-2 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-black/45 text-white backdrop-blur-sm transition-colors group-hover:bg-black/60 md:opacity-0 md:group-hover:opacity-100",children:e.jsx(Vr,{className:"h-4 w-4",strokeWidth:2})}),e.jsx(ja,{count:m.length,className:"left-auto right-2"})]}),m.length>1?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:_("flex w-full items-center justify-center gap-1.5",y&&"shrink-0 px-3"),role:"tablist","aria-label":x("reviewGalleryView"),children:m.map((b,j)=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===g,"aria-label":`${j+1} / ${m.length}`,onClick:()=>l(j),className:_("h-1.5 rounded-full transition-all duration-200",j===g?"w-5 bg-neutral-700":"w-1.5 bg-neutral-300 hover:bg-neutral-400")},b.id))}),e.jsx("div",{className:_("flex w-full justify-center gap-2 overflow-x-auto pb-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",y&&"shrink-0 px-3"),children:m.map((b,j)=>e.jsx("button",{type:"button",onClick:()=>l(j),className:_("shrink-0 overflow-hidden rounded-lg transition-all duration-200",y?"h-10 w-10":"h-12 w-12 md:h-14 md:w-14",j===g?"opacity-100 ring-1 ring-neutral-200 ring-offset-2 ring-offset-neutral-50/50 shadow-sm":"opacity-50 hover:opacity-80"),children:e.jsx(Bn,{src:b.url,alt:"",className:"h-full w-full bg-neutral-100",fit:"cover",width:56,height:56,sizes:"56px",skeletonVariant:"thumbnail"})},b.id))})]}):null]})}function Xl({attachments:t,onViewPdfInline:a,onOpenPdfNewTab:r,onDownloadPdf:i}){const{t:c}=ae(),l=t.filter(h=>!Ql(h));return l.length===0?null:e.jsxs("section",{className:"pt-2",children:[e.jsx("h3",{className:"mb-3 text-[11px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:c("portalModalAssets","Assets")}),e.jsx("ul",{className:"divide-y divide-neutral-100/80",children:l.map(h=>{const x=h.file_type==="application/pdf";return e.jsxs("li",{className:"flex items-center gap-3 py-2.5 first:pt-0 last:pb-0",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center text-neutral-400",children:x?e.jsx(ns,{className:"h-4 w-4",strokeWidth:1.5}):e.jsx(wi,{className:"h-4 w-4",strokeWidth:1.5})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-relaxed text-neutral-800",title:h.file_name,children:h.file_name}),e.jsx("div",{className:"flex shrink-0 items-center gap-0.5",children:x?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>a(h),className:"rounded-md p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700","aria-label":c("viewPdf"),children:e.jsx(ns,{className:"h-4 w-4",strokeWidth:1.5})}),e.jsx("button",{type:"button",onClick:()=>i(h),className:"rounded-md p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700","aria-label":c("downloadPdf"),children:e.jsx(Nr,{className:"h-4 w-4",strokeWidth:1.5})})]}):e.jsx("button",{type:"button",onClick:()=>r(h),className:"rounded-md p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700","aria-label":c("openInNewTab"),children:e.jsx(We,{className:"h-4 w-4",strokeWidth:1.5})})})]}
12,h.id)})})]})}function Jl({approvalStatus:t,roomLabel:a}){const{t:r}=ae(),i=t??"pending",c=r(t||"pending"),l={pending:"bg-slate-100/90 text-slate-600",approved:"bg-emerald-50/90 text-emerald-700",rejected:"bg-red-50/90 text-red-600",maybe:"bg-amber-50/90 text-amber-800"};return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:_("rounded-full px-2.5 py-0.5 text-xs font-medium",l[i]??l.pending),children:c}),a?e.jsx("span",{className:"rounded-full bg-stone-100/90 px-2.5 py-0.5 text-xs font-medium text-stone-600",children:r("portalModalRoomLabel",{room:a})}):null]})}function Zl({model:t}){const{t:a}=ae();return!t.hasAny||t.fields.length===0?null:e.jsxs("section",{className:"pt-4",children:[e.jsx("h3",{className:"mb-4 text-[11px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:a("details")}),e.jsx("dl",{children:t.fields.map(r=>e.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,38%)_1fr] items-center gap-x-5 border-b border-neutral-100 py-3.5 last:border-b-0",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wider text-gray-500",children:zr(r.fieldId,r.label,a)}),e.jsx("dd",{className:"text-right text-sm font-medium leading-relaxed text-neutral-900",children:r.displayValue})]},r.fieldId))})]})}function ec({comment:t,selectedStatus:a,designerReply:r,designerReplyTimestamp:i,previewReadOnly:c,submitting:l,onCommentChange:h,onStatusSelect:x,onSave:m,choiceMode:g=!1}){const{t:w}=ae(),y="bg-gray-100 text-gray-700 hover:bg-gray-200",b=(j,R,L,O)=>e.jsxs("button",{type:"button",disabled:c,onClick:()=>x(j),className:_("inline-flex h-10 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-lg px-2 text-xs font-medium transition-colors sm:h-11 sm:gap-2 sm:text-sm",c?"cursor-not-allowed bg-gray-100 text-gray-400 opacity-60":a===j?O:y),children:[R,e.jsx("span",{className:"truncate",children:L})]});return e.jsx("footer",{className:"shrink-0 border-t border-gray-100 bg-white px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-4 sm:px-5 sm:pb-5 sm:pt-5 md:px-8",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:gap-3.5",children:[r?e.jsx(Ta,{message:r,timestamp:i}):null,e.jsx(Na,{placeholder:w("portalModalCommentPlaceholder"),value:t,onChange:j=>h(j.target.value),readOnly:c,disabled:c,rows:3,maxLength:500,className:_("min-h-[4.5rem] resize-none rounded-lg border border-gray-200 bg-white px-3 py-2.5 text-sm text-neutral-800 shadow-sm placeholder:text-neutral-400 focus-visible:border-gray-300 focus-visible:bg-white focus-visible:ring-1 focus-visible:ring-gray-400 sm:min-h-[5rem]",c&&"cursor-not-allowed opacity-60")}),e.jsx(Gr,{onClick:()=>m(),disabled:c,submitting:l,fullWidth:!0}),g?e.jsx(Ra,{chosen:a==="approved",disabled:c,onChoose:()=>x("approved"),className:"h-11 w-full justify-center"}):e.jsxs("div",{className:"flex w-full flex-row gap-2 sm:gap-3",children:[b("rejected",e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 sm:h-4 sm:w-4",strokeWidth:2}),w("reject"),"bg-red-600 text-white hover:bg-red-700 ring-1 ring-red-500/50"),b("maybe",e.jsx(os,{className:"h-3.5 w-3.5 shrink-0 sm:h-4 sm:w-4",strokeWidth:2}),w("maybe"),"bg-amber-500 text-white hover:bg-amber-600 ring-1 ring-amber-400/50"),b("approved",e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0 sm:h-4 sm:w-4",strokeWidth:2}),w("approve"),"bg-emerald-600 text-white hover:bg-emerald-700 ring-1 ring-emerald-500/50")]})]})})}function tc({open:t,onOpenChange:a,item:r,primaryImageUrl:i,galleryImages:c,attachments:l,showProductDetails:h,showProductPrices:x,showProductLinks:m,hasProductMetadata:g,priceLabel:w,roomLabel:y,approvalStatus:b,previewReadOnly:j,submitting:R,comment:L,designerReply:O,onStatusSelect:E,onCommentChange:M,onSave:C,onViewPdfInline:D,onOpenPdfNewTab:p,onDownloadPdf:fe,choiceMode:ue=!1}){const{t:te}=ae(),[Z,q]=n.useState(0),[S,le]=n.useState(!1),me=Hr(c,i),X=h&&g&&r?.product_metadata?.hasAny===!0,ce=n.useMemo(()=>me.map(ge=>({url:ge.url,caption:null})),[me]);n.useEffect(()=>{t||(q(0),le(!1))},[t,r?.id]);const A=n.useCallback(()=>{me.length>0&&le(!0)},[me.length]);return e.jsx(wr,{open:t,onOpenChange:a,children:e.jsx(yr,{hideClose:!0,overlayClassName:"bg-neutral-950/40 backdrop-blur-[3px]",className:_("flex h-[90vh] max-h-[95vh] w-[95vw] max-w-6xl flex-col overflow-hidden rounded-xl border-0 bg-white p-0 shadow-2xl","max-md:overflow-hidden max-md:overscroll-contain ipad-touch:overflow-hidden","md:h-[min(92vh,52rem)] md:max-h-[min(92vh,52rem)] md:w-[min(100vw-1.25rem,72rem)] md:rounded-2xl"),children:r?e.jsxs(e.Fragment,{children:[e.jsx(vr,{className:"sr-only",children:r.title}),e.jsx("p",{className:"sr-only",children:te("productSpecifications")}),e.jsx(bi,{className:"absolute right-3 top-3 z-50 flex h-9 w-9 items-center justify-center rounded-full bg-white/85 text-neutral-700 shadow-md backdrop-blur-md transition-colors hover:bg-white focus:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300 sm:right-4 sm:top-4","aria-label":te("dialogClose"),children:e.jsx(Ge,{className:"h-4 w-4",strokeWidth:2})}),e.jsx("div",{className:"relative h-[35vh] shrink-0 bg-neutral-50 sm:h-[40vh] md:hidden",children:e.jsx(nr,{variant:"compact",images:c,fallbackUrl:i,alt:r.title,index:Z,onIndexChange:q,onExpand:A})}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[e.jsx("div",{className:"relative hidden shrink-0 border-r border-neutral-100 bg-neutral-50/50 p-6 md:flex md:w-[46%] md:items-center lg:w-[50%] lg:p-8",children:e.jsx(nr,{images:c,fallbackUrl:i,alt:r.title,index:Z,onIndexChange:q,onExpand:A})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsx(Yl,{scrollKey:r.id,className:"p-4 pr-5 sm:p-6 sm:pr-6 md:px-8 md:pt-8",children:e.jsxs("div",{className:"space-y-4 md:space-y-5",children:[e.jsxs("header",{className:"space-y-3 pr-8",children:[e.jsx("h2",{className:"text-xl font-semibold leading-tight tracking-tight text-neutral-900 sm:text-2xl md:text-[1.65rem]",children:r.title}
12),e.jsx(Jl,{approvalStatus:b,roomLabel:y}),x&&w||m&&r.product_link?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[x&&w?e.jsx("span",{className:"text-lg font-semibold tabular-nums tracking-tight text-neutral-900",children:w}):null,m&&r.product_link?e.jsxs("a",{href:r.product_link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-neutral-500 underline-offset-2 transition-colors hover:text-neutral-800 hover:underline",children:[e.jsx(We,{className:"h-3 w-3",strokeWidth:1.75}),te("viewProductDetails")]}):null]}):null,r.description?e.jsx("p",{className:"max-w-prose whitespace-pre-wrap text-sm leading-[1.65] text-neutral-600",children:r.description}):null]}),e.jsx(Xl,{attachments:l,onViewPdfInline:D,onOpenPdfNewTab:p,onDownloadPdf:fe}),X&&r.product_metadata?e.jsx(Zl,{model:r.product_metadata}):null]})}),e.jsx(ec,{comment:L,selectedStatus:b,designerReply:O,designerReplyTimestamp:O?r.updated_at:null,previewReadOnly:j,submitting:R,onCommentChange:M,onStatusSelect:E,onSave:C,choiceMode:ue})]})]}),e.jsx(jr,{open:S,slides:ce,index:Z,onIndexChange:q,onClose:()=>le(!1),ariaLabel:te("reviewGalleryView"),imageAlt:r.title,closeButtonAriaLabel:te("dialogClose"),showSlideCounter:ce.length>1,navButtonClassName:"max-md:bg-black/55 max-md:shadow-md max-md:ring-1 max-md:ring-black/20 max-md:backdrop-blur-sm max-md:hover:bg-black/70"})]}):null})})}function sc({attachment:t,badgeStyles:a,onViewPdfInline:r,onOpenInNewTab:i,onDownloadPdf:c}){const{t:l}=ae();return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 bg-gray-50 border border-gray-100 rounded-md p-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center overflow-hidden",children:[e.jsx("div",{className:`w-6 h-6 ${a.className} rounded flex items-center justify-center text-[10px] font-semibold flex-shrink-0`,children:a.label}),e.jsx("span",{className:"ml-2 min-w-0 flex-1 truncate text-xs text-gray-700",children:t.file_name})]}),t.file_type==="application/pdf"?e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[e.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0 whitespace-nowrap px-2 text-xs",onClick:()=>r(t),children:l("viewPdf")}),e.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0 whitespace-nowrap px-2 text-xs",onClick:()=>i(t),children:[e.jsx(We,{className:"h-3 w-3 mr-1 shrink-0"}),l("openInNewTab")||"Open"]}),e.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0 whitespace-nowrap px-2 text-xs",onClick:()=>c(t),children:[e.jsx(Nr,{className:"h-3 w-3 mr-1 shrink-0"}),l("downloadPdf")]})]}):e.jsx("div",{className:"flex flex-shrink-0 items-center",children:e.jsxs(oe,{variant:"ghost",size:"sm",className:"h-7 shrink-0 whitespace-nowrap px-2 text-xs",onClick:()=>i(t),children:[e.jsx(We,{className:"h-3 w-3 mr-1 shrink-0"}),l("openInNewTab")||"Open"]})})]})}function ac({attachments:t,maxVisible:a=1,onViewAll:r,collapsible:i=!1,getBadgeStyles:c,onViewPdfInline:l,onOpenInNewTab:h,onDownloadPdf:x,className:m}){const{t:g}=ae(),[w,y]=n.useState(!1);if(t.length===0)return null;const b=i&&t.length>1,j=b&&w?t.length:Math.min(a,t.length),R=b&&!w?[]:t.slice(0,j),L=t.length-R.length;return e.jsxs("div",{className:m,children:[e.jsx(vt,{className:"text-sm font-medium text-gray-700",children:g("attachments")||"Attachments"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[b&&e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between rounded-md border border-gray-100 bg-gray-50 px-3 py-2 text-left shadow-sm transition-all duration-200 hover:border-gray-200 hover:bg-gray-100/80",onClick:()=>y(O=>!O),children:[e.jsxs("div",{className:"flex min-w-0 items-center",children:[e.jsx("div",{className:"flex h-6 min-w-6 flex-shrink-0 items-center justify-center rounded-md bg-blue-100 px-1.5 text-[10px] font-semibold text-blue-700",children:t.length}),e.jsx("span",{className:"ml-2 truncate text-xs font-medium text-gray-700",children:g("multipleAttachments")||"Multiple attachments"})]}),w?e.jsx(yi,{className:"h-4 w-4 flex-shrink-0 text-gray-500 transition-transform duration-200"}):e.jsx(_a,{className:"h-4 w-4 flex-shrink-0 text-gray-500 transition-transform duration-200"})]}),e.jsx("div",{className:`grid gap-2 overflow-hidden transition-all duration-200 ease-out ${b?w?"max-h-[32rem] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1 pointer-events-none":"max-h-[32rem] opacity-100 translate-y-0"}`,children:R.map(O=>e.jsx(sc,{attachment:O,badgeStyles:c(O),onViewPdfInline:l,onOpenInNewTab:h,onDownloadPdf:x},O.id))}),L>0&&r&&!b&&e.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-8 w-full text-xs",onClick:r,children:g("viewAllAttachments",{count:t.length,defaultValue:"View all attachments ({{count}})"})})]})]})}const rr=["brand","sku","material","finish","colour","lead_time","dimensions","supplier_name"],nc="flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-slate-200/70 bg-slate-50 p-1",rc="flex w-60 shrink-0 flex-col items-end justify-center gap-2",oc="grid grid-cols-1 items-center gap-4 lg:grid-cols-[minmax(280px,320px)_1fr_15rem] lg:gap-6",ic={rejected:"bg-red-100 font-semibold text-red-700 shadow-sm ring-1 ring-red-200/70",maybe:"bg-amber-100 font-semibold text-amber-800 shadow-sm ring-1 ring-amber-200/70",approved:"bg-emerald-100 font-semibold text-emerald-800 shadow-sm ring-1 ring-emerald-200/70"};function lc(t){const a=new Map(t.map(l=>[l.fieldId,l])),r=rr.map(l=>a.get(l)).filter(l=>!!l),i=new Set(rr),c=t.filter(l=>!i.has(l.fieldId));return[...r,...c]}function Kr({value:t,className:a,as:r="span"}){return t?e.jsxs(kr,{children:[e.jsx(Cr,{asChild:!0,children:e.jsx(r,{className:_("block min-w-0 line-clamp-2",a),title:t,children:t})}),e.jsx(Ir,{side:"top",className:"max-w-xs text-xs leading-relaxed",children:t})]}):null}function cc({label:t,value:a}){return e.jsxs("dl",{className:"min-w-0",children:[e.jsx("dt",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-400",children:t}),e.jsx(Kr,{as:"dd",value:a,className:"mt-0.5 line-clamp-3 text-[11px] font-medium leading-snug text-gray-800"})]})}function dc({value:t,onChange:a,onSave:r,readOnly:i,placeholder:c}){return e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),onBlur:()=>{i||r()},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),l.currentTarget.blur())},readOnly:i,maxLength:500,placeholder:c,className:"h-8 w-full rounded-lg border border-slate-200 bg-white px-3 text-xs text-slate-600 placeholder:text-slate-400 focus:border-slate-400 focus:outline-none focus:ring-0"})}function uc({value:t,onChange:a,onSave:r,readOnly:i,submitting:c,placeholder:l}){const{t:h}=ae(),[x,m]=n.useState(!1),g=n.useRef(null),w=x||t.trim().length>0,y=b=>{const j=b.relatedTarget;j&&g.current?.contains(j)||t.trim()||m(!1)};return e.jsxs("div",{ref:g,className:"w-full transition-all duration-200",onBlur:y,children:[e.jsx("textarea",{value:t,onChange:b=>a(b.target.value),onFocus:()=>m(!0),onClick:b=>b.stopPropagation(),readOnly:i,maxLength:500,rows:w?3:1,placeholder:l,className:_("w-full resize-none rounded-lg border border-gray-200 bg-white px-3 text-[12px] text-gray-600 shadow-sm transition-all duration-200 placeholder:text-gray-400 focus:border-gray-300 focus:bg-white focus:outline-none focus:ring-1 focus:ring-gray-400",w?"py-2 leading-relaxed":"overflow-hidden py-1.5 leading-snug")}),e.jsx("div",{className:_("overflow-hidden transition-all duration-200",w?"mt-2 max-h-12 opacity-100":"max-h-0 opacity-0"),children:e.jsx(Gr,{onClick:b=>{b.stopPropagation(),r()},disabled:i,submitting:c,fullWidth:!0})})]})}function mc({status:t}){const{t:a}
12=ae(),r=t?{approved:{label:a("approved"),dot:"bg-emerald-500",text:"text-emerald-700"},rejected:{label:a("rejected"),dot:"bg-red-500",text:"text-red-600"},maybe:{label:a("maybe"),dot:"bg-amber-500",text:"text-amber-700"}}[t]:{label:a("pending"),dot:"bg-gray-300",text:"text-gray-500"};return e.jsxs("span",{className:_("inline-flex items-center gap-1.5 text-[11px] font-medium",r.text),children:[e.jsx("span",{className:_("h-1.5 w-1.5 shrink-0 rounded-full",r.dot),"aria-hidden":!0}),r.label]})}function pc({label:t}){return e.jsx("span",{className:"inline-flex w-fit items-center rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-medium tracking-wide text-gray-700",children:t})}function hc({primaryImageUrl:t,isPdfPrimary:a,attachments:r,galleryImageCount:i,alt:c,onOpenGallery:l,onViewPdfInline:h,onOpenPdfNewTab:x,onDownloadPdf:m}){const{t:g}=ae();let w;return t&&!a?w=e.jsxs("button",{type:"button",onClick:y=>{y.stopPropagation(),l()},className:"group relative flex h-full w-full cursor-pointer items-center justify-center overflow-hidden","aria-label":g("reviewGalleryView"),children:[e.jsx(_r,{disablePreview:!0,src:t,alt:c,className:"pointer-events-none max-h-full max-w-full object-contain"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/25",children:e.jsx(Sr,{className:"h-5 w-5 text-white opacity-0 drop-shadow-sm transition-opacity group-hover:opacity-100"})})]}):a?w=e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(Fr,{className:"scale-90 p-0",onView:()=>{const y=r.find(b=>b.file_type==="application/pdf");y&&h(y)},onOpenNewTab:()=>{const y=r.find(b=>b.file_type==="application/pdf");y&&x(y)},onDownload:()=>{const y=r.find(b=>b.file_type==="application/pdf");y&&m(y)}})}):w=e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs text-gray-300","aria-hidden":!0,children:"—"}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:nc,children:w}),e.jsx(ja,{count:i,compact:!0})]})}function fc({item:t,primaryImageUrl:a,galleryImages:r,attachments:i,isHighlighted:c,showProductPrices:l,showProductLinks:h,showDetailsButton:x,previewReadOnly:m,submitting:g,selectedStatus:w,comment:y,priceDisplay:b,roomLabel:j,designerReply:R,isPdfPrimary:L,onOpenGallery:O,onOpenDetails:E,onStatusSelect:M,onCommentChange:C,onSave:D,onViewPdfInline:p,onOpenPdfNewTab:fe,onDownloadPdf:ue,choiceMode:te=!1}){const{t:Z}=ae(),q=te&&w==="approved",S=x?E:O,le=()=>{m||M("approved")},me=x&&t.product_metadata?.hasAny?lc(t.product_metadata.fields):[],X=i.filter(A=>!(A.file_type||"").startsWith("image/")),ce=(A,ge,ke)=>e.jsxs("button",{type:"button",disabled:m,onClick:pe=>{pe.stopPropagation(),M(A)},title:ke,"aria-label":ke,"aria-pressed":w===A,className:_("inline-flex flex-1 items-center justify-center gap-1 rounded-md px-1.5 py-1.5 text-[11px] font-medium transition-all duration-150",w===A?ic[A]:"text-gray-500 hover:bg-white hover:text-gray-900"),children:[ge,e.jsx("span",{className:"hidden sm:inline",children:ke})]});return e.jsxs("article",{"data-portal-review-item-id":t.id,onClick:A=>{const ge=A.target;if(!(va(ge)||window.getSelection()?.toString())){if(te){le();return}S()}},onKeyDown:A=>{if(A.target===A.currentTarget&&(A.key==="Enter"||A.key===" ")){if(A.preventDefault(),te){le();return}S()}},role:te?void 0:"button",tabIndex:te?void 0:0,"aria-label":te?void 0:Z(x?"portalCardQuickPreview":"reviewGalleryView"),className:_("cursor-pointer border-b border-slate-100 bg-white last:border-b-0 transition-colors",te?_("px-6 py-2.5 hover:bg-slate-50/50",q&&"bg-emerald-50/30 shadow-[inset_3px_0_0_0_#10b981] hover:bg-emerald-50/30",c&&!q&&"bg-indigo-50/40"):_("px-6 py-4 hover:bg-slate-50/50",c&&"bg-amber-50/40 hover:bg-amber-50/50")),children:[e.jsxs("div",{className:oc,children:[e.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-3.5",children:[e.jsx(hc,{primaryImageUrl:a,isPdfPrimary:L,attachments:i,galleryImageCount:Math.max(r.length,i.filter(A=>(A.file_type||"").startsWith("image/")).length),alt:t.title,onOpenGallery:S,onViewPdfInline:p,onOpenPdfNewTab:fe,onDownloadPdf:ue}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-1.5",children:[x?e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),E()},className:"block w-full min-w-0 text-left",children:e.jsx("span",{className:"block line-clamp-2 text-[14px] font-semibold leading-snug text-gray-900 transition-colors hover:text-gray-700",title:t.title,children:t.title})}):e.jsx(Kr,{as:"p",value:t.title,className:"text-[14px] font-semibold leading-snug text-gray-900"}),j?e.jsx(pc,{label:j}):null,l&&b?e.jsxs("p",{className:"text-[13px] font-medium tabular-nums text-gray-700",children:[b.currency," ",b.amount]}):null,h&&t.product_link?e.jsxs("a",{href:t.product_link,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.stopPropagation(),className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-gray-400 underline-offset-2 transition-colors hover:text-gray-600 hover:underline",title:Z("viewProductDetails"),children:[e.jsx(We,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:Z("viewProductDetails")})]}):null]})]}),me.length>0?e.jsx("div",{className:"grid min-w-0 grid-cols-2 gap-x-6 gap-y-4 self-center sm:grid-cols-4",children:me.map(A=>e.jsx(cc,{label:zr(A.fieldId,A.label,Z),value:A.displayValue},A.fieldId))}):e.jsx("div",{className:"hidden min-w-0 lg:block"}),e.jsxs("div",{className:_(rc,"self-center lg:self-auto",te?"items-end":"items-stretch"),children:[te?e.jsx(Ra,{compact:!0,chosen:q,disabled:m,onChoose:le}):e.jsx("div",{className:"flex justify-end",children:e.jsx(mc,{status:w})}),te?null:e.jsxs("div",{className:"flex w-full items-stretch gap-0.5 rounded-lg border border-gray-200 bg-gray-50/80 p-1 shadow-sm",children:[ce("rejected",e.jsx(Ge,{className:"h-3.5 w-3.5"}),Z("reject")),ce("maybe",e.jsx(os,{className:"h-3.5 w-3.5"}),Z("maybe")),ce("approved",e.jsx(Nt,{className:"h-3.5 w-3.5"}),Z("approve"))]}),R?e.jsx("div",{"data-portal-interactive":!0,className:"w-full",onClick:A=>A.stopPropagation(),children:e.jsx(Ta,{message:R,timestamp:t.updated_at,compact:!0,className:"w-full"})}):null,te?e.jsx(dc,{value:y,onChange:C,onSave:D,readOnly:m,placeholder:Z("addCommentOptional")}):e.jsx(uc,{value:y,onChange:C,onSave:D,readOnly:m,submitting:g,placeholder:Z("addCommentOptional")})]})]}),X.length>0?e.jsx("div",{className:"mt-2.5 flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 text-[10px] text-gray-400",onClick:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation(),children:X.map(A=>e.jsx("button",{type:"button",onClick:()=>A.file_type==="application/pdf"?p(A):fe(A),className:"max-w-[180px] truncate hover:text-gray-600 hover:underline",title:A.file_name,children:A.file_name},A.id))}):null]})}function xc({status:t}){const{t:a}=ae();return t?e.jsxs("span",{className:_("inline-flex items-center rounded-full px-3 py-1.5 text-sm font-medium shadow-md",t==="approved"?"bg-green-500 text-white":t==="rejected"?"bg-red-500 text-white":"bg-amber-500 text-white"),children:[t==="approved"&&e.jsx(Or,{className:"mr-1 h-4 w-4"}),t==="rejected"&&e.jsx(Wr,{className:"mr-1 h-4 w-4"}),t==="maybe"&&e.jsx(os,{className:"mr-1 h-4 w-4"}),a(t)]}):e.jsxs("span",{className:"inline-flex items-center rounded-full bg-gray-500 px-3 py-1.5 text-sm font-medium text-white shadow-md",children:[e.jsx(Pr,{className:"mr-1 h-4 w-4"}),a("pending")]})}function gc(t){const{t:a}=ae(),{item:r,viewMode:i,primaryImageUrl:c,galleryImages:l,attachments:h,isHighlighted:x,hasVisibleCommerceDetails:m,showProductPrices:g,showProductLinks:w,showDetail
12sButton:y,previewReadOnly:b,submitting:j,selectedStatus:R,comment:L,priceDisplay:O,roomLabel:E,designerReply:M,hasPortalGallery:C,isPdfPrimary:D,onOpenGallery:p,onOpenDetails:fe,onStatusSelect:ue,onCommentChange:te,onSave:Z,onViewPdfInline:q,onOpenPdfNewTab:S,onDownloadPdf:le,getAttachmentBadgeStyles:me,choiceMode:X=!1}=t,ce=i==="list",A=y?fe:p,ge=X&&R==="approved",ke=()=>{b||ue("approved")},pe=P=>{!X||b||va(P.target)||window.getSelection()?.toString()||ke()},we=P=>{!X||b||va(P.target)||P.key!=="Enter"&&P.key!==" "||(P.preventDefault(),ke())},B=X?e.jsx(Ra,{chosen:ge,disabled:b,onChoose:ke}):null,Y=(P,H,je,$)=>e.jsxs(oe,{variant:"outline",size:"sm",className:_("h-12 w-full border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 sm:h-10 sm:flex-1 sm:text-sm",R===P&&$),disabled:b,onClick:()=>ue(P),children:[H,e.jsx("span",{children:je})]});return e.jsxs("div",{"data-portal-review-item-id":r.id,onClick:pe,onKeyDown:we,role:X?"button":void 0,tabIndex:X&&!b?0:void 0,"aria-disabled":X&&b?!0:void 0,"aria-label":X?`${a("reviewSelectOption")}: ${r.title}`:void 0,className:_(X?_("relative flex h-full select-none flex-col overflow-hidden rounded-2xl border-2 transition-all duration-200",b?"cursor-default":"cursor-pointer",ge?"border-emerald-500 bg-emerald-500/[0.02] shadow-sm":"border-slate-200/80 bg-white hover:border-slate-300"):_("flex h-full flex-col overflow-hidden rounded-lg border bg-white transition-all hover:shadow-md",!m&&"ring-1 ring-gray-100"),ce&&"sm:flex-row",x&&"bg-red-50/30 shadow-md ring-2 ring-red-200"),children:[e.jsxs("div",{className:_("relative flex aspect-square shrink-0 items-center justify-center bg-gray-50",ce&&"sm:w-1/3",!m&&"bg-gradient-to-br from-gray-50 to-blue-50"),children:[c&&!D?e.jsxs("button",{type:"button",onClick:P=>{P.stopPropagation(),A()},className:"group relative h-full w-full cursor-pointer overflow-hidden","aria-label":a(y?"portalCardQuickPreview":"reviewGalleryView"),children:[e.jsx("div",{className:"h-full w-full transition-transform duration-300 ease-out group-hover:scale-105",children:e.jsx(_r,{disablePreview:!0,src:c,alt:r.title,className:"pointer-events-none h-full w-full object-contain"})}),y?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 z-10 flex justify-center opacity-0 transition-opacity duration-200 group-hover:opacity-100",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/40 bg-white/85 px-3 py-1.5 text-xs font-medium text-neutral-700 shadow-sm backdrop-blur-md",children:[e.jsx(Vr,{className:"h-3.5 w-3.5 shrink-0",strokeWidth:2}),a("portalCardQuickPreview")]})}):e.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/15",children:e.jsx(Sr,{className:"h-8 w-8 text-white opacity-0 transition-opacity group-hover:opacity-100"})})]}):D?e.jsx("div",{"data-portal-interactive":!0,onClick:P=>P.stopPropagation(),className:"p-4",children:e.jsx(Fr,{onView:()=>{const P=h.find(H=>H.file_type==="application/pdf");P&&q(P)},onOpenNewTab:()=>{const P=h.find(H=>H.file_type==="application/pdf");P&&S(P)},onDownload:()=>{const P=h.find(H=>H.file_type==="application/pdf");P&&le(P)}})}):e.jsx("div",{className:"text-center text-gray-400",children:e.jsx("p",{className:"text-sm",children:a("noImage")})}),e.jsx(ja,{count:l.length}),X&&!ce?e.jsx("div",{className:"absolute right-3 top-3 z-20",children:B}):X?null:e.jsx("div",{className:"absolute right-2 top-2 z-30",children:e.jsx(xc,{status:R})})]}),e.jsxs("div",{className:_("flex flex-1 flex-col p-6",ce&&"sm:w-2/3 sm:flex-1"),children:[e.jsxs("div",{className:_("mb-4",ce&&X&&"flex items-start justify-between gap-3"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[y?e.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),fe()},className:"mb-2 block w-full text-left text-lg font-medium text-gray-900 transition-colors hover:text-gray-700",children:r.title}):e.jsx("h3",{className:"mb-2 text-lg font-medium text-gray-900",children:r.title}),r.description?e.jsx("p",{className:"mb-2 line-clamp-3 text-sm text-gray-600",children:r.description}):null,E?e.jsx("p",{className:"inline-block rounded-full bg-gray-100 px-2 py-1 text-xs text-gray-500",children:E}):null]}),X&&ce?e.jsx("div",{className:"shrink-0 pt-0.5",children:B}):null]}),g&&O||w&&r.product_link?e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-4 text-sm",children:[g&&O?e.jsxs("span",{className:"font-semibold tabular-nums text-green-600",children:[O.currency," ",O.amount]}):null,w&&r.product_link?e.jsxs("a",{href:r.product_link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-neutral-500 underline-offset-2 transition-colors hover:text-neutral-800 hover:underline",onClick:P=>P.stopPropagation(),children:[e.jsx(We,{className:"h-3 w-3 shrink-0"}),a("viewProductDetails")]}):null]}):null,h.length>0&&c&&!D?e.jsx("div",{"data-portal-interactive":!0,onClick:P=>P.stopPropagation(),children:e.jsx(ac,{className:"mb-4",attachments:h,maxVisible:1,collapsible:C,getBadgeStyles:me,onViewPdfInline:q,onOpenInNewTab:S,onDownloadPdf:le})}):null,X?null:e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row",children:[Y("rejected",e.jsx(Ge,{className:"mr-1 h-4 w-4"}),a("reject"),"border-red-600 bg-red-600 text-white hover:bg-red-700 hover:text-white"),Y("maybe",e.jsx(os,{className:"mr-1 h-4 w-4"}),a("maybe"),"border-amber-500 bg-amber-500 text-white hover:bg-amber-600 hover:text-white"),Y("approved",e.jsx(Nt,{className:"mr-1 h-4 w-4"}),a("approve"),"border-emerald-600 bg-emerald-600 text-white hover:bg-emerald-700 hover:text-white")]}),M?e.jsx("div",{"data-portal-interactive":!0,onMouseDown:P=>P.stopPropagation(),onClick:P=>P.stopPropagation(),children:e.jsx(Ta,{message:M,className:"mb-3"})}):null,e.jsxs("div",{className:"mt-auto",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Na,{placeholder:a("addCommentOptional"),value:L,onChange:P=>te(P.target.value),onMouseDown:P=>P.stopPropagation(),onClick:P=>P.stopPropagation(),readOnly:b,className:"text-xs",rows:3,maxLength:500})}),R?e.jsx("div",{className:"flex justify-end",children:e.jsx(oe,{size:"sm",onClick:P=>{P.stopPropagation(),Z()},disabled:b,className:"h-12 text-base sm:h-10 sm:text-sm",children:a(j?"saving":"save")})}):null]})]})]})}
12function bc(t){return t.viewMode==="detailed"?e.jsx(fc,{item:t.item,primaryImageUrl:t.primaryImageUrl,galleryImages:t.galleryImages,attachments:t.attachments,isHighlighted:t.isHighlighted,hasVisibleCommerceDetails:t.hasVisibleCommerceDetails,showProductPrices:t.showProductPrices,showProductLinks:t.showProductLinks,showDetailsButton:t.showDetailsButton,previewReadOnly:t.previewReadOnly,submitting:t.submitting,selectedStatus:t.selectedStatus,comment:t.comment,priceDisplay:t.priceDisplay,roomLabel:t.roomLabel,designerReply:t.designerReply,hasPortalGallery:t.hasPortalGallery,isPdfPrimary:t.isPdfPrimary,onOpenGallery:t.onOpenGallery,onOpenDetails:t.onOpenDetails,onStatusSelect:t.onStatusSelect,onCommentChange:t.onCommentChange,onSave:t.onSave,onViewPdfInline:t.onViewPdfInline,onOpenPdfNewTab:t.onOpenPdfNewTab,onDownloadPdf:t.onDownloadPdf,getAttachmentBadgeStyles:t.getAttachmentBadgeStyles,choiceMode:t.choiceMode}):e.jsx(gc,{...t})}const da="__all__",wc=6;function yc(t,a){return`${typeof t.label=="string"?t.label:t.keywords??t.value} ${t.keywords??""} ${t.value}`.toLowerCase().includes(a)}function vc({sections:t,selectedSections:a,onSectionsChange:r,getSectionLabel:i,className:c}){const{t:l}=ae("common",{useSuspense:!1}),[h,x]=n.useState(!1),[m,g]=n.useState(""),w=n.useRef(null),y=n.useRef(null),b=n.useMemo(()=>t.map(M=>({value:M,label:i(M)})),[t,i]),j=vi({mode:"multi",value:a,onChange:M=>r(M),options:b,defaultValue:[]}),R=n.useMemo(()=>{const M=m.trim().toLowerCase();return M?b.filter(C=>yc(C,M)):b},[b,m]),L=n.useMemo(()=>a.length===0?l("allSections"):a.length===1?i(a[0]):`${a.length} ${l("sections")??"sections"}`,[i,a,l]),O=M=>{x(M),M||g("")},E=M=>{j.selectOnly(M),x(!1),g("")};return e.jsx("div",{className:_("relative min-w-0",c),children:e.jsxs(Tr,{open:h,onOpenChange:O,children:[e.jsx(Rr,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":h,"aria-label":l("filterBySection"),title:L,className:_("relative flex h-10 min-w-0 items-center justify-between gap-2 rounded-lg border px-2.5 text-sm font-medium shadow-sm transition-colors sm:px-3 lg:min-w-[200px] lg:px-3.5 xl:min-w-[220px]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-900/10",j.isActive?"border-blue-200 bg-blue-50/40 text-gray-900 hover:bg-blue-50/70":"border-gray-200 bg-white text-gray-700 hover:bg-gray-50"),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pr-4 sm:gap-2 sm:pr-5",children:[e.jsx(ji,{className:"h-4 w-4 shrink-0 text-gray-500","aria-hidden":!0}),e.jsx("span",{className:"max-w-[5.5rem] truncate sm:max-w-[7rem] lg:max-w-[9rem] xl:max-w-none",children:L})]}),e.jsx(_a,{className:"h-4 w-4 shrink-0 text-gray-400","aria-hidden":!0}),e.jsx(Ni,{count:j.activeCount})]})}),e.jsxs(Er,{align:"start",side:"bottom",sideOffset:8,collisionPadding:16,className:"z-[1000] w-72 overflow-hidden rounded-xl border border-gray-100 bg-white p-0 shadow-xl",onOpenAutoFocus:M=>{M.preventDefault(),w.current?.focus({preventScroll:!0})},onWheelCapture:M=>M.stopPropagation(),children:[e.jsx("div",{className:"border-b border-gray-100 px-3 py-2.5",children:e.jsx("p",{className:"text-sm font-medium text-gray-900",children:l("filterBySection")})}),e.jsx("div",{className:"border-b border-gray-100 px-2.5 py-2",children:e.jsx(_i,{ref:w,value:m,onChange:g,placeholder:l("searchRoom")||"Search room...",className:"[&_input]:h-9 [&_input]:rounded-lg [&_input]:border [&_input]:border-gray-200 [&_input]:bg-gray-50 [&_input]:focus-visible:bg-gray-50 [&_input]:focus-visible:ring-1 [&_input]:focus-visible:ring-gray-900"})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-100 px-3 py-2 text-xs",children:[e.jsx("button",{type:"button",className:"font-medium text-blue-600 transition-colors hover:text-blue-700 hover:underline",onClick:()=>j.selectAll(),children:l("filterSelectAll")??"Select all"}),e.jsx("button",{type:"button",className:"text-gray-500 transition-colors hover:text-gray-800 hover:underline",onClick:()=>j.clear(),children:l("filterClearAll")??"Clear all"})]}),e.jsx("div",{ref:y,className:"max-h-60 overflow-y-auto overscroll-contain p-1.5 [scrollbar-gutter:stable]",role:"listbox","aria-label":l("filterBySection"),"aria-multiselectable":!0,children:R.length===0?e.jsx("p",{className:"px-2 py-6 text-center text-sm text-gray-500",children:l("noResultsFound")??"No results found."}):R.map(M=>e.jsx(Si,{option:M,mode:"multi",selected:j.isSelected(M.value),onToggle:j.toggle,onSelectOnly:E,showOnly:!0},M.value))})]})]})})}function jc({sections:t,selectedSections:a,onSectionsChange:r,getSectionLabel:i,className:c}){const{t:l}=ae("common",{useSuspense:!1}),[h,x]=n.useState(!1),g=(a.length===1?a[0]:null)??da,w=t.length>=wc,y=n.useMemo(()=>[{value:da,label:l("allSections")},...t.map(j=>({value:j,label:i(j)}))],[i,t,l]),b=y.find(j=>j.value===g)?.label??l("allSections");return e.jsx("div",{className:_("w-full min-w-0",c),children:e.jsxs(Tr,{open:h,onOpenChange:x,children:[e.jsx(Rr,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":h,"aria-label":l("filterBySection"),title:b,className:_("flex h-12 w-full min-w-0 items-center justify-between gap-2 rounded-md border border-gray-200 bg-white px-3 text-sm font-normal text-gray-900 shadow-sm transition-colors touch-manipulation","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-900/10 focus-visible:ring-offset-2",h&&"border-gray-300 ring-2 ring-gray-900/10 ring-offset-2"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:b}),e.jsx(_a,{className:"h-4 w-4 shrink-0 text-gray-500 opacity-70","aria-hidden":!0})]})}
12),e.jsx(Er,{align:"start",side:"bottom",sideOffset:6,collisionPadding:16,className:"z-[1000] w-[var(--radix-popover-trigger-width)] min-w-0 max-w-[calc(100vw-2rem)] overflow-hidden rounded-xl border border-gray-100 bg-white p-0 shadow-lg",onOpenAutoFocus:j=>{if(!w)return;j.preventDefault(),j.currentTarget.querySelector("input")?.focus()},onWheelCapture:j=>j.stopPropagation(),children:e.jsxs(ki,{className:"max-w-full",children:[w?e.jsx(Ci,{placeholder:l("searchRoom")||"Search room..."}):null,e.jsxs(Ii,{className:_("overflow-y-auto overflow-x-hidden",w?"max-h-60":"max-h-72"),children:[e.jsx(Pi,{children:"No results found."}),e.jsx(Ti,{children:y.map(j=>e.jsxs(Ri,{value:`${j.label} ${j.value}`,className:"min-w-0 gap-2 rounded-md",onSelect:()=>{r(j.value===da?[]:[j.value]),x(!1)},children:[e.jsx(Nt,{className:_("h-4 w-4 shrink-0 text-gray-900",g===j.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"min-w-0 flex-1 truncate",title:j.label,children:j.label})]},j.value))})]})]})})]})})}function or({variant:t="mobile",...a}){return t==="desktop"?e.jsx(vc,{...a}):e.jsx(jc,{...a})}function ir({id:t,value:a,onChange:r,inputRef:i,showShortcut:c,className:l,autoFocus:h}){const{t:x}=ae("common",{useSuspense:!1});return e.jsxs(e.Fragment,{children:[e.jsx(Sa,{className:"h-4 w-4 shrink-0 text-gray-400","aria-hidden":!0}),e.jsx("input",{ref:i,id:t,type:"search",value:a,onChange:m=>r(m.target.value),placeholder:x("portalItemsSearchPlaceholder")||"Search item, SKU, vendor...",autoComplete:"off",autoCorrect:"off",spellCheck:!1,autoFocus:h,className:_("min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-0",l)}),c&&!a.trim()?e.jsx("kbd",{className:"hidden shrink-0 rounded border border-gray-200 bg-gray-50 px-1.5 py-0.5 font-sans text-[10px] font-medium text-gray-400 xl:inline",children:"/"}):null]})}function lr({value:t,onChange:a,className:r,expanded:i=!1,onExpandedChange:c,variant:l="icon"}){const{t:h}=ae("common",{useSuspense:!1}),x=n.useRef(null),m=t.trim().length>0,g=h("portalItemsSearchPlaceholder")||"Search item, SKU, vendor...";n.useEffect(()=>{if(l!=="icon"&&l!=="inline")return;const b=j=>{if(j.key!=="/"||j.metaKey||j.ctrlKey||j.altKey)return;const R=j.target;if(!(R instanceof HTMLElement&&R.closest('input, textarea, select, [contenteditable="true"]'))){if(j.preventDefault(),l==="icon"){c?.(!0);return}x.current?.focus()}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[c,l]),n.useEffect(()=>{if(l!=="expanded-row"||!i)return;const b=requestAnimationFrame(()=>x.current?.focus());return()=>cancelAnimationFrame(b)},[i,l]);const w=()=>{a(""),c?.(!1)};if(l==="inline")return e.jsxs("div",{className:_("w-64 max-w-xs shrink-0",r),children:[e.jsx("label",{className:"sr-only",htmlFor:"portal-items-search",children:g}),e.jsx("div",{className:_("flex h-10 items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm shadow-sm transition-colors","hover:border-gray-300 focus-within:border-gray-900 focus-within:ring-1 focus-within:ring-gray-900"),children:e.jsx(ir,{id:"portal-items-search",value:t,onChange:a,inputRef:x,showShortcut:!0})})]});if(l==="expanded-row")return!i&&!m?null:e.jsxs("div",{className:_("w-full border-t border-gray-100 px-3 pb-2.5 pt-2 lg:px-4",r),children:[e.jsx("label",{className:"sr-only",htmlFor:"portal-items-search-expanded",children:g}),e.jsxs("div",{className:_("flex h-10 w-full items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm shadow-sm transition-colors","hover:border-gray-300 focus-within:border-gray-900 focus-within:ring-1 focus-within:ring-gray-900",m&&"border-blue-200"),children:[e.jsx(ir,{id:"portal-items-search-expanded",value:t,onChange:a,inputRef:x,showShortcut:!0,autoFocus:!0}),e.jsx("button",{type:"button",onClick:w,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600","aria-label":h("close")||"Close",children:e.jsx(Ge,{className:"h-4 w-4"})})]})]});const y=i||m;return e.jsxs("button",{type:"button",onClick:()=>
12{if(y){w();return}c?.(!0)},className:_("relative inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-gray-200 bg-white text-gray-500 shadow-sm transition-colors","hover:border-gray-300 hover:bg-gray-50 hover:text-gray-700",y&&"border-blue-200 text-gray-700",r),"aria-label":g,title:g,"aria-expanded":y,children:[e.jsx(Sa,{className:"h-4 w-4"}),m?e.jsx("span",{className:"absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-blue-500","aria-hidden":!0}):null]})}const Nc=2e4,_c=15e3;function Sc(t){const{portalSessionToken:a,enabled:r=!0,isPreviewReadOnly:i=!1}=t,[c,l]=n.useState(Ar()),[h,x]=n.useState([]),[m,g]=n.useState(!1),w=n.useRef(!0);n.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const y=n.useCallback(async()=>{if(!(!a||!r))try{const[E,M]=await Promise.all([Un(a),Ei(a)]);if(!w.current)return;E&&"unread"in E&&l(E),M&&"items"in M&&x(M.items)}catch(E){console.warn("[usePortalWhatsNew] refetch failed",E)}},[a,r]),b=n.useCallback(async()=>{if(!(!a||!r))try{const E=await Un(a);if(!w.current)return;E&&"unread"in E&&l(E)}catch(E){console.warn("[usePortalWhatsNew] refetchCounts failed",E)}},[a,r]);n.useEffect(()=>{!a||!r||y()},[a,r,y]),n.useEffect(()=>{!m||!a||!r||y()},[m,a,r,y]),n.useEffect(()=>{if(!a||!r)return;const E=()=>{if(document.visibilityState==="visible"){if(m){y();return}b()}};return window.addEventListener("focus",E),document.addEventListener("visibilitychange",E),()=>{window.removeEventListener("focus",E),document.removeEventListener("visibilitychange",E)}},[a,r,m,y,b]),n.useEffect(()=>{if(!a||!r)return;const E=m?_c:Nc,M=window.setInterval(()=>{if(document.visibilityState==="visible"){if(m){y();return}b()}},E);return()=>window.clearInterval(M)},[a,r,m,y,b]);const j=n.useCallback(async E=>{if(!(!a||i||E.length===0))try{x(M=>M.map(C=>E.includes(C.id)?{...C,unread:!1}:C)),await Ai(a,E),await b()}catch(M){console.warn("[usePortalWhatsNew] markRead failed",M)}},[a,i,b]),R=n.useCallback(async()=>{if(!(!a||i))try{x(E=>E.map(M=>({...M,unread:!1}))),await Di(a),await b()}catch(E){console.warn("[usePortalWhatsNew] markAllRead failed",E)}},[a,i,b]),L=n.useCallback(()=>g(!0),[]),O=n.useCallback(()=>g(!1),[]);return{counts:c,items:h,drawerOpen:m,openDrawer:L,closeDrawer:O,refetch:y,refetchCounts:b,markRead:j,markAllRead:R}}function cr(t){return typeof t=="string"?t.trim():""}function kc(t){const a=cr(t.displayMetadata.title);if(a)return a;const r=cr(t.displayMetadata.name);return r||""}function Cc(t){if(typeof t!="string"||!t.trim())return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a}function Ic(t,a){const r=kc(t);switch(t.eventType){case"item_added_to_portal":return String(r?a("portalWhatsNew.item_added_to_portal",{title:r}):a("portalWhatsNew.item_added_to_portal_generic"));case"selection_group_added":return String(r?a("portalWhatsNew.selection_group_added",{name:r}):a("portalWhatsNew.selection_group_added",{name:""}));case"item_designer_reply":return String(r?a("portalWhatsNew.item_designer_reply",{title:r}):a("portalWhatsNew.item_designer_reply_generic"));case"inspiration_added":return String(r?a("portalWhatsNew.inspiration_added",{title:r}):a("portalWhatsNew.inspiration_added_generic"));case"inspiration_designer_note":return String(r?a("portalWhatsNew.inspiration_designer_note",{title:r}):a("portalWhatsNew.inspiration_designer_note_generic"));case"inspiration_designer_reply":return String(r?a("portalWhatsNew.inspiration_designer_reply",{title:r}):a("portalWhatsNew.inspiration_designer_reply_generic"));case"creation_shared":return String(r?a("portalWhatsNew.creation_shared",{title:r}):a("portalWhatsNew.creation_shared_generic"));case"creation_designer_comment":return String(a("portalWhatsNew.creation_designer_comment"));case"creation_designer_reply":return String(a("portalWhatsNew.creation_designer_reply"));case"creation_designer_comment_updated":return String(a("portalWhatsNew.creation_designer_comment_updated"));case"schedule_stage_added":return String(r?a("portalWhatsNew.schedule_stage_added",{title:r}):a("portalWhatsNew.schedule_stage_added_generic"));case"proposal_sent":return String(r?a("portalWhatsNew.proposal_sent",{title:r}):a("portalWhatsNew.proposal_sent_generic"));case"proposal_version_added":{const i=typeof t.displayMetadata.version_number=="number"?t.displayMetadata.version_number:null;return r&&i!=null?String(a("portalWhatsNew.proposal_version_added",{title:r,version:i})):String(r?a("portalWhatsNew.proposal_version_added_title",{title:r}):a("portalWhatsNew.proposal_version_added_generic"))}case"proposal_designer_comment":return String(a("portalWhatsNew.proposal_designer_comment"));case"proposal_designer_reply":return String(a("portalWhatsNew.proposal_designer_reply"));case"document_added":return String(r?a("portalWhatsNew.document_added",{title:r}):a("portalWhatsNew.document_added_generic"));case"document_designer_comment":return String(a("portalWhatsNew.document_designer_comment"));case"document_designer_reply":return String(a("portalWhatsNew.document_designer_reply"));case"document_designer_comment_updated":return String(a("portalWhatsNew.document_designer_comment_updated"));case"contact_added":return String(r?a("portalWhatsNew.contact_added",{name:r}):a("portalWhatsNew.contact_added_generic"));case"portal_module_enabled":return String(a(`portalWhatsNew.portal_module_enabled.${t.module}.title`));default:return String(a("portalWhatsNew.generic_update"))}}function Pc(t,a){if(t.eventType==="schedule_stage_added"){const i=Cc(t.displayMetadata.start_date);return i?String(a("portalWhatsNew.schedule_stage_added_subtitle",{date:ka(i,"PP")})):null}if(t.eventType==="selection_group_added"){const i=typeof t.displayMetadata.member_count=="number"?t.displayMetadata.member_count:0;return i<=0?null:String(a("portalWhatsNew.selection_group_added_subtitle",{count:i}))}if(t.eventType!=="portal_module_enabled")return null;const r=typeof t.displayMetadata.existing_item_count=="number"?t.displayMetadata.existing_item_count:0;return r<=0?null:String(a(`portalWhatsNew.portal_module_enabled.${t.module}.subtitle`,{count:r}))}function Tc(t,a){switch(t){case"items":return String(a("items"));case"inspirations":return String(a("inspirations"));case"creations":return String(a("canvasCreations"));case"schedule":return String(a("schedule")||"Schedule");case"proposals":return String(a("proposal"));case"documents":return String(a("documents")||"Documents");case"contacts":return String(a("portalContacts.module_label")||"Contacts");default:return t}}function Rc(t){return t>99?"99+":String(t)}function qr({count:t,size:a="sm",className:r}){if(t<=0)return null;const i=Rc(t);return e.jsx("span",{"aria-label":`${t} unread updates`,className:_(a==="sm"&&"inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-[5px] text-[10px] font-bold leading-none tabular-nums bg-red-500 text-white",r),children:e.jsx("span",{className:"block translate-y-[-0.5px]",children:i})})}function dr(t,a){for(const r of a){const i=t[r];
12if(typeof i=="string"&&i.trim())return i.trim()}return""}function Ec(t){return/comment|reply|note/.test(t)}function Ac(t){switch(t){case"items":return ba;case"inspirations":return We;case"creations":return ga;case"schedule":return xa;case"proposals":return ns;case"documents":return fa;case"contacts":return Lr;default:return Ca}}const Dc=900*1e3,Lc=new Set(["inspirations","documents"]);function Yr(t,a){const r=[],i=new Set;for(const c of[...t||[],...a||[]])!c?.id||i.has(c.id)||(i.add(c.id),r.push(c));return r}function Mc(t,a){if(t.type!=="comment"||a.type!=="item"||t.isRead!==a.isRead)return!1;const r=t.module||a.module;if(!r||!Lc.has(r)||(a.module||r)!==r)return!1;const i=t.targetId??t.primaryItem?.targetId??t.sourceItem?.targetId??null,c=a.targetId??a.primaryItem?.targetId??a.sourceItem?.targetId??null;if(!i||i!==c)return!1;const l=new Date(t.timestamp).getTime(),h=new Date(a.timestamp).getTime();return!Number.isFinite(l)||!Number.isFinite(h)?!1:l>=h&&l-h<=Dc}function Qr(t){const a=[...t].sort((i,c)=>new Date(c.timestamp).getTime()-new Date(i.timestamp).getTime()),r=[];for(let i=0;i<a.length;i+=1){const c=a[i],l=a[i+1];if(l&&Mc(c,l)){r.push({...c,type:l.type,title:l.title,sourceItems:Yr(c.sourceItems||(c.primaryItem?[c.primaryItem]:c.sourceItem?[c.sourceItem]:[]),l.sourceItems||(l.primaryItem?[l.primaryItem]:l.sourceItem?[l.sourceItem]:[])),subtitle:l.subtitle||null}),i+=1;continue}r.push(c)}return r}function Xr(t){return t.eventType||t.primaryItem?.eventType||t.sourceItem?.eventType||""}function Fc(t,a){const r=Xr(t),i=t.primaryItem||t.sourceItem,c=i?.displayMetadata||{};if(r==="selection_group_added"){if(typeof c.group_id=="string"&&c.group_id)return c.group_id;const h=i?.secondaryTargetId;if(typeof h=="string"&&h)return h}if(r!=="item_added_to_portal")return null;const l=t.targetId??i?.targetId??null;return l?$r(a,l):null}function Jr(t,a,r,i){if(a.length===0&&r.length===0)return t;const c=new Map(a.map(m=>[m.id,m])),l=new Map,h=[];for(const m of t){const g=Fc(m,r);if(!g){h.push(m);continue}const w=l.get(g);w?w.push(m):l.set(g,[m])}const x=[];for(const[m,g]of l){const w=c.get(m),y=g.find(C=>Xr(C)==="selection_group_added");if(!w&&g.length===1&&y){x.push(y);continue}if(!w){x.push(...g);continue}const b=[...g].sort((C,D)=>new Date(D.timestamp).getTime()-new Date(C.timestamp).getTime()),j=y||b[0],R=Yr(void 0,b.flatMap(C=>C.sourceItems||(C.primaryItem?[C.primaryItem]:C.sourceItem?[C.sourceItem]:[]))),L=r.filter(C=>C.group_id===m).length,O=y?.primaryItem?.displayMetadata||y?.sourceItem?.displayMetadata||{},E=Number(O.member_count),M=Number.isInteger(E)&&E>0?E:L||R.length||g.length;x.push({...j,title:String(i("portalWhatsNew.selection_group_added",{name:w.name})),subtitle:String(i("portalWhatsNew.selection_group_added_subtitle",{count:M})),sourceItems:R,eventType:"selection_group_added",isRead:g.every(C=>C.isRead)})}return[...h,...x].sort((m,g)=>new Date(g.timestamp).getTime()-new Date(m.timestamp).getTime())}function Zr(t,a){return Qr(t.map(r=>Wc(r,a)))}function Oc(t,a,r=[],i=[]){const c=Ar().unread.byModule,l=Jr(Zr(t,a),r,i,a).filter(h=>!h.isRead);for(const h of l)h.module&&(c[h.module]+=1);return{total:l.length,byModule:c}}function Wc(t,a){const r=Ec(t.eventType)?"comment":"item",i=Tc(t.module,a),c=t.displayMetadata||{},l=Ic(t,a),h=dr(c,["title","name","label"])||l,x=dr(c,["comment_excerpt","comment","body","message","reply","note"])||Pc(t,a);let m=l,g=x||null;return r==="comment"?(t.eventType==="item_designer_reply"?m=String(a("portalWhatsNew.drawer_comment_title",{defaultValue:"Designer commented"})):t.eventType.includes("reply")?m=String(a("portalWhatsNew.drawer_comment_reply_title",{defaultValue:"Designer replied"})):t.eventType.includes("note")?m=String(a("portalWhatsNew.drawer_comment_note_title",{defaultValue:"Designer left a note"})):t.eventType.includes("updated")?m=String(a("portalWhatsNew.drawer_comment_updated_title",{defaultValue:"Designer updated a comment"})):m=String(a("portalWhatsNew.drawer_comment_title",{defaultValue:"Designer commented"})),!g&&h&&(g=h)):m===l&&(g=x||null),{id:t.id,type:r,tab:i,title:m,subtitle:g,timestamp:t.occurredAt,isRead:!t.unread,icon:Ac(t.module),sourceItem:t,primaryItem:t,sourceItems:[t],module:t.module,targetId:t.targetId,eventType:t.eventType}}function $c({open:t,onClose:a,items:r=[],notifications:i,selectionGroups:c=[],selectionGroupMembers:l=[],isPreviewReadOnly:h=!1,onMarkAllRead:x,onItemClick:m,onMarkItemRead:g}){const{t:w}
12=ae("common",{useSuspense:!1}),[y,b]=n.useState("new"),j=n.useRef(!1),R=n.useMemo(()=>{const C=i?.length?Qr(i):Zr(r,w);return Jr(C,c,l,w)},[r,i,c,l,w]),L=n.useMemo(()=>[...R].sort((C,D)=>new Date(D.timestamp).getTime()-new Date(C.timestamp).getTime()),[R]),O=n.useMemo(()=>L.filter(C=>!C.isRead),[L]),E=n.useMemo(()=>L.filter(C=>C.isRead),[L]),M=y==="new"?O:E;return n.useEffect(()=>{t&&!j.current&&b("new"),j.current=t},[t]),e.jsx(Dr,{open:t,onClose:a,children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5 text-gray-700","aria-hidden":!0}),e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:w("portalWhatsNew.drawer_title")||"What's new"})]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-md p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-800","aria-label":w("close")||"Close",children:e.jsx(Ge,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4 space-y-6",children:e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"inline-flex rounded-full border border-gray-200 bg-gray-50 p-1",children:[e.jsxs("button",{type:"button",onClick:()=>b("new"),className:`rounded-full px-3 py-1.5 text-xs font-medium transition-colors ${y==="new"?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-800"}`,children:[w("portalWhatsNew.new_tab")||"New"," ",e.jsx("span",{className:"text-gray-400",children:O.length})]}),e.jsxs("button",{type:"button",onClick:()=>b("seen"),className:`rounded-full px-3 py-1.5 text-xs font-medium transition-colors ${y==="seen"?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-800"}`,children:[w("portalWhatsNew.seen_tab")||"Seen"," ",e.jsx("span",{className:"text-gray-400",children:E.length})]})]}),!h&&y==="new"&&O.length>0?e.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:x,children:w("portalWhatsNew.mark_all_seen")||"Mark all as seen"}):null]}),M.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-6 text-center",children:y==="new"?w("portalWhatsNew.empty_new")||"No new updates":w("portalWhatsNew.empty_seen")||"Nothing seen yet"}):e.jsx("ul",{className:"space-y-2",children:M.map(C=>{const D=C.icon,p=C.sourceItems||(C.primaryItem?[C.primaryItem]:C.sourceItem?[C.sourceItem]:[]),fe=C.primaryItem||C.sourceItem||p[0],ue=!!fe,te=()=>{fe&&m(fe,p)};return e.jsx("li",{children:e.jsx("div",{role:ue?"button":void 0,tabIndex:ue?0:void 0,onClick:ue?te:void 0,onKeyDown:ue?Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),te())}:void 0,className:`relative w-full rounded-xl border border-zinc-200/80 bg-white p-3 text-left transition-colors ${ue?"cursor-pointer hover:bg-zinc-50 focus:outline-none focus:ring-2 focus:ring-zinc-300":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-zinc-100 text-zinc-500",children:e.jsx(D,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 text-xs font-medium uppercase tracking-wider text-zinc-400",children:C.tab}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[C.isRead?null:e.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500","aria-hidden":!0}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:ka(C.timestamp,"MMM d, yyyy · HH:mm")}),!C.isRead&&p.length>0&&!h&&g?e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-zinc-400 transition-colors hover:bg-zinc-200/70 hover:text-zinc-700","aria-label":w("portalWhatsNew.mark_single_seen")||"Mark as seen",onClick:Z=>{Z.stopPropagation(),g(p)},children:e.jsx(Ge,{className:"h-3.5 w-3.5"})}):null]})]}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium leading-snug text-zinc-900",title:C.title,children:C.title}),C.subtitle?e.jsx("p",{className:"mt-1 line-clamp-1 text-xs text-zinc-500",title:C.subtitle,children:C.subtitle}):null]})]})})},C.id)})})]})})]})})}function Vc({unreadTotal:t,onClick:a}){const{t:r}=ae("common",{useSuspense:!1}),i=n.useRef(t),[c,l]=n.useState(!1);return n.useEffect(()=>{const h=i.current;if(i.current=t,t>h&&t>0){l(!0);const x=window.setTimeout(()=>l(!1),700);return()=>window.clearTimeout(x)}},[t]),e.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-9 shrink-0 items-center gap-2 rounded-lg border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50 min-[760px]:max-lg:px-2.5","aria-label":r("portalWhatsNew.bell_label")||"What's new",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ca,{className:_("h-4 w-4 origin-top text-gray-500",c&&"animate-bell-ring motion-reduce:animate-none")}),t>0&&e.jsxs("span",{className:"pointer-events-none absolute -right-0.5 -top-0.5 h-2 w-2","aria-hidden":!0,
12children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-red-400 opacity-40 animate-ping motion-reduce:animate-none"}),e.jsx("span",{className:"relative block h-2 w-2 rounded-full bg-red-500 ring-2 ring-white"})]})]}),e.jsx("span",{className:"max-[419px]:hidden min-[760px]:max-lg:hidden",children:r("portalWhatsNew.button_label")||"What's new"}),e.jsx("span",{className:"hidden min-[760px]:max-lg:inline",children:r("portalWhatsNew.button_label_short")||"New"}),e.jsx(qr,{count:t,size:"sm"})]})}function Oe({count:t,emphasis:a}){return e.jsx(qr,{count:t,size:"sm",className:"absolute right-1 top-1 z-10 pointer-events-none"})}var Ea="Avatar",[zc]=Li(Ea),[Bc,eo]=zc(Ea),to=n.forwardRef((t,a)=>{const{__scopeAvatar:r,...i}=t,[c,l]=n.useState("idle");return e.jsx(Bc,{scope:r,imageLoadingStatus:c,onImageLoadingStatusChange:l,children:e.jsx(Ia.span,{...i,ref:a})})});to.displayName=Ea;var so="AvatarImage",ao=n.forwardRef((t,a)=>{const{__scopeAvatar:r,src:i,onLoadingStatusChange:c=()=>{},...l}=t,h=eo(so,r),x=Uc(i,l.referrerPolicy),m=Mi(g=>{c(g),h.onImageLoadingStatusChange(g)});return Mr(()=>{x!=="idle"&&m(x)},[x,m]),x==="loaded"?e.jsx(Ia.img,{...l,ref:a,src:i}):null});ao.displayName=so;var no="AvatarFallback",ro=n.forwardRef((t,a)=>{const{__scopeAvatar:r,delayMs:i,...c}=t,l=eo(no,r),[h,x]=n.useState(i===void 0);return n.useEffect(()=>{if(i!==void 0){const m=window.setTimeout(()=>x(!0),i);return()=>window.clearTimeout(m)}},[i]),h&&l.imageLoadingStatus!=="loaded"?e.jsx(Ia.span,{...c,ref:a}):null});ro.displayName=no;function Uc(t,a){const[r,i]=n.useState("idle");return Mr(()=>{if(!t){i("error");return}let c=!0;const l=new window.Image,h=x=>()=>{c&&i(x)};return i("loading"),l.onload=h("loaded"),l.onerror=h("error"),l.src=t,a&&(l.referrerPolicy=a),()=>{c=!1}},[t,a]),r}var oo=to,io=ao,lo=ro;const co=n.forwardRef(({className:t,...a},r)=>e.jsx(oo,{ref:r,className:_("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));co.displayName=oo.displayName;const Gc=n.forwardRef(({className:t,...a},r)=>e.jsx(io,{ref:r,className:_("aspect-square h-full w-full",t),...a}));Gc.displayName=io.displayName;const uo=n.forwardRef(({className:t,...a},r)=>e.jsx(lo,{ref:r,className:_("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));uo.displayName=lo.displayName;const ua=()=>({name:"",email:"",phone:"",company:"",role:"",clientNote:""});function Hc(t){return{name:t.name||"",email:t.email||"",phone:t.phone||"",company:t.company||"",role:t.role||"",clientNote:t.clientNote||""}}const Dt="text-right text-sm font-normal leading-snug text-gray-600",Lt="w-full border-gray-200 bg-white shadow-none placeholder:text-gray-400 autofill:bg-white autofill:shadow-[inset_0_0_0_1000px_#ffffff] focus-visible:ring-gray-300",Kc=30;function qc({name:t}){const a=e.jsx("h3",{className:"min-w-0 truncate text-sm font-semibold text-gray-900",children:t});return t.length<=Kc?a:e.jsx(ya,{delayDuration:200,children:e.jsxs(kr,{children:[e.jsx(Cr,{asChild:!0,children:a}),e.jsx(Ir,{side:"top",maxChars:80,className:"max-w-[16rem] border-gray-800 bg-gray-900 px-2 py-1 text-xs font-normal text-white shadow-lg",children:t})]})})}function Yc(t,a){const r=a.trim().toLowerCase();return r?[t.name,t.role,t.company,t.phone,t.email,t.clientNote].filter(Boolean).join(" ").toLowerCase().includes(r):!0}function Qc(t){return t.name.trim()?!t.email.trim()&&!t.phone.trim()?"contact_method":t.email.trim()&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.email.trim())?"email":t.phone.trim()&&!/^[0-9+\-\s()]+$/.test(t.phone.trim())?"phone":null:"name"}function Xc({onClick:t}){const{t:a}=ae();return e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-2 rounded-lg border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50 min-[760px]:max-lg:px-2.5","aria-label":a("portalContacts.button_label")||"Project Contacts",children:[e.jsx(Lr,{className:"h-4 w-4 text-gray-500","aria-hidden":!0}),e.jsx("span",{className:"max-[419px]:hidden min-[760px]:max-lg:hidden",children:a("portalContacts.button_label")||"Project Contacts"}),e.jsx("span",{className:"hidden min-[760px]:max-lg:inline",children:a("portalContacts.button_label_short")||"Contacts"})]})}
12function Jc(t){const a=t.trim();if(!a)return"?";const i=a.replace(/[\u2013\u2014\u2212\-_/.,;:•·|\\]+/g," ").replace(/\s+/g," ").trim().split(" ").filter(l=>l.length>0),c=l=>(l.match(/\p{L}|\p{N}/u)?.[0]??l.charAt(0)).toUpperCase();if(i.length>=2)return`${c(i[0])}${c(i[1])}`;if(i.length===1){const h=[...i[0]].filter(x=>/\p{L}|\p{N}/u.test(x));if(h.length>=2)return`${h[0].toUpperCase()}${h[1].toUpperCase()}`;if(h.length===1)return h[0].toUpperCase()}return"?"}function ur({value:t,icon:a,href:r,actionAriaLabel:i,copyAriaLabel:c,openInNewTab:l=!1,onCopy:h}){return e.jsxs("div",{className:"group flex w-full items-center justify-between gap-2 rounded-md p-2 transition-colors hover:bg-gray-50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5",children:[e.jsx(a,{className:"h-3.5 w-3.5 shrink-0 text-gray-400","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate text-sm text-gray-700 tabular-nums",children:t})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>h(t),className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100 hover:text-gray-700 group-hover:text-gray-400","aria-label":c,children:e.jsx(br,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("a",{href:r,...l?{target:"_blank",rel:"noopener noreferrer"}:{},className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100 hover:text-gray-700 group-hover:text-gray-400","aria-label":i,children:e.jsx(We,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]})}function Zc({addedByRole:t}){const{t:a}=ae();if(!t)return null;const r=t==="client"?a("addedByYou")||"Added by you":a("fromDesigner")||"From designer";return e.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-gray-100 bg-gray-50 px-2 py-0.5 text-[11px] font-medium leading-none text-gray-500",children:r})}function ed({contact:t,canManage:a,highlighted:r=!1,onEdit:i,onDelete:c}){const{t:l}=ae(),{toast:h}=rs(),x=t.role?.trim()||null,m=t.company?.trim()||null,g=t.clientNote?.trim()||null,w=t.addedByRole??t.createdBy,y=Jc(t.name),b=async j=>{try{await navigator.clipboard.writeText(j),h({title:l("portalContacts.copied")||"Copied"})}catch{h({title:l("portalContacts.copy_failed")||"Could not copy",variant:"destructive"})}};return e.jsxs("div",{"data-portal-contact-id":t.id,className:_("flex flex-col gap-y-3 rounded-xl border bg-white p-4 transition-shadow hover:shadow-sm",r?"border-red-200 bg-red-50/30 shadow-md ring-2 ring-red-200":"border-gray-100"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(co,{className:"h-10 w-10 shrink-0",children:e.jsx(uo,{className:"bg-gray-100 text-xs font-medium tracking-wide text-gray-600",children:y})}),e.jsxs("div",{className:"relative min-w-0 flex-1",children:[a?e.jsxs("div",{className:"absolute right-0 top-0 z-10 flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>i(t),className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700","aria-label":l("portalContacts.edit_contact")||l("editContact")||"Edit contact",children:e.jsx(Ki,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:()=>c(t),className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-red-50 hover:text-red-600","aria-label":l("portalContacts.delete_contact")||l("delete")||"Delete contact",children:e.jsx(qi,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}):null,e.jsxs("div",{className:_("flex flex-col gap-y-2",a?"pr-14":void 0),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:e.jsx(qc,{name:t.name})}),w?e.jsx(Zc,{addedByRole:w}):null]}),x||m?e.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[x?e.jsx("span",{className:"block text-sm leading-snug text-gray-700 break-words line-clamp-2",children:x}):null,m?e.jsx("span",{className:"block text-sm leading-snug text-gray-500 break-words line-clamp-2",children:m}):null]}):null]})]})]}),t.phone||t.email?e.jsxs("div",{className:"-mx-2 space-y-0.5 border-t border-gray-100 pt-3",children:[t.phone?e.jsx(ur,{value:t.phone,icon:Yi,href:`tel:${t.phone}`,actionAriaLabel:l("portalContacts.call")||"Call",copyAriaLabel:l("portalContacts.copy_phone",{phone:t.phone})||`Copy phone number ${t.phone}`,onCopy:b}):null,t.email?e.jsx(ur,{value:t.email,icon:ci,href:`mailto:${t.email}`,openInNewTab:!0,actionAriaLabel:l("portalContacts.email")||"Email",copyAriaLabel:l("portalContacts.copy_email",{email:t.email})||`Copy email ${t.email}`,onCopy:b}):null]}):null,g?e.jsx("div",{className:"border-t border-gray-100 pt-3",children:e.jsx("p",{className:"line-clamp-3 break-words text-sm leading-relaxed text-gray-600 whitespace-pre-wrap",children:g})}):null]})}function td({open:t,onOpenChange:a,mode:r,form:i,onFormChange:c,onSubmit:l,isSubmitting:h}){const{t:x}=ae(),m=r==="edit"?x("portalContacts.edit_contact")||x("editContact")||"Edit Contact":x("portalContacts.add_contact")||"Add Contact";return e.jsx(wr,{open:t,onOpenChange:a,children:e.jsxs(yr,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[e.jsx(Qi,{children:e.jsx(vr,{children:m})}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-x-4 gap-y-4 py-2",children:[e.jsxs(vt,{htmlFor:"portal-contact-name",className:Dt,children:[x("name1")||"Name"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(jt,{id:"portal-contact-name",value:i.name,onChange:g=>c("name",g.target.value),disabled:h,autoComplete:"name",placeholder:x("portalContacts.form_placeholder_name")||"Full name",className:Lt}),e.jsx(vt,{htmlFor:"portal-contact-email",className:Dt,children:x("email")||"Email"}),e.jsx(jt,{id:"portal-contact-email",type:"email",value:i.email,onChange:g=>c("email",g.target.value),disabled:h,autoComplete:"email",placeholder:x("portalContacts.form_placeholder_email")||"[email protected]",className:Lt}),e.jsx(vt,{htmlFor:"portal-contact-phone",className:Dt,children:x("phone")||"Phone"}),e.jsx(jt,{id:"portal-contact-phone",type:"tel",value:i.phone,onChange:g=>c("phone",g.target.value),disabled:h,autoComplete:"tel",placeholder:x("portalContacts.form_placeholder_phone")||"+48 000 000 000",className:Lt}),e.jsx(vt,{htmlFor:"portal-contact-company",className:Dt,children:x("company")||"Company"}),e.jsx(jt,{id:"portal-contact-company",value:i.company,onChange:g=>c("company",g.target.value),disabled:h,autoComplete:"organization",placeholder:x("portalContacts.form_placeholder_company")||"e.g. WoodWorks",className:Lt}),e.jsx(vt,{htmlFor:"portal-contact-role",className:Dt,children:x("role")||"Role"}),e.jsx(jt,{id:"portal-contact-role",value:i.role,onChange:g=>c("role",g.target.value),disabled:h,placeholder:x("portalContacts.form_placeholder_role")||"e.g. Carpenter",className:Lt}),e.jsx(vt,{htmlFor:"portal-contact-note",className:`${Dt} self-start pt-2.5`,children:x("portalContacts.form_note")||"Note"}),e.jsx(Na,{id:"portal-contact-note",value:i.clientNote,onChange:g=>c("clientNote",g.target.value),disabled:h,rows:3,placeholder:x("portalContacts.form_placeholder_note")||"Optional note…",className:`${Lt} min-h-[80px] resize-y self-start`})]}),e.jsxs(Xi,{className:"flex-col gap-2 sm:flex-row sm:gap-0",children:[e.jsx(oe,{type:"button",variant:"outline",onClick:()=>a(!1),disabled:h,className:"w-full sm:w-auto",children:x("cancel")||"Cancel"}),e.jsxs(oe,{type:"button",onClick:l,disabled:h,className:"w-full sm:w-auto",children:[h?e.jsx(wa,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}):null,x("save")||"Save"]})]})]})})}function sd({open:t,onClose:a,portalSessionToken:r,previewReadOnly:i=!1,clientDisplayName:c,initialContactId:l=null,focusNonce:h=0,onFocusHandled:x}){const{t:m}=ae(),{toast:g}=rs(),w=n.useRef(null),y=n.useRef(null),b=n.useRef(null),j=n.useRef(x),[R,L]=n.useState("idle"),[O,E]=n.useState([]),[M,C]=n.useState(0),[D,p]=n.useState(""),[fe,ue]=n.useState(null),[te,Z]=n.useState(!1),[q,S]=n.useState("add"),[le,me]=n.useState(null),[X,ce]=n.useState(null),[A,ge]=n.useState(ua),[ke,pe]=n.useState(!1),[we,B]=n.useState(!1),Y=!i,P=!i;n.useEffect(()=>{j.current=x},[x]);const H=n.useMemo(()=>O.filter(W=>Yc(W,D)),[O,D]),je=n.useCallback(()=>{ge(ua()),me(null),S("add"),Z(!1)},[]),$=n.useCallback(async()=>
12{if(!r){L("error");return}L("loading");const W=await Fi(r);if("error"in W){E([]),L("error");return}if(W.contacts.length===0){E([]),L("empty");return}E(W.contacts),L("success")},[r]);n.useEffect(()=>{if(!t){w.current=null,y.current!=null&&(window.clearTimeout(y.current),y.current=null),b.current!=null&&(window.clearTimeout(b.current),b.current=null),L("idle"),p(""),ue(null),ce(null),je();return}$()},[t,$,M,je]),n.useEffect(()=>{if(!t||!l||!h||R!=="success")return;const W=`${h}:${l}`;if(w.current===W)return;const _e=O.find(Ae=>Ae.id===l||Ae.contactId!=null&&Ae.contactId===l);if(!_e)return;w.current=W,p(""),ue(_e.id);let Ce=0;const st=()=>{b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{ue(Ae=>Ae===_e.id?null:Ae),j.current?.(),b.current=null},5e3)},ls=()=>{const Ae=document.querySelector(`[data-portal-contact-id="${CSS.escape(_e.id)}"]`);if(Ae){Ae.scrollIntoView({behavior:"smooth",block:"center"}),st();return}Ce>=20||(Ce+=1,y.current=window.setTimeout(ls,140))};return requestAnimationFrame(()=>requestAnimationFrame(ls)),()=>{y.current!=null&&(window.clearTimeout(y.current),y.current=null)}},[t,l,h,R,O]);const He=()=>{C(W=>W+1)},V=()=>{Y&&(me(null),S("add"),ge(ua()),Z(!0))},Ee=W=>{!P||!ra(W)||(me(W),S("edit"),ge(Hc(W)),Z(!0))},xe=W=>{!P||!ra(W)||ce(W)},_t=(W,_e)=>{ge(Ce=>({...Ce,[W]:_e}))},Ne=async()=>{if(!r||ke||q==="add"&&!Y||q==="edit"&&!le)return;const W=Qc(A);if(W==="name"){g({title:m("portalContacts.add_contact_validation_name")||"Name is required",variant:"destructive"});return}if(W==="contact_method"){g({title:m("portalContacts.add_contact_validation_contact_method")||"Email or phone is required",variant:"destructive"});return}if(W==="email"){g({title:m("portalContacts.add_contact_validation_email")||"Invalid email address",variant:"destructive"});return}if(W==="phone"){g({title:m("portalContacts.add_contact_validation_phone")||"Invalid phone number",variant:"destructive"});return}pe(!0);try{const _e={name:A.name.trim(),email:A.email.trim()||null,phone:A.phone.trim()||null,company:A.company.trim()||null,role:A.role.trim()||null,clientNote:A.clientNote.trim()||null},Ce=q==="edit"&&le?await Ji(r,{..._e,projectContactId:le.id}):await Zi(r,{..._e,clientDisplayName:c?.trim()||null});if("error"in Ce){g({title:q==="edit"?m("portalContacts.update_contact_failed")||"Could not update contact":m("portalContacts.add_contact_failed")||"Could not add contact",description:Ce.error,variant:"destructive"});return}g({title:q==="edit"?m("portalContacts.update_contact_success")||"Contact updated":m("portalContacts.add_contact_success")||"Contact added"}),je(),C(st=>st+1)}finally{pe(!1)}},St=async()=>{if(!(!r||!X||we)){B(!0);try{const W=await el(r,X.id);if("error"in W){g({title:m("portalContacts.delete_contact_failed")||"Could not delete contact",description:W.error,variant:"destructive"});return}g({title:m("portalContacts.delete_contact_success")||"Contact deleted"}),ce(null),C(_e=>_e+1)}finally{B(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsx(Dr,{open:t,onClose:a,children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"sticky top-0 z-20 shrink-0 border-b border-gray-100 bg-white p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Oi,{className:"h-5 w-5 shrink-0 text-gray-700","aria-hidden":!0}),e.jsx("h2",{className:"truncate text-base font-semibold text-gray-900",children:m("portalContacts.drawer_title")||"Project Contacts"})]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800","aria-label":m("close")||"Close",children:e.jsx(Ge,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Sa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400","aria-hidden":!0}),e.jsx("input",{type:"search",value:D,onChange:W=>p(W.target.value),placeholder:m("portalContacts.search_placeholder")||"Search",className:"w-full rounded-md border-0 bg-gray-50 py-2 pl-9 pr-3 text-sm text-gray-900 placeholder:text-gray-400 transition-colors focus:bg-gray-50 focus:outline-none focus:ring-0","aria-label":m("portalContacts.search_contacts")||"Search contacts"})]}),e.jsxs("button",{type:"button",onClick:V,disabled:i,className:_("inline-flex shrink-0 items-center gap-1.5 rounded-md px-4 py-2 text-sm font-medium transition-colors",i?"cursor-not-allowed bg-gray-200 text-gray-400":"bg-gray-900 text-white hover:bg-gray-800"),"aria-label":m("portalContacts.add_contact")||"Add Contact","aria-disabled":i,children:[e.jsx(Gn,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-[420px]:hidden",children:m("portalContacts.add_contact")||"Add Contact"})]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4","aria-busy":R==="loading","aria-live":"polite",children:[R==="loading"||R==="idle"?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-gray-500",children:[e.jsx(wa,{className:"h-8 w-8 animate-spin","aria-hidden":!0}),e.jsx("p",{className:"text-sm",children:m("portalContacts.loading")||"Loading contacts…"})]}):null,R==="success"&&H.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:D.trim()?m("portalContacts.no_search_results")||"No matching contacts":m("portalContacts.empty_title")||"No contacts to show"}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:D.trim()?m("portalContacts.no_search_results_description")||"Try a different name, role, or company.":m("portalContacts.empty_description")||"There are no project contacts available in the client portal right now."})]}):null,R==="success"&&H.length>0?e.jsx("div",{className:"space-y-2.5",children:H.map(W=>
12e.jsx(ed,{contact:W,highlighted:fe===W.id,canManage:P&&ra(W),onEdit:Ee,onDelete:xe},W.id))}):null,R==="empty"?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:m("portalContacts.empty_add_first_title")||m("portalContacts.empty_title")||"No contacts yet"}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:m("portalContacts.empty_add_first_description")||"You can add the first contact for this portal."}),e.jsxs(oe,{type:"button",className:"mt-4",onClick:V,disabled:i,children:[e.jsx(Gn,{className:"mr-2 h-4 w-4","aria-hidden":!0}),m("portalContacts.add_contact")||"Add Contact"]})]}):null,R==="error"?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:m("portalContacts.error_title")||"Could not load contacts"}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:m("portalContacts.error_description")||"Please try again. If the problem continues, contact your designer."}),e.jsx(oe,{type:"button",variant:"outline",className:"mt-4",onClick:He,children:m("portalContacts.retry")||"Retry"})]}):null]})]})}),Y||P?e.jsx(td,{open:te,onOpenChange:W=>{ke&&!W||(W?Z(!0):je())},mode:q,form:A,onFormChange:_t,onSubmit:()=>void Ne(),isSubmitting:ke}):null,e.jsx(Wi,{open:!!X,onOpenChange:W=>{!W&&!we&&ce(null)},children:e.jsxs($i,{children:[e.jsxs(Vi,{children:[e.jsx(zi,{children:m("portalContacts.confirm_delete_title")||"Delete this contact?"}),e.jsx(Bi,{children:X?m("portalContacts.confirm_delete_description",{name:X.name})||`This will permanently remove "${X.name}". This action cannot be undone.`:m("portalContacts.confirm_delete_description_generic")||"This action cannot be undone."})]}),e.jsxs(Ui,{children:[e.jsx(Gi,{disabled:we,children:m("cancel")||"Cancel"}),e.jsxs(Hi,{onClick:()=>void St(),disabled:we,className:"bg-red-600 hover:bg-red-700 text-white",children:[we?e.jsx(wa,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}):null,m("delete")||"Delete"]})]})]})})]})}class yd extends Error{constructor(r){super(`R2 GET ${r}`);zn(this,"status");this.name="PortalR2FetchError",this.status=r}}function vd(t,a){tt(()=>import("./portalSentry-DTSK8oUl.js"),__vite__mapDeps([0,1,2,3])).then(r=>{r.capturePortalDocumentFailure(t,a)}).catch(()=>{})}function jd(t){tt(()=>import("./portalSentry-DTSK8oUl.js"),__vite__mapDeps([0,1,2,3])).then(a=>
12{a.capturePortalThumbnailRenderFailure(t)}).catch(()=>{})}function ad(t){tt(()=>import("./portalSentry-DTSK8oUl.js"),__vite__mapDeps([0,1,2,3])).then(a=>{a.capturePortalSessionPin(t)}).catch(()=>{})}const nd=is(()=>tt(()=>import("./ProposalTab-BqaH8-2b.js"),__vite__mapDeps([4,1,2,5,3,6])).then(t=>({default:t.ProposalTab}))),rd=is(()=>tt(()=>import("./CanvasCreationsTab-CBkfeb9-.js"),__vite__mapDeps([7,1,2,5,3,6,8,9,10,11,12,13])).then(t=>({default:t.CanvasCreationsTab}))),od=is(()=>tt(()=>import("./InspirationsTab-CAhPALEp.js"),__vite__mapDeps([14,1,2,5,3,6,15,16,17,18])).then(t=>({default:t.InspirationsTab}))),id=is(()=>tt(()=>import("./DocumentsTab-Bqj-HI3S.js"),__vite__mapDeps([19,1,2,5,3,6,20,21,10,11,12,22,23])).then(t=>({default:t.DocumentsTab}))),ld=is(()=>tt(()=>import("./PortalScheduleTab-CtHm-BX3.js"),__vite__mapDeps([24,1,2,22,23,5,3,6,25,13,26]))),ss=()=>e.jsx("div",{className:"flex min-h-[200px] items-center justify-center text-muted-foreground",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600","aria-hidden":!0})});function cd(t){const a=t?.review_portal_hidden_rooms;return Array.isArray(a)?a:[]}function mr(t,a,r){const i=cd(r),c=Tl(t,i),l=new Set(c.map(x=>x.id)),h=a.filter(x=>l.has(x.review_item_id));return{items:c,attachments:h}}function dd(t,a){const r=a.filter(i=>i.success&&i.status==="approved").map(i=>t.find(c=>c.id===i.itemId)).filter(i=>!!i);r.length&&console.log("[Review→ML Category] Client approved review items (portal)",{count:r.length,items:r.map(i=>({reviewItemId:i.id,title:i.title,reviewRoom:i.room??null,extractedProductCategory:i.extracted_product_data?.category??null})),note:"DB trigger queue_review_item_pending_addition stores snapshot.room (not extracted category)"})}const mo="(max-width: 767px)",po="(min-width: 1024px)";function ud(){return typeof window>"u"?{isMobile:!1,allowsDetailed:!0}:{isMobile:window.matchMedia(mo).matches,allowsDetailed:window.matchMedia(po).matches}}function md(t,a){return a.isMobile||!a.allowsDetailed?"list":t}function pr(t){const a=t;return a?.portal_show_product_details===!0||String(a?.portal_show_product_details??"").toLowerCase()==="true"}function hr(t,a){return a&&t.portal_has_any_product_metadata===!0}function fr(t,a){const r=a?.allowDetailed??!1,i=t.portal_review_layout_mode,c=t.portal_review_content_density;return i==="grid"||i==="list"?i:r&&as.PORTAL_PRODUCT_DETAILS&&i==="detailed"||r&&as.PORTAL_PRODUCT_DETAILS&&c==="detailed"?"detailed":"grid"}const pd=()=>{const[t,a]=n.useState(!0),[r,i]=n.useState(!1),[c,l]=n.useState(!1),[h,x]=n.useState(!1),[m,g]=n.useState(!1),[w,y]=n.useState(null),[b,j]=n.useState(!1),{linkToken:R}=gr(),[L,O]=tl(),E=n.useCallback(()=>{O(s=>{const o=new URLSearchParams(s);return!o.has("wnTab")&&!o.has("targetId")&&!o.has("focusNonce")?s:(o.delete("wnTab"),o.delete("targetId"),o.delete("focusNonce"),o.delete("secondaryTargetId"),o)},{replace:!0})},[O]),M=n.useCallback(()=>{y(null),E()},[E]),C=L.get("designer_preview")==="1",{toast:D}=rs(),{t:p,i18n:fe}=ae("common",{useSuspense:!1}),{openVideoBySection:ue}=sl(),te=al(),Z=n.useMemo(()=>Br(),[]),[,q]=n.useReducer(s=>s+1,0),S="project-assets",le="dashboard-logos/",me=()=>{try{const s=Fs("review_access_token");return s?JSON.parse(s):null}catch{return Mt("review_access_token"),null}},X=()=>{Mt("review_access_token")},ce=()=>{try{const s=sessionStorage.getItem(Os);if(!s)return null;const o=JSON.parse(s);return!o?.portalSessionToken||!o?.projectId||o.linkToken&&o.linkToken!==R?null:o}catch{try{sessionStorage.removeItem(Os)}catch{}return null}},A=s=>{try{sessionStorage.setItem(Os,JSON.stringify(s))}catch{}},ge=()=>{try{sessionStorage.removeItem(Os)}catch{}},ke=(s,o)=>{try{if(!s)return!1;if(o&&s.linkToken!==o)return console.warn("Session linkToken mismatch - possible manipulation detected"),!1;const d=new Date;if(s.grantedAt){const u=new Date(s.grantedAt);if(!isNaN(u.getTime())&&u>d)return console.warn("Session grantedAt is in the future - possible manipulation detected"),!1}return s.projectId?!0:(console.warn("Session missing projectId - removing invalid session"),!1)}catch(d){return d instanceof RangeError?(console.warn("Session validation RangeError (Safari fallback) - treating as valid:",d),!0):(console.warn("Session validation error - treating as invali
12d:",d),!1)}},[pe,we]=n.useState(!1),B=Ol(L)||Bl(),Y=!pe&&Z.isInApp&&!B,P=n.useCallback(s=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("planify:portal-in-app-gate",{detail:{phase:s}}))},[]);n.useEffect(()=>{Y&&window.dispatchEvent(new CustomEvent("planify:portal-in-app-gate",{detail:{phase:"shown"}}))},[Y]);const[H,je]=n.useState(null),[$,He]=n.useState(null),[V,Ee]=n.useState([]),[xe,_t]=n.useState([]),[Ne,St]=n.useState([]),[W,_e]=n.useState({}),[Ce,st]=n.useState({}),[ls,Ae]=n.useState(!0),[Aa,cs]=n.useState(null),[ho,Ft]=n.useState(!1),[ye,Da]=n.useState(""),[ne,at]=n.useState({}),[Ie,Ot]=n.useState({}),kt=n.useRef(0),$s=n.useRef(new Set),nt=n.useRef(null),Ct=n.useRef({reviewItems:V,selectedStatusMap:ne,commentsMap:Ie,clientName:ye});Ct.current={reviewItems:V,selectedStatusMap:ne,commentsMap:Ie,clientName:ye};const[ds,us]=n.useState("grid"),[ms,fo]=n.useState(ud),[ie,rt]=n.useState(ts),[dt,Vs]=n.useState(null),zs=n.useRef(null),[ot,Bs]=n.useState([]),[De,Us]=n.useState(""),[La,Ma]=n.useState(!1),[xo,Fa]=n.useState(!1),[Le,ps]=n.useState(!1),[Oa,Wa]=n.useState(new Set),[$a,go]=n.useState(null),[Gs,hs]=n.useState(null),[fs,Va]=n.useState(!0),[xs,za]=n.useState(!0),[gs,Ba]=n.useState(!1),[Ua,Ga]=n.useState(!1),[bo,Ha]=n.useState(!1),[G,wo]=n.useState(null),It=nl(),[$e,Me]=n.useState(!1),[yo,Wt]=n.useState(!1),[Hs,Ks]=n.useState(null),[$t,Pt]=n.useState(null),Ka=n.useRef(!1),[vo,Vt]=n.useState(null),[qs,ut]=n.useState(null),[jo,Ys]=n.useState(!1),zt=n.useRef(!1),Qs=n.useRef(!1),z=$?.previewReadOnly===!0||vo==="designer_preview";n.useEffect(()=>{tt(async()=>{const{initPortalSentry:s,setPortalSentryContext:o}=await import("./portalSentry-DTSK8oUl.js");return{initPortalSentry:s,setPortalSentryContext:o}},__vite__mapDeps([0,1,2,3])).then(({initPortalSentry:s,setPortalSentryContext:o})=>{s(),H&&o({projectId:H,designerPreview:z})}).catch(()=>{})},[H,z]);const[No,qa]=n.useState(!1),[Ya,_o]=n.useState(null),[So,ko]=n.useState(null),[Co,Qa]=n.useState(!1),[T,Ke]=n.useState("items"),[Io,Po]=n.useState(!1),[To,Ro]=n.useState(!1),Bt=n.useRef(null),[Ut,Eo]=n.useState(()=>new Set),[mt,Xa]=n.useState([]),[bs,Ja]=n.useState([]),[Xs,Za]=n.useState([]),[Ao,en]=n.useState(null),[Do,Lo]=n.useState(0),[Mo,ws]=n.useState(!1),ys=n.useRef(null),Xe=n.useRef(null),tn=n.useRef(0),sn=n.useRef(null),an=!1,Ve=mt?.length>0,Te=bs?.length>0,qe=V.length>0,ze=r,Fo=c,nn=n.useCallback(s=>xs&&rl(s),[xs]),rn=n.useCallback(s=>fs&&!!s.product_link,[fs]),Gt=n.useCallback(s=>s.product_metadata?.hasAny===!0,[]),Oo=n.useCallback(s=>nn(s)||rn(s)||Gt(s),[nn,rn,Gt]),Wo=n.useCallback(s=>{s||i(!1)},[]),[hd,on]=n.useState({}),J=$?.portalSessionToken||$?.portal_session_token||null,ln=n.useRef(0),pt=n.useMemo(()=>md(ds,ms),[ms,ds]),Js=n.useCallback(s=>{const o=s,d=ds,u=++ln.current;us(o),!(!J||z)&&ol(J,o).then(f=>{"error"in f&&u===ln.current&&(us(d),D({title:p("error"),description:f.error,variant:"destructive"}))})},[J,z,p,D,ds]),cn=n.useRef(null),dn=n.useRef(null),un=n.useRef(null),mn=n.useRef(null),pn=n.useRef(0),hn=n.useRef(Date.now()),ht=Rl(b?H:null,b?J:null),Ht=n.useCallback(s=>{if(Qs.current)return;Qs.current=!0;const o=s?.previewMode??z;o||X(),o&&ge();try{Mt(et)}catch{}He(null),we(!1),cs(null),ws(!1),Me(!1),Ks(null),o?Ys(!0):s?.showToast!==!1&&D({title:p("clientPortalReauthTitle")||"Please re-enter your PIN",description:p("clientPortalReauthDescription")||"For your security, access timed out. Enter your PIN again to continue."});try{ad({code:il({code:s?.code,reason:s?.reason}),previewMode:o,projectId:H??null})}catch{}},[z,D,p,H]),{items:Kt,drawerOpen:vs,openDrawer:$o,closeDrawer:Zs,refetch:fn,markRead:qt,markAllRead:Vo}=Sc({portalSessionToken:pe?J:null,enabled:pe&&!!J,isPreviewReadOnly:z}),Yt=n.useMemo(()=>Oc(Kt,p,xe,Ne),[Kt,p,xe,Ne]),be=n.useCallback(s=>{const o=Qn(s);return o?Yt.byModule[o]??0:0},[Yt]),Pe=n.useCallback((s,o)=>{Ke(s),O(d=>{const u=new URLSearchParams(d);return o?.preserveWhatsNewLink&&o.module?(u.set("wnTab",o.module),o.targetId?u.set("targetId",o.targetId):u.delete("targetId"),o.secondaryTargetId?u.set("secondaryTargetId",o.secondaryTargetId):u.delete("secondaryTargetId")):(u.delete("wnTab"),u.delete("targetId"),u.delete("secondaryTargetId")),u},{replace:!0})},[O]),xn=n.useCallback((s,o,d)=>{const u=Xn(s);u&&Pe(u,{preserveWhatsNewLink:!0,module:s,targetId:o,secondaryTargetId:d})},[Pe]),gn=n.useCallback((s,o)=>
12{if(!o)return!0;switch(s){case"items":return V.some(d=>d.id===o)||Ne.some(d=>d.review_item_id===o)||xe.some(d=>d.id===o);case"proposals":return mt.some(d=>d.id===o);case"creations":return bs.some(d=>d.id===o);case"inspirations":return Xs.some(d=>d.id===o);case"schedule":return!!ht.data?.tasks.some(d=>d.id===o);case"documents":return!1;default:return!1}},[V,mt,bs,Xs,ht.data?.tasks,Ne,xe]),bn=n.useCallback(s=>{if(s.module==="items"&&$e||s.module==="documents"||s.module==="contacts"||gn(s.module,s.targetId??null))return!1;const o=Date.parse(s.occurredAt);return Number.isFinite(o)?o>=hn.current-15e3:!0},[$e,gn]),js=n.useCallback(async(s,o=1800)=>{if(!J)return;const d=await ha(J,{timeoutMs:o,retryPolicy:{maxRetries:0,baseDelayMs:0,maxTotalRetryMs:0}});if(d?.error)throw new Error(d.error);const u=(d.review_items||[])??[],f=(d.review_attachments||[])??[],k=(d.proposals||[])??[],v=(d.canvas_creations||[])??[],I=(d.portal_inspirations||[])??[],K=d.viewer_client_identity_hash??null,N=d.project,U=mr(u,f,N),F=U.items,se=U.attachments;Xa(k),Ja(v),Za(I),en(K);const he=N?.portal_show_inspirations!==!1,Se=N?.portal_show_documents===!0;a(he),i(Se),j(N?.portal_show_schedule===!0),l(N?.portal_show_contacts===!0),x(N?.has_visible_portal_contacts===!0),Va(N?.portal_show_product_links!==!1),za(N?.portal_show_product_price!==!1);const bt=pr(N),Qe=hr(d,bt);if(Ba(bt),Ga(Qe),us(fr(d,{allowDetailed:Qe})),s!=="items")return;if(F.length===0){Ee([]),_e({}),st({}),Ot({}),at({}),Ft(!0),cs(null),_t([]),St([]);return}Ft(!1),Ee(F);{const ee=Jn(d.selection_groups);_t(ee.groups),St(ee.members)}const Ue={};se.forEach(ee=>{const Ze=ee.review_item_id;Ze&&(Ue[Ze]||(Ue[Ze]=[]),Ue[Ze].push(ee))});const lt={},es={},Et={};await Promise.all(F.map(async ee=>{ee.status&&ee.status!=="pending"?lt[ee.id]=ee.status:lt[ee.id]=null,ee.client_comment&&(Et[ee.id]=ee.client_comment);const Ze=Ue[ee.id]||[],At=Zn(Ze,{preferImage:!0}),wt=typeof ee.external_image_url=="string"?String(ee.external_image_url).trim():"";es[ee.id]=At?At.signed_url||await oa(At.file_path):wt&&(wt.startsWith("http://")||wt.startsWith("https://"))?wt:null})),at(lt),_e(Ue),st(es),Ot(Et)},[J]),Ns=n.useCallback(async(s,o=1800,d=!1)=>{const u=()=>{switch(s){case"proposals":return cn.current;case"creations":return dn.current;case"inspirations":return un.current;case"documents":return mn.current;default:return null}},f=Date.now()+o;let k=u();for(;d&&!k&&Date.now()<f;)await new Promise(I=>window.setTimeout(I,60)),k=u();if(s==="schedule"){const I=Math.max(250,f-Date.now());await Promise.race([ht.refetch().then(()=>{}).catch(()=>{}),new Promise(K=>window.setTimeout(K,I))]);return}if(!k)return;const v=Math.max(250,f-Date.now());await Promise.race([k().catch(()=>{}),new Promise(I=>window.setTimeout(I,v))])},[ht.refetch]),zo=n.useCallback(async(s,o=[s])=>{const d=Array.from(new Set(o.map(k=>k.id).filter(k=>typeof k=="string"&&k.length>0)));if(qt(d.length>0?d:[s.id]),Zs(),s.module==="contacts"){const k={contactId:s.targetId??null,nonce:Date.now()};y(k),g(!0),O(v=>{const I=new URLSearchParams(v);return I.set("wnTab","contacts"),I.set("focusNonce",String(k.nonce)),k.contactId?I.set("targetId",k.contactId):I.delete("targetId"),I.delete("secondaryTargetId"),I},{replace:!0});return}const u=bn(s),f={module:s.module,targetId:s.targetId??null,secondaryTargetId:s.secondaryTargetId??null,nonce:Date.now()};wn(f),xn(s.module,s.targetId??null,s.secondaryTargetId??null),u&&js(s.module,1200).catch(()=>{}).then(()=>Ns(s.module,1200,!0)).catch(()=>{})},[bn,js,xn,Ns,qt,Zs,O]);n.useEffect(()=>{J&&(hn.current=Date.now())},[J]);const Ye=n.useCallback(s=>{const o=new Set;s.targetId&&o.add(s.targetId),Array.isArray(s.targetIds)&&s.targetIds.forEach(f=>{f&&o.add(f)});const d=new Set;if(s.secondaryTargetId&&d.add(s.secondaryTargetId),Array.isArray(s.secondaryTargetIds)&&s.secondaryTargetIds.forEach(f=>{f&&d.add(f)}),o.size===0&&d.size===0)return;const u=Kt.filter(f=>!f.unread||f.module!==s.module?!1:!!(f.targetId&&o.has(f.targetId)||f.secondaryTargetId&&d.has(f.secondaryTargetId)||f.secondaryTargetId&&o.has(f.secondaryTargetId))).map(f=>f.id);u.length!==0&&qt(u)},[qt,Kt]);n.useEffect(()=>{const s=Yt.total??0,o=pn.current;if(pn.current=s,o<=0||s<=o||document.visibilityState!=="visible"||(vs||fn(),$e))return;const d=Qn(T);d&&js(d,1800).then(()=>Ns(d,1800,!1)).catch(()=>{})},[Yt.total,vs,fn,$e,T,js,Ns]);const Bo="client_portal",[Uo,ft]=n.useState(!1),[Q,wn]=n.useState(null),[Go,yn]=n.useState(null),[Qt,vn]=n.useState(null);n.useEffect(()=>{ft(!1)},[R]),n.useEffect(()=>{const s=Hn(L.get("wnTab")),o=L.get("targetId"),d=L.get("secondaryTargetId");!s||!o||(wn(u=>u?.module===s&&u.targetId===o&&(u.secondaryTargetId??null)===(d??null)?u:{module:s,targetId:o,secondaryTargetId:d||null,nonce:Date.now()}),O(u=>{const f=new URLSearchParams(u);return f.delete("wnTab"),f.delete("targetId"),f.delete("secondaryTargetId"),f},{replace:!0}))},[L,O]);const ea=n.useRef(null);n.useEffect(()=>{if(Q?.module!=="items"||!Q.targetId){ea.current=null;return}const s=Q.targetId;if(ea.current===s)return;const o=V.find(f=>f.id===s),d=Object.prototype.hasOwnProperty.call(ne,s);if(!o&&!d&&V.length===0)return;ea.current=s;const u=xe.some(f=>f.id===s)?s:$r(Ne,s);rt(u?null:Sl(s,ne,o)),Bs([]),Us(""),vn(u)},[Q,ne,V,Ne,xe]),n.useEffect(()=>{if(T!=="items"||Q?.module!=="items"||!Q.targetId)return;const s=Q.targetId,o=Qt;let d=null,u=!1,f=0;const k=()=>
12{if(u)return;const v=o?document.querySelector(`[data-review-selection-group-id="${CSS.escape(o)}"]`):document.querySelector(`[data-portal-review-item-id="${CSS.escape(s)}"]`);if(v){v.scrollIntoView({behavior:"smooth",block:"center"}),yn(s),d=window.setTimeout(()=>{yn(I=>I===s?null:I),vn(I=>I===o?null:I)},1800);return}f>=30||(f+=1,d=window.setTimeout(k,140))};return k(),()=>{u=!0,d!=null&&window.clearTimeout(d)}},[T,Q,Qt]);const Ho=n.useCallback(async s=>{if(z&&R){try{localStorage.setItem(er(R),"1")}catch{}ft(!0);return}if(!J)return;const o=await ll(J);if("error"in o&&o.error){D({title:p("error")||"Error",description:o.error,variant:"destructive"});return}ft(!0)},[z,R,J,D,p]),Ko=n.useMemo(()=>{const s=ht.data;return s?s.tasks.length>0||s.groups.length>0:!1},[ht.data]),Be=!!H&&b&&(ht.isLoading||Ko),qo=n.useMemo(()=>qe||Ve||Te||t||ze||Be,[qe,Ve,Te,t,ze,Be]),_s=n.useMemo(()=>{let s=0;return qe&&s++,Ve&&s++,Te&&s++,t&&s++,ze&&s++,Be&&s++,s},[qe,Ve,Te,t,ze,Be]),Tt=_s>=5?"max-[551px]:flex-none max-[551px]:shrink-0 max-[551px]:basis-auto min-[552px]:flex-1 min-[552px]:basis-0":"flex-1 basis-0",it=n.useCallback(()=>{const s=Bt.current;if(!s)return;const o=3,d=s.scrollWidth>s.clientWidth+o,u=s.scrollLeft+s.clientWidth>=s.scrollWidth-o,f=typeof window<"u"?window.innerWidth:typeof document<"u"?document.documentElement.clientWidth:0,k=f>0&&f<=551,v=f>0&&f<=551,I=v&&(d&&!u||k&&_s>4&&!d),K=v&&s.scrollLeft>o;Ro(I),Po(K)},[_s]),Xt=n.useCallback(()=>{ys.current&&(ys.current.abort(),ys.current=null)},[an]),Yo=n.useCallback(()=>{Xt(),ws(!1),Lo(s=>s+1)},[Xt,an]);n.useEffect(()=>{const s=window.matchMedia(mo),o=window.matchMedia(po),d=()=>{fo({isMobile:s.matches,allowsDetailed:o.matches})};return d(),s.addEventListener?.("change",d),o.addEventListener?.("change",d),()=>{s.removeEventListener?.("change",d),o.removeEventListener?.("change",d)}},[]),n.useEffect(()=>{const s=Hn(L.get("wnTab"));if(s){if(s==="contacts"){const u=L.get("targetId")?.trim()||null,f=L.get("focusNonce"),k=f?Number(f):NaN,v=Number.isFinite(k)?k:Date.now();y(I=>I?.contactId===u&&I?.nonce===v?I:{contactId:u,nonce:v}),g(!0);return}const d=Xn(s);d&&T!==d&&Ke(d);return}const o=qe?["items",...t?["inspirations"]:[],...Te?["creations"]:[],...Ve?["proposal"]:[],...Be?["schedule"]:[],...ze?["documents"]:[]]:[...t?["inspirations"]:[],...Te?["creations"]:[],...Ve?["proposal"]:[],...Be?["schedule"]:[],...ze?["documents"]:[]];if(o.length===0){T!=="items"&&Ke("items");return}o.includes(T)||Ke(o[0])},[T,Te,qe,Ve,t,ze,Be,L]),n.useEffect(()=>{Eo(s=>{if(s.has(T))return s;const o=new Set(s);return o.add(T),o})},[T]),n.useEffect(()=>{if(!Bt.current)return;const s=Bt.current.querySelector('[aria-selected="true"]');s&&s.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),requestAnimationFrame(()=>{requestAnimationFrame(it)})},[T,it]),n.useLayoutEffect(()=>{it()},[it,T,qe,Ve,Te,t,ze,Be,_s]),n.useEffect(()=>{const s=Bt.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(()=>{it()});o.observe(s);const d=()=>it();return window.addEventListener("resize",d),()=>{o.disconnect(),window.removeEventListener("resize",d)}},[it]),n.useEffect(()=>{if(!J||!mt?.length)return;let s=!1;return(async()=>{const o=(mt||[]).filter(u=>{const f=String(u?.status||"").toLowerCase();return f!=="approved"&&f!=="rejected"});if(!o.length)return;const d=await Promise.all(o.map(async u=>{try{const f=await cl(J,String(u.id)),k=f?.comments||[],v=f?.signatures||[];return[String(u.id),{hasComments:k.length>0,hasDecision:v.length>0}]}catch{return[String(u.id),{hasComments:!1,hasDecision:!1}]}}));s||on(u=>{const f={...u};for(const[k,v]of d)f[k]=v;return f})})(),()=>{s=!0}},[J,mt]),n.useEffect(()=>{const s=o=>{};return fe.on("languageChanged",s),()=>{fe.off("languageChanged",s)}},[fe]),n.useEffect(()=>{if(!pe||typeof window>"u"||!("PerformanceObserver"in window))return;let s=null;const o=d=>{try{const u="https://vnpdgalygzenijmlmhgw.supabase.co".replace(/\/+$/,""),f="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZucGRnYWx5Z3plbmlqbWxtaGd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDQxMTI3OTUsImV4cCI6MjA1OTY4ODc5NX0.36mL-8d2o0RVruh5jaakuQzSN5oAqeH5URjSDe6z7v0";if(!u||!f)return;fetch(`${u}/functions/v1/client-portal/telemetry`,{method:"POST",headers:{apikey:f,authorization:`Bearer ${f}`,"content-type":"application/json"},body:JSON.stringify({op:"client_longtask",timing:d}),keepalive:!0}
12).catch(()=>{})}catch{}};try{s=new PerformanceObserver(d=>{for(const u of d.getEntries()){const f={requestId:`longtask-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,endpoint:"ui-longtask",method:"OBSERVE",attempt:1,status:200,ok:!0,durationMs:Math.round(u.duration),name:u.name,entryType:u.entryType,route:window.location.pathname,ts:Date.now()};window.dispatchEvent(new CustomEvent("planify:portal-longtask",{detail:f})),o(f)}}),s.observe({type:"longtask",buffered:!1})}catch{}return()=>{s?.disconnect()}},[pe]),n.useEffect(()=>{const s=()=>{const o=window.innerWidth<768,d=T==="creations"&&Te&&o;document.documentElement.classList.toggle("creations-tab-mobile-no-scrollbar",d),document.body.classList.toggle("creations-tab-mobile-no-scrollbar",d)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),document.documentElement.classList.remove("creations-tab-mobile-no-scrollbar"),document.body.classList.remove("creations-tab-mobile-no-scrollbar")}},[T,Te]);const re=n.useCallback(s=>p(s),[]),jn=n.useMemo(()=>V.filter(s=>!ne[s.id]),[V,ne]),Nn=n.useMemo(()=>V.filter(s=>ne[s.id]==="approved"),[V,ne]),_n=n.useMemo(()=>V.filter(s=>ne[s.id]==="rejected"),[V,ne]),Sn=n.useMemo(()=>V.filter(s=>ne[s.id]==="maybe"),[V,ne]),ta=n.useMemo(()=>V.filter(s=>kl(s.id,ne,s.status)),[V,ne]),Ss=`${ie??"__all__"}|${ot.length>0?[...ot].sort().join(","):"__all_sections__"}|${De.trim().toLowerCase()}`,ks=n.useCallback(s=>{if(ot.length===0)return!0;const o=s.room||"Uncategorized";return ot.includes(o)},[ot]);n.useEffect(()=>{if(ie===null){Vs(null),zs.current=Ss;return}const s=()=>{const u=new Set,f=De.trim().length>0;for(const k of V){if(!ks(k)||!tr(k,De))continue;if(f){u.add(k.id);continue}sr(k.id,ie,ne,k.status)&&u.add(k.id)}return u},d=zs.current!==Ss;if(zs.current=Ss,d){Vs(s());return}Vs(u=>{if(u&&u.size>0)return u;const f=s();return f.size>0?f:u??new Set})},[Ss,ie,ks,De,V,ne]);const kn=n.useMemo(()=>Array.from(new Set(V.map(s=>s.room||"Uncategorized"))).filter(s=>s!==null),[V]),Qo=768,[Xo,Jo]=n.useState(()=>typeof window<"u"?window.innerWidth:1200),Zo=Xo<Qo;n.useEffect(()=>{if(typeof window>"u")return;const s=()=>Jo(window.innerWidth);return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);const xt=n.useCallback(s=>s==="Uncategorized"?re("uncategorized"):dl(s,re,ul),[re]),Jt=n.useMemo(()=>{const s=De.trim().length>0,o=De.trim().toLowerCase(),d=new Set(xe.filter(f=>o&&f.name.toLowerCase().includes(o)).map(f=>f.id)),u=new Set(Ne.filter(f=>d.has(f.group_id)).map(f=>f.review_item_id));return V.filter(f=>{if(!ks(f)||!tr(f,De)&&!u.has(f.id))return!1;if(ie===null||s)return!0;const v=sr(f.id,ie,ne,f.status),I=dt?.has(f.id)??!1;return v||I})},[V,ie,ne,ks,De,dt,xe,Ne]),sa=ta.length===0&&!(ie==="needs_attention"&&(dt?.size??0)>0),Cs=jn.length===0&&!(ie==="pending"&&(dt?.size??0)>0),Is=Nn.length===0&&!(ie==="approved"&&(dt?.size??0)>0),Ps=_n.length===0&&!(ie==="rejected"&&(dt?.size??0)>0),Ts=Sn.length===0&&!(ie==="maybe"&&(dt?.size??0)>0),ei=n.useMemo(()=>Jt.reduce((s,o)=>{const d=o.room||"Uncategorized";return s[d]||(s[d]=[]),s[d].push(o),s},{}),[Jt]),Rs=xe.length>0,Fe=n.useMemo(()=>Rs?Cl(xe,Ne):new Map,[Rs,xe,Ne]),ti=ie==="needs_attention"&&ot.length===0&&ta.length===0&&V.length>0,Zt=(s,o,d=!1)=>{const u=As(s.id),f=u.length>1,k=W[s.id]||[],I=k.find(F=>F.is_primary)?.file_type==="application/pdf",K=Yn(s),N=gs||Gt(s),U=d||Fe.has(s.id);return e.jsx(bc,{item:s,viewMode:pt,primaryImageUrl:Ce[s.id]??null,galleryImages:u,attachments:k,isHighlighted:Go===s.id,hasVisibleCommerceDetails:Oo(s),showProductPrices:xs,showProductLinks:fs,showDetailsButton:N,previewReadOnly:z,submitting:Oa.has(s.id),selectedStatus:ne[s.id]??(s.status==="approved"||s.status==="rejected"||s.status==="maybe"?s.status:null),comment:Ie[s.id]||"",priceDisplay:K?{currency:K.currency,amount:K.amount}:null,roomLabel:o!==void 0?o:s.room?xt(s.room):null,designerReply:s.designer_reply,hasPortalGallery:f,isPdfPrimary:I,onOpenGallery:()=>oi(s),onOpenDetails:()=>ni(s),choiceMode:U,onStatusSelect:F=>{if(U){F==="approved"&&Tn(s.id);return}Cn(s.id,F)},onCommentChange:F=>In(s.id,F),onSave:()=>void gt({itemIds:[s.id]}),onViewPdfInline:Dn,onOpenPdfNewTab:Ln,onDownloadPdf:Mn,getAttachmentBadgeStyles:Fn},s.id)};n.useEffect(()=>{(()=>{if(C){try{sessionStorage.removeItem("review_access_token")}catch{}const d=ce();d&&(Vt("designer_preview"),ut(null),Ys(!1),we(!0),je(d.projectId),He(d));return}const o=me();
12if(o)try{if(ke(o,R)){if(we(!0),je(o.projectId),He(o),o.previewReadOnly){try{ma(et,"1")}catch{}Vt("designer_preview")}}else{X();try{Mt(et)}catch{}}}catch(d){console.error("❌ Session validation error:",d),X();try{Mt(et)}catch{}}})()},[te,D,R,C]),n.useEffect(()=>{if(typeof window>"u"||!R)return;zt.current=!1;const s=window.location.origin,o=window.opener,d=!!ce();if(C&&!d&&(!o||o===window)){ut({message:p("portal.preview.open_from_dashboard"),showReturnToDashboard:!1});return}if(C&&o&&o!==window)try{o.postMessage({type:ar.READY},s)}catch{}const u=async k=>{if(k.origin!==s)return;const v=k.data;if(v?.type!==ar.TOKEN||v.link_token&&v.link_token!==R||zt.current)return;const I=!!(v.portal_session_token&&v.expires_at&&v.project_id);if(!I&&!v.preview_exchange_token){ut({message:p("portal.preview.exchange_failed"),showReturnToDashboard:!0});return}zt.current=!0,window.removeEventListener("message",u);try{const K=I?{portal_session_token:v.portal_session_token,expires_at:v.expires_at,project_id:v.project_id,access_granted_at:new Date().toISOString()}:await yl(R,v.preview_exchange_token),N=K.project_id?.trim();if(!N){ut({message:p("portal.preview.expired"),showReturnToDashboard:!0});return}const U={projectId:N,expiresAt:K.expires_at,grantedAt:K.access_granted_at??new Date().toISOString(),linkToken:R,portalSessionToken:K.portal_session_token,mode:"edge_proxy",previewReadOnly:!0};try{ma(et,"1")}catch{}A(U),Vt("designer_preview"),ut(null),Ys(!1),we(!0),je(N),He(U)}catch{zt.current=!1,ut({message:p("portal.preview.expired"),showReturnToDashboard:!0})}};window.addEventListener("message",u);const f=window.setTimeout(()=>{C&&!zt.current&&!ce()&&ut({message:p("portal.preview.open_from_dashboard"),showReturnToDashboard:!1})},12e3);return()=>{window.removeEventListener("message",u),window.clearTimeout(f)}},[R,p,C]);const aa=n.useRef(!1),na=n.useRef(!1);n.useEffect(()=>{($?.portalSessionToken??$?.portal_session_token)&&(aa.current=!1,na.current=!1,Qs.current=!1)},[$?.expiresAt,$?.portalSessionToken,$?.portal_session_token]),n.useEffect(()=>{if(z||!pe||!$?.expiresAt)return;const s=()=>
12{if(document.visibilityState==="hidden")return;const d=new Date($.expiresAt).getTime();if(Number.isNaN(d))return;const u=d-Date.now();if(!(u<=0)){if(u<=120*1e3&&!na.current){na.current=!0,D({title:p("portalSessionExpiringTitle"),description:p("portalSessionExpiringTwoMinutesBody"),duration:16e3});return}u<=600*1e3&&!aa.current&&(aa.current=!0,D({title:p("portalSessionExpiringTitle"),description:p("portalSessionExpiringTenMinutesBody"),duration:12e3}))}};s();const o=window.setInterval(s,3e4);return()=>window.clearInterval(o)},[pe,$?.expiresAt,p,D,z]),n.useEffect(()=>{const s=o=>{const d=o.detail;Ht({reason:d?.message,code:d?.code,previewMode:Fs(et)==="1"})};return window.addEventListener(Kn,s),()=>{window.removeEventListener(Kn,s)}},[Ht]),n.useEffect(()=>{let s=!0;return(async()=>{if(!H)return;tn.current+=1,tn.current,Xt();const d=new AbortController;ys.current=d,Xe.current&&window.clearTimeout(Xe.current),Xe.current=window.setTimeout(()=>{s&&ws(!0)},15e3),ws(!1),s&&(Ae(!0),Ft(!1));try{const f=z&&!!$?$:me(),k=f?.portalSessionToken||f?.portal_session_token;if(k){const v=await ha(k,{signal:d.signal});if(v?.error)throw new Error(v.error);const I=v.review_items||[],K=v.review_attachments||[],N=v.project,U=mr(I,K,N),F=U.items,se=U.attachments,he=v.proposals||[],Se=v.canvas_creations||[],bt=v.portal_inspirations||[];if(!F||F.length===0){if(!s)return;Ee([]),_e({}),st({}),Ot({}),at({}),Ft(!0),cs(null),_t([]),St([])}else s&&Ft(!1);if(!s)return;if(Ee(F),as.REVIEW_SELECTION_GROUPS){const de=Jn(v.selection_groups);_t(de.groups),St(de.members)}const Qe={};se.forEach(de=>{const Re=de.review_item_id;Re&&(Qe[Re]||(Qe[Re]=[]),Qe[Re].push(de))});const Ue={},lt={},es={};if(await Promise.all(F.map(async de=>{de.status&&de.status!=="pending"?Ue[de.id]=de.status:Ue[de.id]=null,de.client_comment&&(es[de.id]=de.client_comment);const Re=Qe[de.id]||[],yt=Zn(Re,{preferImage:!0}),Ds=typeof de.external_image_url=="string"?String(de.external_image_url).trim():"";lt[de.id]=yt?yt.signed_url||await oa(yt.file_path):Ds&&(Ds.startsWith("http://")||Ds.startsWith("https://"))?Ds:null})),!ye){const de=F.find(Re=>Re.client_name)?.client_name||"";de&&Da(de)}if(!s)return;at(Ue),_e(Qe),st(lt),Ot(es),Xa(he),Ja(Se),Za(bt),en(v.viewer_client_identity_hash??null);const Et=v.session_mode;if(Et==="designer_preview"?Vt("designer_preview"):Et==="client"&&Vt("client"),Et==="designer_preview")try{ft(R?localStorage.getItem(er(R))==="1":!1)}catch{ft(!1)}else ft(!!v.portal_tutorial_fab_dismissed);const ee=v.project,Ze=ee?.portal_show_inspirations!==!1;a(Ze);const At=as.PORTAL_DOCUMENTS&&ee?.portal_show_documents===!0;i(At),j(ee?.portal_show_schedule===!0),l(as.PORTAL_CONTACTS&&ee?.portal_show_contacts===!0),x(ee?.has_visible_portal_contacts===!0),Va(ee?.portal_show_product_links!==!1),za(ee?.portal_show_product_price!==!1);const wt=pr(ee),Vn=hr(v,wt);if(Ba(wt),Ga(Vn),us(fr(v,{allowDetailed:Vn})),sn.current!==H&&(sn.current=H,(F||[]).length>0?Ke("items"):vl&&Se?.length>0?Ke("creations"):Ze?Ke("inspirations"):At?Ke("documents"):he?.length>0?Ke("proposal"):Ke("items")),ee?.logo_path){const de=jl(),Re=ee.logo_path;if(Re.startsWith("private/"))hs(null);else if(ee.signed_logo_url)hs(ee.signed_logo_url);else if(Re.startsWith(le)){const{data:yt}=de.storage.from(S).getPublicUrl(Re);hs(yt?.publicUrl||null)}else{const{data:yt}=de.storage.from("review_attachments").getPublicUrl(Re);hs(yt?.publicUrl||null)}}go({name:ee?.name||"Dashboard",lastUpdated:ka(new Date,"MMM dd, yyyy HH:mm")});return}Ht({reason:"missing-portal-session-token",code:"missing_portal_session",previewMode:Fs(et)==="1"});return}catch(u){if(!s||u?.name==="AbortError"||String(u?.message||"").toLowerCase().includes("aborted"))return;const f=String(u?.message||"");if(Nl(u)){Ht({reason:f,code:typeof u?.code=="string"?String(u.code):void 0,previewMode:Fs(et)==="1"});return}console.error("Error fetching review data:",u),cs(p("failedToLoadReviewDataPleaseTryA"))}finally{Xe.current&&(window.clearTimeout(Xe.current),Xe.current=null),s&&Ae(!1)}})(),()=>{s=!1,Xt(),Xe.current&&(window.clearTimeout(Xe.current),Xe.current=null)}},[H,Do,Xt,z,$,R,Ht]);const Cn=n.useCallback((s,o)=>{z||(kt.current+=1,at(d=>({...d,[s]:o})),Me(!0))},[z]),In=n.useCallback((s,o)=>{z||(kt.current+=1,Ot(d=>({...d,[s]:o})),Me(!0))},[z]),Je=n.useCallback(s=>{const o=s?.status??null;return!o||o==="pending"?null:o==="approved"||o==="rejected"||o==="maybe"?o:null},[]),ve=n.useCallback(s=>(s??"").toString().trim(),[]),Pn=n.useCallback(s=>{const o=Je(s),d=ne[s.id]??o,u=ve(s?.client_comment??""),f=ve(Ie[s.id]??""),k=ve(s?.client_name??""),v=ve(ye);return d!==o||f!==u||v!==k},[ye,Ie,Je,ve,ne]),gt=n.useCallback(async({silent:s=!1,itemIds:o}={})=>
12{if(z||!J)return;const d=o?new Set(o):null,u=Ct.current,f=u.reviewItems.filter(N=>{if(d&&!d.has(N.id)||$s.current.has(N.id))return!1;const U=Je(N),F=u.selectedStatusMap[N.id]??U,se=ve(N?.client_comment??""),he=ve(u.commentsMap[N.id]??"");return F!==U||he!==se});if(f.length===0){u.reviewItems.some(U=>{const F=Je(U),se=u.selectedStatusMap[U.id]??F,he=ve(U?.client_comment??""),Se=ve(u.commentsMap[U.id]??"");return se!==F||Se!==he})||Me(!1),s||D({title:re("allFeedbackSubmitted"),description:re("feedbackForAllItemsSaved")});return}const k=kt.current,v=f.map(N=>N.id);v.forEach(N=>$s.current.add(N));const I=f.map(N=>({reviewItemId:N.id,status:u.selectedStatusMap[N.id]??Je(N)??null,client_name:u.clientName.trim()||null,client_comment:u.commentsMap[N.id]||""}));return(async()=>{s||Wa(N=>{const U=new Set(N);return v.forEach(F=>U.add(F)),U});try{const N=I.filter(F=>F.status==="approved"||F.status==="rejected"||F.status==="maybe");if(I.length>1&&N.length===I.length){const F=await Ms(J,N);if("error"in F&&F.error)throw new Error(F.error)}else{if(N.length>1){const se=await Ms(J,N);if("error"in se&&se.error)throw new Error(se.error)}const F=new Set(N.length>1?N.map(se=>se.reviewItemId):[]);await Promise.all(I.filter(se=>!F.has(se.reviewItemId)).map(async se=>{const he=await ia(J,se);if("error"in he&&he.error)throw new Error(he.error)}))}const U=new Date().toISOString();if(Ee(F=>F.map(se=>{const he=I.find(Se=>Se.reviewItemId===se.id);return he?{...se,status:he.status??se.status,client_name:he.client_name,client_comment:he.client_comment,client_responded_at:U}:se})),Ye({module:"items",targetIds:v}),k===kt.current){const F=new Set(v),se=Ct.current,he=se.reviewItems.some(Se=>{if(F.has(Se.id))return!1;const bt=Je(Se),Qe=se.selectedStatusMap[Se.id]??bt,Ue=ve(Se?.client_comment??""),lt=ve(se.commentsMap[Se.id]??"");return Qe!==bt||lt!==Ue});Me(he)}s||D({title:re("allFeedbackSubmitted"),description:re("feedbackForAllItemsSaved")})}catch(N){console.error("Error autosaving portal feedback:",N),D({title:re("submissionFailed"),description:re("failedToSaveFeedback"),variant:"destructive"})}finally{s||Wa(N=>{const U=new Set(N);return v.forEach(F=>U.delete(F)),U}),v.forEach(N=>$s.current.delete(N)),k!==kt.current&&window.setTimeout(()=>void gt({silent:!0}),0)}})()},[Je,re,Ye,ve,J,z,D]),Tn=n.useCallback(s=>{if(z)return;const o=Fe.get(s)??[s],d={...Ct.current.selectedStatusMap};for(const u of o)d[u]=u===s?"approved":"rejected";kt.current+=1,Ct.current={...Ct.current,selectedStatusMap:d},at(d),Me(!0),gt({silent:!0,itemIds:o})},[Fe,gt,z]);n.useEffect(()=>{if(nt.current!==null&&(window.clearTimeout(nt.current),nt.current=null),!(z||!J||!$e))return nt.current=window.setTimeout(()=>{nt.current=null,gt({silent:!0})},800),()=>{nt.current!==null&&(window.clearTimeout(nt.current),nt.current=null)}},[Ie,$e,gt,J,z,ne]),n.useEffect(()=>{const s=o=>{$e&&(o.preventDefault(),o.returnValue="")};return window.addEventListener("beforeunload",s),()=>{window.removeEventListener("beforeunload",s)}},[$e]),n.useEffect(()=>{const s={__clientReviewGuard:!0}
12;try{history.pushState(s,document.title,window.location.href)}catch{}const o=()=>{if(!Ka.current&&$e){try{history.pushState(s,document.title,window.location.href)}catch{}Ks(null),Wt(!0)}},d=u=>{if(!$e)return;const f=u.target;if(!f)return;const k=f.closest("a");if(!k)return;const v=k.getAttribute("href")||"";if(!v||v.startsWith("#")||k.target==="_blank")return;const I=new URL(k.href,window.location.origin);I.origin===window.location.origin&&(u.preventDefault(),Ks(I.pathname+I.search+I.hash),Wt(!0))};return window.addEventListener("popstate",o),document.addEventListener("click",d,!0),()=>{window.removeEventListener("popstate",o),document.removeEventListener("click",d,!0)}},[$e]);const Es=n.useCallback(()=>{Hs?window.location.href=Hs:(Ka.current=!0,window.history.back())},[Hs]),Rn=n.useCallback(async()=>{if(z)return!0;const s=V.filter(o=>Pn(o));if(s.length===0)return!0;ps(!0);try{D({title:re("submittingYourAnswers"),description:re("savingAllFeedback")});const o=me(),d=o?.portalSessionToken||o?.portal_session_token;let u=[];const f=s.map(v=>{const I=ne[v.id];return I?{reviewItemId:v.id,status:I,client_name:ye.trim()||null,client_comment:Ie[v.id]||""}:null}).filter(Boolean);if(d){let v=!1;try{(await Ms(d,f))?.success&&(v=!0,u=f.map(K=>({itemId:K.reviewItemId,status:K.status,success:!0})))}catch{v=!1}if(!v){if(f.some(K=>Fe.has(K.reviewItemId)))throw new Error("Selection-group feedback requires an atomic bulk save");const I=f.map(async K=>{const N=await ia(d,K);if(N?.error)throw new Error(N.error);return{itemId:K.reviewItemId,status:K.status,success:!0}});u=await Promise.all(I)}}else throw new Error("Missing portal session. Please re-enter PIN.");Ee(v=>v.map(I=>{const K=u.find(N=>N.itemId===I.id&&N.success);return K&&K.success?{...I,status:K.status,client_name:ye.trim()||null,client_comment:Ie[I.id]||"",client_responded_at:new Date().toISOString()}:I}));const k={...ne};return u.forEach(v=>{v.success&&(k[v.itemId]=v.status)}),at(k),D({title:re("allFeedbackSubmitted"),description:re("feedbackForAllItemsSaved")}),Ye({module:"items",targetIds:u.filter(v=>v.success).map(v=>String(v.itemId))}),Me(!1),!0}catch(o){return console.error("Error submitting all feedback:",o),D({title:re("submissionFailed"),description:re("failedToSaveFeedback"),variant:"destructive"}),!1}finally{ps(!1)}},[Fe,ye,V,ne,Ie,D,re,Pn,z,Ye]),si=n.useCallback(async()=>{await Rn()&&(Wt(!1),Me(!1),Es())},[Rn,Es]),ai=n.useCallback(()=>{Wt(!1),Me(!1),Es()},[Es]),ni=n.useCallback(s=>{wo(s),Ha(!0)},[]),En=n.useCallback(async s=>{if(!z){ps(!0);try{D({title:re("submittingYourAnswers"),description:re("savingAllFeedback")});const o=me(),d=o?.portalSessionToken||o?.portal_session_token,f=V.filter(N=>{if(Fe.has(N.id))return!1;const U=Je(N),F=ve(N?.client_comment??""),se=ve(Ie[N.id]??""),he=ve(N?.client_name??""),Se=ve(ye);return U!==s||F!==se||he!==Se}).map(N=>({reviewItemId:N.id,status:s,client_name:ye.trim()||null,client_comment:Ie[N.id]||""}));if(f.length===0){D({title:re("noFeedbackToSubmit"),description:re("allItemsAlreadyReviewed")}),Me(!1);return}let k=[];if(d){let N=!1;try{(await Ms(d,f))?.success&&(N=!0,k=f.map(F=>({itemId:F.reviewItemId,status:F.status,success:!0})))}catch{N=!1}if(!N){if(f.some(F=>Fe.has(F.reviewItemId)))throw new Error("Selection-group feedback requires an atomic bulk save");const U=f.map(async F=>{const se=await ia(d,F);if(se?.error)throw new Error(se.error);return{itemId:F.reviewItemId,status:F.status,success:!0}});k=await Promise.all(U)}}else throw new Error("Missing portal session. Please re-enter PIN.");const v=k.filter(N=>N.success).length;dd(V,k);const I=new Set(f.map(N=>N.reviewItemId)),K=new Date().toISOString();Ee(N=>N.map(U=>I.has(U.id)?{...U,status:s,client_name:ye.trim()||null,client_comment:Ie[U.id]||"",client_responded_at:K}:U)),D({title:re("allFeedbackSubmitted"),description:re("feedbackForAllItemsSaved")}),Ye({module:"items",targetIds:k.filter(N=>N.success).map(N=>String(N.itemId))}),Me(!1)}catch(o){console.error("Error submitting all feedback:",o),D({title:re("submissionFailed"),description:re("failedToSaveFeedback"),variant:"destructive"})}finally{ps(!1)}}},[Fe,ye,V,Ie,D,re,Je,ve,z,Ye]),An=n.useCallback(async s=>{const o={...ne};
12V.forEach(d=>{Fe.has(d.id)||(o[d.id]=s)}),at(o),Me(!0),await En(s)},[Fe,V,ne,En]),ri=n.useCallback(async()=>{const s=$t;s&&(Pt(null),await An(s))},[$t,An]),Rt=n.useCallback(async s=>{try{return s.signed_url?s.signed_url:await oa(s.file_path)}catch{return null}},[]),Dn=n.useCallback(async s=>{Qa(!0),ko(s.file_name);const o=await Rt(s);_o(o),Qa(!1),o&&qa(!0)},[Rt]),Ln=n.useCallback(async s=>{const o=await Rt(s);o&&window.open(o,"_blank","noopener,noreferrer")},[Rt]),Mn=n.useCallback(async s=>{const o=await Rt(s);o&&await Il(o,s.file_name||"document.pdf")},[Rt]),Fn=n.useCallback(s=>{const o=s.file_name?.split(".").pop()?.toUpperCase()||s.file_type?.split("/").pop()?.toUpperCase()||"FILE",d={label:o||"FILE",className:"bg-gray-100 text-gray-700"};return s.file_type==="application/pdf"||o==="PDF"?{label:"PDF",className:"bg-red-100 text-red-700"}:s.file_type?.startsWith("image/")?{label:o||"IMG",className:"bg-blue-100 text-blue-700"}:["DOC","DOCX","TXT","RTF","MD"].includes(o)?{label:o,className:"bg-indigo-100 text-indigo-700"}:["XLS","XLSX","CSV"].includes(o)?{label:o,className:"bg-emerald-100 text-emerald-700"}:["ZIP","RAR","7Z"].includes(o)?{label:o,className:"bg-amber-100 text-amber-700"}:d},[]),On=n.useCallback(s=>!!s?.file_type?.startsWith("image/"),[]),Wn=n.useCallback((s,o)=>s.signed_url||s.public_url||s.is_primary&&Ce[o]||null,[Ce]),As=n.useCallback(s=>(W[s]||[]).filter(o=>On(o)).map(o=>({id:o.id,url:Wn(o,s)||"",isPrimary:o.is_primary})).filter(o=>!!o.url),[W,Wn,On]),oi=n.useCallback(s=>{const d=As(s.id).map(f=>f.url).filter(Boolean),u=Ce[s.id]?.trim();if(d.length>0){It.openWithUrls(d,{title:s.title});return}u&&It.openWithUrls([u],{title:s.title})},[As,It,Ce]),$n=()=>{try{window.close()}catch{}setTimeout(()=>te("/"),300)};return jo&&!pe?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50 px-4",children:[e.jsx("div",{className:"w-full flex justify-center mb-6 mt-4",children:e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm px-6 py-3 flex items-center",children:e.jsx(ct,{})})}),e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:p("portal.preview.expired")}),e.jsx(oe,{type:"button",onClick:$n,children:p("portal.preview.return_to_dashboard")})]})]}):qs&&!pe?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50 px-4",children:[e.jsx("div",{className:"w-full flex justify-center mb-6 mt-4",children:e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm px-6 py-3 flex items-center",children:e.jsx(ct,{})})}),e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:qs.message}),qs.showReturnToDashboard?e.jsx(oe,{type:"button",variant:"outline",onClick:$n,children:p("portal.preview.return_to_dashboard")}):null]})]}):pe?ls?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50",children:[e.jsx("div",{className:"w-full flex justify-center mb-6 mt-4",children:e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm px-6 py-3 flex items-center",children:e.jsx(ct,{})})}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:p("loadingReviewItems")}),Mo?e.jsxs("div",{className:"mt-4 rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-left text-sm text-amber-900",children:[e.jsx("div",{className:"font-medium",children:p("stillLoading")||"Still loading..."}),e.jsx("div",{className:"mt-1",children:p("portalRetryPrompt")||"This is taking longer than expected. You can retry now."}),e.jsx("div",{className:"mt-3",children:e.jsx(oe,{size:"sm",variant:"outline",onClick:Yo,children:p("retry")||"Retry"})})]}):null]})]}):Aa?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50",children:[e.jsx("div",{className:"w-full flex justify-center mb-6 mt-4",children:e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm px-6 py-3 flex items-center",children:e.jsx(ct,{})})}),e.jsxs("div",{className:"text-center max-w-lg mx-auto",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:p("reviewNotFound")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:Aa}),e.jsx(ml,{to:"/",children:e.jsxs(oe,{variant:"outline",children:[e.jsx(qn,{
12className:"mr-2 h-4 w-4"}),p("returnToHome")]})})]})]}):e.jsxs("div",{className:_("flex flex-col bg-gray-50",T==="schedule"?"h-[100dvh] max-h-[100dvh] overflow-hidden":"min-h-[100dvh]"),children:[z?e.jsx("div",{role:"status",className:_("sticky top-0 z-40 shrink-0 border-b border-blue-200 bg-blue-50 px-4 py-2.5 text-center text-sm font-medium text-blue-800",(m||vs)&&"sm:w-[calc(100%-400px)]"),children:p("portal.preview.banner")}):null,e.jsx("div",{className:"shrink-0 bg-white border-b border-gray-200",children:e.jsx("div",{className:"max-w-7xl mx-auto px-6",children:e.jsxs("div",{className:"flex flex-col py-4 min-[760px]:h-36 min-[760px]:flex-row min-[760px]:items-center min-[760px]:justify-between min-[760px]:gap-4 min-[760px]:py-0 lg:h-40",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3 md:gap-4",children:[e.jsx("div",{className:_("flex shrink-0 items-center",Gs?"h-20 max-w-[200px] min-[760px]:h-24 min-[760px]:max-w-[180px] lg:h-28 lg:max-w-[280px]":"h-16 w-16 md:h-20 md:w-20"),children:e.jsx("img",{src:Gs||"/images/Logo.png",alt:"Logo",className:_("object-contain",Gs?"h-20 w-auto max-h-20 max-w-[200px] object-left min-[760px]:h-24 min-[760px]:max-h-24 min-[760px]:max-w-[180px] lg:h-28 lg:max-h-28 lg:max-w-[280px]":"h-16 w-16 md:h-20 md:w-20"),onError:s=>{s.target.src="/images/Logo.png"}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"truncate text-xl font-bold text-gray-900 sm:text-2xl md:text-3xl",children:$a?.name||p("projectReview")}),e.jsxs("p",{className:"mt-1 truncate text-sm text-gray-500",children:[p("lastUpdated")," ",$a?.lastUpdated||"recently"]})]})]})}),e.jsx("div",{className:"mt-4 flex h-9 w-full shrink-0 items-center justify-center gap-3 min-[760px]:mt-0 min-[760px]:w-auto min-[760px]:justify-end",children:e.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-center gap-2",children:[Fo?e.jsx(Xc,{onClick:()=>g(!0)}):null,e.jsx(Vc,{unreadTotal:Yt.total,onClick:$o}),e.jsx(ct,{})]})})]})})}),e.jsx("div",{className:_("mx-auto flex w-full max-w-7xl flex-1 flex-col px-6 py-6",T==="schedule"?"min-h-0 overflow-hidden":"min-h-0"),children:qo?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 shrink-0 bg-white border border-gray-200 rounded-lg px-4 sm:px-6 py-3",children:[e.jsxs("div",{className:"min-[858px]:hidden relative",children:[e.jsx("div",{className:"mx-auto w-full border-b border-gray-200 pb-0.5",role:"tablist","aria-label":p("portalSections")||"Portal sections",children:e.jsxs("div",{ref:Bt,className:"flex w-full min-w-0 items-stretch gap-0 overflow-x-auto scrollbar-hide",onScroll:()=>it(),children:[qe?e.jsxs("button",{type:"button",onClick:()=>Pe("items"),role:"tab","aria-selected":T==="items",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="items"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("items"),emphasis:T==="items"?"medium":"subtle"}),e.jsx(ba,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("items")||"Items"}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="items"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null,t?e.jsxs("button",{type:"button",onClick:()=>Pe("inspirations"),role:"tab","aria-selected":T==="inspirations",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="inspirations"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("inspirations"),emphasis:T==="inspirations"?"medium":"subtle"}),e.jsx(We,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("inspirations")||"Inspirations"}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="inspirations"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null,Te?e.jsxs("button",{type:"button",onClick:()=>Pe("creations"),role:"tab","aria-selected":T==="creations",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="creations"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("creations"),emphasis:T==="creations"?"medium":"subtle"}),e.jsx(ga,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("canvasCreations")||"Creations"}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="creations"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null,Ve?e.jsxs("button",{type:"button",onClick:()=>Pe("proposal"),role:"tab","aria-selected":T==="proposal",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="proposal"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("proposal"),emphasis:T==="proposal"?"medium":"subtle"}),e.jsx(ns,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("proposal")||"Proposal"}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="proposal"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null,Be?e.jsxs("button",{type:"button",onClick:()=>Pe("schedule"),role:"tab","aria-selected":T==="schedule",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="schedule"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("schedule"),emphasis:T==="schedule"?"medium":"subtle"}
12),e.jsx(xa,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("schedule.tab","Schedule")}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="schedule"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null,ze?e.jsxs("button",{type:"button",onClick:()=>Pe("documents"),role:"tab","aria-selected":T==="documents",className:`relative min-h-[3.5rem] min-w-[64px] ${Tt} px-1 py-2 text-[13px] font-semibold transition-colors inline-flex flex-col items-center justify-center gap-1 rounded-t-md ${T==="documents"?"text-gray-900":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Oe,{count:be("documents"),emphasis:T==="documents"?"medium":"subtle"}),e.jsx(fa,{className:"h-3.5 w-3.5 shrink-0 opacity-90","aria-hidden":"true"}),e.jsx("span",{className:"w-full text-center text-[10px] min-[360px]:text-[11px] font-semibold leading-tight whitespace-normal break-words",children:p("clientPortalDocumentsTab")}),e.jsx("span",{className:`pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-full transition-opacity ${T==="documents"?"bg-gray-900 opacity-100":"opacity-0"}`,"aria-hidden":"true"})]}):null]})}),Io?e.jsxs("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 flex items-center z-10",children:[e.jsx("div",{className:"w-14 bg-gradient-to-r from-white from-25% via-white/85 to-transparent h-full"}),e.jsx("div",{className:"absolute left-1.5 text-gray-500 drop-shadow-sm",children:e.jsx(qn,{className:"h-4 w-4",strokeWidth:2.25})})]}):null,To?e.jsxs("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 flex items-center z-10",children:[e.jsx("div",{className:"w-14 bg-gradient-to-l from-white from-25% via-white/85 to-transparent h-full"}),e.jsx("div",{className:"absolute right-1.5 text-gray-500 drop-shadow-sm",children:e.jsx(pl,{className:"h-4 w-4",strokeWidth:2.25})})]}):null]}),e.jsx("div",{className:"hidden min-[858px]:flex items-center justify-center",children:e.jsxs("div",{className:"inline-flex items-center rounded-md border border-gray-200 bg-gray-50 p-0.5",children:[qe?e.jsxs("button",{type:"button",onClick:()=>Pe("items"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="items"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("items")>0?"pr-8":""}`,children:[e.jsx(ba,{className:"h-4 w-4"}),p("items")||"Items",e.jsx(Oe,{count:be("items"),emphasis:T==="items"?"medium":"subtle"})]}):null,t?e.jsxs("button",{type:"button",onClick:()=>Pe("inspirations"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="inspirations"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("inspirations")>0?"pr-8":""}`,children:[e.jsx(We,{className:"h-4 w-4"}),p("inspirations")||"Inspirations",e.jsx(Oe,{count:be("inspirations"),emphasis:T==="inspirations"?"medium":"subtle"})]}):null,Te?e.jsxs("button",{type:"button",onClick:()=>Pe("creations"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="creations"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("creations")>0?"pr-8":""}`,children:[e.jsx(ga,{className:"h-4 w-4"}),p("canvasCreations")||"Creations",e.jsx(Oe,{count:be("creations"),emphasis:T==="creations"?"medium":"subtle"})]}):null,Ve?e.jsxs("button",{type:"button",onClick:()=>Pe("proposal"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="proposal"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("proposal")>0?"pr-8":""}`,children:[e.jsx(ns,{className:"h-4 w-4"}),p("proposal")||"Proposal",e.jsx(Oe,{count:be("proposal"),emphasis:T==="proposal"?"medium":"subtle"})]}):null,Be?e.jsxs("button",{type:"button",onClick:()=>Pe("schedule"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="schedule"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("schedule")>0?"pr-8":""}
12`,children:[e.jsx(xa,{className:"h-4 w-4"}),p("schedule.tab","Schedule"),e.jsx(Oe,{count:be("schedule"),emphasis:T==="schedule"?"medium":"subtle"})]}):null,ze?e.jsxs("button",{type:"button",onClick:()=>Pe("documents"),className:`relative h-9 px-5 text-sm font-medium rounded whitespace-nowrap transition-all inline-flex items-center gap-2 ${T==="documents"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-white/60"} ${be("documents")>0?"pr-8":""}`,children:[e.jsx(fa,{className:"h-4 w-4"}),p("clientPortalDocumentsTab"),e.jsx(Oe,{count:be("documents"),emphasis:T==="documents"?"medium":"subtle"})]}):null]})})]}),Ve&&Ut.has("proposal")?e.jsx("div",{className:`mb-10 bg-white border border-gray-200 rounded-lg p-4 ${T==="proposal"?"":"hidden"}`,children:e.jsx(n.Suspense,{fallback:e.jsx(ss,{}),children:e.jsx(nd,{portalSessionToken:$?.portalSessionToken||$?.portal_session_token,proposals:mt,previewReadOnly:z,onRefreshRef:cn,initialProposalId:Q?.module==="proposals"?Q.targetId:null,initialThreadEntryId:Q?.module==="proposals"?Q.secondaryTargetId:null,focusNonce:Q?.module==="proposals"?Q.nonce:0,onHandled:s=>{Ye({module:"proposals",targetId:s})},onThreadMeta:(s,o)=>{on(d=>({...d,[s]:o}))}})})}):null,Te&&Ut.has("creations")?e.jsx("div",{className:`mb-10 min-w-0 max-w-full ${T==="creations"?"":"hidden"}`,children:e.jsx(n.Suspense,{fallback:e.jsx(ss,{}),children:e.jsx(rd,{portalSessionToken:$?.portalSessionToken||$?.portal_session_token,isActive:T==="creations",initialCreations:bs,previewReadOnly:z,onRefreshRef:dn,initialCreationId:Q?.module==="creations"?Q.targetId:null,initialCommentId:Q?.module==="creations"?Q.secondaryTargetId:null,focusNonce:Q?.module==="creations"?Q.nonce:0,onHandled:s=>{Ye({module:"creations",targetId:s})}})})}):null,t&&(T==="inspirations"||Ut.has("inspirations"))?e.jsx("div",{className:`mb-10 bg-white border border-gray-200 rounded-lg p-4 ${T==="inspirations"?"":"hidden"}`,children:e.jsx(n.Suspense,{fallback:e.jsx(ss,{}),children:e.jsx(od,{portalSessionToken:$?.portalSessionToken||$?.portal_session_token,isActive:T==="inspirations",initialInspirations:Xs,viewerClientIdentityHash:Ao,clientDisplayName:ye,previewReadOnly:z,onRefreshRef:un,initialInspirationId:Q?.module==="inspirations"?Q.targetId:null,focusNonce:Q?.module==="inspirations"?Q.nonce:0,onHandled:s=>{Ye({module:"inspirations",targetId:s})}})})}):null,ze&&J&&(T==="documents"||Ut.has("documents"))?e.jsx("div",{className:`mb-10 bg-white border border-gray-200 rounded-lg p-4 ${T==="documents"?"":"hidden"}`,children:e.jsx(n.Suspense,{fallback:e.jsx(ss,{}),children:e.jsx(id,{portalSessionToken:J,projectId:H,previewReadOnly:z,portalAuthorName:ye.trim()||null,onPortalShowDocumentsChange:Wo,onRefreshRef:mn,initialDocumentId:Q?.module==="documents"?Q.targetId:null,initialCommentId:Q?.module==="documents"?Q.secondaryTargetId:null,focusNonce:Q?.module==="documents"?Q.nonce:0,onHandled:s=>{Ye({module:"documents",targetId:s})}})})}):null,Be&&Ut.has("schedule")&&H&&J?e.jsx("div",{className:`mb-10 bg-white border border-gray-200 rounded-lg p-4 ${T==="schedule"?"flex min-h-0 flex-1 flex-col overflow-hidden":""} ${T==="schedule"?"":"hidden"}`,children:e.jsx(n.Suspense,{fallback:e.jsx(ss,{}),children:e.jsx(ld,{projectId:H,portalSessionToken:J,initialTaskId:Q?.module==="schedule"?Q.targetId:null,focusNonce:Q?.module==="schedule"?Q.nonce:0})})}):null,!qe||T!=="items"?null:e.jsxs(e.Fragment,{children:[ho?e.jsxs("div",{className:"mb-8 rounded-lg border bg-white p-6 text-center",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:p("noReviewItemsYet","No review items yet")}),e.jsx("p",{className:"text-sm text-gray-600",children:p("reviewLinkNoItemsDescription","This review link is active, but the project does not have any review items yet. Please ask the designer to add items and refresh this page.")})]}):null,e.jsxs("div",{className:"flex flex-row flex-nowrap gap-1 sm:gap-2 md:gap-3 w-full min-w-0 mb-0 md:grid md:grid-cols-6",children:[e.jsx(ya,{delayDuration:200,children:e.jsx(Pl,{children:e.jsxs("div",{className:`rounded-lg border max-md:touch-manipulation transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie==="needs_attention"?"bg-violet-50 border-violet-200 ring-1 ring-violet-100":"bg-white border-gray-200"} ${sa?"cursor-not-allowed opacity-50 grayscale-[0.35]":"cursor-pointer hover:shadow-md max-md:active:scale-[0.99]"}`,onClick:sa?void 0:()=>rt("needs_attention"),"aria-disabled":sa,children:[e.jsxs("div",{className:"flex flex-row items-center justify-center gap-1 md:gap-1.5",children:[e.jsx(pa,{className:"h-4 w-4 shrink-0 text-violet-700","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-semibold text-center leading-tight text-violet-700",children:p("reviewFilterNeedsAttention","Needs attention")})]}),e.jsx("span",{className:"text-base font-bold md:text-lg leading-none text-center tabular-nums text-gray-900",children:ta.length})]})})}),e.jsxs("div",{className:`rounded-lg border max-md:touch-manipulation transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie==="pending"?"bg-gray-50 border-gray-300":"bg-white border-gray-200"} ${Cs?"opacity-50 cursor-not-allowed pointer-events-none grayscale-[0.35]":"cursor-pointer hover:shadow-md max-md:active:scale-[0.99]"}`,onClick:Cs?void 0:()=>rt(ie==="pending"?ts:"pending"),title:Cs?`${p("pending")} (0)`:p("pending"),"aria-disabled":Cs,children:[e.jsxs("div",{className:"flex flex-row items-center justify-center gap-1 md:gap-1.5",children:[e.jsx(Pr,{className:"h-4 w-4 shrink-0 text-gray-500","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-medium text-center leading-tight text-gray-500",children:p("pending")})]}),e.jsx("span",{className:"text-base font-bold md:text-lg leading-none text-center tabular-nums text-gray-900",children:jn.length})]}),e.jsxs("div",{className:`rounded-lg border max-md:touch-manipulation transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie==="maybe"?"bg-amber-50 border-amber-200":"bg-white border-gray-200"} ${Ts?"opacity-50 cursor-not-allowed pointer-events-none grayscale-[0.35]":"cursor-pointer hover:shadow-md max-md:active:scale-[0.99]"}`,onClick:Ts?void 0:()=>rt(ie==="maybe"?ts:"maybe"),title:Ts?`${p("maybe")} (0)`:p("maybe"),"aria-disabled":Ts,children:[e.jsxs("div",{className:"flex flex-row items-center justify-center gap-1 md:gap-1.5",children:[e.jsx(os,{className:"h-4 w-4 shrink-0 text-amber-600","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-medium text-center leading-tight text-amber-600",children:p("maybe")})]}),e.jsx("span",{className:"text-base font-bold md:text-lg leading-none text-center tabular-nums text-gray-900",children:Sn.length})]}),e.jsxs("div",{className:`rounded-lg border max-md:touch-manipulation transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie==="rejected"?"bg-red-50 border-red-200":"bg-white border-gray-200"} ${Ps?"opacity-50 cursor-not-allowed pointer-events-none grayscale-[0.35]":"cursor-pointer hover:shadow-md max-md:active:scale-[0.99]"}`,onClick:Ps?void 0:()=>rt(ie==="rejected"?ts:"rejected"),title:Ps?`${p("rejected")} (0)`:p("rejected"),"aria-disabled":Ps,children:[e.jsxs("div",{className:"flex flex-row items-center justify-center gap-1 md:gap-1.5",children:[e.jsx(Wr,{className:"h-4 w-4 shrink-0 text-red-600","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-medium text-center leading-tight text-red-600",children:p("rejected")})]}),e.jsx("span",{className:"text-base font-bold md:text-lg leading-none text-center tabular-nums text-gray-900",children:_n.length})]}),e.jsxs("div",{className:`rounded-lg border max-md:touch-manipulation transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie==="approved"?"bg-green-50 border-green-200":"bg-white border-gray-200"} ${Is?"opacity-50 cursor-not-allowed pointer-events-none grayscale-[0.35]":"cursor-pointer hover:shadow-md max-md:active:scale-[0.99]"}`,onClick:Is?void 0:()=>rt(ie==="approved"?ts:"approved"),title:Is?`${p("approved")} (0)`:p("approved"),"aria-disabled":Is,children:[e.jsxs("div",{className:"flex flex-row items-center justify-center gap-1 md:gap-1.5",children:[e.jsx(Or,{className:"h-4 w-4 shrink-0 text-green-600","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-medium text-center leading-tight text-green-600",children:p("approved")})]}),e.jsx("span",{className:"text-base font-bold md:text-lg leading-none text-center tabular-nums text-gray-900",children:Nn.length})]}),e.jsxs("div",{className:`rounded-lg border cursor-pointer max-md:touch-manipulation hover:shadow-md max-md:active:scale-[0.99] transition-shadow min-w-0 flex-1 basis-0 md:flex-none md:w-full flex flex-col items-center justify-center gap-1 max-md:min-h-[4.25rem] max-md:py-2 max-md:px-0.5 md:gap-1 md:p-2 ${ie===null?"bg-white border-gray-200 shadow-sm":"bg-slate-50/80 border-gray-200/70"}`,onClick:()=>rt(null),title:p("allItems"),children:[e.jsxs("div",{className:`flex flex-row items-center justify-center gap-1 md:gap-1.5 ${ie===null?"text-slate-600":"text-muted-foreground"}`,children:[e.jsx(hl,{className:"h-4 w-4 shrink-0 opacity-80","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline text-sm font-normal text-center leading-tight",children:p("allItems")})]}),e.jsx("span",{className:`text-base font-bold md:text-lg leading-none text-center tabular-nums ${ie===null?"text-gray-900":"text-gray-600"}`,children:V.length})]})]}),e.jsxs("div",{className:"mb-8 mt-2.5 w-full",children:[e.jsx("div",{className:"w-full rounded-lg border border-gray-200 bg-white p-4 shadow-sm md:hidden",children:e.jsx(or,{variant:"mobile",sections:kn,selectedSections:ot,onSectionsChange:Bs,get
12SectionLabel:xt,className:"w-full"})}),e.jsxs("div",{className:"hidden w-full flex-col rounded-xl border border-gray-100 bg-white shadow-sm md:flex",children:[e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-2 gap-y-2 px-3 py-2.5 lg:gap-x-3 lg:px-4 xl:flex-nowrap xl:gap-x-4",children:[e.jsxs("div",{className:"flex min-w-0 shrink-0 items-center gap-2 lg:gap-2.5",children:[e.jsx(or,{variant:"desktop",sections:kn,selectedSections:ot,onSectionsChange:Bs,getSectionLabel:xt,className:"min-w-0 shrink"}),e.jsx(lr,{variant:"icon",value:De,onChange:Us,expanded:La||De.trim().length>0,onExpandedChange:Ma})]}),ms.allowsDetailed?e.jsx("div",{className:"mx-1 hidden h-6 w-px shrink-0 self-center bg-gray-200 xl:block","aria-hidden":!0}):null,e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto lg:gap-3 xl:gap-4",children:[ms.allowsDetailed?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:_("grid h-10 min-w-0 rounded-lg bg-gray-100 p-0.5",gs&&Ua?"w-full min-w-[11rem] max-w-full grid-cols-2 sm:w-auto sm:min-w-[10rem] lg:min-w-[15rem] lg:max-w-[20rem] lg:grid-cols-3 xl:w-[22.5rem] xl:max-w-[22.5rem]":"w-full min-w-[9rem] max-w-full grid-cols-2 sm:w-auto sm:min-w-[10rem] lg:min-w-[12rem] xl:w-[15rem] xl:max-w-[15rem]"),role:"group","aria-label":p("reviewViewMode")||"View mode",children:[e.jsxs("button",{type:"button",onClick:()=>Js("grid"),title:p("reviewGalleryView")||"Gallery View","aria-label":p("reviewGalleryView")||"Gallery View",className:_("flex h-full min-w-0 items-center justify-center gap-1 rounded-md px-1 text-sm font-medium transition-all lg:gap-1.5 lg:px-2",pt==="grid"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"),children:[e.jsx(fl,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden truncate lg:inline",children:p("reviewGalleryShort")||"Gallery"})]}),e.jsxs("button",{type:"button",onClick:()=>Js("list"),title:p("reviewListView")||"List View","aria-label":p("reviewListView")||"List View",className:_("flex h-full min-w-0 items-center justify-center gap-1 rounded-md px-1 text-sm font-medium transition-all lg:gap-1.5 lg:px-2",pt==="list"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"),children:[e.jsx(xl,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden truncate lg:inline",children:p("reviewListShort")||"List"})]}),gs&&Ua?e.jsxs("button",{type:"button",onClick:()=>Js("detailed"),title:p("reviewDetailedView")||"Detailed View","aria-label":p("reviewDetailedView")||"Detailed View",className:_("hidden h-full min-w-0 items-center justify-center gap-1 rounded-md px-1 text-sm font-medium transition-all lg:flex lg:gap-1.5 lg:px-2",pt==="detailed"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"),children:[e.jsx(Dl,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden truncate lg:inline",children:p("reviewDetailedShort")||"Detailed"})]}):null]}),e.jsx("div",{className:"h-6 w-px shrink-0 bg-gray-200","aria-hidden":!0})]}):null,e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 lg:gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>Pt("rejected"),disabled:Le||z,className:"inline-flex h-10 items-center rounded-md px-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 disabled:pointer-events-none disabled:opacity-50 md:px-2.5 lg:px-3","aria-label":p("rejectAll"),title:p("rejectAll"),children:[e.jsx(Ge,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"ml-1 whitespace-nowrap",children:p(Le?"saving":"rejectAll")})]}),e.jsxs("button",{type:"button",onClick:()=>Pt("approved"),disabled:Le||z,className:"inline-flex h-10 items-center rounded-md bg-emerald-600 px-2.5 text-sm font-medium text-white shadow-sm transition-colors hover:bg-emerald-700 disabled:pointer-events-none disabled:opacity-50 md:px-3 lg:px-4","aria-label":p("approveAll"),title:p("approveAll"),children:[e.jsx(Nt,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"ml-1 whitespace-nowrap",children:p(Le?"saving":"approveAll")})]})]})]})]}),e.jsx(lr,{variant:"expanded-row",value:De,onChange:Us,expanded:La||De.trim().length>0,onExpandedChange:Ma})]}),Zo?e.jsxs("div",{className:"mt-2.5 flex w-full gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>Pt("rejected"),disabled:Le||z,className:"inline-flex h-10 min-w-0 flex-1 touch-manipulation items-center justify-center rounded-md px-3 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 disabled:pointer-events-none disabled:opacity-50",children:[e.jsx(Ge,{className:"mr-1.5 h-4 w-4 shrink-0"}),p(Le?"saving":"rejectAll")]}),e.jsxs("button",{type:"button",onClick:()=>Pt("approved"),disabled:Le||z,className:"inline-flex h-10 min-w-0 flex-1 touch-manipulation items-center justify-center rounded-md bg-emerald-600 px-3 text-sm font-medium text-white shadow-sm transition-colors hover:bg-emerald-700 disabled:pointer-events-none disabled:opacity-50",children:[e.jsx(Nt,{className:"mr-1.5 h-4 w-4 shrink-0"}),p(Le?"saving":"approveAll")]})]}):null]}),Jt.length>0?pt==="detailed"?e.jsx("div",{className:"mb-12",children:e.jsx(ya,{delayDuration:200,children:Rs?e.jsx("div",{className:"flex flex-col gap-2",children:la(Jt,xe,Ne,V).map((s,o)=>
12{const d=s.kind==="group"&&s.group.selection_mode==="choose_one",u=s.items.map(f=>Zt(f,f.room?xt(f.room):p("generalItems"),d));return s.kind==="items"?e.jsx("div",{className:"overflow-hidden rounded-xl border border-gray-200/80 bg-white shadow-[0_2px_8px_rgb(0,0,0,0.04)]",children:e.jsx("div",{className:"divide-y divide-gray-100",children:u})},`items-${o}`):e.jsx(ca,{groupId:s.group.id,name:s.group.name,selectionMode:s.group.selection_mode,items:s.items,variant:"table",innerClassName:"flex flex-col p-0",isHighlighted:Qt===s.group.id,children:u},s.group.id)})}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-gray-200/80 bg-white shadow-[0_2px_8px_rgb(0,0,0,0.04)]",children:e.jsx("div",{className:"divide-y divide-gray-100",children:Jt.map(s=>Zt(s,s.room?xt(s.room):p("generalItems")))})})})}):Object.entries(ei).map(([s,o])=>{const d=pt==="grid"?"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3":"grid grid-cols-1 gap-6";return e.jsxs("div",{className:"mb-12",children:[e.jsx("h2",{className:"mb-6 text-xl font-semibold",children:s==="Uncategorized"?p("generalItems"):xt(s)}),Rs?pt==="grid"?e.jsx("div",{className:d,children:la(o,xe,Ne,V).map((u,f)=>{const k=u.kind==="group"&&u.group.selection_mode==="choose_one",v=u.items.map(K=>Zt(K,void 0,k)),I=u.items.length;return u.kind==="items"?e.jsx(di.Fragment,{children:v},`items-${s}-${f}`):e.jsx(ca,{groupId:u.group.id,name:u.group.name,selectionMode:u.group.selection_mode,items:u.items,className:_("min-w-0 h-full self-stretch col-span-1",I>=2&&"sm:col-span-2",I>=3&&"xl:col-span-3"),innerClassName:_("grid h-full auto-rows-fr grid-cols-1 gap-6",I>=2&&"sm:grid-cols-2 lg:grid-cols-2",I>=3&&"xl:grid-cols-3"),isHighlighted:Qt===u.group.id,children:v},u.group.id)})}):e.jsx("div",{className:"flex flex-col gap-6",children:la(o,xe,Ne,V).map((u,f)=>{const k=u.kind==="group"&&u.group.selection_mode==="choose_one",v=u.items.map(I=>Zt(I,void 0,k));return u.kind==="items"?e.jsx("div",{className:d,children:v},`items-${s}-${f}`):e.jsx(ca,{groupId:u.group.id,name:u.group.name,selectionMode:u.group.selection_mode,items:u.items,innerClassName:d,isHighlighted:Qt===u.group.id,children:v},u.group.id)})}):e.jsx("div",{className:d,children:o.map(u=>Zt(u))})]},s)}):ti?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-white px-6 py-20 text-center shadow-sm",role:"status",children:[e.jsx(pa,{className:"mx-auto mb-5 h-11 w-11 shrink-0 text-violet-600","aria-hidden":!0}),e.jsx("p",{className:"max-w-lg text-sm leading-relaxed text-muted-foreground",children:p("reviewNeedsAttentionEmpty","No items need attention right now. View all items to see approved, rejected and completed review items.")}),e.jsx(oe,{variant:"outline",size:"sm",className:"mt-6 bg-white text-slate-900 hover:bg-slate-50",onClick:()=>rt(null),children:p("reviewViewAllItems","View all items")})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-white px-6 py-20 text-center shadow-sm",role:"status",children:[e.jsx(gl,{className:"mx-auto mb-5 h-11 w-11 shrink-0 text-indigo-500","aria-hidden":!0}),e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:p("portal.emptyState.title","Nothing here yet")}),e.jsx("p",{className:"mt-3 max-w-lg text-sm leading-relaxed text-gray-600",children:p("portal.emptyState.description","This is your shared space with your designer. When they add review items, proposals, or share materials, it will all show up here. Check back later or refresh after they update the project.")})]})]})]}):null}),$t&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md w-full",children:[e.jsx("h3",{className:"text-lg font-medium mb-2",children:p($t==="approved"?"bulkApproveAllConfirmTitle":"bulkRejectAllConfirmTitle")}),e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:p($t==="approved"?"bulkApproveAllConfirmMessage":"bulkRejectAllConfirmMessage")}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(oe,{variant:"outline",onClick:()=>Pt(null),disabled:Le,className:"flex-1",children:p("cancel")}),e.jsx(oe,{onClick:ri,disabled:Le,className:"flex-1",children:p(Le?"saving":"continue")})]})]})}),xo&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md w-full",children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:p("enterYourName")}),e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:p("pleaseEnterYourNameToContinue")}),e.jsx(jt,{value:ye,onChange:s=>Da(s.target.value),placeholder:p("yourName"),className:"mb-4"}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(oe,{variant:"outline",onClick:()=>Fa(!1),className:"flex-1",children:p("cancel")}),e.jsx(oe,{onClick:()=>Fa(!1),disabled:!ye.trim(),className:"flex-1",children:p("continue")})]})]})}),e.jsx(bl,{open:yo,onOpenChange:Wt,onSave:si,onDiscard:ai,isSaving:Le}),e.jsx(tc,{open:bo,onOpenChange:Ha,item:G,primaryImageUrl:G?Ce[G.id]??null:null,galleryImages:G?As(G.id):[],attachments:G?W[G.id]||[]:[],showProductDetails:gs||(G?Gt(G):!1),showProductPrices:xs,showProductLinks:fs,hasProductMetadata:G?Gt(G):!1,priceLabel:G?(()=>{const s=Yn(G);return s?`${s.currency} ${s.amount}`:null}
12)():null,roomLabel:G?.room?xt(G.room):null,approvalStatus:G?ne[G.id]??(G.status==="approved"||G.status==="rejected"||G.status==="maybe"?G.status:null):null,previewReadOnly:z,submitting:G?Oa.has(G.id):!1,comment:G&&Ie[G.id]||"",designerReply:G?.designer_reply,choiceMode:G?Fe.has(G.id):!1,onStatusSelect:s=>{if(G){if(Fe.has(G.id)){s==="approved"&&Tn(G.id);return}Cn(G.id,s)}},onCommentChange:s=>{G&&In(G.id,s)},onSave:()=>{G&&gt({itemIds:[G.id]})},getAttachmentBadgeStyles:Fn,onViewPdfInline:Dn,onOpenPdfNewTab:Ln,onDownloadPdf:Mn}),No&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-4 w-full max-w-4xl h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h3",{className:"text-sm font-medium truncate",children:So||"PDF"})}),e.jsx(oe,{variant:"ghost",size:"sm",onClick:()=>qa(!1),className:"h-8 w-8 p-0",children:e.jsx(Ge,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex-1 border rounded overflow-hidden bg-gray-50",children:Co?e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-500",children:p("loading")||"Loading..."}):Ya?e.jsx("iframe",{title:"PDF",src:Ya,className:"w-full h-full"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-500 p-4 text-center",children:p("pdfPreviewUnsupported")||"PDF preview is not supported on this device. Use Open in new tab or Download."})})]})}),e.jsx(jr,{...It.lightboxProps,onIndexChange:It.setIndex,closeButtonAriaLabel:p("dialogClose"),showSlideCounter:It.slides.length>1}),pe&&J?e.jsx(sd,{open:m,onClose:()=>{g(!1),y(null),E()},portalSessionToken:J,previewReadOnly:z,clientDisplayName:ye,initialContactId:w?.contactId??null,focusNonce:w?.nonce??0,onFocusHandled:M}):null,pe&&J?e.jsx($c,{open:vs,onClose:Zs,items:Kt,selectionGroups:xe,selectionGroupMembers:Ne,isPreviewReadOnly:z,onMarkAllRead:()=>void Vo(),onMarkItemRead:s=>void qt(Array.from(new Set(s.map(o=>o.id).filter(o=>typeof o=="string"&&o.length>0)))),onItemClick:zo}):null,pe&&J?e.jsx(wl,{sectionKey:Bo,variant:"portal",hidden:Uo,onWatch:s=>void ue(s,{publicAccess:!0,showUnavailable:!0,portalSessionToken:J||void 0}),onDismiss:s=>void Ho(s)}):null]}):C?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gray-50",children:[e.jsx("div",{className:"w-full flex justify-center mb-6 mt-4",children:e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm px-6 py-3 flex items-center",children:e.jsx(ct,{})})}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:p("loadingReviewItems")})]})]}):Y?e.jsx(Gl,{onContinueAnyway:q,onGateEvent:P}):e.jsx(Ml,{onAuthSuccess:s=>{je(s),we(!0);const o=me();o&&He(o)}})},Nd=Object.freeze(Object.defineProperty({__proto__:null,default:pd},Symbol.toStringTag,{value:"Module"}));export{Nd as C,yd as P,jd as a,vd as c};

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.