1import{r as m,j as e,a9 as F,aa as S,B as x,ab as k,as as E,at as I,au as $,av as T,R as V,_ as p,w as G,aw as J,x as f}from"./index-BmQy57Ri.js";import{S as R}from"./switch-BDaQ6gng.js";import{C as L}from"./code-Do55wE-x.js";import{C as B}from"./copy-DzLckSzo.js";const K=s=>s.font_type==="google"||s.source==="Google Fonts",D=s=>{const t=(s==null?void 0:s.toLowerCase())||"sans-serif";return t.includes("serif")&&!t.includes("sans")?"ui-serif, Georgia, Cambria, 'Times New Roman', serif":t.includes("mono")?"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace":t.includes("display")?"system-ui, sans-serif":"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},Q=s=>{const t=(s==null?void 0:s.toLowerCase())||"sans-serif";return t.includes("mono")?[400,600]:t.includes("display")?[400,700]:[400,600,700]},X=(s,t,o)=>{const l=s.map(n=>{const g=n.name.replace(/\s+/g,"+"),i=o&&n.hasItalic!==!1;let a;if(t)n.isVariable?i?a="ital,wght@0,100..900;1,100..900":a="[email protected]":i?a="ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900":a="wght@100;200;300;400;500;600;700;800;900";else{const c=Q(n.category);i?a=`ital,wght@${c.map(u=>`0,${u};1,${u}`).join(";")}`:a=`wght@${c.join(";")}`}return`family=${g}:${a}`});return`https://fonts.googleapis.com/css2?${[...new Set(l)].join("&")}&display=swap`},Y=(s,t,o)=>`<link rel="preconnect" href="https://fonts.googleapis.com"> 2<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> 3<link href="${X(s,t,o)}" rel="stylesheet">`,Z=(s,t)=>{const o=D(s.category),l=D(t.category);return`:root { 4 --font-heading: '${s.name}', ${o}; 5 --font-body: '${t.name}', ${l}; 6} 7 8body { 9 font-family: var(--font-body); 10} 11 12h1, h2, h3, h4, h5, h6 { 13 font-family: var(--font-heading); 14}`};function oe({fonts:s,pairingMode:t,open:o,onOpenChange:l,showTrigger:h=!0}){const[n,g]=m.useState(!1),i=o!==void 0,a=i?o:n,c=i?l||(()=>{}):g,[r,u]=m.useState(!1),[j,q]=m.useState(!1),[z,b]=m.useState(!1),[A,w]=m.useState(!1),y=s.every(K),C=s.some(d=>d.hasItalic!==!1);if(!y&&h)return e.jsxs(F,{children:[e.jsx(S,{asChild:!0,children:e.jsx(x,{variant:"secondary",size:"icon",className:"rounded-full h-10 w-10 opacity-50 cursor-not-allowed",children:e.jsx(L,{className:"h-4 w-4"})})}),e.jsx(k,{children:e.jsx("p",{children:"Embed code available for Google Fonts only"})})]});if(!y&&!h)return e.jsx(E,{open:a,onOpenChange:c,children:e.jsxs(I,{className:"max-w-md",children:[e.jsx($,{children:e.jsx(T,{children:"Embed Fonts"})}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-lg bg-muted",children:[e.jsx(V,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Embed code is only available for Google Fonts. The current font pair uses Fontshare fonts which need to be downloaded and self-hosted."})]})})]})});const M=s.filter((d,H,_)=>H===_.findIndex(P=>P.name===d.name)),N=Y(M,r,j),v=t?Z(t.headingFont,t.bodyFont):"",O=async()=>{try{await navigator.clipboard.writeText(N),b(!0),f.success("Embed code copied to clipboard"),setTimeout(()=>b(!1),2e3)}catch{f.error("Failed to copy to clipboard")}},U=async()=>{try{await navigator.clipboard.writeText(v),w(!0),f.success("CSS code copied to clipboard"),setTimeout(()=>w(!1),2e3)}catch{f.error("Failed to copy to clipboard")}},W=h?e.jsxs(F,{children:[e.jsx(S,{asChild:!0,children:e.jsx(J,{asChild:!0,children:e.jsx(x,{variant:"secondary",size:"icon",className:"rounded-full h-10 w-10 bg-primary-foreground",children:e.jsx(L,{className:"h-4 w-4"})})})}),e.jsx(k,{children:e.jsx("p",{children:"Get font embed code"})})]}):null;return e.jsxs(E,{open:a,onOpenChange:c,children:[W,e.jsxs(I,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx($,{children:e.jsx(T,{children:"Embed Google Fonts"})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{htmlFor:"weight-toggle-modal",className:"text-sm font-medium",children:r?"All weights":"Recommended weights"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"Loads larger font files. Use only if you need the full range.":"Best for performance. Covers most websites."})]}),e.jsx(R,{id:"weight-toggle-modal",checked:r,onCheckedChange:u})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{htmlFor:"italic-toggle-modal",className:"text-sm font-medium",children:"Include italics"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C?"Add italic styles to the font request.":"No italic styles available for this font."})]}),e.jsx(R,{id:"italic-toggle-modal",checked:j,onCheckedChange:q,disabled:!C})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{className:"text-sm font-medium",children:"Embed code (HTML <head>)"}),e.jsxs(x,{variant:"ghost",size:"sm",onClick:O,className:"h-8 px-2",children:[z?e.jsx(G,{className:"h-4 w-4 text-green-500"}):e.jsx(B,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-1",children:"Copy"})]})]}),e.jsx("pre",{className:"p-4 bg-muted rounded-lg overflow-x-auto text-xs font-mono whitespace-pre-wrap break-all",children:N})]}),t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{className:"text-sm font-medium",children:"Font styles (CSS)"}),e.jsxs(x,{variant:"ghost",size:"sm",onClick:U,className:"h-8 px-2",children:[A?e.jsx(G,{className:"h-4 w-4 text-green-500"}):e.jsx(B,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-1",children:"Copy"})]})]}),e.jsx("pre",{className:"p-4 bg-muted rounded-lg overflow-x-auto text-xs font-mono whitespace-pre-wrap",children:v})]})]})]})]})}export{oe as GoogleFontsEmbedModal};
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.