/*
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","../../../../../symbols/cim/CIMSymbolHelper","../../../../../symbols/cim/Rect","../../../engine/webgl/definitions","../../graphics/graphicsUtils","../../support/cimSymbolUtils"],(function(e,t,i,r,n,s,o,a){"use strict";const u={"simple-marker":1,"picture-marker":1,text:0,"simple-line":0,"simple-fill":0,"picture-fill":0,cim:1,"web-style":1},l=.707;function p(e){if(!("visualVariables"in e))return 0;if(!e.hasVisualVariables("size"))return 0;const t=e.getVisualVariablesForType("size");if(!t[0])return 0;const i=t[0];if("outline"===i.target)return 0;if("stops"===i.transformationType)return i.stops.map((e=>e.size)).reduce(T,0);if("clamped-linear"===i.transformationType){let e=-1/0,t=-1/0;return e="number"==typeof i.maxSize?i.maxSize:i.maxSize.stops.map((e=>e.size)).reduce(T,0),t="number"==typeof i.minSize?i.minSize:i.minSize.stops.map((e=>e.size)).reduce(T,0),Math.max(e,t)}return"real-world-size"===i.transformationType?30:void 0}function c(e){return e.type in u}function m(e,t,i,r,n,s){return f.apply(this,arguments)}function f(){return(f=t._asyncToGenerator((function*(e,t,r,n,s,o){if(!e||o&&"cluster"===o.type)return 0;if("heatmap"===e.type)return Math.round(i.pt2px(e.radius));if("dot-density"===e.type)return 0;if("dictionary"===e.type)return"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?100:200;const a=e.getSymbols(),u=p(e),l=[];for(const i of a)l.push(S(i,u,r,t,n,s));const c=yield Promise.all(l);return i.pt2px(c.reduce(T,0))}))).apply(this,arguments)}const y=[0,0,0,0];function h(e,t){return null==e?t:e}function d(e,t){return null==e.outline?t:h(e.outline.width,t)}const x={sdf:!0,code:99,metrics:s.AVERAGE_GLYPH_MOSAIC_ITEM.metrics,rect:new n(0,0,24,24),page:0,textureBinding:2};function M(e){const t=e.text&&e.text.length;if(!t)return{glyphMosaicItems:[x]};const i=[];for(let r=0;r<t;r++)i.push({...x,code:e.text.charCodeAt(r)});return{glyphMosaicItems:i}}function g(e,t,i,r,n,s){return b.apply(this,arguments)}function b(){return(b=t._asyncToGenerator((function*(e,t,i,n,s,u){if("simple-marker"===e.type){const i=Math.max(h(e.size,12),t);return w(e)+i*l}if("picture-marker"===e.type){const i=Math.max(h(e.height,12),t),r=h(e.width,12)*(i/h(e.height,12))/2,n=i/2;return w(e)+Math.sqrt(r*r+n*n)}if("text"===e.type){const t=M(e);o.getTextSymbolSize(y,e.toJSON(),t);const i=Math.abs(y[0]),r=Math.abs(y[1]),n=y[2],s=y[3];return Math.max(i,r)+Math.max(n,s)}if("simple-line"===e.type){const i=e,r=Math.max(h(i.width,.75),t)/2;return i.marker?Math.max(6*i.width,2*t):r}if("simple-fill"===e.type||"picture-fill"===e.type)return Math.max(d(e,0),t)/2;if("cim"===e.type){const o={geometryType:n,fields:s,spatialReference:u},l={type:"cim",rendererKey:0,data:e.data,maxVVSize:t};yield a.expandSymbol(l,o,i);const p=r.CIMSymbolHelper.getEnvelope(e.data,i);return p?Math.sqrt(p.width*p.width+p.height*p.height):0}return"web-style"===e.type?g(yield e.fetchCIMSymbol(),t,i,n,s,u):0}))).apply(this,arguments)}function S(e,t,i,r,n,s){return z.apply(this,arguments)}function z(){return(z=t._asyncToGenerator((function*(e,t,i,r,n,s){return c(e)?Math.min(yield g(e,t,i,r,n,s),75):0}))).apply(this,arguments)}function w(e){const t=h(e.xoffset,0),i=h(e.yoffset,0);return Math.sqrt(t*t+i*i)}function T(e,t){return Math.max(e,t)}e.computePxBuffer=m,e.getPtMaxVVSize=p,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
