/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import{packFloatRGBA as t}from"../../core/floatRGBA.js";import{isExtent as o}from"../../geometry/support/jsonUtils.js";import n from"./Rect.js";function r(t){if(!t)return null;switch(t.type){case"CIMPointSymbol":{const o=t.symbolLayers;return o&&1===o.length?r(o[0]):null}case"CIMVectorMarker":{const o=t.markerGraphics;if(!o||1!==o.length)return null;const n=o[0];if(!n)return null;const r=n.geometry;if(!r)return null;const l=n.symbol;return!l||"CIMPolygonSymbol"!==l.type&&"CIMLineSymbol"!==l.type||l.symbolLayers?.some((t=>!!t.effects))?null:{geom:r,asFill:"CIMPolygonSymbol"===l.type}}case"sdf":return{geom:t.geom,asFill:t.asFill}}return null}function l(t){return t?t.rings?t.rings:t.paths?t.paths:void 0!==t.xmin&&void 0!==t.ymin&&void 0!==t.xmax&&void 0!==t.ymax?[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]:null:null}function e(t){let o=1/0,r=-1/0,l=1/0,e=-1/0;for(const n of t)for(const t of n)t[0]r&&(r=t[0]),t[1]e&&(e=t[1]);return new n(o,l,r-o,e-l)}function s(t){let o=1/0,n=-1/0,r=1/0,l=-1/0;for(const e of t)for(const t of e)t[0]n&&(n=t[0]),t[1]l&&(l=t[1]);return[o,r,n,l]}function i(t){return t?t.rings?s(t.rings):t.paths?s(t.paths):o(t)?[t.xmin,t.ymin,t.xmax,t.ymax]:null:null}function f(t,o,n,r,l){const[e,s,i,f]=t;if(i0&&(b=(o.xmax-o.xmin)/(o.ymax-o.ymin),p=r.x/(n*b),d=r.y/n):(p=r.x,d=r.y)),p=.5*(o.xmax+o.xmin)+p*(o.xmax-o.xmin),d=.5*(o.ymax+o.ymin)+d*(o.ymax-o.ymin),p-=e,d-=s,p*=y,d*=y,p+=h,d+=h;let w=p/x-.5,F=d/M-.5;return l&&(w*=n*b,F*=n),[g,w,F]}function a(t){const o=l(t.geom),n=e(o),r=128,s=1,i=Math.floor(.5*(.5*r-s)),f=(r-2*(i+s))/Math.max(n.width,n.height),a=Math.round(n.width*f)+2*i,h=Math.round(n.height*f)+2*i,y=[];for(const l of o)if(l&&l.length>1){const o=[];for(const r of l){let[l,e]=r;l-=n.x,e-=n.y,l*=f,e*=f,l+=i-.5,e+=i-.5,t.asFill?o.push([l,e]):o.push([Math.round(l),Math.round(e)])}if(t.asFill){const t=o.length-1;o[0][0]===o[t][0]&&o[0][1]===o[t][1]||o.push(o[0])}y.push(o)}const x=m(y,a,h,i);return t.asFill&&u(y,a,h,i,x),[c(x,i),a,h]}function m(t,o,n,r){const l=o*n,e=new Array(l),s=r*r+1;for(let i=0;io&&(h=o),y<0&&(y=0),x>n&&(x=n);const M=s[0]-t[0],g=s[1]-t[1],p=M*M+g*g;for(let r=c;rp?(i=s[0],f=s[1]):(a/=p,i=t[0]+a*M,f=t[1]+a*g);const m=(r-i)*(r-i)+(l-f)*(l-f),u=(n-l-1)*o+r;mo-r&&(h=o-r),yn-r&&(x=n-r);for(let e=y;ee==i[1]>e)continue;const s=(n-e-1)*o;for(let o=c;o