"use strict";(self.webpackChunkchrome_extension=self.webpackChunkchrome_extension||[]).push([["985"],{44168(t,e,a){function n(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}a.d(e,{createCanvasFallbackModule:()=>_});let r=(0,a(64565).a)("img:canvas-fallback");class i{get_width(){return this._width}get_height(){return this._height}get_raw_pixels(){return new Uint8Array(this.ctx.getImageData(0,0,this._width,this._height).data.buffer)}get_bytes_jpeg(t){let e=atob(this.canvas.toDataURL("image/jpeg",t/100).split(",")[1]),a=new Uint8Array(e.length);for(let t=0;t{let n=new Image;n.onload=()=>{let t=document.createElement("canvas");t.width=n.width,t.height=n.height;let r=t.getContext("2d");r?(r.drawImage(n,0,0),e(new i(t))):a(Error("Failed to get 2d context"))},n.onerror=()=>{a(Error("Failed to load image"))},t.startsWith("data:")?n.src=t:n.src=`data:image/png;base64,${t}`})}static async new_from_byteslice(t){return new Promise((e,a)=>{let n=new Blob([t],{type:"image/png"}),r=URL.createObjectURL(n),o=new Image;o.onload=()=>{let t=document.createElement("canvas");t.width=o.width,t.height=o.height;let n=t.getContext("2d");if(!n){URL.revokeObjectURL(r),a(Error("Failed to get 2d context"));return}n.drawImage(o,0,0),URL.revokeObjectURL(r),e(new i(t))},o.onerror=()=>{URL.revokeObjectURL(r),a(Error("Failed to load image from bytes"))},o.src=r})}constructor(t){n(this,"canvas",void 0),n(this,"ctx",void 0),n(this,"_width",void 0),n(this,"_height",void 0),this.canvas=t;const e=t.getContext("2d");if(!e)throw Error("Failed to get 2d context");this.ctx=e,this._width=t.width,this._height=t.height}}let o={Nearest:"nearest",Triangle:"triangle",CatmullRom:"catmullrom",Gaussian:"gaussian",Lanczos3:"lanczos3"};class g{constructor(t,e,a,r){n(this,"r",void 0),n(this,"g",void 0),n(this,"b",void 0),n(this,"a",void 0),this.r=t,this.g=e,this.b=a,this.a=r}}function h(t,e,a,n){let r=document.createElement("canvas");r.width=e,r.height=a;let o=r.getContext("2d");if(!o)throw Error("Failed to get 2d context");return o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high",o.drawImage(t._getCanvas(),0,0,e,a),new i(r)}function l(t,e,a,n,r){let o=n-e,g=r-a,h=document.createElement("canvas");h.width=o,h.height=g;let l=h.getContext("2d");if(!l)throw Error("Failed to get 2d context");return l.drawImage(t._getCanvas(),e,a,o,g,0,0,o,g),new i(h)}function d(t,e,a){let n=t.get_width()+e,r=t.get_height(),o=document.createElement("canvas");o.width=n,o.height=r;let g=o.getContext("2d");if(!g)throw Error("Failed to get 2d context");return g.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a/255})`,g.fillRect(0,0,n,r),g.drawImage(t._getCanvas(),0,0),new i(o)}function c(t,e,a){let n=t.get_width(),r=t.get_height()+e,o=document.createElement("canvas");o.width=n,o.height=r;let g=o.getContext("2d");if(!g)throw Error("Failed to get 2d context");return g.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a/255})`,g.fillRect(0,0,n,r),g.drawImage(t._getCanvas(),0,0),new i(o)}function s(t,e,a){let n=t.get_width()+2*e,r=t.get_height()+2*e,o=document.createElement("canvas");o.width=n,o.height=r;let g=o.getContext("2d");if(!g)throw Error("Failed to get 2d context");return g.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a/255})`,g.fillRect(0,0,n,r),g.drawImage(t._getCanvas(),e,e),new i(o)}function w(t,e,a){let n=t.get_width()+e,r=t.get_height(),o=document.createElement("canvas");o.width=n,o.height=r;let g=o.getContext("2d");if(!g)throw Error("Failed to get 2d context");return g.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a/255})`,g.fillRect(0,0,n,r),g.drawImage(t._getCanvas(),e,0),new i(o)}function m(t,e,a){let n=t.get_width(),r=t.get_height()+e,o=document.createElement("canvas");o.width=n,o.height=r;let g=o.getContext("2d");if(!g)throw Error("Failed to get 2d context");return g.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a/255})`,g.fillRect(0,0,n,r),g.drawImage(t._getCanvas(),0,e),new i(o)}function u(t,e,a,n){let r=document.createElement("canvas");r.width=t.get_width(),r.height=t.get_height();let o=r.getContext("2d");if(!o)throw Error("Failed to get 2d context");return o.drawImage(t._getCanvas(),0,0),o.drawImage(e._getCanvas(),a,n),new i(r)}function _(){return r("Creating Canvas fallback module"),console.log("[midscene:img] Using Canvas fallback (Photon WASM not available)"),{PhotonImage:i,SamplingFilter:o,resize:h,crop:l,open_image:()=>{throw Error("open_image not supported in Canvas fallback")},base64_to_image:i.new_from_base64,padding_uniform:s,padding_left:w,padding_right:d,padding_top:m,padding_bottom:c,watermark:u,Rgba:g}}}}]); //# sourceMappingURL=985.ffb21172.js.map