1import{aC as L,K as R}from"./index-DgF7sRNe.js";import{r as j}from"./resolveRelativeLayers-rz6znpKJ.js";import{g as k,A as F,h as S,L as T,s as W,l as $}from"./PhoneCard3D-AKeudAX8.js";import"./lazy-img-Df6Ew-Fc.js";import"./use-transform-CSRRfta5.js";import"./use-spring-Cxc2Fqcq.js";import"./LemonHighlight-DJsPvrIS.js";import"./SlideReveal-Cgf_feC2.js";import"./use-mobile-CvDwzyAI.js";const n=1200,c=630;async function x(e){const s=await fetch(e,{mode:"cors",credentials:"omit"});if(!s.ok)throw new Error(`Failed to fetch ${e}: ${s.status}`);const i=await s.blob(),l=URL.createObjectURL(i);try{const a=new Image;return a.crossOrigin="anonymous",a.decoding="async",a.src=l,await a.decode(),a}finally{setTimeout(()=>URL.revokeObjectURL(l),0)}}async function B(e){const s=e.bgImagePath||e.heroImagePath;if(!s)return null;const i=R(s,{width:1600,quality:85});if(!i)return null;const l=e.kind,a=T[l]==="bottom",A=e.authoredAspect||(a?k[l]:F[l]),g=n*$(A,n/c),D=(n-g)/2,u=document.createElement("canvas");u.width=n,u.height=c;const o=u.getContext("2d");if(!o)throw new Error("Canvas 2D context unavailable");o.fillStyle="#f5efe4",o.fillRect(0,0,n,c);const v=await x(i);S(o,v,n,c,A);const U=(e.layers??[]).filter(t=>t.showInHero!==!1).map(t=>a?{...t}:{...t,xPct:t.heroXPct??t.xPct,yPct:t.heroYPct??t.yPct,widthPct:t.heroWidthPct??t.widthPct,rotationDeg:t.heroRotationDeg??t.rotationDeg??0}),C=j(U,a?"bottom":"top").sort((t,m)=>t.position-m.position);for(const t of C){const m=R(t.imagePath,{width:1400,quality:85});if(!m)continue;let h;try{h=await x(m)}catch{continue}const E=t.xPct,y=t.yPct,O=t.widthPct,I=(t.rotationDeg??0)*Math.PI/180,d=O/100*g,r=d*(h.naturalHeight/Math.max(h.naturalWidth,1)),f=D+E/100*g,P=a?c-y/100*g-r:y/100*c,w=W(t,{left:f,top:P,width:d,height:r},n,c);if(o.save(),o.shadowColor="rgba(0,0,0,0.45)",o.shadowBlur=60,o.shadowOffsetY=30,o.translate(w.tx,w.ty),w.scale!==1&&(o.translate(f,P),o.scale(w.scale,w.scale),o.translate(-f,-P)),a){const p=y/100*g,b=c-p;o.translate(f,b),o.rotate(I),o.drawImage(h,0,-r,d,r)}else{const p=y/100*c,b=f+d/2,H=p+r/2;o.translate(b,H),o.rotate(I),o.drawImage(h,-d/2,-r/2,d,r)}o.restore()}return await new Promise(t=>u.toBlob(m=>t(m),"image/jpeg",.86))}async function Q(e){const s=await B(e);if(!s)return null;const i=new File([s],`${e.slug||"social"}-${Date.now()}.jpg`,{type:"image/jpeg"});return await L(i,`social/${e.kind}`)}export{Q as composeAndUploadSocialImage,B as composeSocialImage};
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.