1import{bO as w,b as o,u as C,o as R,aC as O,j as e,aM as T,l as D,q as S}from"./index-BxmgPWYo.js";import{g as F,R as L,b as $,d as _}from"./recurringSlotsRepo-aP2oy6uX.js";import"./mapbox-Dsi-_OTH.js";function A(s){const{user:d}=w(),r=d?.id??null,[c,a]=o.useState(null),[x,t]=o.useState(!0),[p,u]=o.useState(null),n=o.useCallback(async()=>{if(!s||!r){a(null),t(!1);return}t(!0),u(null);try{a(await F(s,r))}catch(l){u(l instanceof L?l.message:"NETWORK"),a(null)}finally{t(!1)}},[s,r]);o.useEffect(()=>{n()},[n]);const f=o.useCallback(async l=>{s&&(await $(s,l),await n())},[s,n]),b=o.useCallback(async l=>{c&&(await _(c.slot.id,l),await n())},[c,n]);return{occurrence:c,loading:x,error:p,refetch:n,respond:f,skip:b}}const k={fr:"fr-FR",en:"en-GB",es:"es-ES"},B=[1,2,3];function K(s,d){const r=k[d?.slice(0,2)]??k.fr,c=new Date(`${s}T12:00:00Z`),a=new Intl.DateTimeFormat(r,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}).format(c);return a.charAt(0).toUpperCase()+a.slice(1)}function W({occurrenceId:s,onBack:d}){const{t:r,i18n:c}=C();R(!0,d);const{enabled:a,loading:x}=O("recurring_slots_enabled"),{occurrence:t,loading:p,error:u,respond:n,skip:f}=A(s),[b,l]=o.useState(!1),[m,h]=o.useState(!1),g=e.jsx(T,{title:r("recurringSlots.occurrence.title"),onBack:d,backTestId:"occurrence-back"});if(x||p)return e.jsxs("div",{"data-testid":"occurrence-loading","aria-busy":"true",className:"flex min-h-screen flex-col bg-background",children:[g,e.jsx("div",{className:"m-4 h-32 animate-pulse rounded-2xl bg-muted"})]});if(!a)return null;if(u||!t)return e.jsxs("div",{className:"flex min-h-screen flex-col bg-background",children:[g,e.jsx("p",{"data-testid":"occurrence-error",className:"m-4 rounded-2xl border border-dashed border-border bg-muted/50 px-4 py-6 text-center text-sm text-muted-foreground",children:r("recurringSlots.occurrence.notFound")})]});const j=K(t.occurrenceDate,c.language),N=`${t.slot.timeStart.slice(0,5)} - ${t.slot.timeEnd.slice(0,5)}`,v=t.state==="cancelled"||t.state==="realized",y=async(i,E)=>{h(!0);try{await i(),S.success(r(E))}catch{S.error(r("recurringSlots.occurrence.actionError"))}finally{h(!1)}};return e.jsxs("div",{className:"flex min-h-screen flex-col bg-background",children:[g,e.jsxs("main",{className:"flex-1 px-4 py-4",children:[e.jsxs("section",{"data-testid":"occurrence-card",className:"flex flex-col gap-2 rounded-2xl border border-primary/30 bg-primary/5 p-4",children:[e.jsx("span",{className:"text-lg font-bold text-foreground",children:j}),e.jsx("span",{className:"text-sm text-muted-foreground",children:N}),e.jsx("span",{"data-testid":"occurrence-tally",className:"mt-1 inline-flex w-fit items-center rounded-full bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground",children:r("recurringSlots.occurrence.tally",{confirmed:t.confirmedCount,capacity:t.slot.capacity})})]}),t.myResponse?e.jsx("p",{"data-testid":"occurrence-my-response",className:"mt-3 text-sm text-muted-foreground",children:r(`recurringSlots.occurrence.myResponse.${t.myResponse}`)}):null,b?e.jsxs("div",{"data-testid":"occurrence-skip-options",className:"mt-4 flex flex-col gap-2 rounded-2xl border border-border p-3",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:r("recurringSlots.occurrence.skipPrompt")}),e.jsx("div",{className:"flex gap-2",children:B.map(i=>e.jsx("button",{type:"button",disabled:m,"data-testid":`occurrence-skip-${i}`,onClick:()=>y(()=>f(i),"recurringSlots.occurrence.skipDone"),className:"flex-1 rounded-xl border border-border px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:opacity-50",children:r("recurringSlots.occurrence.weeks",{count:i})},i))})]}):null]}),v?null:e.jsxs("footer",{className:"sticky bottom-0 flex flex-col gap-2 border-t border-border bg-background px-4 pt-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:[e.jsx("button",{type:"button",disabled:m,"data-testid":"occurrence-confirm",onClick:()=>y(()=>n("confirmed"),"recurringSlots.occurrence.confirmDone"),className:D("w-full rounded-xl px-4 py-3 text-sm font-semibold transition-colors disabled:opacity-50",t.myResponse==="confirmed"?"bg-primary/20 text-primary":"bg-primary text-primary-foreground hover:bg-primary/90"),children:r("recurringSlots.occurrence.confirm")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",disabled:m,"data-testid":"occurrence-decline",onClick:()=>y(()=>n("declined"),"recurringSlots.occurrence.declineDone"),className:"flex-1 rounded-xl border border-border px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:opacity-50",children:r("recurringSlots.occurrence.decline")}),e.jsx("button",{type:"button",disabled:m,"data-testid":"occurrence-skip-toggle",onClick:()=>l(i=>!i),className:"flex-1 rounded-xl border border-border px-4 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted disabled:opacity-50",children:r("recurringSlots.occurrence.skipToggle")})]})]})]})}export{W as RecurringSlotOccurrenceScreen};
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.