/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../core/screenUtils","../cim/CIMSymbolRasterizer","./cimSymbolUtils","./previewUtils","./renderUtils"],(function(e,t,l,i,n,a,o){"use strict";const s=new i.CIMSymbolRasterizer(null,!0),r=a.SymbolSizeDefaults.maxSize;function c(e){return u.apply(this,arguments)}function u(){return(u=t._asyncToGenerator((function*(e,t={}){const{size:i,maxSize:a,node:c,opacity:u}=t,m=t.cimOptions||t,{feature:y,fieldMap:p,geometryType:d,style:f}=m,h=n.getCIMSymbolSize(e),b="number"==typeof i?i:null,g=Math.min(null!=b?b:h,null!=a?a:l.px2pt(r));g!==h&&(e=e.clone(),n.scaleCIMSymbolTo(e,g,{preserveOutlineWidth:!0}));let S=3;e&&e.data&&e.data.symbol&&"CIMPointSymbol"!==e.data.symbol.type&&(S=1);const M=yield s.rasterizeCIMSymbolAsync(e,y,p,d,{scaleFactor:S,style:f}),w=document.createElement("canvas");w.width=M.imageData.width,w.height=M.imageData.height;w.getContext("2d").putImageData(M.imageData,0,0);let C=w.width/S,I=w.height/S;if(null!=i&&(null==(null==t?void 0:t.scale)||(null==t?void 0:t.scale))){const e=C/I;C=e<=1?Math.ceil(g*e):g,I=e<=1?g:Math.ceil(g/e)}const v=new Image(C,I);v.src=w.toDataURL(),null!=u&&(v.style.opacity=`${u}`);let z=v;if(null!=t.effectView){const e={shape:{type:"image",x:0,y:0,width:C,height:I,src:v.src},fill:null,stroke:null,offset:[0,0]};z=o.renderSymbol([[e]],[C,I],{effectView:t.effectView})}return c&&c.appendChild(z),z}))).apply(this,arguments)}e.previewCIMSymbol=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
