import{n as x,a as w}from"./Bd4FQpE7.js";import{p as b,t as k,k as h,m as S,a as y}from"./Bj8SChEI.js";import{c as g,C as E}from"./BAITReer.js";import{p}from"./ZhKyHBKW.js";function v(i,e,l){const d=i.reduce((s,f)=>s+f,0),r=Math.ceil(d/e),o=document.createElement("canvas");o.width=e,o.height=r;const n=o.getContext("2d");if(!n)throw new Error("Failed to get canvas context");n.imageSmoothingEnabled=!1,n.fillStyle=l;let t=0,c=0;return i.forEach((s,f)=>{if(f%2===0){let a=s;for(;a>0;){const m=e-t;a<m?(t+=a,a=0):(a-=m,t=0,c++)}}else{let a=s;for(;a>0;){const m=e-t,u=Math.min(a,m);n.fillRect(t,c,u,1),a-=u,a>0?(t=0,c++):t+=u}}}),{dataUrl:o.toDataURL(),height:r}}var C=x('<image x="0" y="0"></image>');function M(i,e){b(e,!0);const l=p(e,"colorFill",3,"rgba(255, 0, 0, 0.2)"),d=p(e,"opacity",3,.4);if(!e.segmentation)throw new Error("Segmentation data is required");const r=S(()=>{const c=l().replace(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*[\d.]+)?\)/,"rgb($1)");return v(e.segmentation,e.width,c)}),o=S(()=>h(r).dataUrl),n=S(()=>h(r).height);var t=C();k(()=>{g(t,"href",h(o)),g(t,"width",e.width),g(t,"height",h(n)),g(t,"opacity",d())}),w(i,t),y()}function _(i,e){const l=p(e,"isSelected",3,!1);E(i,{get checked(){return l()},get onCheckedChange(){return e.onSelect}})}export{M as S,_ as a};
