1import{r as l,j as e}from"./query-vendor-Dp9tfhuh.js";import{e as F,L as w}from"./react-vendor-DfslLuwi.js";import{u as I,G as T,M as z,P as q,I as W}from"./esm-BHLdRt99.js";import{G as $,a as K,b as V}from"./googleMaps-CnGBkgZD.js";import{w as C,B as f,h as H,m as J,c as U,s as p}from"./index-CgOeqv80.js";import{u as Y}from"./useRouteCalculation-BhAVtfOt.js";import{M as g}from"./map-pin-B63H-upO.js";import{A as Z}from"./arrow-left-BmX2tYO6.js";import{R as y}from"./route-Df-61sSI.js";import{C as k}from"./clock-BmPJ466V.js";import{A as Q}from"./arrow-down-CIVFAk8G.js";import"./ui-vendor-DW4RoVmg.js";import"./chart-vendor-BoynbIzZ.js";const X={width:"100%",height:"100%"},ee={lat:32.0853,lng:34.7818},m=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#06B6D4","#F97316","#84CC16","#6366F1"],he=()=>{const{token:x}=F(),[c,E]=l.useState(null),[a,L]=l.useState([]),[_,u]=l.useState(!0),[j,h]=l.useState(null),[o,N]=l.useState(null),[i,S]=l.useState(!0),[P,R]=l.useState(!1),d=l.useRef(null),{isLoaded:O,loadError:A}=I({id:$,googleMapsApiKey:K,libraries:V}),{routeInfo:r,isCalculating:M}=Y(a,P);l.useEffect(()=>{(async()=>{if(!x){h("Invalid link"),u(!1);return}try{const{data:t,error:n}=await p.from("showcase_portfolios").select("*").eq("public_token",x).eq("is_published",!0).maybeSingle();if(n)throw n;if(!t){h("Portfolio not found or not published"),u(!1);return}E(t),await p.from("showcase_portfolios").update({view_count:(t.view_count||0)+1}).eq("id",t.id);const{data:G,error:v}=await p.from("showcase_portfolio_pins").select("*").eq("portfolio_id",t.id).order("display_order",{ascending:!0});if(v)throw v;L(G||[])}catch(t){console.error("Error fetching portfolio:",t),h("Failed to load portfolio")}finally{u(!1)}})()},[x]);const B=l.useCallback(s=>{if(d.current=s,R(!0),a.length>0){const t=new google.maps.LatLngBounds;a.forEach(n=>{t.extend({lat:n.latitude,lng:n.longitude})}),s.fitBounds(t)}},[a]),b=s=>{N(s),d.current&&(d.current.panTo({lat:s.latitude,lng:s.longitude}),d.current.setZoom(15))},D=l.useCallback(s=>{if(typeof google<"u"&&google.maps)return{path:google.maps.SymbolPath.CIRCLE,scale:12,fillColor:s,fillOpacity:1,strokeColor:"#ffffff",strokeWeight:2}},[]);return _?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(C,{})}):j||!c?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background p-4",children:[e.jsx(g,{className:"h-16 w-16 text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-semibold mb-2",children:"Portfolio Not Found"}),e.jsx("p",{className:"text-muted-foreground text-center mb-6",children:j||"This portfolio doesn't exist or is not available."}),e.jsx(f,{asChild:!0,children:e.jsx(w,{to:"/",children:"Go Home"})})]}):A?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-destructive",children:"Error loading map"})}):O?e.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[e.jsx("header",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto flex items-center gap-4",children:[e.jsx(f,{variant:"ghost",size:"icon",asChild:!0,children:e.jsx(w,{to:"/",children:e.jsx(Z,{className:"h-4 w-4"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-semibold truncate",children:c.title}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:c.description})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[a.length," location",a.length!==1?"s":""]})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs(T,{mapContainerStyle:X,center:a.length>0?{lat:a[0].latitude,lng:a[0].longitude}:ee,zoom:10,onLoad:B,options:{fullscreenControl:!0,streetViewControl:!1,mapTypeControl:!0,zoomControl:!0},children:[a.map(s=>e.jsx(z,{position:{lat:s.latitude,lng:s.longitude},icon:D(s.pin_color),onClick:()=>b(s)},s.id)),i&&(r==null?void 0:r.segments.map((s,t)=>e.jsx(q,{path:s.polyline,options:{strokeColor:m[t%m.length],strokeOpacity:.8,strokeWeight:4}},`route-${s.from.id}-${s.to.id}`))),o&&e.jsx(W,{position:{lat:o.latitude,lng:o.longitude},onCloseClick:()=>N(null),children:e.jsxs("div",{className:"p-2 max-w-[250px]",children:[e.jsx("h3",{className:"font-semibold mb-1",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o.description}),o.address&&e.jsx("p",{className:"text-xs text-muted-foreground",children:o.address})]})})]}),r&&r.segments.length>0&&e.jsx("div",{className:"absolute top-4 right-4 z-10 max-w-xs",children:e.jsx(H,{className:"bg-background/95 backdrop-blur-sm",children:e.jsxs(J,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-semibold text-sm",children:"Routes"})]}),e.jsx(f,{variant:i?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>S(!i),children:i?"On":"Off"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-4 mb-3 p-2 bg-primary/10 rounded text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(g,{className:"h-3 w-3"}),e.jsx("span",{children:r.totalDistance})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3"}),e.jsx("span",{children:r.totalDuration})]})]}),e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:r.segments.map((s,t)=>e.jsxs("div",{className:"text-xs border-l-2 pl-2 py-1",style:{borderColor:m[t%m.length]},children:[e.jsx("div",{className:"font-medium truncate",children:s.from.title}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:"â"}),e.jsx("span",{children:s.distance}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:s.duration})]}),e.jsx("div",{className:"font-medium truncate",children:s.to.title})]},`segment-${t}`))})]}),M&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Calculating routes..."})]})})})]}),e.jsxs("aside",{className:"w-80 border-l bg-background overflow-y-auto hidden md:block",children:[e.jsx("div",{className:"p-4 border-b",children:e.jsx("h2",{className:"font-semibold",children:"Locations"})}),r&&r.segments.length>0&&e.jsxs("div",{className:"mx-4 mt-4 mb-3 p-3 bg-primary/10 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium mb-1",children:[e.jsx(y,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Total Route"})]}),e.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:r.totalDistance}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:r.totalDuration})]})]}),e.jsx("div",{className:"p-2 space-y-2",children:a.length===0?e.jsxs("div",{className:"p-6 text-center text-muted-foreground",children:[e.jsx(g,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No locations added yet"})]}):a.map((s,t)=>{const n=r&&t<a.length-1?r.segments[t]:null;return e.jsxs("button",{onClick:()=>b(s),className:U("w-full p-3 text-left rounded-lg border transition-all hover:shadow-md",(o==null?void 0:o.id)===s.id&&"ring-2 ring-primary bg-muted/50"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm font-medium shrink-0",style:{backgroundColor:s.pin_color},children:t+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:s.title}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:s.description}),s.address&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:s.address})]})]}),n&&e.jsxs("div",{className:"mt-3 pt-3 border-t flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:n.distance}),e.jsx("span",{children:"â¢"}),e.jsx(k,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:n.duration})]})]},s.id)})})]})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(C,{})})};export{he 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.