1import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{_ as n,d as r,f as i,g as a,h as o,m as s,p as c,r as l,t as u}from"./pdfExportService-BIc6SIiE.js";import{X as d,c as f,p,r as m,s as h}from"./badge-CVSePxQg.js";import{t as g}from"./jsx-runtime-DREnUpxT.js";import{n as _,t as v}from"./authStore-B-Yx7osF.js";import{t as y}from"./IconArrowRight-DkXRmKzO.js";import{t as b}from"./IconEye-a5NV6diC.js";import{F as x,I as S,T as C}from"./DialogTitle-Dd5V4h6k.js";import{n as w}from"./dist-EjjBAI2P.js";import{s as T}from"./wizard-CeVf9Tcj.js";import{n as E}from"./projectsStore-D8TETJ8b.js";import{i as D,n as O,r as k,t as A}from"./tooltip-CyPp7tua.js";import{t as j}from"./WordReveal-CtgbpTPJ.js";import{t as M}from"./SpotlightCard-CA4-nAd2.js";var N=_(`outline`,`alert-triangle`,`AlertTriangle`,[[`path`,{d:`M12 9v4`,key:`svg-0`}],[`path`,{d:`M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),P=e(t(),1),F=g();function I({project:e,primaryColor:t,brandInitial:n}){let r=C(e=>e.projectId),i=C(e=>e.logoUrl),a=C(e=>e.svgContent),[o,s]=(0,P.useState)(()=>{if(e.logo_url)return e.logo_url;if(r===e.id){if(i)return i;if(a)return`data:image/svg+xml;utf8,${encodeURIComponent(a)}`}return null}),[c,l]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let t=!0,n=()=>t;if(e.logo_url){s(e.logo_url),l(!1);return}if(r===e.id){if(i){s(i),l(!1);return}if(a){s(`data:image/svg+xml;utf8,${encodeURIComponent(a)}`),l(!1);return}}return(async()=>{try{let t=await T(`brand_svg_${e.id}`);if(!n())return;if(t){s(`data:image/svg+xml;utf8,${encodeURIComponent(t)}`),l(!1);return}let r=await T(`brand_raster_${e.id}`);if(!n())return;if(r){s(r),l(!1);return}let i=localStorage.getItem(`brandio_local_brand_${e.id}`);if(i){let e=JSON.parse(i);if(e.logoUrl){s(e.logoUrl),l(!1);return}if(e.svgContent){s(`data:image/svg+xml;utf8,${encodeURIComponent(e.svgContent)}`),l(!1);return}}}catch{}})(),()=>{t=!1}},[e.id,e.logo_url,r,i,a]);let u=(0,P.useCallback)(async()=>{if(o?.startsWith(`data:`)||o?.startsWith(`blob:`)){l(!0);return}try{let t=await T(`brand_svg_${e.id}`);if(t){s(`data:image/svg+xml;utf8,${encodeURIComponent(t)}`);return}let n=await T(`brand_raster_${e.id}`);if(n){s(n);return}let r=localStorage.getItem(`brandio_local_brand_${e.id}`);if(r){let e=JSON.parse(r);if(e.svgContent){s(`data:image/svg+xml;utf8,${encodeURIComponent(e.svgContent)}`);return}if(e.rasterDataUri){s(e.rasterDataUri);return}}}catch{}l(!0)},[e.id,o]);return o&&!c?(0,F.jsx)(`div`,{className:`flex size-12 items-center justify-center overflow-hidden rounded-2xl border border-border/80 bg-background/80 p-2 transition-transform duration-300 group-hover:scale-105`,style:{borderColor:`${t}30`},children:(0,F.jsx)(`img`,{src:o,alt:e.brand_name||e.name,className:`size-full object-contain`,onError:u})}):(0,F.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl border border-white/20 text-base font-bold text-white transition-transform duration-300 group-hover:scale-105`,style:{backgroundColor:t},children:n})}function L({onOpenCreateModal:e}){let t=v(e=>e.user?.id),g=E(e=>e.projects),_=E(e=>e.loading),T=E(e=>e.deleteProject),L=g.length>0,R=(0,P.useRef)(null),[z,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(!1),U=C(e=>e.designMovement),[W,G]=(0,P.useState)(null),[K,q]=(0,P.useState)(!1),[J,Y]=(0,P.useState)(!1),[X,Z]=(0,P.useState)(``),Q=async e=>{try{G(e.id),await C.getState().loadFromProject(e.id),q(!0)}catch(e){console.error(`Failed to load project for preview:`,e),w.error(`Unable to load brand project for preview.`)}finally{G(null)}};return(0,P.useEffect)(()=>{if(!R.current)return;let e=p.context(()=>{let e=R.current?.querySelectorAll(`.project-card`);e&&e.length>0&&m(e,{y:30,duration:1.1,stagger:.1,delay:.2,ease:`power3.out`});let t=R.current?.querySelector(`.empty-create-btn`);t&&m(t,{y:20,duration:1,delay:.35,ease:`power3.out`})},R);return()=>e.revert()},[L,_,g.length]),(0,F.jsx)(k,{delay:100,children:(0,F.jsxs)(`div`,{ref:R,className:`space-y-6`,children:[L&&(0,F.jsx)(`div`,{className:`flex flex-col justify-between gap-6 lg:flex-row lg:items-end`,children:(0,F.jsxs)(`div`,{className:`max-w-3xl space-y-4 pt-4 sm:pt-8`,children:[(0,F.jsx)(j,{as:`h2`,stagger:.03,duration:1.4,start:`top 90%`,children:`Your Brand Projects`}),(0,F.jsx)(j,{as:`p`,stagger:.02,duration:1.2,start:`top 90%`,children:_?`Loading projects...`:`${g.length} of 2 slots used`})]})}),_?(0,F.jsx)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(e=>(0,F.jsxs)(`div`,{className:`flex min-h-65 animate-pulse flex-col justify-between rounded-2xl border border-border/40 bg-card/60 p-7`,children:[(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`div`,{className:`size-10 rounded-2xl bg-muted`}),(0,F.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,F.jsx)(`div`,{className:`size-8 rounded-full bg-muted`}),(0,F.jsx)(`div`,{className:`size-8 rounded-full bg-muted`})]})]}),(0,F.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,F.jsx)(`div`,{className:`h-6 w-3/4 rounded-lg bg-muted`}),(0,F.jsx)(`div`,{className:`h-3 w-1/3 rounded-lg bg-muted`})]})]}),(0,F.jsxs)(`div`,{className:`mt-6 flex items-center justify-between border-t border-border/60 pt-5`,children:[(0,F.jsx)(`div`,{className:`h-5 w-20 rounded-full bg-muted`}),(0,F.jsx)(`div`,{className:`h-9 w-28 rounded-full bg-muted`})]})]},e))}):L?(0,F.jsx)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>{let t=e.primary_color||`#624b59`,n=(e.brand_name||e.name||`B`).charAt(0).toUpperCase();return(0,F.jsxs)(M,{color:t,interactive:!1,tilt:!1,shimmer:!1,className:`project-card group flex min-h-68 flex-col justify-between rounded-3xl bg-card/75 p-6 backdrop-blur-xl transition-all duration-300`,children:[(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(I,{project:e,primaryColor:t,brandInitial:n}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsxs)(A,{children:[(0,F.jsx)(D,{type:`button`,disabled:W===e.id,onClick:t=>{t.stopPropagation(),Q(e)}
1,className:`cursor-pointer rounded-full border border-border/60 p-2 text-muted-foreground transition hover:border-border hover:bg-muted hover:text-foreground disabled:opacity-50`,"aria-label":`Preview Brand Deck`,children:W===e.id?(0,F.jsx)(f,{size:`sm`}):(0,F.jsx)(b,{size:15})}),(0,F.jsx)(O,{side:`top`,sideOffset:6,className:`text-xs font-medium shadow-xl`,children:`Preview Brand Manual`})]}),(0,F.jsxs)(A,{children:[(0,F.jsx)(D,{type:`button`,onClick:t=>{t.stopPropagation(),B(e)},className:`cursor-pointer rounded-full border border-destructive/20 p-2 text-destructive transition hover:bg-destructive/10`,"aria-label":`Delete Brand`,children:(0,F.jsx)(x,{size:15})}),(0,F.jsx)(O,{side:`top`,sideOffset:6,className:`text-xs font-medium shadow-xl`,children:`Delete Brand`})]})]})]}),(0,F.jsxs)(`div`,{className:`pt-1`,children:[(0,F.jsx)(`h3`,{children:e.brand_name||e.name}),e.vision?(0,F.jsx)(`p`,{className:`mt-1.5 line-clamp-2`,children:e.vision}):null]})]}),(0,F.jsxs)(`div`,{className:`mt-6 flex items-center justify-between border-t border-border/60 pt-5`,children:[(0,F.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-muted-foreground`,children:[`Last edited`,` `,new Date(e.updated_at).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})]}),(0,F.jsx)(d,{to:`/studio/$projectId`,params:{projectId:e.id},children:(0,F.jsx)(h,{size:`pill`,variant:`outline`,gsapFill:!0,className:`cursor-pointer rounded-full px-5 py-3 text-xs font-semibold`,icon:(0,F.jsx)(y,{size:14,className:`transition-transform group-hover:translate-x-0.5`}),iconPlacement:`right`,children:`Open Studio`})})]})]},e.id)})}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-3xl p-12 text-center backdrop-blur-sm`,children:[(0,F.jsx)(j,{as:`h5`,stagger:.03,duration:1.4,start:`top 90%`,text:`No active brand workspaces`}),(0,F.jsx)(j,{as:`p`,stagger:.03,duration:1.4,start:`top 90%`,className:`mt-1 max-w-sm`,text:`Create your first brand workspace to generate typography, color 2 palettes, and export brand guideline decks.`}),(0,F.jsx)(h,{variant:`shiny`,size:`pill`,gsapFill:!0,onClick:e,className:`empty-create-btn mt-6 rounded-full px-8! py-5! text-xs font-semibold`,icon:(0,F.jsx)(S,{size:16}),children:`Create New Studio`})]}),(0,F.jsx)(r,{open:z!==null,onOpenChange:e=>{e||B(null)},children:(0,F.jsxs)(c,{className:`max-w-md rounded-3xl border-0 bg-card/95 p-6 backdrop-blur-xl`,children:[(0,F.jsxs)(a,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl border border-destructive/20 bg-destructive/10 text-destructive shadow-xs`,children:(0,F.jsx)(N,{size:22})}),(0,F.jsx)(n,{className:`font-heading text-lg font-bold text-foreground`,children:`Delete Brand Workspace?`}),(0,F.jsxs)(s,{className:`text-base text-foreground`,children:[`Are you sure you want to permanently delete`,` `,(0,F.jsx)(`span`,{className:`font-semibold text-foreground`,children:z?.brand_name||z?.name||`this workspace`}),`? This action cannot be undone. All color matrices, typography pairings, and saved tokens will be permanently removed.`]})]}),(0,F.jsxs)(o,{className:`mt-6 flex items-center justify-end gap-2.5`,children:[(0,F.jsx)(i,{onClick:()=>B(null),className:`cursor-pointer rounded-full`,disabled:V,children:`Cancel`}),(0,F.jsx)(h,{variant:`destructive_outline`,size:`sm`,onClick:async()=>{if(z){H(!0);try{await T(z.id,t),B(null)}finally{H(!1)}}},disabled:V,className:`cursor-pointer rounded-full`,icon:V?(0,F.jsx)(f,{size:`sm`}):void 0,children:V?`Deleting...`:`Delete Project`})]})]})}),(0,F.jsx)(l,{isOpen:K,onClose:()=>q(!1),styleTheme:U,initialPage:1,onDownloadPdf:async()=>{try{Y(!0),Z(`Preparing pages...`);let e=C.getState();await u({brandName:e.brandName||`Brand`,onProgress:(e,t,n)=>{Z(n)}}),w.success(`Brand Manual PDF exported.`)}catch(e){console.error(`PDF generation failed:`,e),w.error(`Failed to export PDF manual. Please try again.`)}finally{Y(!1),Z(``)}},isDownloadingPdf:J,downloadProgress:X})]})})}export{L as t};
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.