1import{c8 as q,r as h,a as w,s as y,j as e,ae as B,S as E,I as L,e as p,B as C,a1 as v,ak as $,al as I,U as K,G as U,M as O,b as P,c as D,C as T}from"./index-D5R9CWr2.js";import{E as W}from"./EmptyState-BOaRBtLI.js";import{W as b}from"./wifi-MgEJqqub.js";import{B as z}from"./bed-B39gk1ne.js";import{C as _}from"./clock-D72xm9Eo.js";import{L as M}from"./lock-C94r9PEZ.js";import{C as R}from"./copy-D4zef6MA.js";function Y(){const{workspace:t}=q(),[d,l]=h.useState(null),[n,c]=h.useState(""),[i,o]=h.useState(null),{data:m=[],isLoading:k}=w({queryKey:["ops-all-properties",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:a}=await y.from("properties").select("*").eq("workspace_id",t.id).order("name");if(a)throw a;return s||[]},enabled:!!(t!=null&&t.id)}),{data:F=[]}=w({queryKey:["ops-credentials",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:a}=await y.from("property_service_credentials").select("*").eq("workspace_id",t.id);if(a)throw a;return s||[]},enabled:!!(t!=null&&t.id)}),x=(s,a)=>{navigator.clipboard.writeText(s),o(a),P.success(`${a} copied`),setTimeout(()=>o(null),2e3)},g=m.filter(s=>{if(!n)return!0;const a=n.toLowerCase();return(s.name||"").toLowerCase().includes(a)||(s.address||"").toLowerCase().includes(a)});return k?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"page-container-wide",children:[e.jsx("h2",{className:"page-title mb-3",children:"Properties"}),e.jsx("div",{className:"sticky top-0 z-10 bg-background pb-3 -mx-4 px-4 pt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(L,{placeholder:"Rechercher...",value:n,onChange:s=>c(s.target.value),className:"pl-9 h-10 text-[16px]"})]})}),g.length===0?e.jsx(W,{icon:p,title:"No properties found"}):e.jsx("div",{className:"space-y-2",children:g.map(s=>{const a=d===s.id,j=F.filter(r=>r.property_id===s.id);return e.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden active:scale-[0.98] transition-transform",children:[(()=>{const r=s.cover_photo||(s.photos&&s.photos.length>0?s.photos[0]:null);return r?e.jsx("div",{className:"h-32 w-full bg-muted",children:e.jsx("img",{src:r,alt:s.name,className:"w-full h-full object-cover",loading:"lazy",onError:S=>{var N;const u=S.target;u.src===s.cover_photo&&((N=s.photos)==null?void 0:N.length)>0&&s.photos[0]!==s.cover_photo?u.src=s.photos[0]:u.style.display="none"}})}):null})(),e.jsxs(C,{variant:"ghost",className:"w-full p-3 flex gap-3 h-auto text-left rounded-none",onClick:()=>l(a?null:s.id),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s.name}),s.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[[s.address,s.city].filter(Boolean).join(", "),s.floor?` · Floor ${s.floor}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.door_code&&e.jsx(v,{className:"w-4 h-4 text-muted-foreground"}),s.wifi_password&&e.jsx(b,{className:"w-4 h-4 text-muted-foreground"}),a?e.jsx($,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(I,{className:"w-4 h-4 text-muted-foreground"})]})]}),a&&e.jsxs("div",{className:"border-t border-border px-3 pb-4 pt-3 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[s.property_type&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(p,{className:"w-3.5 h-3.5"}),s.property_type]}),s.bedrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"w-3.5 h-3.5"}),s.bedrooms," bed"]}),s.max_guests&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),s.max_guests," guests"]}),s.floor&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3.5 h-3.5"}),"Floor ",s.floor]})]}),s.address&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-foreground",children:[s.address,s.city,s.country].filter(
1Boolean).join(", ")})]}),(s.check_in_time||s.check_out_time)&&e.jsxs("div",{className:"flex gap-4 text-sm",children:[s.check_in_time&&e.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(_,{className:"w-4 h-4"})," In: ",e.jsx("span",{className:"text-foreground font-medium",children:s.check_in_time})]}),s.check_out_time&&e.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(_,{className:"w-4 h-4"})," Out: ",e.jsx("span",{className:"text-foreground font-medium",children:s.check_out_time})]})]}),(s.door_code||s.wifi_password)&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Codes"}),s.door_code&&e.jsx(f,{icon:e.jsx(v,{className:"w-4 h-4"}),label:"Door",value:s.door_code,fieldKey:`door-${s.id}`,copiedField:i,onCopy:x}),s.wifi_name&&e.jsx(f,{icon:e.jsx(b,{className:"w-4 h-4"}),label:"WiFi",value:`${s.wifi_name} / ${s.wifi_password||""}`,fieldKey:`wifi-${s.id}`,copiedField:i,onCopy:x})]}),s.access_instructions&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1",children:"Access Instructions"}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.access_instructions})]}),j.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Service Passwords"}),j.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:r.service_name}),r.username&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["User: ",r.username]})]}),r.password&&e.jsx(f,{icon:e.jsx(M,{className:"w-3.5 h-3.5"}),label:"",value:r.password,fieldKey:`cred-${r.id}`,copiedField:i,onCopy:x,compact:!0})]},r.id))]})]})]},s.id)})})]})}function f({icon:t,label:d,value:l,fieldKey:n,copiedField:c,onCopy:i,compact:o}){const m=c===n;return e.jsxs(C,{variant:"ghost",className:D("flex gap-2 w-full h-auto text-left group p-0",o?"":"py-0.5"),onClick:()=>i(l,n),children:[e.jsx("span",{className:"text-muted-foreground",children:t}),d&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:[d,":"]}),e.jsx("span",{className:"font-mono font-semibold text-foreground",children:l}),m?e.jsx(T,{className:"w-3.5 h-3.5 text-success ml-auto shrink-0"}):e.jsx(R,{className:"w-3.5 h-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 ml-auto shrink-0"})]})}export{Y as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.