1import{loadImage as w,canvasToObjectUrl as g,getReadCanvasContext as W,computeAlphaBbox as A}from"./effectUtils-BVIDUeZ4.js";import{ae as y,ai as b,a5 as I,a6 as O,aj as B}from"./BackgroundRemovalPage-BMoQ9wjg.js";import"./island-loader-Bwoy5hNQ.js";import"./client-BDJMow-F.js";import"./tabler-icons-development-DI2L2NPt.js";import"./TurnstileInvisible-DM6Jw6Yu.js";import"./wifi-off-DwJz-_vd.js";import"./createLucideIcon-CBKpTRs4.js";import"./circle-alert-xn4NmiVy.js";import"./SiteFooter-COKBpZBe.js";import"./shapeBuiltins-D8W_W2dg.js";import"./paletteHandoff-D2VNCt5x.js";import"./toolImageHandoff-CUflIiOA.js";import"./ColorPaletteLink-FWdedcjL.js";const E=128,p=new Map,P=16;async function k(t){const h=p.get(t);if(h!==void 0)return h;let i=null;try{const c=await w(t),o=E,r=Math.max(1,Math.round(c.naturalHeight/c.naturalWidth*o)),a=document.createElement("canvas");a.width=o,a.height=r;const n=W(a);if(n){n.drawImage(c,0,0,o,r);const e=A(a);e&&(i={x:e.x/o,y:e.y/r,w:e.w/o,h:e.h/r})}}catch{i=null}for(p.set(t,i);p.size>P;){const c=p.keys().next().value;if(c===void 0)break;p.delete(c)}return i}function f(t,h,i){t.translate(i.x,i.y),t.scale(i.w/h.bw,i.h/h.bh),t.translate(-h.bx,-h.by)}async function K(t,h,i){const c=y(h);if(!c)return t;try{const o=await w(t),r=o.naturalWidth,a=o.naturalHeight;if(!r||!a)return t;const n=document.createElement("canvas");n.width=r,n.height=a;const e=n.getContext("2d");return e?(e.drawImage(o,0,0),e.save(),e.globalCompositeOperation="destination-in",f(e,c,b(r,a,i)),e.fillStyle="#000",e.fill(new Path2D(c.d),c.fr||"nonzero"),e.restore(),await g(n)):t}catch{return t}}async function N(t,h,i,c){const o=y(h);if(!o||!i)return t;try{const r=await w(t),a=r.naturalWidth,n=r.naturalHeight;if(!a||!n)return t;const e=document.createElement("canvas");e.width=a,e.height=n;const s=e.getContext("2d");return s?(s.save(),s.fillStyle=I(s,a,n,i),s.fillRect(0,0,a,n),s.globalCompositeOperation="destination-in",f(s,o,b(a,n,c)),s.fillStyle="#000",s.fill(new Path2D(o.d),o.fr||"nonzero"),s.restore(),s.drawImage(r,0,0),await g(e)):t}catch{return t}}async function Q(t,h,i,c){const o={url:t,w:0,h:0},r=y(h.shapeId);if(!r)return o;try{const a=await w(t),n=a.naturalWidth,e=a.naturalHeight;if(!n||!e)return o;const s=await k(t)??{x:0,y:0,w:1,h:1},u=O(n,e,s,r.bw/r.bh,i,c);if(!u)return o;const{winX:C,winY:M,winW:H,winH:S,outW:x,outH:v,box:m}=u,d=document.createElement("canvas");d.width=x,d.height=v;const l=d.getContext("2d");return l?(l.drawImage(a,C,M,H,S,m.x,m.y,m.w,m.h),l.globalCompositeOperation="destination-in",l.save(),f(l,r,m),l.fill(new Path2D(r.d),r.fr||"nonzero"),l.restore(),l.globalCompositeOperation="source-over",{url:await g(d),w:x,h:v}):o}catch{return o}}async function V(t,h,i,c){const o=B(h);if(Math.abs(o-1)<.001&&Math.abs(i.x)<.001&&Math.abs(i.y)<.001)return t;try{const r=await w(t);let a=r.naturalWidth,n=r.naturalHeight;if(!a||!n)return t;if(c>0&&Math.max(a,n)>c){const u=c/Math.max(a,n);a=Math.max(1,Math.round(a*u)),n=Math.max(1,Math.round(n*u))}const e=document.createElement("canvas");e.width=a,e.height=n;const s=e.getContext("2d");return s?(s.translate(a/2+i.x*a,n/2+i.y*n),s.scale(o,o),s.drawImage(r,-a/2,-n/2,a,n),await g(e)):t}catch{return t}}export{V as applyArtTransform,K as applyShapeClip,N as applyShapeFill,Q as applyShapeMaskDetailed,k as measureSubjectBox};
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.